Official website: https://www.percona.com/doc/percona-toolkit/2.1/pt-table-checksum.html#dsn-options
Environment
Master: 10.50.12.33
From: 10.50.12.35
Simulation **************************************** of master-slave difference phenomenon
Main:
mysql> CREATE DATABASE Gaoquan;
mysql> use Gaoquan;
mysql> CREATE TABLE t1 (id int PRIMARY KEY NOT null auto_increment,name varchar (TEN), age int);
mysql> INSERT INTO T1 (name,age) VALUES (' a ', ' + '), (' B ', +), (' C ', 34);
From:
Mysql> Use Gaoquan
mysql> Delete from T1 where name= ' a ';
Master-Slave data difference check ********************************************
Main operation:
Mysql-s/tmp/mysql3336.sock
##### #创建cheksums账号
Mysql> GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE on * * to ' checksums ' @ ' 10.50.12.% ' identified by ' checksums ';
##### #创建从库信息表dsns
mysql> use test;
Mysql> CREATE TABLE DSNs (ID int (one) not null auto_increment,parent_id int (one) default NULL,DSN varchar (255) Not NULL,PR Imary key (ID));
##### #将从库信息插入dsns表中, insert multiple records from
Mysql> INSERT into DSNs (PARENT_ID,DSN) VALUES (1, ' h=10.50.12.35,u=checksums,p=checksums,p=3336 ');
##### #下载pt-tools Tools
wget percona.com/get/percona-toolkit.tar.gz
TAR-ZXF percona-toolkit.tar.gz
CD Percona-toolkit/bin
##### #执行校验
./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
##### #结果查询, THIS_CRC! = MASTER_CRC, indicating a difference in master-slave data
Mysql-h 10.50.12.35-uchecksums-p3336-p-E "select * from Test.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 |
+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+--- ---------+------------+---------------------+
Pt-table-checksums monitoring MySQL master-slave data consistency