Databases 7 min read

Install & Configure MaxScale for MySQL Read/Write Splitting & Load Balancing

This guide explains what MaxScale is, its plugin architecture, and provides step‑by‑step instructions to install, configure, start, and test MaxScale for MySQL read/write splitting and load balancing in a master‑slave cluster.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Install & Configure MaxScale for MySQL Read/Write Splitting & Load Balancing

What is MaxScale?

After configuring MySQL master‑slave replication, we often need read/write splitting and load balancing across slaves. These are basic requirements for a MySQL cluster, and MaxScale provides an easy way to achieve them.

Basic Architecture of MaxScale

MaxScale is developed by MariaDB, a sister company of MySQL, and has matured into a plugin‑based system that allows users to develop custom plugins. Currently MaxScale offers five types of plugins:

Authentication plugins : cache user table information and validate connections.

Protocol plugins : handle client‑to‑server and server‑to‑client protocols.

Routing plugins : decide how client requests are forwarded, implementing read/write splitting and load balancing.

Monitoring plugins : monitor server health and exclude slow servers.

Logging and filtering plugins : provide simple firewall functions, SQL filtering and fault tolerance.

Installing and Using MaxScale

Assume a three‑node MySQL cluster (one master, two slaves).

Step 1: Prepare the cluster environment

Set up MySQL master‑slave replication on three servers (refer to existing guides).

Step 2: Install MaxScale

Download from https://downloads.mariadb.com/files/MaxScale and install the appropriate package. For CentOS 7:

yum install libaio.x86_64 libaio-devel.x86_64 novacom-server.x86_64 libedit -y
rpm -ivh maxscale-1.4.3-1.centos.7.x86_64.rpm

Step 3: Configure MaxScale

Create two MySQL users on the master for monitoring and routing:

mysql> create user scalemon@'%' identified by '111111';
mysql> grant replication slave, replication client on *.* to scalemon@'%';
mysql> create user maxscale@'%' identified by '111111';
mysql> grant select on mysql.* to maxscale@'%';

Edit /etc/maxscale.cnf:

Define [server1], [server2], [server3] sections with appropriate address and port.

In [MySQL Monitor] set servers=server1,server2,server3 and the monitoring user credentials.

In [Read-Write Service] set the same servers and routing user credentials.

Remove the default [Read-Only Service] section.

Step 4: Start MaxScale maxscale --config=/etc/maxscale.cnf Verify listening ports (e.g., 4006 for client connections, 6603 for the manager) with netstat -ntelp.

Log into the manager with maxadmin --user=admin --password=mariadb and run list servers to see connected master and slaves.

Step 5: Test

Create a test user on the master:

mysql> grant ALL PRIVILEGES on *.* to rtest@'%' identified by '111111';

Connect through MaxScale: mysql -h <MaxScale_IP> -P 4006 -u rtest -p111111 Running a transaction routes queries to the master, while regular SELECTs are served by slaves, confirming that read/write splitting works.

MaxScale configuration is now complete.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mysqlread/write splittingInstallationDatabase ProxyMaxScale
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.