pt-slave-find:寻找和打印mysql slave复制拓扑
使用方法:
pt-slave-find [OPTIONS] [DSN]
pt-slave-find连接到一个mysql群集的复制master,寻找它的slave。当前仅仅能打印一个类似树状结构的复制拓扑。
master主机可以使用两种方式指定:
1、使用标准的连接相关命令行选项:--defaults-file,--password,--host,--port,--socket,--user
如:使用工具连接到master(172.17.0.48),得到连接到该master的slave服务器信息
# pt-slave-find --host=172.17.0.48 --user=root --password=admin@123
172.17.0.48
Version 5.6.19-67.0-log
Server ID 29
Uptime 1+16:51:48 (started 2014-08-26T13:15:56)
Replication Is not a slave, has 2 slaves connected, is not read_only
Filters
Binary logging ROW
Slave status
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
+- 172.17.0.51 #slave实例
Version 5.6.19-67.0-log
Server ID 500
Uptime 17:16:34 (started 2014-08-27T12:51:10)
Replication Is a slave, has 0 slaves connected, is read_only #只读
Filters
Binary logging ROW
Slave status 0 seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
+- 172.17.0.50 #slave实例
Version 5.6.19-67.0-log
Server ID 27
Uptime 1+16:39:13 (started 2014-08-26T13:28:31)
Replication Is a slave, has 0 slaves connected, is read_only #只读
Filters
Binary logging ROW
Slave status 0 seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
选项说明:
--ask-pass:提升输入密码
--charset,-A:默认字符集
--config:读逗号分隔的配置文件列表,如果指定,必须是命令行第一个选项
--database,-D:连接到哪个库
--defaults-file,-F:从给定文件读取mysql选项,必须给绝对路径
--host,-h:指定连接主机
--password,-p:连接时的认证密码
--pid:创建一个pid文件,如果pid文件存在将不运行该工具
--port,-P:连接的端口
--recurse:递归多少级,默认无限
--recursion-method:使用寻找slave的方法,默认processlis,hosts,还支持none(不寻找slave)
--report-format:打印slave的什么信息,默认summary(打印每个slave的简要信息),还支持hostname(仅仅打印slave的主机名),
只打印主机名:
# pt-slave-find --report-format=hostname h=172.17.0.48,P=3306,u=root,p=admin@123
172.17.0.48
+- 172.17.0.51
+- 172.17.0.50
--set-vars:设置mysql变量值,以逗号分隔的variable=value,默认wait_timeout=10000
--socket,-S:连接的socket文件
--user,-u:连接用户
2、使用DSN(使用key=value)指定master主机
# pt-slave-find h=172.17.0.48,P=3306,u=root,p=admin@123
172.17.0.48
Version 5.6.19-67.0-log
Server ID 29
Uptime 1+18:24:00 (started 2014-08-26T13:15:56)
Replication Is not a slave, has 2 slaves connected, is not read_only
Filters
Binary logging ROW
Slave status
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
+- 172.17.0.51
Version 5.6.19-67.0-log
Server ID 500
Uptime 18:48:46 (started 2014-08-27T12:51:10)
Replication Is a slave, has 0 slaves connected, is read_only
Filters
Binary logging ROW
Slave status 0 seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
+- 172.17.0.50
Version 5.6.19-67.0-log
Server ID 27
Uptime 1+18:11:25 (started 2014-08-26T13:28:31)
Replication Is a slave, has 0 slaves connected, is read_only
Filters
Binary logging ROW
Slave status 0 seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment 1, offset 1
InnoDB version 5.6.19-rel67.0
key说明:
h:指定连接主机
P:连接端口号
S:连接的socket文件
u:连接用户
p:认证密码
F:从给定文件读取默认选项
总结:
1、该工具可以方便的显示当前连接master的slave信息;
2、该工具不能通过连接到任何mysql实例,打印其拓扑信息(比如连接到slave,打印其master);