pt-table-checksum data verification tool

1. Principle:
1. You can specify the data verification of the slave library:
create a table in the specified database in advance to store the ip, user name, and password of the slave library to be verified, and use the master library to connect to the slave library. Then use the pt tool, and pt will generate a table during verification. The location of this table can be set in the parameters of the pt tool. The function of this table is to store the check value, the block mark and check of the check table. Time, etc.; when pt is working, it will split a table in a library in the main library to form a check value and store it in the generated table. The main library will generate the same table after generating a table The statement is synchronized to the slave library, the slave library does the same action as the main library, the table is generated and the verification data is stored in the table

There is also a pt-table-sync tool which is basically the same as the above tools, but it has the function of data recovery. It will focus on the main library. The inconsistent part from the library and the main library will be taken out to form a SQL statement, and dba will take it. To this sql statement, to execute it from the library, the inconsistent part will be filled back to be consistent with the main library

2. Do not specify data verification from the library: the
default is that all tables will generate a verification value, and the table is not built in advance, if you take parameters, pt defaults to show slave host / show processlist for all tables in the library for verification

The last comparison is the this_crc field and master_crc field in the check value table from the inventory. The
inconsistency between the two indicates that the master-slave data is inconsistent.

2. Parameters:
pt-table-checksum
–user=username
–password=password
–host=main library Ip
–replicate=repository where the verification result is stored. The table where the verification result is stored
–recursion-method=hosts (found in the slave library Method)
–no-check-binlog-format
–empty-replicate-table #Each table is emptied before verification data before verification
–replicate-check-retries=3
–recurse=1
–run-time=run time Long
--ignore databases=Do not check databases

Note:
--recursion-method means the way to find the slave library. By default, the pt tool can find the replication process of the slave library in the processlist of the main library, so that you can not find out which slave libraries are there, but if it is a port other than 3306, it will cause failure to find To the slave library information, use the hosts method at this time, which needs to be configured in the slave library my.cnf in advance

report_host = MASTER_HOST
report = 3306

Reference: https://tyoung.me/2016/09/usage_of_pt-table-checksum_and_replication_consistency_check/

Guess you like

Origin blog.csdn.net/weixin_43202081/article/details/107919400