Project

General

Profile

Support #380

Installing A MariaDB Galera Node in a FreeNAS Jail

Added by Daniel Curtis almost 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Database Server
Target version:
Start date:
04/28/2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

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" 
      

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
      
  • 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
    
    1. The alternate way to bootstrap the cluster is like so:
      /usr/local/mysql/bin/mysqld --user=mysql --wsrep-new-cluster
      
  • 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

#1

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
  • % Done changed from 30 to 70
#2

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
  • % Done changed from 70 to 80
#3

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
#4

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
#5

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
#6

Updated by Daniel Curtis almost 10 years ago

  • Description updated (diff)
#7

Updated by Daniel Curtis over 9 years ago

  • Project changed from 82 to FreeBSD Administration
  • Description updated (diff)
#8

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#9

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#10

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • % Done changed from 80 to 90
#11

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
  • Status changed from In Progress to Resolved
  • % Done changed from 90 to 100
#12

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#13

Updated by Daniel Curtis over 9 years ago

  • Description updated (diff)
#14

Updated by Daniel Curtis over 9 years ago

  • Status changed from Resolved to Closed
#15

Updated by Daniel Curtis about 9 years ago

  • Target version set to 5
#16

Updated by Daniel Curtis about 9 years ago

  • Category set to Database Server
#17

Updated by Daniel Curtis about 9 years ago

  • Target version changed from 5 to FreeNAS 9.x

Also available in: Atom PDF