一、构建思路
(2)装包 配置文件
- [maxscale]
- threads=auto
- [server1]
- type=server
- address=192.168.4.51
- port=3306
- protocol=MySQLBackend
- [server2]
- type=server
- address=192.168.4.52
- port=3306
- protocol=MySQLBackend
- [MySQL Monitor]
- type=monitor
- module=mysqlmon
- servers=server1, server2
- user=maxscalemon
- passwd=123qqq...A
- monitor_interval=10000
- #[Read-Only Service]
- #type=service
- #router=readconnroute
- #servers=server1
- #user=myuser
- #passwd=mypwd
- #router_options=slave
- [Read-Write Service]
- type=service
- router=readwritesplit
- servers=server1, server2
- user=maxscalerouter
- passwd=123qqq…A
- max_slave_connections=100%
- [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=default
- port=4016
其中的监控用户的作用 监控服务器 获取信息 查看那个是主库那个是从库(在主库上写 从库上读)
其中的路由用户的作用 查看服务器上是否有授权的用户(在读写分离服务器上连接后台数据库时的连接授权用户)
(3)添加授权用户
(4)启动服务
MySQL 读写分离
原文:https://www.cnblogs.com/zshBlos/p/13127340.html