1、安装Atlas-2.2.1.el6.x86_64.rpm
rpm -ivh Atlas-2.2.1.el6.x86_64.rpm
2、进入Atlas目录并且备份配置文件
cd /usr/local/mysql-proxy/conf
cp test.cnf test.cnf.bak
3、密码加密采用的是自带的工具
/usr/local/mysql-proxy/bin/encrypt 123456 #因为我的密码是123456
4、修改配置文件
vi /usr/local/mysql-proxy/conf/test.cnf
[mysql-proxy]
admin-username = root
admin-password = 123456
proxy-backend-addresses = 192.168.31.220:3306 #主库地址,而我们采用的是vip漂移,所以这个地方我们放的是vip地址
proxy-read-only-backend-addresses = 192.168.31.214:3306,192.168.31.215:3306
pwds = repl:/iZxz+0GRoA=, mha:/iZxz+0GRoA=, root:/iZxz+0GRoA=
daemon = true
keepalive = true
event-threads = 8
log-level = message
log-path = /usr/local/mysql-proxy/log
sql-log = ON
proxy-address = 0.0.0.0:33060
admin-address = 0.0.0.0:2345
charset = utf8
5、启动Atlas
/usr/local/mysql-proxy/bin/mysql-proxyd test start #启动Atlas。
/usr/local/mysql-proxy/bin/mysql-proxyd test restart #重启Atlas。
/usr/local/mysql-proxy/bin/mysql-proxyd test stop #停止Atlas。
6、查询Atlas
ps -ef | grep proxy
7、开放Atlas端口号
开启2345端口 firewall-cmd --zone=public --add-port=2345/tcp --permanent
开启33060端口 firewall-cmd --zone=public --add-port=33060/tcp --permanent
刷新防火墙 firewall-cmd --reload
8、测试Atlas
mysql -umha -p123456 -h192.168.31.215 -P 33060
select @@server_id;
begin;select @@server_id;commit;
9、Atlas在线管理
mysql -uroot -p123456 -h192.168.31.215 -P2345
select * from help;
a、查看节点信息
mysql> select * from backends;
+-------------+---------------------+-------+------+
| backend_ndx | address | state | type |
+-------------+---------------------+-------+------+
| 1 | 192.168.31.220:3306 | up | rw |
| 2 | 192.168.31.214:3306 | up | ro |
| 3 | 192.168.31.215:3306 | up | ro |
+-------------+---------------------+-------+------+
b、临时关闭节点与启动
set offline $backend_id; #临时关闭
set online $backend_id; #临时启动
c、动态添加、删除节点
remove backend 3; #动态删除从库节点
add slave 192.168.31.215:3306; #动态添加从库节点
d、保存配置到配置文件
save config;
标签:--,MySQL5.7,36,192.168,proxy,mysql,Atlas,local
From: https://blog.csdn.net/m0_63603104/article/details/141923327