Support #380
Updated by Daniel Curtis over 10 years ago
This guide a is to show how to build MariaDB with WSREP and Galera for a Multi-Master SQL database cluster. It is assumed that a FreeNAS jail has been setup as per Issue #329 and root access has been obtained.
h2. Fix and prepare the Jail
* Currently, I have noticed a bug that prevents a jail from upgrading properly. This is due to a conflict in GCC versions, to fix this lang/gcc47 must be removed along with one of its dependencies:
<pre>
pkg remove lang/gcc47 aria2
</pre>
* Next update the ports tree:
<pre>
portsnap fetch
portsnap extract
</pre>
* Once that is done, build mariadb55-server from the ports tree. This is to resolve the source dependencies for recompiling the MariaDB server later on with wsrep.
<pre>
cd /usr/ports/databases/mariadb55-server
make install clean
</pre>
* Now uninstall MariaDB server:
<pre>
make deinstall
</pre>
* And now resolve a few dependencies before compiling the new MariaDB server:
<pre>
pkg install bzr bison boost-all scons
</pre>
* Install the check unit testing framework:
mkdir /usr/local/src/
cd /usr/local/src
wget http://sourceforge.net/projects/check/files/latest/download
mv download check.tar.gz
tar xzf check.tar.gz
cd check*
./configure
make make install
h2. Download and compile MariaDB with wsrep
* Download the latest MariaDB from launchpad
<pre>
bzr branch lp:~maria-captains/maria/maria-5.5-galera trunk
</pre>
* Compile MariaDB with wsrep:
<pre>
cd trunk
cmake . -DBUILD_CONFIG=mysql_release -DWITH_WSREP=ON -DWITH_INNODB_DISALLOW_WRITES=1
make
make install
</pre>
* Install Galera from the ports tree
<pre>
cd /usr/ports/databases/galera
make install clean
</pre>
* Copy the boot mariadb boot script
<pre>
cd /usr/local/mysql/support-files/
cp mysql.server /usr/local/etc/rc.d/mysql.server.sh
</pre>
*# The boot script also needs to be edited, like the following example:
<pre>
vi /usr/local/etc/rc.d/mysql.server.sh
</pre>
> basedir=/usr/local/mysql
> datadir=/usr/local/mysql/data
* Initialize and secure the MariaDB database
<pre>
cd /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db
cd ..
chown -R mysql:mysql mysql/
</pre>
* Bootstrap the new Galera cluster
<pre>
/usr/local/mysql/bin/mysqld --user=mysql --wsrep-new-cluster
</pre>
* Now in a second terminal connection run the @mysql_secure_installation@ script to do some post-installation hardening:
<pre>
/usr/local/mysql/bin/mysql_secure_installation
</pre>
By this point MariaDB should be able to be controlled by the service command:
<pre>
service mysql.server.sh bootstrap
service mysql.server.sh stop
service mysql.server.sh start
</pre>
h2. Configuring the Galera Cluster