MySQL Router是一个轻量级的中间件,提供了应用程序与后端数据库的透明路由,是mysql用来实现负载均衡和高可用功能。同时router也提供了使用fabric 高可用的方式。
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为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 = read-only时,客户端请求将被循环分发给配置列表,当配置列表中服务器不可用,将会跳过该服务器,列表中下一个可用机器将处理请求,如列表没有可用服务器,路由将失败。
mode = read-write时,所有客户端请求都会被列表中第一个可用服务器处理,当此服务器宕机时,列表中下一个可用机器才会处理客户端请求,如列表没有可用服务器,路由将失败。第一个被成功连接的服务器信息将被保存在内存中,重启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;"
亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:http://blog.itpub.net/29733787/viewspace-2015672/