Tool Overview
Install the percona-toolkit (including pt-heartbeat) tool on the client.
pt-heartbeat is used to monitor the primary/secondary delay. It is unreliable to determine the primary/secondary delay traditionally based on the value of Seconds_Behind_Master in the show slave status command.
The design principle of pt-heartbeat is as follows: A record with the current time (the now() function in MySQL) is inserted into the heartbeat table in the primary database. Then the record is copied to the secondary database. The secondary database subtracts the record value in the heartbeat table from the current system timestamp (the time() function in Perl) to obtain the primary/secondary delay information. The system time of the primary and secondary databases must be the same. Otherwise, the obtained result is meaningless.