From: Johan Andersson Date: October 19 2011 10:58am Subject: Re: Problem connecting to cluster with NDPAPI List-Archive: http://lists.mysql.com/cluster/8123 Message-Id: <4E9EAD64.6090602@severalnines.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Paul, If you do ndb_mgm -e "show" Do you have any "free slots" accepting connections from the host you want to connect from? Here is a sample: Connected to Management Server at: 10.30.30.32:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=3 @10.30.30.34 (mysql-5.1.56 ndb-7.1.15, Nodegroup: 0, Master) id=4 @10.30.30.35 (mysql-5.1.56 ndb-7.1.15, Nodegroup: 0) [ndb_mgmd(MGM)] 2 node(s) id=1 @10.30.30.32 (mysql-5.1.56 ndb-7.1.15) id=2 @10.30.30.33 (mysql-5.1.56 ndb-7.1.15) [mysqld(API)] 15 node(s) id=5 @10.30.30.32 (mysql-5.1.56 ndb-7.1.15) id=6 @10.30.30.32 (mysql-5.1.56 ndb-7.1.15) id=7 @10.30.30.32 (mysql-5.1.56 ndb-7.1.15) id=8 @10.30.30.32 (mysql-5.1.56 ndb-7.1.15) id=9 @10.30.30.33 (mysql-5.1.56 ndb-7.1.15) id=10 @10.30.30.33 (mysql-5.1.56 ndb-7.1.15) id=11 @10.30.30.33 (mysql-5.1.56 ndb-7.1.15) id=12 @10.30.30.33 (mysql-5.1.56 ndb-7.1.15) id=13 (not connected, accepting connect from any host) id=14 (not connected, accepting connect from any host) If you don't have like that you need to add in config.ini the following: [MYSQLD] and then restart the management servers ( ndb_mgmd ... --reload) Then restart the data nodes, all at once, or as a rolling restart. Good luck, Johan Andersson Severalnines AB twitter : http://twitter.com/#!/severalnines blog: http://www.severalnines.com web: http://www.severalnines.com On 2011-10-19 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, > > Paul > > #include > #include > > #include > > #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; > } > >