Install MySQL Replication and Cluster using Galera

INFO: Updated version of Galera cluster installation with high-availability MySQL setup can be refer here

What is Galera? Its generic synchronous multi-master replication plugin for transactional applications.

I will not telling you about this application cause you can read and understand by go to or refer to the image for Galera overview. I just show you on how to install Galera/MySQL with 1 master and 1 slave (joined node) architecture.

Please find variables that I used as below:

OS: CentOS 5.6 64bit
Server1: (master)
Server2: (joined node)
MySQL root password: rootpass
SST MySQL user: sst
SST MySQL password: sstpass123

Configuration in both servers are quite similar. So I will show you on how to install Galera MySQL in Server1 and then same procedure in Server2 with some minor changes. Lets configure Server1 first:

1. Install gcc44 and gcc44-c++ packages and set CC and CXX variables accordingly:

[root@centos ~] yum install gcc44 gcc44-c++ -y
export CC=gcc44
export CXX=g++44

2. Lets check what kind of MySQL applications installed in the box:

[[email protected] ~] rpm -qa | grep mysql

3. Lets download all needed applications. Download following applications in respective site:

Download MySQL-server-wsrep-5.1.53-0.8.0b-x86_64.rpm = the MySQL server
Download galera-0.8.0-x86_64.rpm = Galera library
Download the client-community and shared-community for 64bit

4. Following files should exist if you download the correct version:

[[email protected] galera] ls -1

5. Lets remove currently installed mysql. Dont worry about this, because we are actually upgrading our MySQL to version 5.1:

[[email protected] galera] rpm -e --nodeps mysql.i386 mysql.x86_64 mysql-devel.i386 mysql-devel.x86_64 mysql-server mysql-bench

Continue reading “Install MySQL Replication and Cluster using Galera” »

The Best Way to Setup MySQL Replication

In this case, I have 2 servers installed with MySQL 5 and running in CentOS 5. Assuming Server1 is master server and currently host a database called db1 and Server2 is slave server and have nothing inside.

Variable used in this case:

Server1 IP=
Server2 IP=
Database name=db1
Replication user=replicator
Replication user password=slavepass

Now we configure Server1 first. Login to the server and do following:

1. Login to Server1 and open MySQL configuration file, /etc/my.cnf and add following lines under [mysqld] section:


2. Restart MySQL:

service mysqld restart

3. Create a user account so slave can use to connect to this master server:

mysql> GRANT REPLICATION SLAVE on *.* to 'replicator'@'%' IDENTIFIED BY 'slavepass';

4. Dump the database so we can bring the database to the slave server:

mysqldump -u[root] -p[password] --master-data --single-transaction db1 > db1.sql

Continue reading “The Best Way to Setup MySQL Replication” »