[root@node01 ~]# wget https://repo.percona.com/yum/percona-release-latest.noarch.rpm
[root@node01 ~]# rpm -ivh percona-release-latest.noarch.rpm
[root@node01 ~]# yum install -y percona-toolkit
[root@node01 ~]# pt-heartbeat --version
pt-heartbeat 3.5.2
[mysql@node01 ~]$ mysql -uroot -pabcd.1234 -e 'create database percona;'
[mysql@node01 ~]$ pt-heartbeat --user=root --ask-pass --database=percona --create-table --update --daemonize
Enter password:
[mysql@node01 ~]$ mysql -uroot -pabcd.1234 -hnode01 -D percona
(root@node01) > select * from heartbeat;
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| ts | server_id | file | position | relay_master_log_file | exec_master_log_pos |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| 2023-04-03T22:26:15.004650 | 101 | mysql-bin.000023 | 2033393 | NULL | NULL |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
1 row in set (0.00 sec)
[root@node02 ~]# wget https://repo.percona.com/yum/percona-release-latest.noarch.rpm
[root@node02 ~]# rpm -ivh percona-release-latest.noarch.rpm
[root@node02 ~]# yum install -y percona-toolkit
[root@node02 ~]# pt-heartbeat --version
pt-heartbeat 3.5.2
[mysql@node02 ~]# pt-heartbeat --user=root --ask-pass --database=percona --monitor --daemonize --log=/tmp/slave-lag.log
Enter password:
[mysql@node02 ~]$ tail -n 10 /tmp/slave-lag.log
0.00s [ 27.17s, 8.60s, 2.87s ]
0.00s [ 26.61s, 8.60s, 2.87s ]
0.00s [ 26.05s, 8.60s, 2.87s ]
0.00s [ 25.46s, 8.60s, 2.87s ]
0.00s [ 24.86s, 8.60s, 2.87s ]
0.00s [ 24.24s, 8.60s, 2.87s ]
0.00s [ 23.60s, 8.60s, 2.87s ]
0.00s [ 22.95s, 8.60s, 2.87s ]
0.00s [ 22.28s, 8.60s, 2.87s ]
0.00s [ 21.60s, 8.60s, 2.87s ]
标签:主库,8.0,2.87,pt,--,0.00,percona,8.60,root
From: https://blog.51cto.com/dbprofessional/7244333