pt-table-checksum,?pt-table-sync及percona-toolkit工具包的安装和使用
percona-toolkit MySQL的一个很有用的工具
详情请参考
http://www.cnblogs.com/zping/p/5678652.html检查数据一致性(前提是 从库必须是活动的)
保证rep_40 用户有对主库及冲库的访问权限
最简单的做法就是赋予所有的权限
pt-table-checksum h=192.168.27.40,u=rep_40,p='*****',P=3306 --databases=afantisoft --tables=wx_app_car_usercar --nocheck-replication-filters --set-vars innodb_lock_wait_timeout=50#所有库的一致性检查 主库ip192.168.27.40(此语句在主库上执行) 同时dba用户必须能同时访问主库及从库
pt-table-checksum h=127.0.0.1,u=dba,p='******',P=3306 --nocheck-replication-filters --set-vars innodb_lock_wait_timeout=50
执行完了之后 可以在从库的percona.checksums 中查看效果
this_crc<>master_crc 不一致就代表了主从数据又差异
crc为工具截取的数据块经过函数转换之后的值
可以使用如下sql查找 异常不一致的表
select * from checksums where this_crc<>master_crc
详细请参考
https://segmentfault.com/a/1190000004309169主库上执行192.168.27.21 是从库ip
print是打印修改数据的语句pt-table-sync修复数据时 有可能会将中文改成?等乱码,需谨慎
pt-table-sync --replicate=percona.checksums h=127.0.0.1,u=dba,p=******h=192.168.27.21,u=dba,p=jsrh2sdshj --print
打印出来的sql 在从库上执行(此处需谨慎 需要慎重操作)
execute是执行修复
pt-table-sync --replicate=percona.checksums h=127.0.0.1,u=dba,p=******h=192.168.27.21,u=dba,p=jsrh2sdshj --execute
打印出来的sql 在从库上执行(此处需谨慎 需要慎重操作)检查42环境--no-check-binlog-format 忽略复制格式
pt-table-checksum h=127.0.0.1,u=dba,p='******',P=3306 --nocheck-replication-filters --no-check-binlog-format
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。