There are binary installation packages available for RPM and Debian-based distributions, which will pull in all required Galera dependencies.
If these are not available, you will need to build Galera from source, as follows:
make cannot manage dependencies for Galera or the build process, so the following packages need to be installed first:
apt-get build-dep mariadb-server
If running on an alternative system, or the commands are available, the following packages are required. You will need to check the repositories for the correct package names on your distribution - these may differ between distributions, or require additional packages:
MariaDB database server with wsrep API
- Git, CMake (on Fedora, both cmake and cmake-fedora are required), GCC and GCC-C++, Automake, Autoconf, and Bison, as well as development releases of libaio and ncurses.
Galera replication plugin
- SCons, as well as development releases of Boost, Check and OpenSSL.
MariaDB 10.1 includes the wsrep API for Galera Cluster by default. You can use Git to download the source code, as MariaDB source code is available through GitHub.
- Clone the repository:
# git clone https://github.com/mariadb/server
- Checkout the branch (there are three main branches: 10.1, 10.0-galera and 5.5-galera), for example:
# git checkout 10.0-galera
- This makes the source files for the database server, along with the wsrep API, available. You also need the Galera Replicator Plugin, which needs to be in a separate directory. Run
# cd ..and
# git clone -b mariadb-3.x https://github.com/MariaDB/galera.gitAfter this, the source files for the database server will be in the
/serverdirectory, and for Galera in the
Building the database server
The standard and Galera cluster database servers are the same, except that for Galera Cluster, the wsrep API patch is included. Enable the patch with the CMake configuration options
WITH_INNODB_DISALLOW_WRITES. To build the database server, cd into the server/ directory and run the following commands:
# cmake -DWITH_WSREP=ON -DWITH_INNODB_DISALLOW_WRITES=ON ./ # make # make install
There are also some build scripts in the BUILD/ directory which may be more convenient to use. For example, the following pre-configures the build options discussed above:
There are several others as well, so you can select the most convenient.
Building the wsrep Provider
The Galera Replication Plugin both implements the wsrep API and operates as the database server's wsrep Provider. To build, cd into the galera/ directory, run build.sh under scripts/, and copy the resulting
libgalera_smm.so file to where it can be found, for example:
# ./scripts/build.sh # mkdir /usr/lib64/galera## # cp libgalera_smm.so /usr/lib64/galera/##
The path to
libgalera_smm.so needs to be defined in the my.cnf configuration file.
Building Galera Replication Plugin from source on FreeBSD runs into issues due to Linux dependencies. To overcome these, either install the binary package:
pkg install galera, or use the ports build available at
After building, a number of other steps are necessary:
- Create the database server user and group:
# groupadd mysql # useradd -g mysql mysql
- Install the database (the path may be different if you specified CMAKE_INSTALL_PREFIX):
# cd /usr/local/mysql # ./scripts/mysql_install_db --user=mysql
- If you want to install the database in a location other than /usr/local/mysql/data , use the --basedir or --datadir options.
- Change the user and group permissions for the base directory.
# chown -R mysql /usr/local/mysql # chgrp -R mysql /usr/local/mysql
- Create a system unit for the database server.
# cp /usr/local/mysql/supported-files/mysql.server \ /etc/init.d/mysql # chmod +x /etc/init.d/mysql # chkconfig --add mysql
- Galera Cluster can now be started using the service command, and is set to start at boot.