Project

General

Profile

Support #380

Updated by Daniel Curtis over 9 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. 

 * Update the ports tree: 
 <pre> 
 portsnap fetch 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 clean 
 </pre> 

 * And now resolve a few dependencies before compiling the new MariaDB server: 
 <pre> 
 pkg install bzr bison boost-all scons libcheck cmake 
 </pre> 

 * Install the check unit testing framework: 
 <pre> 
 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 
 cd .. 
 </pre> 

 h2. Download and compile MariaDB with wsrep 

 * Download the latest MariaDB from launchpad 
 <pre> 
 cd /usr/src 
 bzr branch lp:~maria-captains/maria/maria-5.5-galera maria-5.5-galera 
 </pre> 

 * Compile MariaDB with wsrep: 
 <pre> 
 cd maria-5.5-galera 
 cmake . -DBUILD_CONFIG=mysql_release -DWITH_WSREP=ON -DWITH_INNODB_DISALLOW_WRITES=1 
 make 
 make install 
 cd .. 
 </pre> 

 h2. Download and compile Galera 

 * Install Galera from the ports tree (recommended) 
 <pre> 
 cd /usr/ports/databases/galera 
 make install clean 
 </pre> 
 #* Or install from the developers tree: 
 <pre> 
 bzr branch lp:galera/2.x galera-2.x 
 cd galera-2.x 
 scons 
 </pre> 

 * Copy the boot mariadb boot script 
 <pre> 
 cd /usr/local/mysql/support-files/ 
 cp /usr/local/mysql/support-files/mysql.server 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> 
 #* And modify the two configuration parameters: 
 <pre> 
 > basedir=/usr/local/mysql 
 > datadir=/usr/local/mysql/data 
 </pre> 

 * Initialize and secure the MariaDB database 
 <pre> 
 cd /usr/local/mysql 
 /usr/local/mysql/scripts/mysql_install_db 
 chown -R mysql:mysql data/ 
 </pre> 

 * Configure the new cluster: 
 <pre> 
 vi /usr/local/etc/mysql/conf.d/cluster.cnf 
 </pre> 
 #* And add the following: 
 <pre> 
 [mysqld] 
 binlog_format=ROW 
 default-storage-engine=innodb 
 innodb_autoinc_lock_mode=2 
 bind-address=0.0.0.0 

 # Galera Provider Configuration 
 wsrep_provider=/usr/lib/galera/libgalera_smm.so 
 #wsrep_provider_options="gcache.size=32G"  

 # Galera Cluster Configuration 
 wsrep_cluster_name="example_cluster"  

 # Initialize the cluster; switch after --wsrep-new-cluster has been run and other nodes have joined. 
 wsrep_cluster_address="gcomm:// 

 # Set cluster node addresses (hostnames work too) 
 #wsrep_cluster_address="gcomm://192.168.0.1,192.168.0.2,192.168.0.3"  

 # Galera Synchronization Configuration 
 wsrep_sst_method=rsync 
 #wsrep_sst_auth=user:pass 

 # Galera Node Configuration 
 wsrep_node_address="192.168.0.1"  
 wsrep_node_name="db1.example.com" 
 </pre>  

 * Bootstrap the new Galera cluster 
 <pre> 
 service mysql.server.sh bootstrap 
 </pre> 
 *# The alternate way to bootstrap the cluster is like so: 
 <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 stop 
 service mysql.server.sh start 
 </pre> 

 h2. Configuring the Galera Cluster 

 h2. Resources 

 * https://mariadb.com/kb/en/getting-the-mariadb-source-code/ 
 * https://mariadb.com/kb/en/generic-build-instructions/ 
 * https://mariadb.com/kb/en/getting-started-with-mariadb-galera-cluster/ 
 * https://code.launchpad.net/maria 
 * http://www.fromdual.ch/building-galera-replication-from-scratch 
 * https://mariadb.com/kb/en/starting-and-stopping-mariadb-automatically/ 
 * http://planet.mysql.com/entry/?id=30931 
 * http://galeracluster.com/documentation-webpages/compiling.html

Back