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 <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;
}