码迷,mamicode.com
首页 > 数据库 > 详细

percona-toolkit之pt-table-sync修复Mysql主从数据一致性

时间:2015-12-28 19:00:01      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:pt-table-sync

下载及用户赋权参考上篇文章percona-toolkit之pt-table-checksums检测Mysql主从数据一致性

先使用pt-table-checksums检测数据一致性,然后使用pt-table-sync进行主从一致性修复,注意修复的表必须有主键或者唯一索引

主库bash下执行:

./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

从库执行:

mysql> select * from 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 |

+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+------------+------------+---------------------+

1 row in set (0.00 sec)

主库执行:

./pt-table-sync --execute --replicate test.checksums --sync-to-master h=10.50.12.35,P=3336,u=checksums,p=checksums

修复完毕后再使用pt-table-checksums进行主从一致性检测

主库执行:

./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

从库执行:

mysql> select * from 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.0008 | NULL        | NULL           | NULL           | 9cf2c2d4 |        4 | 9cf2c2d4   |          4 | 2015-12-28 11:44:53 |

+---------+-----+-------+------------+-------------+----------------+----------------+----------+----------+------------+------------+---------------------+

1 row in set (0.00 sec)



percona-toolkit之pt-table-sync修复Mysql主从数据一致性

标签:pt-table-sync

原文地址:http://gaoquan.blog.51cto.com/4503718/1729063

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!