Recent project we implemented MaxScale to load balancing a cluster of MariaDB Galera servers. This solution previously used haproxy to evenly distribute the load across all the servers. The issue with haproxy is the site would get issues deadlock’s. For a variety of reasons this solution required a way to split reads across the entire cluster but only write to a single node with failover. MaxScale fits this bill perfectly as it has intelligent SQL analysis of sql statements going though it.
First thing for the distribution you are using you need to download the source, deb, rpm. We will be installing this example on Ubuntu 14.04 and the current version as of this post MaxScale 1.4.3. Substitute for the distribution and version of your choice.
What we are doing here is the following:
* Prep to download to /tmp
* In Ubuntu libaio1 is a dependency so it must be installed before MaxScale
* Download the latest deb file
* Install MaxScale
* Enable MaxScale to start on boot
Now that we have MaxScale installed the next step is the configuration. The first thing we need to do is create a new MaxScale user. This user will login and get the credentials from the privileges table (you authenticate against MaxScale technically) and monitor each instance.
Finally here is the working /etc/maxscale.cnf. I have included notes in the important configuration section.
Now we can run the maxadmin commands to view the status. As you can see the three nodes are in the load balancer. Current server2 (172.16.20.141) is the current Master. You can test this by stopping MariaDB on the node marked Master and watch MaxScale automatically switch.
Brian has spent more than fifteen years as Unix enthusiast, specalising in systems administration and solutions architecture for SMB's to Fortune 100 companies. His career has focused on emerging and niche technologies to major advancements in the industry - most notibly cloud.