Adding Management Server to MySQL Cluster

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

192.168.1.108 mgm2   # second Management Server

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

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

// Copy config.ini from mgm1 to mgm2 and edit for 4G memory

mgm2: # /usr/local/mysql/# vi config.ini
 
 
[ndb default]
NoOfReplicas = 2
DataDir = /usr/local/mysql/mysql-cluster
DataMemory = 3072M
IndexMemory = 384M
 
[ndb_mgmd]
NodeId = 1
PortNumber = 1186
HostName = mgm1
DataDir = /usr/local/mysql/mysql-cluster
[ndb_mgmd]
NodeId = 8
PortNumber = 1186
HostName = mgm2
DataDir = /usr/local/mysql/mysql-cluster
 
[ndbd]
NodeId = 11
HostName = ndb1
LockExecuteThreadToCPU = 1
LockMaintThreadsToCPU = 0
 
[ndbd]
NodeId = 12
HostName = ndb2
LockExecuteThreadToCPU = 1
LockMaintThreadsToCPU = 0
 
[api]
NodeId = 31
HostName = app1
[api]
NodeId = 32
HostName = app2
 
[tcp default]
SendBufferMemory = 2M
ReceiveBufferMemory = 2M

// Add config.ini on mgm1 server

mgm1: # /usr/local/mysql/# vi config.ini
 
[ndb_mgmd]
NodeId = 8
PortNumber = 1186
HostName = mgm2
DataDir = /usr/local/mysql/mysql-cluster

// Restart mgm1

mgm1:/usr/local/mysql# ./ndbmgm_daemon stop
NDB_MGM daemon stopped.
 
mgm1:/usr/local/mysql# ./ndbmgm_daemon initial
MySQL Cluster Management Server mysql-5.6.11 ndb-7.3.2
NDB_MGM daemon started
 
root@node01:/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)] 2 node(s)
id=1	@192.168.200.101  (mysql-5.6.11 ndb-7.3.2)
id=8 (not connected, accepting connect from mgm2)
 
[mysqld(API)]   2 node(s)
id=31   @192.168.200.105  (mysql-5.6.11 ndb-7.3.2)
id=32   @192.168.200.109  (mysql-5.6.11 ndb-7.3.2)
 
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)

// Start mgm2

mgm2:/usr/local/mysql# ./ndbmgm_daemon initial
MySQL Cluster Management Server mysql-5.6.11 ndb-7.3.2
NDB_MGM daemon started

// in Application server app1 and app2 append in my.cnf for 4G memory

app1: /usr/local/mysql/# vi my.cnf
[ndbd default]
LockPagesInMainMemory = 1  # need for Linux and Solaris systems
# for 4 GB RAM
DataMemory = 3072M
IndexMemory = 384M
 
NoOfFragmentLogFiles = 300
MaxNoOfConcurrentOperations = 100000
 
SchedulerSpinTimer = 400
SchedulerExecutionTimer = 100
RealTimeScheduler = 1
 
TimeBetweenGlobalCheckpoints = 1000
TimeBetweenEpochs = 200
DiskCheckpointSpeed = 10M
DiskCheckpointSpeedInRestart = 100M
RedoBuffer = 32M
 
MaxNoOfTables=1024
MaxNofOfOrderedIndexes=256
 
[mysqld]
ndb-connectstring = "mgm1;mgm2"
 
[mysql_cluster]
ndb-connectstring = "mgm1;mgm2"
app2: /usr/local/mysql/# vi my.cnf
[mysqld]
ndb-connectstring = "mgm1;mgm2"
 
[mysql_cluster]
ndb-connectstring = "mgm1;mgm2"
 
[tcp default]
SendBufferMemory = 2M
ReceiveBufferMemory = 2M

// Restart app1 & app2

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

// Verify mgm2

mgm2:/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)]    2 node(s)
id=1    @192.168.200.101  (mysql-5.6.11 ndb-7.3.2)
id=8    @192.168.200.108  (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.109  (mysql-5.6.11 ndb-7.3.2)
 
ndb_mgm> 11 restart
Node 11: Node shutdown initiated
Node 11 is being restarted
 
Node 11: Start initiated (version 7.3.2)
ndb_mgm> Node 11: Started (version 7.3.2)

// We can reload ndb use mgm2
// All Done