Adding a New MySQL Server to the Cluster
Preparing the Application Server
// Append to /etc/hosts on every machine
@everyhost:~#vi /etc/hosts
192.168.1.109 app2 # MySQL node Server 2
Extracting Compresses Files
// Login to app2 server and extract files (see previous post)
@app2:~# tar xzf mysql.tgz -C /usr/local/mysql
Add MySQL user & group
// Adding mysql user and group;
// You will need to do this on all machines where MySQL Node will be running
@app2:~# /usr/local/mysql# groupadd mysql
@app2:~# /usr/local/mysql# useradd -g mysql mysql@app2:~# /usr/local/mysql# chown -R mysql.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"
Append app2 setting in mgm1 config.ini
@app2:/usr/local/mysql/# vi config.ini
[api]
NodeId = 32
HostName = app2
Restart Management Server 1,
@mgm1:/usr/local/mysql# ./ndbmgm_daemon stop
@mgm1:/usr/local/mysql# ./ndbmgm_daemon initial
MySQL Cluster Management Server mysql-5.6.19 ndb-7.3.6
NDB_MGM daemon started
Running Management Console to restart ndb1, and ndb2
@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.100.106 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=12 @192.168.100.107 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.104 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=31 @192.168.100.102 (mysql-5.6.19 ndb-7.3.6)
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.6)
ndb_mgm> Node 11: Started (version 7.3.6)
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.6)
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=11 @192.168.100.106 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=12 @192.168.100.107 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.104 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=31 @192.168.100.102 (mysql-5.6.19 ndb-7.3.6)
id=32 (not connected, accepting connect from app2)
Restart MySQL Node 1 (app1)
@app1:/usr/local/mysql# ./mysqld restart
Shutting down MySQL
.... SUCCESS!
Starting MySQL
..... SUCCESS!
Start MySQL Node 2 (app2)
@app2:/usr/local/mysql# ./mysqld start
Starting MySQL
.. SUCCESS!
Verify Management Server 1 (mgm1)
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=11 @192.168.100.106 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0, *)
id=12 @192.168.100.107 (mysql-5.6.19 ndb-7.3.6, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.100.104 (mysql-5.6.19 ndb-7.3.6)
[mysqld(API)] 2 node(s)
id=31 @192.168.100.102 (mysql-5.6.19 ndb-7.3.6)
id=32 @192.168.100.103 (mysql-5.6.19 ndb-7.3.6)
Test cluster connection to app2
@app2:/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.19-ndb-7.3.6 Source distribution
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
@app1:/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.19-ndb-7.3.6 Source distribution
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 MySQL Server added successfully!
Post a Comment