-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecksum.log
22 lines (11 loc) · 1.88 KB
/
checksum.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
yum install -y perl-TermReadKey.x86_64 perl-ExtUtils-MakeMaker.x86_64 perl-DBD-MySQL.x86_64 perl-Time-HiRes.x86_64 && tar -xf /root/percona-toolkit-2.2.19.tar.gz &&cd /root/percona-toolkit-2.2.19 &&perl Makefile.PL &&make && make install && echo installOK
pt-table-checksum --nocheck-binlog-format --nocheck-plan --nocheck-replication-filters --set-vars innodb_lock_wait_timeout=120 --databases jdorders_4 -uroot -p -h10.0.56.87 -P4306 -S /usr/local/percona-server-5.6.32-78.1/mysql.sock
pt-table-sync --user=root --ask-pass --sync-to-master h=xxx,P=xxx --replicate=percona.checksums --databases=xxx -S /export/data/mysql/tmp/mysql.sock --charset=utf8 --print
查看差异(Slave库运行)
select * from percona.checksums where master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_crc) <> ISNULL(this_crc) ;
SELECT db, tbl, SUM(this_cnt) AS total_rows, COUNT(*) AS chunks FROM percona.checksums WHERE ( master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_crc) <> ISNULL(this_crc)) GROUP BY db, tbl;
GRANT UPDATE,INSERT,DELETE,SELECT, PROCESS, SUPER, REPLICATION SLAVE ON *.* TO'checksums'@'xxx' identified by 'xxx';
GRANT ALL ON percona.* TO 'checksums'@'xxx' IDENTIFIED BY 'xxx';
pt-table-checksum h=xxx,u='checksums',p='xxx',P=4306 -d jdorders_4 --nocheck-replication-filters --chunk-size-limit=130000 --max-lag=5 --recursion-method=processlist --recurse=1 --no-check-plan --no-check-binlog-format
这里纠正一个认识,网上很多人说 pt-table-checksum 要在主库上执行,其实不是的,我的mysql实例比较多,只需在某一台服务器上安装percona-toolkit,这台服务能够同时访问主库和从库就行了,只需修改 -h 指定的ip即可
pt-table-sync --user=checksums --ask-pass --sync-to-master h=xxx,P=xxx --replicate=percona.checksums --databases=xxx -S /usr/local/percona-server-5.6.32-78.1/mysql5306.sock --charset=utf8 --print