SQL nodes are the most common form of API nodes, and are used to provide a standard MySQL interface to the cluster. To do this, they use a standard version of the MySQL server compiled to include support for the MySQL Cluster storage engine—NDBCLUSTER
.
In earlier versions, this was included in most binaries, but to use more current and future versions of MySQL, you must specifically select the MySQL Cluster server downloads. It is highly recommended to install a mysql
client on each SQL node for testing.
Note
Terminology sometimes causes confusion. A MySQL server is a mysqld
process. A MySQL client is the mysql
command that communicates with a MySQL server. It is recommended to install both on each SQL node, but of course, it is only required to have the server (which can be connected to by the clients on the other machines).
Download and install the following two files. For the sake of brevity, the process of using wget
to download a file and rpm
to install a package is not shown in this recipe, but it is identical to the procedure in the previous two recipes:
Server (from the cluster section)—
MySQL-Cluster-gpl-server-7.a.b-c.rhel5.x86_64.rpm
Client (this is identical to the standard MySQL client and has the same filename)—
MySQL-client-community-5.a.b-c.rhel5.x86_64.rpm
After installing these RPMs, a very simple /etc/my.cnf
file will exist. We need to add two parameters to the [mysqld]
section of this file to tell the mysqld
server to enable support for MySQL Cluster and where to find its management node:
[mysqld] # Enable MySQL Cluster ndbcluster # Tell this node where to find its management node ndb-connectstring=10.0.0.5
Note
The requirement to add lines to the [mysqld]
section in addition to any [mysql_cluster]
that may already be there is only read by the ndb_*
daemons (but has a similar purpose). If you have a SQL node on the same server as a storage node you would have both.
Some modern versions of MySQL will also use a [mysql_cluster]
section, but it is feasible to stick to defining the parameters in a [mysqld]
section.
With these lines added, start the SQL node as follows:
[root@node1 ~]# service mysql start Starting MySQL. [ OK ]
At this point, even if there is an error connecting to the cluster, it is unlikely that you will get anything other than okay here. However, if you see the following error in the standard mysql
log (often /var/lib/mysqld.log
or /var/lib/mysql/hostname.err
), you should go and check that you have installed the correct server (the cluster server and not the standard server):
090708 23:48:14 [ERROR] /usr/sbin/mysqld: unknown option '--ndbcluster' 090708 23:48:14 [ERROR] Aborting
Even if your SQL node (MySQL server) starts without an error, it is important to verify that it has successfully joined the cluster. There are three tests to carry out:
On the management node, run the SHOW
command and ensure that this node is now connected:
ndb_mgm> SHOW Cluster Configuration --------------------- [ndbd(NDB)] 4 node(s) id=3 @10.0.0.1 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master) id=4 @10.0.0.2 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0) id=5 @10.0.0.3 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 1) id=6 @10.0.0.4 (mysql-5.1.34 ndb-7.0.6, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=1 @10.0.0.5 (mysql-5.1.34 ndb-7.0.6) [mysqld(API)] 4 node(s) id=11 @10.0.0.1 (mysql-5.1.34 ndb-7.0.6) id=12 @10.0.0.2 (mysql-5.1.34 ndb-7.0.6) id=13 @10.0.0.3 (mysql-5.1.34 ndb-7.0.6) id=14 @10.0.0.4 (mysql-5.1.34 ndb-7.0.6)
Now that you have confirmed that the SQL node is connected to the management node, in the mysql
client on the SQL node confirm the status of the NDB
engine:
[root@node1 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.34-ndb-7.0.6-cluster-gpl MySQL Cluster Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SHOW ENGINE NDB STATUS; +------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Type | Name | Status | +------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ndbcluster | connection | cluster_node_id=11, connected_host=10.0.0.5, connected_port=1186, number_of_data_nodes=4, number_of_ready_data_nodes=4, connect_count=0 |
Also check the output of the SHOW ENGINES
command:
mysql> SHOW ENGINES; +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +------------+---------+----------------------------------------------------------------+--------------+------+------------+ | ndbcluster | YES | Clustered, fault-tolerant tables | YES | NO | NO |
If the node is not connected, the status from the first command, SHOW ENGINE NDB STATUS
, will typically be something like:
cluster_node_id=0, connected_host=(null), connected_port=0, number_of_data_nodes=0, number_of_ready_data_nodes=0, connect_count=0
Otherwise, the command will fail with ERROR 1286 (42000): Unknown table engine 'NDB'
. If the second command does not have a YES
in the supported column for ndbcluster
there is a problem.
If any of these commands fail, check the following:
/etc/my.cnf [mysqld]
sectionThat you have installed the cluster-specific
mysqld
binary
If the commands work, follow the steps in the next recipe to create a test MySQL Cluster table and ensure that your cluster is working correctly.