Atlas做mysql读写分离

tangjianft 2020-02-26

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:,10.0.1.5:

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;"

相关推荐