共计 1487 个字符,预计需要花费 4 分钟才能阅读完成。
装置 rpm
yum install gnutls libaio.x86_64 libaio-devel.x86_64 novacom-server.x86_64 libedit -y
wget https://downloads.mariadb.com/MaxScale/2.2.0/centos/7server/x86_64/maxscale-2.2.0-1.centos.7.x86_64.rpm
rpm -ivh maxscale-2.2.0-1.centos.7.x86_64.rpm
MaxScale 服务器批改配置
vi /etc/maxscale.cnf
[maxscale]
threads=1
# 主服务器 3306
[server1]
type=server
address=192.168.91.108
port=3306
protocol=MySQLBackend
# 配置从服务器 3306
[server2]
type=server
address=192.168.91.109
port=3306
protocol=MySQLBackend
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2
user=root
passwd=123456
monitor_interval=10000
detect_stale_master=true
[Read-Write Service]
type=service
router=readwritesplit
servers=server1,server2
user=root
passwd=123456
max_slave_connections=100%
use_sql_variables_in=master
enable_root_user=1
max_slave_replication_lag=3600
[MaxAdmin Service]
type=service
router=cli
[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=3306
[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
socket=default
启动 maxscale 服务
maxscale --config=/etc/maxscale.cnf
netstat -ntelp #次要查问 3306 端口是否监听
查看 maxscale 服务状态
maxadmin
> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
server1 | 主服务器 ip | 10336 | 0 | Master, Running
server2 | 从服务器 ip | 10336 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
至此,实现 MaxScale 中间件实现 MySQL 读写拆散。
正文完