1在Atlas所在的db03中连接管理接口查看所有的管理命令:
[root@db03 binlog]# mysql -uuser -ppwd -h 10.0.0.203 -P 2345
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.99-agent-admin
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
db03 [(none)]>select * from help;
+----------------------------+---------------------------------------------------------+
| command | description |
+----------------------------+---------------------------------------------------------+
| SELECT * FROM help | shows this help |
| SELECT * FROM backends | 可以看到后端所有节点的情况 |
| SET OFFLINE $backend_id | 临时将某个节点下线 |
| SET ONLINE $backend_id | 将某个节点上线, ... |
| ADD MASTER $backend | example: "add master 127.0.0.1:3306", ... |
| ADD SLAVE $backend | 动态添加节点 |
| REMOVE BACKEND $backend_id | 删除一个节点 |
| SELECT * FROM clients | lists the clients |
| ADD CLIENT $client | example: "add client 192.168.1.2", ... |
| REMOVE CLIENT $client | example: "remove client 192.168.1.2", ... |
| SELECT * FROM pwds | lists the pwds |
| ADD PWD $pwd | example: "add pwd user:raw_password", ... |
| ADD ENPWD $pwd | example: "add enpwd repl:3yb5jEku5h4"添加一个用户 |
| REMOVE PWD $pwd | example: "remove pwd repl", 删除一个用户 |
| SAVE CONFIG | 保存设置 |
| SELECT VERSION | display the version of Atlas |
+----------------------------+---------------------------------------------------------+
16 rows in set (0.00 sec)
db03 [(none)]>
16 rows in set (0.00 sec)
db03 [(none)]>SELECT * FROM backends; #查看所有节点
+-------------+-----------------+-------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+-------+------+
| 1 | 10.0.0.55:3306 | up | rw |
| 2 | 10.0.0.202:3306 | up | ro |
| 3 | 10.0.0.203:3306 | up | ro |
+-------------+-----------------+-------+------+
3 rows in set (0.00 sec)
db03 [(none)]>SET OFFLINE 3; #将id为3的节点下线
+-------------+-----------------+---------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+---------+------+
| 3 | 10.0.0.203:3306 | offline | ro |
+-------------+-----------------+---------+------+
1 row in set (0.00 sec)
db03 [(none)]>SELECT * FROM backends; #查看所有节点
+-------------+-----------------+---------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+---------+------+
| 1 | 10.0.0.55:3306 | up | rw |
| 2 | 10.0.0.202:3306 | up | ro |
| 3 | 10.0.0.203:3306 | offline | ro |
+-------------+-----------------+---------+------+
3 rows in set (0.00 sec)
db03 [(none)]>SET ONLINE 3; #将id为3的节点上线
+-------------+-----------------+---------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+---------+------+
| 3 | 10.0.0.203:3306 | unknown | ro |
+-------------+-----------------+---------+------+
1 row in set (0.00 sec)
db03 [(none)]>SELECT * FROM backends; #查看所有节点
+-------------+-----------------+-------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+-------+------+
| 1 | 10.0.0.55:3306 | up | rw |
| 2 | 10.0.0.202:3306 | up | ro |
| 3 | 10.0.0.203:3306 | up | ro |
+-------------+-----------------+-------+------+
3 rows in set (0.00 sec)
db03 [(none)]>REMOVE BACKEND 3; #移除id为3的节点
Empty set (0.00 sec)
db03 [(none)]>SELECT * FROM backends; #查看所有节点
+-------------+-----------------+-------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+-------+------+
| 1 | 10.0.0.55:3306 | up | rw |
| 2 | 10.0.0.202:3306 | up | ro |
+-------------+-----------------+-------+------+
2 rows in set (0.00 sec)
db03 [(none)]>ADD SLAVE 10.0.0.203:3306; #添加一个从节点
Empty set (0.00 sec)
db03 [(none)]>SELECT * FROM backends; #查看所有节点
+-------------+-----------------+-------+------+
| backend_ndx | address | state | type |
+-------------+-----------------+-------+------+
| 1 | 10.0.0.55:3306 | up | rw |
| 2 | 10.0.0.202:3306 | up | ro |
| 3 | 10.0.0.203:3306 | up | ro |
+-------------+-----------------+-------+------+
3 rows in set (0.01 sec)
db03 [(none)]>SAVE CONFIG; #保存设置
Empty set (0.07 sec)
db03 [(none)]>