MariaDB MaxScale — Replica Rebuild – Part 5

Part 5 — Configure MaxScale

This multi-part series breaks down each section into easy logical steps.

If you have not completed part 1, start here.


MaxScale Configuration

To configure MaxScale various parts need to be completed. We will be using the MaxScale Config Sync to save the configuration within our database. This is a good thing, as it means your configuration for MaxScale is backed up by the database backups, but also, if you introduce more MaxScale servers, the configuration can be read and shared from the database servers.

To configure MaxScale, we must create a /etc/maxscale.cnf file, there will be one in place from the installation, and I like to move this out of the way first:

Bash
mv /etc/maxscale.cnf /etc/maxscale.cnf.OLD

Using your favourite editor create a file:

Bash
vi /etc/maxscale.cnf

and insert some very basic MaxScale configuration. Within the [server1] definition, you must enter the IP address of your database server, that we created the users on:

Bash
[maxscale]
threads=auto
config_sync_cluster="Server-Monitor"
config_sync_user=config_sync_user
config_sync_password=aBcd123_
admin_secure_gui=false
admin_host=0.0.0.0

# Server definitions
[server1]
type=server
address=10.106.0.2
port=3306
protocol=MariaDBBackend

# Monitor for the servers
[Server-Monitor]
type=monitor
module=mariadbmon
servers=server1
user=monitor_user
password=aBcd123_
replication_user=replication_user
replication_password=aBcd123_
rebuild_port=4444
monitor_interval=2000ms
ssh_port=22
ssh_user=maxscaleUser
ssh_keyfile=/etc/maxscale/.ssh/id_rsa
ssh_check_host_key=false

At this point, you can restart the MaxScale service, and if everything has gone to plan, it will restart without an error:

Bash
systemctl restart maxscale

MaxScale has a command line tool called maxctrl. We will use this tool to manipulate the MaxScale server further. To start we will list the servers:

Bash
maxctrl list servers

When you run this command, you should see some output similar to this:

It is very important that you have a GTID showing, if there is no GTID showing, you must run a command on the server1 database, for the GTID to start.

Using the maxctrl tool, we will add the other servers to our MaxScale configuration. (Make sure you use the correct IP addresses for your servers):

Bash
maxctrl create server server2 10.106.0.3 3306
maxctrl create server server3 10.106.0.4 3306
maxctrl list servers

You should now see all three servers in the table:

You will note, that the server is marked as down, and this is because the monitor, mariadbmon, is not yet configured. The two additional servers are visible, but they are not part of the monitor, so we need to add them. This is done with the maxctrl tool:

Bash
maxctrl link monitor Server-Monitor server2
maxctrl link monitor Server-Monitor server3
maxctrl list monitors

You can now see the servers as part of the monitor:

This image has an empty alt attribute; its file name is image-6.png

We will use the MaxScale Replica Rebuild command in Part 6 to see how this is completed.


Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7 | Part 8 | Part 9

Kester Riley

Kester Riley is a Senior Solutions Engineer who leverages his website to establish his brand and build strong business relationships. Through his blog posts, Kester shares his expertise as a consultant, mentor, trainer, and presenter, providing innovative ideas and code examples to empower ambitious professionals.

CentOS (15) Connector (5) Continuous Availability (1) Cooperative Monitoring (3) High Availability (12) Java (3) MariaDB (16) MaxScale (14) Python (2) Replica Rebuild (10) Rocky Linux (15)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.