Steps to Set Up MySQL Cluster For Multiple Dedicated Servers


Main aim to setup clustering MySQL is to have redundancy – you server and applications will run smoothly even if one server goes down.

Note: For better performance you should have a 3rd server as a management node but this can be shut down after the cluster starts. Also note that shutting down the management server is not recommended (see the extra notes at the bottom of this document for more information). You can not run a MySQL Cluster with just two Dedicated servers And have true redundancy.

It is possible to set up the cluster on two Dedicated Servers you will not get the ability to “kill” one server and for the cluster to continue as normal. For this you need a third server running the management node.

Now below I had given the example for three servers ip booter: – – –

Servers 1 and 2 will be the two that end up “clustered”. This would be perfect for two servers behind a load balancer or using round robin DNS and is a good replacement for replication. Server 3 needs to have only minor changes made to it and does NOT require a MySQL install. It can be a low-end machine and can be carrying out other tasks.

STAGE 1: Install MySQL on the first two servers:

Complete the following steps on both mysql1 and mysql2:

cd /usr/local/

groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
rm mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
ln -s mysql-max-4.1.9-pc-linux-gnu-i686 mysql
cd mysql
scripts/mysql_install_db –user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
cp support-files/mysql.server /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig –add mysql.server

Do not start MySQL yet.

STAGE 2: Install and configure the management server

You need the following files from the bin/ of the mysql directory: ndb_mgm and ndb_mgmd. Download the whole mysql-max tarball and extract them from the bin/ directory.

mkdir /usr/src/mysql-mgm
cd /usr/src/mysql-mgm

tar -zxvf mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
rm mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
cd mysql-max-4.1.9-pc-linux-gnu-i686
mv bin/ndb_mgm .
mv bin/ndb_mgmd .
chmod +x ndb_mg*
mv ndb_mg* /usr/bin/
rm -rf /usr/src/mysql-mgm

You now need to set up the config file for this management:

mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi [or emacs or any other editor] config.ini

Now, insert the following (changing the bits as indicated):

# Managment Server
HostName= # the IP of THIS SERVER
# Storage Engines
HostName= # the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
HostName= # the IP of the SECOND SERVER
# 2 MySQL Clients
# I personally leave this blank to allow rapid changes of the mysql clients;
# you can enter the hostnames of the above two servers here. I suggest you dont.

Now, start the management server:


This is the MySQL management server, not management console. You should therefore not expect any output (we will start the console later).

STAGE 3: Configure the storage/SQL servers and start MySQL

On each of the two storage/SQL servers ( and enter the following (changing the bits as appropriate):

Leave a Reply

Your email address will not be published. Required fields are marked *