You are here

Building Galera Replication from Scratch


MySQL/Galera synchronous Multi-Master Replication consists of 2 parts:

If you do not want to download the prepared binaries you can build it on you own.
First you have to download the native MySQL sources, then patch it with the Galera wsrep patches and compile it. In a second step you have to build the Galera Plugin.

This is especially useful because in the standard Galera binary tar balls the garbd (and possibly other tools) is not provided.

The following steps describe how to do it:

Prepare a patched MySQL

Download MySQL Sources

Download the normal MySQL source code:


Download wsrep Patch

Download the wsrep Patch for MySQL:


Patch MySQL

Patch MySQL as follows:

cd /tmp
tar xf /download/mysql-5.5.15.tar.gz
cd mysql-5.5.15
patch -p1 < /download/mysql-5.5.15-wsrep_21.2.patch

If you want avoid this step you can also download the already patched codership-mysql directly as follows:

bzr branch lp:codership-mysql


bzr branch lp:codership-mysql/5.5

If you want to do create your own wsrep patch:

bzr branch lp:codership-mysql/5.5
cd 5.5
bzr diff -p1 -v --diff-options " --exclude=.bzrignore " -r tag:mysql-5.5.15..branch:lp:codership-mysql/5.5 \
  > mysql-5.5.15-wsrep_21.2.patch

Compile MySQL with the wsrep patch

To compile the patched MySQL do the following:

chmod a+x BUILD/compile-amd64-wsrep
BUILD/compile-amd64-wsrep --prefix=/home/mysql/product/mysql-5.5.15-wsrep-21.2
make install

Up to here this was the first step to get a prepared MySQL working with wsrep. Now we have to make the Galera Plugin...

Prepeare the Galera Replication Plugin

Download Galera Replication Plugin

The source of the Galera Replication Plugin you can get like this:


or if you want to get the most recent source take if directly from launchpad:

bzr branch lp:galera/1.x

Compile the Galera Replication Plugin

cd /tmp/
tar xf /download/galera-21.1.0-src.tar.gz
cd galera-21.1.0-src/

cp garb/garbd /home/mysql/product/mysql-5.5.15-wsrep-21.2/bin/
cp /home/mysql/product/mysql-5.5.15-wsrep-21.2/lib/plugin/

This is the whole magic. The most difficult thing is to put everything in the right order and to get the right packages in place (for Ubuntu/Debian: libboost-dev, libboost-program-options-dev (>= v1.41), scons, libssl-dev, check, g++ (>= 4.4.0), etc.).


Thanks Shinguz for such a good post, its very hard to find any blog for Galera patch & implementation. What i am doing to implement Galera: I have downloaded galera from and ran command: ./mysql-galera -g gcomm:// start ./mysql-galera -g gcomm://{IPADDR} start its working very fine. But i am confused about you have downloaded mysql source and then complied it. How its different from this implementation. Another thing is i am not getting any help on Galera Arbitrator. How its work and its required any other implementation steps. Thanks in advance.

Hello Vineet, Great if it was a help for you... I did it from source because of several reasons:
  1. I have a complicated environment (up to 50 MySQL instances running potentially in parallel) and deb/rpm packages would not help here. So I have to use binary tar balls. By the way: our 17-node Galera Cluster was built on such a set-up.
  2. Version 5.5 is definitely the way to go.
  3. The binary tar ball I got did not contain everything I needed (garbd, rsync SST script).
  4. I just want to know how it works and do it on my own... :)
So your way is OK as well. Except that you should go for a more contemporary release... MySQL 5.1 is going to die sooner or later... About the garbd: This is the next but one topic (first I want to have a look about rsync SST (and potentially ssh and LVM snapshot SST)... If you cannot wait for the blog I suggest you to subscribe to the Forum and ask questions there... Oli

Thanks Oli for your reply and knowledge sharing.

bzr branch lp:codership-mysq/5.5 -> bzr branch lp:codership-mysql/5.5

Hello xcooling, Thanks for the hint. I have fixed it.

Follow the Galera documentation as well! What was needed in addition in my case:
yum remove boost.x86_64 boost-devel.x86_64
yum install boost141.x86_64 boost141-devel.x86_64 openssl-devel.x86_64
yum install ncurses-devel.x86_64 bison.x86_64 bison-devel.x86_64
yum install gcc44.x86_64 gcc44-c++.x86_64

ldconfig -p | grep libboost_program_options

ln -s /usr/lib64/ /usr/lib64/