Wednesday, 2 October 2013

MySQL NDB Cluster Configuration Step by Step

To set up the cluster, I create 5 Hyper-V virtual machine with CENTOS 6.4, one management node, two data node and two mysql node.
192.168.1.144 (mgm)
192.168.1.196 (ndb)
192.168.1.197 (ndb)
192.168.1.152 (mysqld)
192.168.1.193 (mysqld)
Step1:
Download mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz  binary file from mysql website http://dev.mysql.com/downloads/cluster/
Copy the download file to those 5 Linux server and do the next step on all 5 servers.
groupadd mysql
useradd –g mysql mysql
tar –zxvf  /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz
mv /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64 /opt/mysql_cluster
chown mysql.mysql –R /opt/mysql_cluster

On server  192.168.1.196 and 192.168.1.197 create a new folder
mkdir  /opt/mysql_cluster/ndbdata
chown mysql.mysql –R /opt/mysql_cluster



Step2:
Mgm Node(192.168.1.144) configuration
cd /opt/mysql_cluster/
vi config.ini


[root@CENTOS2 ~]# cat /opt/mysql_cluster/config.ini
 [ndbd default]
 NoOfReplicas= 2
 [NDB_MGMD]
 nodeid=1
 HostName= 192.168.1.144
 [NDBD]
 nodeid=11
 HostName= 192.168.1.196
 Datadir= /opt/mysql_cluster/ndbdata
 [NDBD]
 nodeid=12
 HostName= 192.168.1.197
 Datadir= /opt/mysql_cluster/ndbdata
 [MYSQLD]
 nodeid=21
 HostName= 192.168.1.152
 [MYSQLD]
 nodeid=22
 HostName= 192.168.1.193



Step3:
Install and configure mysql on two mysqld node (192.168.1.152, 192.168.1.193)
cd /opt/mysql_cluster/
scripts/mysql_cluster_install --user=mysql --datadir=/opt/mysql_cluster/data --basedir=/opt/mysql_cluster/
mv /opt/mysql_cluster/my.cnf /etc/my.cnf
vi /etc/my.cnf


[mysqld]
 ndbcluster
 ndb-connectstring=192.168.1.144
 [mysql_cluster]
 ndb-connectstring=192.168.1.144


Modify the /opt/mysql_cluster/support-files/mysql.server, replace datadir and basedir
datadir=/opt/mysql_cluster/data
basedir=/opt/mysql_cluster/

Step 4:
Start all cluster and mgm node
Startup data node(192.168.1.196, 192.168.1.197)
[root@Node1]# /opt/mysql_cluster/bin/ndbd --defaults-file=/opt/mysql_cluster/my.cnf --initial
2013-10-02 13:17:36 [ndbd] INFO     -- Angel connected to '192.168.1.144:1186'
2013-10-02 13:17:36 [ndbd] INFO     -- Angel allocated nodeid: 11

Startup mysqld node(192.168.1.152, 192.168.1.193)





Startup the mgm node
/opt/mysql_cluster/bin/ndb_mgmd -f /opt/mysql_cluster/config.ini --configdir=/opt/mysql_cluster
Step 5:
Check status

-----------------------------------------The End---------------------------------------------------------------






No comments:

Post a Comment