List:Cluster« Previous MessageNext Message »
From:Jonas Oreland Date:October 19 2011 10:57am
Subject:Re: Problem connecting to cluster with NDPAPI
View as plain text  
On 10/19/11 12:54, paul@stripped wrote:
> Hello,
> 
> I have successfully set-up a MySQL cluster (built from source
> mysql-cluster-gpl-7.2.1.tar.gz), with two management nodes, two data
> nodes, and four mysqld nodes. Everything works fine, and I can access
> the cluster through the SQL API using the four mysqld servers.
> 
> However, when I try to connect with the NDBAPI (using the sample code
> from the NDPAPI manual, see below), I get the following error:
> 
> "Configuration error: Error: Could not alloc node id at localhost port
> 1186: Connection done from wrong host ip 127.0.0.1. Unable to connect to
> cluster within 30 seconds."
> 
> Apparently I need to configure access to the cluster somehow, is this
> something I need to add to config.ini? What exactly? Is it documented
> somewhere?
> 
> Thanks for your help,

connecting with connect-string "localhost" only works if all of the nodes are running on
localhost
(if i remember correctly)

so maybe try with a real hostname ?

(or include config.ini/my.cnf in next mail)

/Jonas

> 
> Paul
> 
> #include <stdio.h>
> #include <stdlib.h>
> 
> #include <NdbApi.hpp>
> 
> #define CONNECTSTR "localhost"
> 
> Ndb_cluster_connection* example_init()
> {
>   Ndb_cluster_connection* conn;
> 
>   // initialise MySQL and Ndb client libraries
>   if( ndb_init() )
>   {
>     exit(EXIT_FAILURE);
>   }
> 
>   // prepare connection to cluster
>   conn = new Ndb_cluster_connection(CONNECTSTR);
> 
>   // initiate connection
>   if( conn->connect(4, 5, 1) )
>   {
>     fprintf(stderr, "Unable to connect to cluster within 30 seconds.");
>     exit(EXIT_FAILURE);
>   }
>   
>   // wait for data (ndbd) nodes
>   if(conn->wait_until_ready(30, 0) < 0)
>   {
>     fprintf(stderr, "Cluster was not ready within 30 seconds.\n");
>     exit(EXIT_FAILURE);
>   }
> 
>   return conn; 
> }
> 
> void example_end(Ndb_cluster_connection* conn)
> {
>   // terminate connection
>   delete conn;
> 
>   // shut down MySQL and Ndb client libraries
>   ndb_end(2);
> }
> 
> 
> int main(int argc, char** argv)
> {
>   Ndb_cluster_connection* conn;
> 
>   conn = example_connect();
> 
>   printf("Connection established.");
> 
>   example_end(conn);
> 
>   return EXIT_SUCCESS;
> }
> 
> 

Thread
Problem connecting to cluster with NDPAPIpaul19 Oct
  • Re: Problem connecting to cluster with NDPAPIJonas Oreland19 Oct
  • Re: Problem connecting to cluster with NDPAPIJohan Andersson19 Oct
Re: Problem connecting to cluster with NDPAPIJonas Oreland19 Oct
RE: Problem connecting to cluster with NDPAPIpaul19 Oct