Percona-Toolkit is a useful DBA toolkit, one of the most useful tool is pt-table-checksum
.
Here is the general steps:
Configure same users with same passwords for Master and Slaves databases;
Grand necessary privileges for Master database and Slave databases with proper master host ip:
Master
- ```mysql
GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE,CREATE,DELETE,INSERT,UPDATE ON . TO ‘percona‘@MASTER_HOST identified by ‘password’;
flush privileges;1
2
3
4
5
6
- Slaves
- ```mysql
mysql> GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE ON *.* TO 'percona'@MASTER_HOST IDENTIFIED BY 'password';
mysql> flush privileges;
- ```mysql
Then just execute pt-table-checksum
on your master, here is a quick reference for options:
–nocheck-replication-filters :not check filter, required if want to use –databases
–no-check-binlog-format : do not check replicate binlog mode, if it is ROW, report error
–replicate-check-only : only show not synced info
–replicate= :checksums info storage location, e.g. database.table, it should be replicated by slaves!
–databases= :databases to check, separate with “,”
–tables= : tables to check, separate with “,”
h= : Master IP
u= : database username
p= : password
P= : database port
And the example command is
1 | pt-table-checksum --nocheck-replication-filters --no-check-binlog-format --replicate=MasterChecksums.checksums --create-replicate-table h=MASTER_HOST,u=percona,p=password,P=3306 |
If you get the error that getting stuck in the loop of “Waiting for the —replicate table to replicate to <replicant name>“
It is caused by the checksums table not synced by slaves.
Add the database contains checksums tables into the my.cnf
of Master, then restart the mysql service.