$ mysql -h127.0.0.1 -P2345 -uuser -ppwd
> select * from help;
+----------------------------+---------------------------------------------------------+
| command | description |
+----------------------------+---------------------------------------------------------+
| SELECT * FROM help | shows this help |
| SELECT * FROM backends | lists the backends and their state |
| SET OFFLINE $backend_id | offline backend server, $backend_id is backend_ndx's id |
| SET ONLINE $backend_id | online backend server, ... |
| ADD MASTER $backend | example: "add master 127.0.0.1:3306", ... |
| ADD SLAVE $backend | example: "add slave 127.0.0.1:3306", ... |
| REMOVE BACKEND $backend_id | example: "remove backend 1", ... |
| 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 user:encrypted_password", ... |
| REMOVE PWD $pwd | example: "remove pwd user", ... |
| SAVE CONFIG | save the backends to config file |
| SELECT VERSION | display the version of Atlas |
+----------------------------+---------------------------------------------------------+
10.登录工作接口查看,使用工作接口1234 工作账户 proxy: 123456.Com
1
2
3
4
5
6
7
8
$ mysql -h127.0.0.1 -P1234 -uproxy -p123456.Com
> select * from test.student;+----+--------+-----+-----+
| id | name | age | sex |+----+--------+-----+-----+
|1| 张三 |20| 男 ||2| 李四 |19| 男 |+----+--------+-----+-----+
192.168.100.10:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |100|+---------------+-------+
192.168.100.20:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |100|+---------------+-------+
192.168.100.30:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |100|+---------------+-------+
每执行一次访问量增加1,确保两个从库访问量相同
192.168.100.10:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |100|+---------------+-------+
192.168.100.20:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |102|+---------------+-------+
192.168.100.30:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |102|+---------------+-------+
从库值访问量各增加1,读取负载成功
192.168.100.10:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |103|+---------------+-------+
192.168.100.20:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |102|+---------------+-------+
192.168.100.30:
> show global status like 'Question%';+---------------+-------+
| Variable_name | Value |+---------------+-------+
| Questions |102|+---------------+-------+
主库访问量增加2,读写分离成功