MaxScale安装
服务器
主1:192.168.0.131
从1:192.168.0.7
从2:192.168.0.9
1.在从2服务器上下载安装包
如若缺少依赖包请自行安装
[root@hadoop02 home]# rpm -ivh maxscale-1.3.0-1.rhel6.x86_64.rpm
warning: maxscale-1.3.0-1.rhel6.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 8167ee24: NOKEY
Preparing... ########################################### [100%]
1:maxscale ########################################### [100%]
which: no systemctl in (/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin)
Could not find systemd service file: /usr/share/maxscale/maxscale.service
安装完成后执行max再按tab键可看到有如下命令可供使用
maxadmin maxbinlogcheck maxkeys maxpasswd maxscale
3.主服务器上创建账号
#监控账号
create user scalemon@’192.168.0.%’ identified by ‘123456’;
grant replication slave, replication client on *.* to scalemon@’192.168.0.%’;
#路由账号
create user maxscale@’192.168.0.%’ identified by ‘123456’;
grant select on mysql.* to maxscale@’192.168.0.%’ ;
4. 生产环境不想在配置文件中用明文密码的话,可以在从2上使用maxkeys命令来进行加密,如:
[root@hadoop02 home]# maxkeys
Generating .secrets file in /var/lib/maxscale/ ...
[root@hadoop02 home]# maxpasswd /var/lib/maxscale 123456
AB8A76D48AD05821462EB1405E22A1A5
这里生成的AB8A76D48AD05821462EB1405E22A1A5即为加密后123456的加密字符串
5.配置MaxScale/etc/f
threads=4 #根据实际情况调整
#服务器的配置
[server1]
type=server
address=192.168.0.9
port=3306
protocol=MySQLBackend
[server2]
type=server
address=192.168.0.131
port=3306
protocol=MySQLBackend
[server3]
type=server
address=192.168.0.7
port=3306
protocol=MySQLBackend
#监控配置
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3
user=scalemon
passwd=123456
monitor_interval=1000 #单位毫秒
#本处配置读写分离,所以删除只读模块[Read-Only Service]
#读写分离配置
[Read-Write Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxscale
passwd=123456
max_slave_connections=100%
max_slave_replication_lag=60
#本处配置读写分离,所以删除只读监听模块[Read-Only Listener]
6.启动MaxScale服务
maxscale --config=/etc/f
进入MaxScale的管理窗口
maxadmin --user=admin --password=mariadb #默认用户名密码