MySQL Router介绍

MySQL Router介绍

MySQL Router是一个轻量级的中间件,提供了应用程序与后端数据库的透明路由,是mysql用来实现负载均衡和高可用功能。同时router也提供了使用fabric 高可用的方式。

安装配置 MySQL Router

shell> tar zxvf mysql-router-2.0.2-linux-glibc2.17-x86-64bit.tar.gz
shell> mv mysql-router-2.0.2-linux-glibc2.17-x86-64bit /opt/mysqlrouter
shell> cd /opt/mysqlrouter
shell> mkdir config log

创建Router配置文件
shell> more conf/router.cnf
[DEFAULT]
logging_folder = /opt/mysqlrouter/log/

[logger]
level = INFO

[routing:read_only]
bind_address = 10.106.58.174
bind_port = 7001
connect_timeout = 3
max_connections = 1024
destinations = 10.106.58.176:3307,10.106.58.177:3307
mode = read-only

[routing:read_write]
bind_address = 10.106.58.174
bind_port = 7002
connect_timeout = 3
max_connections = 1024
destinations = 10.106.58.175:3307,10.106.58.176:3307
mode = read-write

升级gcc、glibc

升级gcc为4.8版本,升级glibc为2.14以上版本

查看系统GLIBCXX版本
shell> strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

升级gcc,查看gcc4.8.5中GLIBCXX版本
shell> strings /usr/local/lib64/libstdc++.so.6.0.19 | grep GLIBCXX

升级支持GLIBCXX_3.4.15
shell> cp /usr/local/lib64/libstdc++.so.6.0.19 /usr/lib64/
shell> cd /usr/lib64/
shell> rm -f libstdc++.so.6
shell> ln -s libstdc++.so.6.0.19 libstdc++.so.6

查看系统glibc支持的版本:
shell> strings /lib64/libc.so.6  |grep GLIBC_
升级glibc支持2.14以上版本

运行mode介绍

mode = read-only时,客户端请求将被循环分发给配置列表,当配置列表中服务器不可用,将会跳过该服务器,列表中下一个可用机器将处理请求,如列表没有可用服务器,路由将失败。

mode = read-write时,所有客户端请求都会被列表中第一个可用服务器处理,当此服务器宕机时,列表中下一个可用机器才会处理客户端请求,如列表没有可用服务器,路由将失败。第一个被成功连接的服务器信息将被保存在内存中,重启router后失效。

启动router

1、启动router前,需要确保配置文件中转发的server可用。
2、运行router

shell> /opt/mysqlrouter/bin/mysqlrouter --config=/opt/mysqlrouter/config/router.cnf &
2016-02-24 06:10:35 INFO    [7f898af9e700] routing:read_write started: listening on 10.106.58.174:7002; read-write
2016-02-24 06:10:35 INFO    [7f898b99f700] routing:read_only started: listening on 10.106.58.174:7001; read-only

shell> netstat -an | grep 700
tcp        0      0 10.106.58.174:7001          0.0.0.0:*                   LISTEN
tcp        0      0 10.106.58.174:7002          0.0.0.0:*                   LISTEN

3、测试连接

shell> mysql -h 10.106.58.174 -P 7001 -u test -p -e "select @@hostname;"
shell> mysql -h 10.106.58.174 -P 7002 -u test -p -e "select @@hostname;"

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29733787/viewspace-2015672/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29733787/viewspace-2015672/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值