This article will take you through setting up MySql cluster. As we will be using mysql-cluster tar package, this guide should work with most distros, including fedora, ubuntu. I am testing cluster on centos 6.
For this you need 3 servers, two of which will work as storage cluster & one as management server.
cluster1 192.168.0.36 – management server
cluster2 192.168.0.37 – storage node 1
cluster3 192.168.0.38 – storage node 1
Disable SELinux | iptables | iptables6
Download Mysql-Cluster:
mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
Install MySQL on CLUSTER 2 & CLUSTER 3:
Adding mysql user and group:
groupadd mysql
useradd -g mysql mysql
cd /usr/local/
tar -zxvf /root/mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
mv mysql-cluster-gpl-7.2.5-linux2.6-x86_64 mysql-cluster
ln -s mysql-cluster mysql
cd /usr/local/mysql
scripts/mysql_install_db –user=mysql

Note: please make sure you install shared libraries: libaio with yum.
Change permissions:
chown -R root .
chown -R mysql data
chgrp -R mysql .
init script:
cp support-files/mysql.server /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig –add mysql.server
We can check mysql server:
/etc/init.d/mysql.server start
/etc/init.d/mysql.server stop
Install and configure the management server ON CLUSTER 1:
tar -zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
cd mysql-cluster-gpl-7.2.5-linux2.6-x86_64
mv bin/ndb_mgm .
mv bin/ndb_mgmd .
chmod +x ndb_mg*
mv ndb_mg* /usr/bin/
We now need to set up the config file ON CLUSTER 1:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.0.36 # the IP of THIS SERVER
# Storage Engines
[NDBD]
HostName=192.168.0.37 # the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=192.168.0.38 # the IP of the SECOND SERVER
DataDir=/var/lib/mysql-cluster
# 2 MySQL Clients
[MYSQLD]
[MYSQLD]
mkdir -p /usr/local/mysql/mysql-cluster
Now we can start the Management server:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
Configure the storage servers and start mysql ON CLUSTER 1 & CLUSTER 2:
vi /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.36 # the IP of the MANAGMENT (THIRD) SERVER
[mysql_cluster]
ndb-connectstring=192.168.0.36 # the IP of the MANAGMENT (THIRD) SERVER
Now, we make the data directory and start the storage engine:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
/usr/local/mysql/bin/ndbd –initial
/etc/rc.d/init.d/mysql.server start
Now we check on cluster1:
ndb_mgm
show

Stop Cluster:
To stop cluster run shutdown command in ndb_mgm Console
On storage clusters /etc/init.d/mysql.server stop
Start Cluster:
Management Server – Cluster1
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
On Storage Clusters 2 and 3:
/usr/local/mysql/bin/ndbd
/etc/init.d/mysql.server start
Test for Mysql Cluster:
ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /var/lib/mysql/mysql.sock /tmp/
On storage cluster 2 and check on cluster 3:
mysql -u root -p
mysql> use test;
mysql> CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
mysql> INSERT INTO ctest () VALUES (1);
mysql> SELECT * FROM ctest;

NOTE: PLEASE USE “ENGINE=NDBCLUSTER” OTHERWISE IT MAY NOT WORK.
Thank You….
If you face any other issues please let me know.
http://linuxdump.com/