Mysql Router 读写分离配置

1.安装

rpm -ivh mysql-router-2.0.4-1.el6.x86_64.rpm

2.配置

cat >/etc/mysqlrouter/mysqlrouter.ini <<EOF

[DEFAULT]
logging_folder = /var/log/mysqlrouter/
plugin_folder = /usr/lib64/mysqlrouter
runtime_folder = /var/run/mysqlrouter
config_folder = /etc/mysqlrouter
hostname=192.168.1.201

[logger]
level = info

# If no plugin is configured which starts a service, keepalive
# will make sure MySQL Router will not immediately exit. It is
# safe to remove once Router is configured.
#[keepalive]
#interval = 60

[routing:read_write]
#将router绑定到哪个NIC
bind_address = {hostname}:7001
#将路由的后端db列表,rw模式将采用first available模式轮训
#ro模式采用round-robin模式轮训
destinations = {hostname}:3306
mode = read-write
# default 512,like mysql's max_connections
max_connections = 1024
#default 100,like mysql's ax_connect_errors 
max_connect_errors = 100
#default 9,like mysql's connect_timeout 
client_connect_timeout = 9

[routing:read_only]
bind_address = {hostname}:7002
destinations = {hostname}:3306,{hostname}:3307,{hostname}:3308
mode = read-only
max_connections = 65535
max_connect_errors = 100
client_connect_timeout = 9
EOF

3.启动

service mysqlrouter start

4.测试

[root@localhost ~]# netstat -ntpl|grep mysqlrouter
tcp        0      0 192.168.1.201:7001          0.0.0.0:*                   LISTEN      20498/mysqlrouter   
tcp        0      0 192.168.1.201:7002          0.0.0.0:*                   LISTEN      20498/mysqlrouter 

5.连接

mysql -uroot -p123456 -P7002 -h192.168.1.201

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值