Setup MySQL NDB Cluster Part 2

Standard

OK here is the part 2. In part one, we end of with the setup of the NDB management instance. Next run the command ndb_mgm and you will get this:

[root@kr-ndb-mgmt-1 tmp]# ndb_mgm
— NDB Cluster — Management Client —
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2 (not connected, accepting connect from ndb-data-1)
id=3 (not connected, accepting connect from ndb-data-2)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.240.50.200 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=4 (not connected, accepting connect from ndb-sqld-1)
id=5 (not connected, accepting connect from ndb-sqld-2)
ndb_mgm>

From here, you can see that the management node (ndb_mgmd) is connected, but the data node (ndbd) and the query node (mysqld) has not been accepted. You need to go to the servers and activate them one by one.

Step 1: SSH into ndb-data-1 and create a new file at /etc/my.cnf and write the following:

[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine

[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=ndb-mgmt-1  # location of management server

Step 2: Run this command “ndbd”

Step 3: Go back to your management instance and run ndb_mgm, then type the command “show”. You will see a new node being added.

[moses_liao_gumi_sg@ndb-mgmt-1 ~]$ ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @10.240.105.44  (mysql-5.6.19 ndb-7.3.6, starting, Nodegroup: 0)
id=3 (not connected, accepting connect from ndb-data-2)
[ndb_mgmd(MGM)] 1 node(s)
id=1    @10.240.50.200  (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)]   2 node(s)
id=4 (not connected, accepting connect from ndb-sqld-1)
id=5 (not connected, accepting connect from ndb-sqld-2)
ndb_mgm> 

Step 4: do the same step 1-3 for instance ndb-data-2

Step 5: SSH into ndb-sqld-1 and do step 1 ONLY, create the same /etc/my.cnf file

Step 6: Run mysqld by entering the below command

/etc/init.d/mysql start

Step 7: Do step 5 and 6 for instance ndb-sqld-2. After that check the Management Console

You should be able to see that from the management node that all the nodes has been connected and activated.

[moses_liao_gumi_sg@kndb-mgmt-1 ~]$ ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.240.105.44 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=3 @10.240.31.66 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.240.50.200 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=4 @10.240.226.38 (mysql-5.6.19 ndb-7.3.6)
id=5 @10.240.65.24 (mysql-5.6.19 ndb-7.3.6)
ndb_mgm>

So it is time to party right?

WRONG!!!!

You need to login to the database and create users. This is where the mysql secret key comes in.

Step 8: On the ndb-sqld-1 instance, install MySQL client

rpm -Uhv MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm

Step 9: Get the first time login password. Remember in part 1 when you installed the server cluster, you are given a hidden password? Use that to login.

[root@ndb-sqld-1 tmp]# cat /root/.mysql_secret
# The random password set for the root user at Wed Sep 24 01:47:05 2014 (local time): Eg7_VF_CwOftXSTI
[root@ndb-sqld-1 tmp]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.19-ndb-7.3.6-cluster-gpl
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 

Ok so now you are in the mysql and you happily tried to create a new database. You try to key in “create database myfirstcluster” and suddenly you get a “ERROR 1820 (HY000): You must SET PASSWORD before executing this statement”.

doing_things

If you recall on the part 1, you have to reset the root password. So in MySQL, type:

mysql > set password = password(<your damned password>);

Once you change the password, you are good to go. Of course there are other steps like create database, users, grant them global access but I won’t go through them. Do take note that you have to redo steps 8 and 9 for the second sqld node. Also note that you have to create tables in NDB engine, if not the tables will not be saved in the data node

Advertisements

4 thoughts on “Setup MySQL NDB Cluster Part 2

  1. driggs

    I’m having trouble on my.cnf on my data nodes. I can only start the mysql using “/etc/init.d/mysql.server start” when my.cnf is removed on the ‘/etc/’ folder.

    And the error I got when I start the mysql.server when there’s my.cnf is: “The server quit without updating PID file (/usr/local/mysql/data/dtnode1.pid)

    This is the content of my.cnf:
    [mysqld]
    ndbcluster
    ndb-connectstring=10.88.41.50 (IP of the management node)
    datadir=/usr/local/mysql/data
    default-storage-engine=ndbcluster

    [mysql_cluster]
    ndb-connectstring=10.88.41.50 (IP of the management node)

  2. I’m having trouble on my.cnf on my data nodes. I can only start the mysql using ‘/etc/init.d/mysql.server start’ when my.cnf is removed on the ‘/etc/’ folder.

    And the error I got when I start the mysql.server when there’s my.cnf is: “The server quit without updating PID file (/usr/local/mysql/data/dtnode1.pid)

    This is the content of my.cnf:
    [mysqld]
    ndbcluster
    ndb-connectstring=10.88.41.50 (IP of the management node)
    datadir=/usr/local/mysql/data
    default-storage-engine=ndbcluster

    [mysql_cluster]
    ndb-connectstring=10.88.41.50 (IP of the management node)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s