MaxScale的基本使用

1 MaxScale作为proxy

标识 IP地址 角色 版本
node1 *.*.*.200 MaxScale MaxScale 2.1.9
node2 *.*.*.14 master percona-5.7.19-17
node3 *.*.*.182 slave1 percona-5.7.19-17
node4 *.*.*.192 slave2 percona-5.7.19-17

MaxScale Master_Slave

[maxscale]
threads=auto
syslog=1

log_warning=1
log_notice=1
log_info=1
log_debug=0

log_augmentation=1

basedir=/usr/local/maxscale/
logdir=/u01/maxscale/logs/trace/
datadir=/u01/maxscale/data/
cachedir=/u01/maxscale/cache/
piddir=/u01/maxscale/tmp/

[server1]
type=server
address=*.*.*.14
port=3306
protocol=MySQLBackend

[server2]
type=server
address=*.*.*.182
port=3306
protocol=MySQLBackend

[server3]
type=server
address=*.*.*.192
port=3306
protocol=MySQLBackend

[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3
user=test
passwd=pwd
monitor_interval=10000

[Read-Only Service]
type=service
router=readconnroute
servers=server2,server3
user=test
passwd=pwd
router_options=slave

[Read-Write Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=test
passwd=pwd

[MaxAdmin Service]
type=service
router=cli

[Read-Only Listener]
type=listener
service=Read-Only Service
protocol=MySQLClient
port=4008

[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006

[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
socket=/u01/maxscale/tmp/maxadmin.sock
port=6603
/usr/bin/maxscale -f /etc/maxscale.cnf
/usr/bin/maxadmin -S /u01/maxscale/tmp/maxadmin.sock
list servers
list services
mysql -utest -p -hXXX -P4006
mysql -utest -p -hXXX -P4008

2 MaxScale作为Binlog Server

node5 *.*.*.226 Binlog Server MaxScale 2.1.9
node6 *.*.*.151 sub-slave percona-5.7.19-17

Master_MaxScale_BinlogServer_Slave

cat /etc/maxscale.cnf

[maxscale]
threads=auto
syslog=1
maxlog=1
log_warning=1
log_notice=1
log_info=1
log_debug=0
log_augmentation=1

basedir=/usr/local/maxscale/
logdir=/u01/maxscale/logs/trace/
datadir=/u01/maxscale/data/
cachedir=/u01/maxscale/cache/
piddir=/u01/maxscale/tmp/

[Replication]
type=service
router=binlogrouter
version_string=5.7.19-17

router_options=server_id=1024, heartbeat=30, send_slave_heartbeat=1
binlogdir=/data/binlog
user=test
passwd=pwd

[ReplicationListener]
type=listener
service=Replication
protocol=MySQLClient
port=5308

[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
socket=/u01/maxscale/tmp/maxadmin.sock
port=6603

[MaxAdmin Service]
type=service
router=cli
cat /data/binlog/master.ini
[binlog_configuration]
master_host=*.*.*.14
master_port=3306
master_user=repl
master_password=pwd
filestem=mysql-bin
/usr/bin/maxscale -f /etc/maxscale.cnf
mysql -utest -p  -h*.*.*.226 -P5308
show master status;
show slave status\G

3 MaxScale作为proxy & Binlog Server

node1 *.*.*.226 proxy & Binlog Server MaxScale 2.1.9
node7 *.*.*.7 sub-slave percona-5.7.19-17

MaxScale_BinlogServer_Master_Slave

cat /etc/maxscale.cnf

[Replication]
type=service
router=binlogrouter
version_string=5.7.19-17

router_options=server_id=1024, heartbeat=30, send_slave_heartbeat=1
binlogdir=/data/binlog
user=test
passwd=pwd

[ReplicationListener]
type=listener
service=Replication
protocol=MySQLClient
port=5308
cat /data/binlog/master.ini
[binlog_configuration]
master_host=*.*.*.14
master_port=3306
master_user=repl
master_password=pwd
filestem=mysql-bin
/usr/bin/maxscale -f /etc/maxscale.cnf
mysql -utest -p  -h*.*.*.226 -P5308
show master status;
show slave status\G

参考