Tag Archives: MariaDB

MaxScale MariaDB

MaxScale MariaDB

This is a small guide to install MaxScale on Ubuntu. Scalable, highly available and powerful transformative database services with MariaDB MaxScale.

First step is to add the repository into your config

sudo apt-get install software-properties-common
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8167EE24
sudo add-apt-repository 'deb [arch=amd64] http://downloads.mariadb.com/software/MaxScale/maxscale/DEB trusty main'

Now you can install MaxScale

sudo apt-get update
sudo apt-get install maxscale

This should look like this

# aptitude install maxscale
The following NEW packages will be installed:
libaio1{a} maxscale
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.8 MB of archives. After unpacking 76.8 MB will be used.
Do you want to continue? [Y/n/?]
Get: 1 http://downloads.mariadb.com/software/MaxScale/maxscale/DEB/ trusty/main maxscale amd64 1.0.5 [27.7 MB]
Get: 2 http://archive.ubuntu.com/ubuntu/ trusty/main libaio1 amd64 0.3.109-4 [6,364 B]
Fetched 27.8 MB in 2s (12.8 MB/s)
Selecting previously unselected package libaio1:amd64.
(Reading database ... 16780 files and directories currently installed.)
Preparing to unpack .../libaio1_0.3.109-4_amd64.deb ...
Unpacking libaio1:amd64 (0.3.109-4) ...
Selecting previously unselected package maxscale.
Preparing to unpack .../maxscale_1.0.5_amd64.deb ...
Unpacking maxscale (1.0.5) ...
Setting up libaio1:amd64 (0.3.109-4) ...
Setting up maxscale (1.0.5) ...
Processing triggers for libc-bin (2.19-0ubuntu6.5) ...

Default password for MaxScale is

skysql

Main directory

/usr/local/skysql/maxscale

Logroate script

/usr/local/skysql/maxscale/log/*.log {
monthly
rotate 5
missingok
nocompress
sharedscripts
postrotate
# run if maxscale is running
if test -n "`ps acx|grep maxscale`"; then
/usr/local/skysql/maxscale/bin/maxadmin -pskysql flush logs
fi
endscript
}

Create a DB user for MaxScale, on your MariaDB server

create user 'maxscale'@'192.168.0.%' identified by 'setup123';
grant SELECT on mysql.user to 'maxscale'@'192.168.0.%';
grant SELECT on mysql.db to 'maxscale'@'192.168.0.%';
grant SHOW DATABASES on *.* to 'maxscale'@'192.168.0.%';
flush privileges;

Small config for MaxScale

[maxscale]
threads=6

[Galera Monitor]
type=monitor
module=galeramon
servers=amupv-db01-test,amupv-db02-test,amupv-db03-test
user=maxscale
passwd=setup123
monitor_interval=10000

[Read Connection Router]
type=service
router=readconnroute
servers=amupv-db01-test,amupv-db02-test,amupv-db03-test
user=maxscale
passwd=setup123
router_options=slave

[RW Split Router]
type=service
router=readwritesplit
servers=amupv-db01-test,amupv-db02-test,amupv-db03-test
user=maxscale
passwd=setup123

[Debug Interface]
type=service
router=debugcli

[CLI]
type=service
router=cli

[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
port=4008

[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=3306

[Debug Listener]
type=listener
service=Debug Interface
protocol=telnetd
address=127.0.0.1
port=4442

[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=127.0.0.1
port=6603

[amupv-db01-test]
type=server
address=192.168.0.1
port=3306
protocol=MySQLBackend

[amupv-db02-test]
type=server
address=192.168.0.2
port=3306
protocol=MySQLBackend

[amupv-db03-test]
type=server
address=192.168.0.3
port=3306
protocol=MySQLBackend

Now you can start MaxScale

service maxscale start

maxadmin

# /usr/local/skysql/maxscale/bin/maxadmin 
Password: 
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server             | Address         | Port  | Connections | Status              
-------------------+-----------------+-------+-------------+--------------------
amupv-db01-test    | 192.168.0.1  |  3306 |           0 | Master, Synced, Running
amupv-db02-test    | 192.168.0.2  |  3306 |           0 | Slave, Synced, Running
amupv-db03-test    | 192.168.0.3  |  3306 |           0 | Slave, Synced, Running
-------------------+-----------------+-------+-------------+--------------------
MaxScale> show servers
Server 0x1fb8b90 (amupv-db01-test)
	Server:				192.168.0.1
	Status:               		Master, Synced, Running
	Protocol:			MySQLBackend
	Port:				3306
	Server Version:			10.0.15-MariaDB-1~trusty-wsrep-log
	Node Id:			0
	Master Id:			-1
	Repl Depth:			0
	Number of connections:		0
	Current no. of conns:		0
	Current no. of operations:	0
Server 0x1f153b0 (amupv-db02-test)
	Server:				192.168.0.2
	Status:               		Slave, Synced, Running
	Protocol:			MySQLBackend
	Port:				3306
	Server Version:			10.0.15-MariaDB-1~trusty-wsrep-log
	Node Id:			2
	Master Id:			-1
	Repl Depth:			0
	Number of connections:		0
	Current no. of conns:		0
	Current no. of operations:	0
Server 0x1f152a0 (amupv-db03-test)
	Server:				192.168.0.3
	Status:               		Slave, Synced, Running
	Protocol:			MySQLBackend
	Port:				3306
	Server Version:			10.0.15-MariaDB-1~trusty-wsrep-log
	Node Id:			1
	Master Id:			-1
	Repl Depth:			0
	Number of connections:		0
	Current no. of conns:		0
	Current no. of operations:	0

Links:
https://mariadb.com/portal_file/60898
https://mariadb.com/products/mariadb-maxscale