How to setup MariaDB MaxScale on CentOS 7

Share on Social Media

In this configuration guide, you will learn, how to setup MariaDB MaxScale on CentOS 7 or other Redhat based Linux OS. #centlinux #linux #mysql

What is MaxScale? :

MaxScale is an intelligent database proxy developed by MariaDB Corporation. MaxScale is free and open source under Business Source License (BSL). MaxScale extends the high availability, load-balancing, scalability and security of MariaDB server and it simplifies the application development by decoupling it from underlying database infrastructure.

In our previous post “Install MariaDB Galera Cluster on CentOS 7”, we have configured two node MariaDB cluster on CentOS 7 server using Galera. In this article, we will install MariaDB MaxScale database proxy for our Galera cluster.

Read Also: How to install MariaDB MaxScale on Rocky Linux 9

System Specification:

We will use the same MariaDB Galera cluster that we have configured in our previous post. Besides Galera cluster, we have also provisioned a virtual machine with following specification. This new virtual machine is used as the MaxScale database proxy for our MariaDB cluster.

  • Hostname –
  • IP Address –
  • CPU – 2.4 Ghz (2 cores)
  • Memory – 1 GB
  • Operating System – CentOS 7.6

Install MariaDB MaxScale on CentOS 7:

Connect to arbitrary node using ssh.

Install MariaDB and MaxScale yum repositories.

# curl -sS | bash
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo.
[info] Adding trusted package signing keys...
[info] Succeessfully added trusted package signing keys.

Build yum cache.

# yum makecache fast
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base:
 * extras:
 * updates:
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
mariadb-main                                             | 2.9 kB     00:00
mariadb-maxscale                                         | 2.4 kB     00:00
mariadb-tools                                            | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/5): extras/7/x86_64/primary_db                          | 156 kB   00:01
(2/5): mariadb-tools/7/x86_64/primary_db                   |  11 kB   00:02
(3/5): mariadb-maxscale/7/x86_64/primary_db                | 6.7 kB   00:02
(4/5): mariadb-main/7/x86_64/primary_db                    |  50 kB   00:03
(5/5): updates/7/x86_64/primary_db                         | 1.4 MB   00:04
Metadata Cache Created

Install MariaDB MaxScale using yum command.

# yum install -y maxscale

Create MySQL User:

To setup MariaDB MaxScale communication with Galera Cluster, we need a MySQL database user.

Connect to an instance of MariaDB Galera Cluster and create a user for monitoring and authentication by MaxScale. (Since, our nodes have formed a cluster, therefore, we only need to execute the following commands on any single node).

# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 11
Server version: 10.3.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]>

Execute following commands to create a MaxScale user with necessary privileges to perform it’s function properly.

> create user 'maxscale'@'' identified by '123';
Query OK, 0 rows affected (0.005 sec)

> grant select on mysql.user to 'maxscale'@'';
Query OK, 0 rows affected (0.041 sec)

> grant select on mysql.db to 'maxscale'@'';
Query OK, 0 rows affected (0.002 sec)

> grant select on mysql.tables_priv to 'maxscale'@'';
Query OK, 0 rows affected (0.043 sec)

> grant show databases on *.* to 'maxscale'@'';
Query OK, 0 rows affected (0.003 sec)

> flush privileges;
Query OK, 0 rows affected (0.004 sec)

Create a user with privileges to remotely connect from any machine. This user will be used by our application to connect to MariaDB Galera cluster.

> create user ahmer@'%' identified by '123';
Query OK, 0 rows affected (0.005 sec)

> grant show databases on *.* to ahmer@'%';
Query OK, 0 rows affected (0.003 sec)

> flush privileges;
Query OK, 0 rows affected (0.004 sec)

> exit

Setup MariaDB MaxScale on CentOS 7:

Now, connect to and configure MaxScale database proxy.

Edit MaxScale configurations.

# mv /etc/maxscale.cnf /etc/maxscale.cnf.old
# vi /etc/maxscale.cnf

and add following directives. (Please refer to MaxScale Documentation for more information about MaxScale configuration parameters)

#Global MaxScale Settings

#Define Server Nodes 


#Define Monitoring Service 

#Define Galera Service 

#Define Galera Listener 

#Define Administration Service 

#Define Administration Listener 

Configure Linux Firewall:

Allow Service Port in Linux Firewall.

# firewall-cmd --permanent --add-port=4306/tcp
# firewall-cmd --reload

Test MariaDB MaxScale configurations:

Start and enable MaxScale service.

# systemctl start maxscale.service
# systemctl enable maxscale.service

Make some connections from clients to Galera Cluster using ahmer user via MaxScale database proxy.

# mysql -h -P 4306 -u ahmer -p

Connect to using ssh, and use maxadmin command to see status of connections to MariaDB Galera Cluster.

# maxadmin
MaxScale> list servers
Server             | Address         | Port  | Connections | Status             
mariadb-01         |  |  3306 |           2 | Slave, Synced, Running
mariadb-02         |  |  3306 |           3 | Master, Synced, Running

The above command shows the status of nodes in MariaDB Galera cluster including the active connections and replication status. You can use help command to get help on a maxadmin command or refer to maxadmin documentation for complete reference.


In this configuration guide, you have learned, how to setup MariaDB MaxScale on CentOS 7 or other Redhat based Linux OS.