配置一主一从主从同步结构,并在客户端测试配置
master51>格兰特webdb。* webuser@" %”;被“123456“;
装包
rpm -ivh maxscale - 2.1.2 - 1. - rhel.7.x86_64.rpm
[root@host56 ~] # rpm qa | grep maxscale
maxscale - 2.1.2 - 1. - x86_64
[root@host56 ~] # rpm qc maxscale
/etc/maxscale.cnf.template
[root@host56 ~] #
修改配置文件
[root@host56 ~] # ls/etc/maxscale.cnf
/etc/maxscale.cnf
[root@host56 ~] # cp/etc/maxscale.cnf/etc/maxscale.cnf.bak
[root@host56 ~] # vim/etc/maxscale.cnf
[maxscale]
=1线程也可是是汽车
(server1)
类型=服务器
地址=192.168.4.51
=3306=
协议港MySQLBackend
[server2]
类型=服务器
地址=192.168.4.52
=3306=
协议港MySQLBackend
[MySQL监控]
类型=
监测模块=mysqlmon
服务器=server1, server2
用户=scalemon
密码=123456
monitor_interval=10000
type=服务路由器=readwritesplit
服务器=server1, server2
用户=maxscale
密码=123456
max_slave_connections
[MaxAdmin服务]
type=服务路由器=cli
=侦听器服务类型=读写服务
协议=MySQLClient
=4006港
[MaxAdmin侦听器]
=侦听器服务类型=MaxAdmin服务
协议=maxscaled
套接字=默认
端口=4018
根据配置文件做相应的设置(在2台数据库服务器上添加用户)
监控数据库服务器时,连接数据库服务器的用户
mysql>格兰特复制奴隶,复制在星客户。星,scalemon@‘%’被“123456“;
验证访问数据时,连接数据库服务器使用的用户,是否在数据库服务器上存在的,连接用户
mysql>格兰特选择mysql。* maxscale@‘%’被“123456“;
查看授权用户
mysql>选择用户、主机从mysql。用户在用户(“scalemon",“maxscale");
+ - - - - - - - - - - - - - - - - - +
|用户主机| |
+ - - - - - - - - - - - - - - - - - +
| maxscale | % |
| scalemon | % |
+ - - - - - - - - - - - - - - - - - +
启动服务
[root@host56 ~] # maxscale - f/etc/maxscale.cnf
查看服务进程和端口
查看端口
[root@host56 ~] # netstat -utnlp | grep: 4006
[root@host56 ~] # netstat -utnlp | grep: 4018
[root@host56 ~] # ps - c maxscale
停止服务
[root@host56 ~] # ps - c maxscale
PID TTY时间CMD
29688 ?就是maxscale
[root@host56 ~] # kill - 9 29688
[root@host56 ~] #
[root@host56 ~] #
[root@host56 ~] # kill - 9 29688
bash:杀死:(29688)——进程不存在
2.2.3测试配置
在本机访问管理管端口查看监控状态
[root@host56 ~] # maxadmin -P4018 -uadmin -pmariadb
MaxScale>服务器
服务器列表。
- - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
服务器|地址| | |端口连接状态
- - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
server1 | 192.168.4.51 | 3306 | 0 |主人,运行
server2 | 192.168.4.52 | 3306 | 0 |奴隶,运行
- - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MaxScale>退出
[root@host56 ~] #
b客户端访问数据读写分离服务器
) # mysql
) # mysql -h292.168.4.56 -P4006 -uwebuser -p123456
mysql>选择@@hostname;
mysql>执行插入或查询(在51和52本机查看记录)