码迷,mamicode.com
首页 > 数据库 > 详细

Atlas做mysql读写分离

时间:2020-02-26 17:09:29      阅读:75      评论:0      收藏:0      [点我收藏+]

标签:mysq   pwd   plt   from   lock   读写   安装   lease   xxxx   

Atlas做mysql读写分离:

Atlas奇虎360的一个开源中间代理,是在mysql-proxy 0.8.2的基础上进行了优化,增加一些新的功能特性。

wget https://github.com/Qihoo360/Atlas/releases/download/2.2.1/Atlas-2.2.1.el6.x86_64.rpm

rpm -i Atlas-2.2.1.el6.x86_64.rpm

安装路径为/usr/local/mysql-proxy

/usr/local/mysql-proxy/bin/encrypt xxxxxxx

vi /usr/local/mysql-proxy/conf/test.cnf

admin-username = ming

admin-password = xxxxxx

proxy-backend-addresses = 10.0.1.3:3306

proxy-read-only-backend-addresses = 10.0.1.4:3306@1,10.0.1.5:3306@1

pwds = ming:QeoyfAql8w4a8s/oWZlMvQ==

proxy-address = 10.0.1.2:1234

admin-address = 10.0.1.2:2345

#client-ips = 127.0.0.1, 192.168.1 (设置允许连接的ip或网段,不启用就是允许所有)

:wq

/usr/local/mysql-proxy/bin/mysql-proxy test start

netstat -nplt | grep 1234 (数据端口)

netstat -nplt | grep 2345 (管理端口)

mysql -u ming -p‘xxxxx‘ -h 10.0.1.24 -P2345

select * from backends;

验证:

只读:

mysql -h 10.0.1.2 -u ming -p‘xxxxxx‘ -P1234 -e "select * from ming.test;select @@hostname;"

写入:

mysql -h 10.0.1.2 -u ming -p‘xxxxx‘ -P1234 -e "begin;insert ming.test value(‘a5‘,10,30);select @@hostname;commit;"

Atlas做mysql读写分离

标签:mysq   pwd   plt   from   lock   读写   安装   lease   xxxx   

原文地址:https://blog.51cto.com/yangzhiming/2473655

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!