percona-toolkit之pt-table-sync修復Mysql主從數據一致性

下載及用戶賦權參考上篇文章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)



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章