I. Pt-table-checksum
1. Create a new account on both master and slave
GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE on * * to ' checksum ' @ ' 192.168.1.% ' identified by ' xxx ';
2. Our Lord new Percona database
3. Give all the permissions of the checksum account to the Percona database ( It is not required, it is already super privilege )
GRANT all privileges on ' Percona '. * to ' checksum ' @ ' 192.168.118.126 ' with GRANT OPTION;
4. The Lord performs the checklist
Pt-table-checksum--nocheck-replication-filters--no-check-binlog-format--set-vars innodb_lock_wait_timeout=50-- Replicate=percona.checksums--databases=db07--tables=test,trade,point,play h=192.168.1.126,u=checksum,p= ' xxx ', p= 3306
Parameter explanation:
--databases
A library that specifies checksums, separated by commas (,) for multiple libraries
--tables
Specify the check table, multiple tables, separated by
--nocheck-replication-filters
Ignore REPLICATION-DO-DB rules
--replicate=test.checksums
Create a checksums table under the test library and write the data to
--recursion-method=none
Specifies how replication checks are used, by default, show Processlist, if a non-standard 3306 port is used in the way of show SLAVE hosts, it is recommended to use the DSN method to manually specify
Check that all tables in the library are synchronized on the master and slave
Pt-table-checksum--nocheck-replication-filters--no-check-binlog-format--set-vars innodb_lock_wait_timeout=50-- Replicate=percona.checksums--databases=db07 h=192.168.1.126,u=checksum,p= ' xxx ', p=3306
Output Result:
TS ERRORS diffs ROWS CHUNKS skipped time TABLE
12-05T19:39:40 0 0 4 1 0 0.114 Db_77313.test
Diffs:
0 represents the master-slave data consistency
1 stands for inconsistency
* If an error occurs:
The problem with waiting for the--replicate table to replicate to XXX is that the percona.checksums table does not exist from the library, copy the main library checksums build the table SQL statement, Perform a build table in the Percona library corresponding to the library
Two. Pt-heartbeat
1. Sometimes we need to look at how much lag from the server to the main server, this time need pt-heartbeat
2. accounts created with Pt-table-checksum
3. The Lord executes:
Pt-heartbeat--update-h 192.168.1.126-u checksum-p xx--database Percona--create-table
Always running in the foreground
Pt-heartbeat--update-h 192.168.1.126-u checksum-p xx--database Percona
Running in the background
Pt-heartbeat--update-h 192.168.1.126-u checksum-p xx--database Percona--daemonize
4. Execute from top
pt-heartbeat-d Percona--monitor-h 192.168.1.126--master-server-id=10-u checksum-p xxx
Output:
0.00s [0.00s, 0.00s, 0.00s]
respectively, say:
Real-time latency [1-point delay, 5-point delay, 15-minute delay]
Use of Pt-table-checksum and pt-heartbeat