Download and user Empowerment Reference previous article Percona-toolkit pt-table-checksums detection of MySQL master-slave data consistency
Use Pt-table-checksums to detect data consistency, and then use Pt-table-sync for master-slave consistency repair, noting that the repaired table must have a primary key or a unique index
Under Main vault bash execution:
./pt-table-checksum--nocheck-replication-filters--replicate=test.checksums--host=10.50.12.33--port 3336-- Databases=gaoquan-uchecksums-pchecksums--no-check-binlog-format--recursion-method=dsn=h=10.50.12.33,d=test,t= DSNs
Execute from Library:
Mysql> select * from checksums;
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
| db | TBL | Chunk | Chunk_time | Chunk_index | Lower_boundary | Upper_boundary | THIS_CRC | this_cnt | MASTER_CRC | master_cnt | ts |
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
| Gaoquan | T1 | 1 | 0.001375 | NULL | NULL | NULL | afa2742d | 3 | 9cf2c2d4 | 4 | 2015-12-25 16:17:35 |
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
1 row in Set (0.00 sec)
Main Library Execution:
./pt-table-sync--execute--replicate test.checksums--sync-to-master h=10.50.12.35,p=3336,u=checksums,p=checksums
After repair, use pt-table-checksums for master-Slave conformance detection
Main Library Execution:
./pt-table-checksum--nocheck-replication-filters--replicate=test.checksums--host=10.50.12.33--port 3336-- Databases=gaoquan-uchecksums-pchecksums--no-check-binlog-format--recursion-method=dsn=h=10.50.12.33,d=test,t= DSNs
Execute from Library:
Mysql> select * from checksums;
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
| db | TBL | Chunk | Chunk_time | Chunk_index | Lower_boundary | Upper_boundary | THIS_CRC | this_cnt | MASTER_CRC | master_cnt | ts |
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
| Gaoquan | T1 | 1 | 0.0008 | NULL | NULL | NULL | 9cf2c2d4 | 4 | 9cf2c2d4 | 4 | 2015-12-28 11:44:53 |
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
1 row in Set (0.00 sec)
Percona-toolkit's Pt-table-sync repair MySQL master-slave data consistency