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

aaron8219發表於2018-07-19
 
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 statusG” 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
1 pt-slave-find [OPTIONS] [DSN]

 

Common parameter

1 --host //Specify the host your want to connect.
2 --port //Specify the port of the server to connect.
3 --user //Specify the username of target instance.
4 --password //Specify the password of user.

 

Example
 
Check out the information on master.
 1 [root@zlm1 08:37:58 ~]
 2 #pt-slave-find -h192.168.56.100 -P3306 -urepl -prepl4slave
 3 192.168.56.100
 4 Version         5.7.21-log
 5 Server ID       1003306
 6 Uptime          23:40:33 (started 2018-07-21T09:01:24)
 7 Replication     Is not a slave, has 2 slaves connected, is not read_only
 8 Filters         
 9 Binary logging  ROW
10 Slave status    
11 Slave mode      STRICT
12 Auto-increment  increment 1, offset 1
13 InnoDB version  5.7.21
14 +- zlm3
15    Version         5.7.21-log
16    Server ID       1023306
17    Uptime          08:04 (started 2018-07-22T08:33:53)
18    Replication     Is a slave, has 0 slaves connected, is not read_only
19    Filters         
20    Binary logging  ROW
21    Slave status    0 seconds behind, running, no errors
22    Slave mode      STRICT
23    Auto-increment  increment 1, offset 1
24    InnoDB version  5.7.21
25 +- zlm2
26    Version         5.7.21-log
27    Server ID       1013306
28    Uptime          23:40:27 (started 2018-07-21T09:01:30)
29    Replication     Is a slave, has 0 slaves connected, is not read_only
30    Filters         
31    Binary logging  ROW
32    Slave status    0 seconds behind, running, no errors
33    Slave mode      STRICT
34    Auto-increment  increment 1, offset 1
35    InnoDB version  5.7.21

 

Check out the information on slaves.

 1 [root@zlm1 08:41:57 ~]
 2 #pt-slave-find -h192.168.56.101 -P3306 -urepl -prepl4slave
 3 192.168.56.101
 4 Version         5.7.21-log
 5 Server ID       1013306
 6 Uptime          23:40:36 (started 2018-07-21T09:01:31) //It shows that the slave has been run almost 24 hours.
 7 Replication     Is a slave, has 0 slaves connected, is not read_only
 8 Filters         
 9 Binary logging  ROW
10 Slave status    0 seconds behind, running, no errors
11 Slave mode      STRICT
12 Auto-increment  increment 1, offset 1
13 InnoDB version  5.7.21
14 
15 [root@zlm1 08:42:07 ~]
16 #pt-slave-find -h192.168.56.102 -P3306 -urepl -prepl4slave
17 192.168.56.102
18 Version         5.7.21-log
19 Server ID       1023306
20 Uptime          08:21 (started 2018-07-22T08:33:54) //This was the newly added slave 10 minutes ago.
21 Replication     Is a slave, has 0 slaves connected, is not read_only
22 Filters         
23 Binary logging  ROW
24 Slave status    0 seconds behind, running, no errors
25 Slave mode      STRICT
26 Auto-increment  increment 1, offset 1
27 InnoDB version  5.7.21

 

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.

 

相關文章