MySQL Forums
Forum List  »  NDB clusters

Re: A question about remote connection via ndb api to mgm
Posted by: Mikael Ronström
Date: April 18, 2016 05:43AM

Hi,
Rafael Mateo Wrote:
-------------------------------------------------------
> Hi:
>
> I'm trying to create a ndb api utility on c for
> loading records into ndb tables as "load data in
> file". We haven't got any experience on ndb api
> libraries.
>
> we have started with this simple connect example.
>
>
> #include <NdbApi.hpp>
> #include <mysql.h>
> #include <mysqld_error.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char** argv)
> {
> Ndb_cluster_connection * conn;
> ndb_init();
> conn = new Ndb_cluster_connection("<mgm linux
> box ip>:10000");
> conn->connect(5, 3, 1);
> printf("%s
> \n\n",conn->get_latest_error_msg());
> if (conn->wait_until_ready(30,0) <0)
> {
> printf("No ok");
> return -1;
> }
> delete(conn);
> ndb_end(0);
> return EXIT_SUCCESS;
> }
>
> This source code generates on linux a binary
> called connection.
>
>
> We have a cluster with:
>
>
> One cluster manager (mgm)
> Two Datanodes
> Two msqld(API) nodes.
>

Looks straightforward so far.

> Cluster Manager and one Api node are in the same
> server.
> Data node are in different linux boxes alone.
> The other Api node is alone on one linux box.
>
>
> When we copy the "connection" binary plus
> libndbclient.so.6.0.0 to other server out of the
> cluster infrastructure and try to connect to mgm
> cluster we receive the next message
>
> Error: Could not alloc node id at <mgm linux box
> ip> port 10000: No free node id found for
> mysqld(API).
>
> and we have been able to see via tcpdump the next
> strange lines:
>
>
>
>
> sendto(3, "get nodeid\n", 11, 0, NULL, 0) = 11

This is the protocol used to MGM server to allocate a node id
for the API (same also used for data nodes when they start up.

> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "version: 459780\n", 16, 0, NULL, 0) =
> 16
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "nodetype: 1\n", 12, 0, NULL, 0) = 12
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "nodeid: 0\n", 10, 0, NULL, 0) = 10
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "user: mysqld\n", 13, 0, NULL, 0) = 13
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "password: mysqld\n", 17, 0, NULL, 0) =
> 17
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "public key: a public key\n", 25, 0,
> NULL, 0) = 25
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "endian: little\n", 15, 0, NULL, 0) =
> 15
> poll([{fd=3, events=POLLOUT}], 1, 30000) = 1
> ([{fd=3, revents=POLLOUT}])
> sendto(3, "log_event: 0\n", 13, 0, NULL, 0) = 13
>
> We don't understand these lines:
>
> sendto(3, "user: mysqld\n", 13, 0, NULL, 0) = 13
> sendto(3, "password: mysqld\n", 17, 0, NULL, 0) =
> 17
>
> Who is mysqld user ¿?¿?¿?¿

The protocol is prepared for users and password, but it ignores
those lines and currently these lines should be exactly as they
are. The protocol is prepared for future extension.

>
>
> Finally when we run this code into mgm linux box
> it works fine.
>
>
> We need this code for bulk load data from batch
> processes.
>
>
> Only ndb api works when it runs into the mgm
> process server ???
>

Sounds to me like you have specified a specific hostname
in the config file. The hostname for mgm server seems to
work but not the hostname of the other node.

Either the other server simply has a hostname you haven't
set in the config, otherwise it could be that you have two
hostnames for the server and the MGM server thinks you are
connecting from the other one.

One solution is to remove the hostname part from API/MYSQLD
nodes in the config.

If you want to keep those you have to figure out which hostname
is the correct to use or ensure that the API node is using the
correct hostname when connecting (not trivial).

Rgrds Mikael Ronström

>
> Regards in advance.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: A question about remote connection via ndb api to mgm
874
April 18, 2016 05:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.