Support #380
Installing A MariaDB Galera Node in a FreeNAS Jail
Description
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:
portsnap fetch extract
- Once that is done, build mariadb55-server from the ports tree, the uninstall mariadb55-server. This is to resolve the source dependencies for recompiling the MariaDB server later on with wsrep.
cd /usr/ports/databases/mariadb55-server make install clean make deinstall clean
- And now resolve a few dependencies before compiling the new MariaDB server:
pkg install bzr bison boost-all scons libcheck cmake bash rsync gcc48
Download and compile MariaDB with wsrep¶
- Download the latest Galera patched MariaDB from launchpad
cd /usr/src bzr branch lp:~maria-captains/maria/maria-5.5-galera maria-5.5-galera
- Compile MariaDB with wsrep:
cd maria-5.5-galera cmake . -DBUILD_CONFIG=mysql_release -DWITH_WSREP=ON -DWITH_INNODB_DISALLOW_WRITES=1 make make install cd ..
Download and compile Galera¶
- Install Galera from the ports tree (recommended)
cd /usr/ports/databases/galera make install clean
Or install from the developers tree:¶
- Remove any existing galera packages:
cd /usr/ports/databases/galera make deinstall clean pkg remove galera cd /usr/src bash
- Modify the build environment
export CC=gcc48 export CXX=c++48 export CPP=cpp48
- Download galera source
bzr branch lp:galera/2.x galera-2.x cd galera-2.x bash ./scripts/build.sh
- Copy the modules:
cp garb/garbd /usr/local/mysql/bin/ cp libgalera_smm.so /usr/local/lib/
Configure mysql¶
- Copy mysql config sample:
cp /usr/local/mysql/support-files/my-small.cnf /usr/local/etc/my.cnf
- Edit the mysql config file:
vi /usr/local/etc/my.cnf
- And add or modify the following:
[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/local/lib/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 Congifuration 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"
- And add or modify the following:
Setup the boot scripts¶
- Copy the boot mariadb boot script
cp /usr/local/mysql/support-files/mysql.server /usr/local/etc/rc.d/mysql.server.sh
- The boot script also needs to be edited, like the following example:
vi /usr/local/etc/rc.d/mysql.server.sh
- And modify the two configuration parameters:
basedir=/usr/local/mysql datadir=/usr/local/mysql/data
- And modify the two configuration parameters:
- Initialize and secure the MariaDB database
cd /usr/local/mysql /usr/local/mysql/scripts/mysql_install_db chown -R mysql:mysql data/
- Bootstrap the new Galera cluster
service mysql.server.sh bootstrap
- The alternate way to bootstrap the cluster is like so:
/usr/local/mysql/bin/mysqld --user=mysql --wsrep-new-cluster
- The alternate way to bootstrap the cluster is like so:
- Now in a second terminal connection run the
mysql_secure_installation
script to do some post-installation hardening:/usr/local/mysql/bin/mysql_secure_installation
- By this point MariaDB should be able to be controlled by the service command:
service mysql.server.sh stop service mysql.server.sh start
- Check the wsrep status
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_%';"
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
http://www.fromdual.com/building-galera-replication-from-scratch
Updated by Daniel Curtis over 10 years ago
- Description updated (diff)
- % Done changed from 30 to 70
Updated by Daniel Curtis over 10 years ago
- Description updated (diff)
- % Done changed from 70 to 80
Updated by Daniel Curtis about 10 years ago
- Project changed from 82 to FreeBSD Administration
- Description updated (diff)
Updated by Daniel Curtis about 10 years ago
- Description updated (diff)
- % Done changed from 80 to 90
Updated by Daniel Curtis about 10 years ago
- Description updated (diff)
- Status changed from In Progress to Resolved
- % Done changed from 90 to 100