pt-slave-find – 查找MySQL从库信息
2,571 total views, 1 views today
工作中进入一个全新的环境,需要了解MySQL的架构,比如有几个从库等信息。一般我们使用show slave hosts;命令得出从库情况,但是 show slave hosts; 命令只适用于主从架构;如果是主从从架构, 无法知道第1级从库是否还有第2级从库连接。
而,pt-slave-find 就能很好的打印出MySQL slave的层级关系,给DBA带来了很大便利。
pt-slave-find该工具连接主库,然后查找从库信息。
用法:
1 |
Usage: pt-slave-find [OPTIONS] [DSN] |
例子:列出了MySQL的从库信息,如版本,主从角色、server id、已运行时间、过滤条件、从库是否还有从库等信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# pt-slave-find --user=root --password=xxxx --defaults-file=/etc/my.cnf Cannot connect to F=/etc/my.cnf,h=10.5.5.82,p=...,u=root Localhost Version 5.6.26-log Server ID 105546 Uptime 449+00:59:18 (started 2015-09-27T16:00:35) Replication Is not a slave, has 7 slaves connected, is not read_only Filters Binary logging MIXED Slave status Slave mode STRICT Auto-increment increment 1, offset 1 InnoDB version 5.6.26 +- 10.5.5.49 Version 5.6.26-log Server ID 105549 Uptime 449+01:02:43 (started 2015-09-27T15:57:10) Replication Is a slave, has 0 slaves connected, is read_only Filters slave_skip_errors=126,1032,1048,1062,1114,1146,1396; replicate_ignore_db=mysql,test,performance_schema,information_schema Binary logging MIXED Slave status 0 seconds behind, running, no errors Slave mode STRICT Auto-increment increment 1, offset 1 InnoDB version 5.6.26 +- 10.5.5.78 Version 5.6.26-log Server ID 105578 Uptime 334+07:37:45 (started 2016-01-20T09:22:08) Replication Is a slave, has 0 slaves connected, is read_only Filters slave_skip_errors=126,1032,1048,1062,1114,1146,1396; replicate_ignore_db=mysql,test,performance_schema,information_schema Binary logging MIXED Slave status 0 seconds behind, running, no errors Slave mode STRICT Auto-increment increment 1, offset 1 InnoDB version 5.6.26 |
上面的例子只显示IP地址,为了便于观看,加上显示主机名
1 |
# pt-slave-find --user=root --password=xxxx --defaults-file=/etc/my.cnf --resolve-address |