This document is designed as a quick introduction to setting up MariaDB MaxScale.
The installation and configuration of the MariaDB Server is not covered in this document. See the following MariaDB documentation articles for more information on setting up a primary-replica-cluster or a Galera-cluster: and .
This tutorial assumes that one of the standard MaxScale binary distributions is used and that MaxScale is installed using default options.
Building from source code in GitHub is covered in Building from Source.
The precise installation process varies from one distribution to another. Details on package installation can be found in the .
MaxScale checks that incoming clients are valid. To do this, MaxScale needs to retrieve user authentication information from the backend databases. Create a special user account for this purpose by executing the following SQL commands on the primary server of your database cluster. The following tutorials will use these credentials.
MariaDB versions 10.2.2 to 10.2.10 also require GRANT SELECT ON mysql.* TO 'maxscale'@'%';
Because MariaDB MaxScale sits between the clients and the backend databases, the backend databases will see all clients as if they were connecting from MaxScale's address. This usually means that two sets of grants for each user are required.
For example, assume that the user 'jdoe'@'client-host' exists and MaxScale is located at_maxscale-host_. If 'jdoe'@'client-host' needs to be able to connect through MaxScale, another user, 'jdoe'@'maxscale-host', must be created. The second user must have the same password and similar grants as 'jdoe'@'client-host'.
The quickest way to do this is to first create the new user:
Then do a SHOW GRANTS query:
Then copy the same grants to the 'jdoe'@'maxscale-host' user.
An alternative to generating two separate accounts is to use one account with a wildcard host ('jdoe'@'%') which covers both hosts. This is more convenient but less secure than having specific user accounts as it allows access from all hosts.
MaxScale reads its configuration from /etc/maxscale.cnf. A template configuration is provided with the MaxScale installation.
A global maxscale section is included in every MaxScale configuration file. This section sets the values of various global parameters, such as the number of threads MaxScale uses to handle client requests. To set thread count to the number of available cpu cores, set the following.
Read the mini-tutorial for server configuration instructions.
The type of monitor used depends on the type of cluster used. For a primary-replica cluster read . For a Galera cluster read .
This part is covered in two different tutorials. For a fully automated read-write-splitting setup, read the . For a simple connection based setup, read the .
After configuration is complete, MariaDB MaxScale is ready to start. For systems that use systemd, use the systemctl command.
For older SysV systems, use the service command.
If MaxScale fails to start, check the error log in /var/log/maxscale/maxscale.log to see if any errors are detected in the configuration file.
The maxctrl-command can be used to confirm that MaxScale is running and the services, listeners and servers have been correctly configured. The following shows expected output when using a read-write-splitting configuration.
MariaDB MaxScale is now ready to start accepting client connections and route queries to the backend cluster.
More options can be found in the , and .
For more information about MaxCtrl and how to secure it, see the .
This page is licensed: CC BY-SA / Gnu FDL
CREATE USER 'maxscale'@'%' IDENTIFIED BY 'maxscale_pw';
GRANT SELECT ON mysql.user TO 'maxscale'@'%';
GRANT SELECT ON mysql.db TO 'maxscale'@'%';
GRANT SELECT ON mysql.tables_priv TO 'maxscale'@'%';
GRANT SELECT ON mysql.columns_priv TO 'maxscale'@'%';
GRANT SELECT ON mysql.procs_priv TO 'maxscale'@'%';
GRANT SELECT ON mysql.proxies_priv TO 'maxscale'@'%';
GRANT SELECT ON mysql.roles_mapping TO 'maxscale'@'%';
GRANT SHOW DATABASES ON *.* TO 'maxscale'@'%';CREATE USER 'jdoe'@'maxscale-host' IDENTIFIED BY 'my_secret_password';MariaDB [(none)]> SHOW GRANTS FOR 'jdoe'@'client-host';
+-----------------------------------------------------------------------+
| Grants for jdoe@client-host |
+-----------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'jdoe'@'client-host' |
+-----------------------------------------------------------------------+
1 row in set (0.01 sec)GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'jdoe'@'maxscale-host';[maxscale]
threads=autosudo systemctl start maxscalesudo service maxscale start% sudo maxctrl list services
ββββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββ¬ββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β Service β Router β Connections β Total Connections β Servers β
ββββββββββββββββββββΌβββββββββββββββββΌββββββββββββββΌββββββββββββββββββββΌββββββββββββββββββββββββββββ€
β Splitter-Service β readwritesplit β 1 β 1 β dbserv1, dbserv2, dbserv3 β
ββββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
% sudo maxctrl list servers
βββββββββββ¬ββββββββββββββ¬βββββββ¬ββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββ
β Server β Address β Port β Connections β State β GTID β
βββββββββββΌββββββββββββββΌβββββββΌββββββββββββββΌββββββββββββββββββΌββββββββββββ€
β dbserv1 β 192.168.2.1 β 3306 β 0 β Master, Running β 0-3000-62 β
βββββββββββΌββββββββββββββΌβββββββΌββββββββββββββΌββββββββββββββββββΌββββββββββββ€
β dbserv2 β 192.168.2.2 β 3306 β 0 β Slave, Running β 0-3000-62 β
βββββββββββΌββββββββββββββΌβββββββΌββββββββββββββΌββββββββββββββββββΌββββββββββββ€
β dbserv3 β 192.168.2.3 β 3306 β 0 β Slave, Running β 0-3000-62 β
βββββββββββ΄ββββββββββββββ΄βββββββ΄ββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββ
% sudo maxctrl list listeners Splitter-Service
βββββββββββββββββββββ¬βββββββ¬βββββββ¬ββββββββββ
β Name β Port β Host β State β
βββββββββββββββββββββΌβββββββΌβββββββΌββββββββββ€
β Splitter-Listener β 3306 β β Running β
βββββββββββββββββββββ΄βββββββ΄βββββββ΄ββββββββββ