Adding Application Server to MySQL Cluster

// Preparing the server
// Append to /etc/hosts on every machine

192.168.1.109 app2   # second Application Server

// Login to app2 server and extract files (see previous post)

app2: # tar xzf mysql.tgz -C /usr/local/mysql

// Create my.cnf file on app2

app2: /usr/local/mysql/# vi my.cnf
 
# my.cnf
 
[mysqld]
server-id = 32
ndbcluster
 
# location of management servers
ndb-connectstring = "mgm1"
 
[mysql_cluster]
# location of management servers
ndb-connectstring = "mgm1"

// in mgm1 config.ini append

mgm1: /usr/local/mysql/# vi config.ini
 
[api]
NodeId = 32
HostName = app2

// restart mgm1, ndb1, and ndb2

mgm1:/usr/local/mysql# ./ndbmgm_daemon stop
mgm1:/usr/local/mysql# ./ndbmgm_daemon initial
MySQL Cluster Management Server mysql-5.6.11 ndb-7.3.2
NDB_MGM daemon started
 
mgm1:/usr/local/mysql# bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 	2 node(s)
id=11   @192.168.200.103  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)
id=12   @192.168.200.104  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0)
 
[ndb_mgmd(MGM)] 1 node(s)
id=1	@192.168.200.101  (mysql-5.6.11 ndb-7.3.2)
 
[mysqld(API)]   2 node(s)
id=31   @192.168.200.105  (mysql-5.6.11 ndb-7.3.2)
id=32 (not connected, accepting connect from app2)
 
ndb_mgm> 11 restart
Node 11: Node shutdown initiated
Node 11: Node shutdown completed, restarting, no start.
Node 11 is being restarted
 
Node 11: Start initiated (version 7.3.2)
 
ndb_mgm> Node 11: Started (version 7.3.2)
 
ndb_mgm> 12 restart
Node 12: Node shutdown initiated
Node 12: Node shutdown completed, restarting, no start.
Node 12 is being restarted
 
ndb_mgm> Node 12: Started (version 7.3.2)
 
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 	2 node(s)
id=11   @192.168.200.103  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)
id=12   @192.168.200.104  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0)
 
[ndb_mgmd(MGM)] 1 node(s)
id=1	@192.168.200.101  (mysql-5.6.11 ndb-7.3.2)
 
[mysqld(API)]   2 node(s)
id=31   @192.168.200.105  (mysql-5.6.11 ndb-7.3.2)
id=32 (not connected, accepting connect from app2)

// Restart app1

app1:/usr/local/mysql# ./mysqld restart
Shutting down MySQL
.... SUCCESS!
Starting MySQL
..... SUCCESS!

// start app2

app2:/usr/local/mysql# ./mysqld start
Starting MySQL
.. SUCCESS!

// Verify mgm1 server

ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 	2 node(s)
id=11   @192.168.200.103  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)
id=12   @192.168.200.104  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0)
 
[ndb_mgmd(MGM)] 1 node(s)
id=1	@192.168.200.101  (mysql-5.6.11 ndb-7.3.2)
 
[mysqld(API)]   2 node(s)
id=31   @192.168.200.105  (mysql-5.6.11 ndb-7.3.2)
id=32   @192.168.200.105  (mysql-5.6.11 ndb-7.3.2)

// Test cluster connection to app2

ubuntu: /usr/local/mysql/# bin/mysql -u root -p -h app2
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 5.6.11-ndb-7.3.2-cluster-gpl MySQL Cluster Community Server (GPL)
 
mysql> use clusterdb
Database changed
 
mysql> select * from testcluster;
+----+-------------------------+
| id | message                 |
+----+-------------------------+
|  1 | first test our cluster! |
+----+-------------------------+
1 row in set (0.01 sec)
 
mysql> insert into testcluster(message) values('add new application server to cluster!');
Query OK, 1 row affected (0.01 sec)

// Reconnect to app1

ubuntu: /usr/local/mysql/# bin/mysql -u root -p -h app1
Enter password:
 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 5.6.11-ndb-7.3.2-cluster-gpl MySQL Cluster Community Server (GPL)
 
mysql> select * from clusterdb.testcluster;
+----+----------------------------------------+
| id | message                                |
+----+----------------------------------------+
|  1 | first test our cluster!                |
|  2 | add new application server to cluster! |
+----+----------------------------------------+
2 rows in set (0.01 sec)

// New Application server added successfully!