Building Galera Replication from Scratch
Introduction
MySQL/Galera synchronous Multi-Master Replication consists of 2 parts:
- The wsrep patches for MySQL (codership-mysql) and
- the Galera Replication Plugin (galera).
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:
wget http://mirror.switch.ch/ftp/mirror/mysql/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz
Download wsrep Patch
Download the wsrep Patch for MySQL:
wget http://launchpad.net/codership-mysql/5.5/5.5.15-21.2/+download/mysql-5.5.15-wsrep_21.2.patch
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
or
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 <br>
> 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:
wget http://launchpad.net/galera/1.x/21.1.0/+download/galera-21.1.0-src.tar.gz
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/
scons
cp garb/garbd /home/mysql/product/mysql-5.5.15-wsrep-21.2/bin/
cp libgalera_smm.so /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.).


Comments
Re: Building Galera Replication from Scratch
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
http://launchpad.net/codership-mysql/5.1/5.1.58-21.1/+download/mysql-5.1.58-galera-21.0.8.3-x86_64.tgz
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.
http://www.codership.com/wiki/doku.php?id=galera_arbitrator
Thanks in advance.
Why I build from source
Hello Vineet,
Great if it was a help for you…
I did it from source because of several reasons:
garbd,rsyncSST script).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 aboutrsyncSST (and potentiallysshand LVM snapshot SST)…If you cannot wait for the blog I suggest you to subscribe to the Forum and ask questions there…
Oli
Additions for compiling on RedHat/CENTOS
Follow the Galera documentation as well!
What was needed in addition in my case: