ITPub博客

首页 > 数据库 > MySQL > pt-table-checksum,?pt-table-sync及percona-toolkit工具包的安装和使用

pt-table-checksum,?pt-table-sync及percona-toolkit工具包的安装和使用

原创 MySQL 作者:yleizzz 时间:2017-03-28 10:51:24 0 删除 编辑

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


#所有库的一致性检查 主库ip 192.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=jsrh1sdshj  --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=jsrh1sdshj  --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 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30127122/viewspace-2136167/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-02-03

  • 博文量
    101
  • 访问量
    184276