Percona-Tookit工具包之pt-slave-find

时间:2025-02-05 20:37:14
Preface
 
    If we want to check out how many slaves in our replication environment.We can execute "show processlit;" on master.Whatif we'd like to check the detail of slaves.We have to execute "show slave status\G" on slaves.
 
Introduce
 
    pt-salve-find is a tool to find and print the the hierarchy tree of MySQL slaves.It can provide us a simple way to check out whether our slaves are working normally.
 
Procedure
 
Usage
 pt-slave-find [OPTIONS] [DSN]

Common parameter

 --host //Specify the host your want to connect.
--port //Specify the port of the server to connect.
--user //Specify the username of target instance.
--password //Specify the password of user.
Example
 
Check out the information on master.
 [root@zlm1 :: ~]
#pt-slave-find -h192.168.56. -P3306 -urepl -prepl4slave
192.168.56.100
Version 5.7.-log
Server ID
Uptime :: (started --21T09::)
Replication Is not a slave, has slaves connected, is not read_only
Filters
Binary logging ROW
Slave status
Slave mode STRICT
Auto-increment increment , offset
InnoDB version 5.7.
+- zlm3
Version 5.7.-log
Server ID
Uptime : (started --22T08::)
Replication Is a slave, has slaves connected, is not read_only
Filters
Binary logging ROW
Slave status seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment , offset
InnoDB version 5.7.
+- zlm2
Version 5.7.-log
Server ID
Uptime :: (started --21T09::)
Replication Is a slave, has slaves connected, is not read_only
Filters
Binary logging ROW
Slave status seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment , offset
InnoDB version 5.7.

Check out the information on slaves.

 [root@zlm1 :: ~]
#pt-slave-find -h192.168.56. -P3306 -urepl -prepl4slave
192.168.56.101
Version 5.7.-log
Server ID
Uptime :: (started --21T09::) //It shows that the slave has been run almost 24 hours.
Replication Is a slave, has slaves connected, is not read_only
Filters
Binary logging ROW
Slave status seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment , offset
InnoDB version 5.7. [root@zlm1 :: ~]
#pt-slave-find -h192.168.56. -P3306 -urepl -prepl4slave
192.168.56.102
Version 5.7.-log
Server ID
Uptime : (started --22T08::) //This was the newly added slave 10 minutes ago.
Replication Is a slave, has slaves connected, is not read_only
Filters
Binary logging ROW
Slave status seconds behind, running, no errors
Slave mode STRICT
Auto-increment increment , offset
InnoDB version 5.7.
Summary
  • There're merely several simple connection parameters you need to specify.
  • It's convenient to get the information about slaves on master without executing any commands.
  • This tool can also be used to checkout the lag time of slaves.