How to setup a Galera Arbitrator on Ubuntu 16

Try it in our public cloud & Get $5 Credit
CLAIM NOW

For best results, your Galera cluster should have three nodes, preferably in three distinct data centers. But sometimes this isn’t practical or possible. Maybe you simply can’t afford the server capacity to acquire an odd number of nodes, but still want to enjoy the benefits gained from clustering across two or four separate Galera servers.

But due to how Galera’s clustering algorithm operates, it is strongly recommended that you have an odd number of nodes. Even numbers may result in split-brain situations, where cluster members cannot vote effectively due to ties. You may also want a consistent application state for backups, which an arbitrator can help with. This guide sets up an Ubuntu 14.04 LTS server as a Galera arbitrator. It will not replicate data, but will resolve ties and help enforce application consistency.

Getting Started

You’ll need the following in place before getting started with this guide:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 16.
• Root access

Tutorial

This example will add a Galera arbitrator to an existing two-node cluster, thus making the total node count an odd number and immune to deadlocks.

Start by installing the software-properties package. This provides you with the add-apt-repository command, a convenient helper for quickly integrading Ubuntu PPAs into your system.

apt-get install software-properties-common -y

Next we’ll install the packages necessary to run the Galera arbitrator.

apt-get install galera-3 galera-arbitrator-3 -y

With that complete, we’ll now configure the arbitrator node to connect to your existing cluster. Begin by editing the configuration file.

nano /etc/default/garb

Uncomment the following line:

# Copyright (C) 2012 Codership Oy
# This config file is to be sourced by garb service script.
# A comma-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES="10.0.0.119:4567"
# Galera cluster name, should be the same as on the rest of the nodes.
GALERA_GROUP="test_cluster"
# Optional Galera internal options string (e.g. SSL settings)
# see http://galeracluster.com/documentation-webpages/galeraparameters.html
# GALERA_OPTIONS=""
# Log file for garbd. Optional, by default logs to syslog
# LOG_FILE=""

Next, start the arbitrator you’ve just configured.

service garb start

The arbitrator should have joined your existing Galera cluster. To confirm this, log into any of the two other nodes in your current cluster and execute the following command:

mysql -u root -p -e "show status like 'wsrep_cluster_size'"

Assuming the arbitrator is correctly configured and has joined, you’ll have output indicating that there are two cluster nodes and one arbitrator. It should look as follows:

+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+

Conclusion

Your Galera cluster is now immune to deadlocks, and other conditions that arise with an odd number of members. Share this article with anyone wishing to set up a highly available Galera cluster, but for whom a full three-node setup might be impractical.