pt-table-checksum工具應(yīng)用

    1.認(rèn)真看錯誤提示,弄不清楚狀況的時候打開debugPTDEBUG=1
    2.10.10.10.10為主,其它ip為從
    3.h=10.10.10.10,u=checksums,p=checksums 中間一定不能有空格,不然會報錯,本人排查這個錯誤花了很長時間
    
一:sakila庫的film_actor表的數(shù)據(jù)檢測與同步
1,在主庫和從庫上面添加用戶:
GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE ON *.* TO 'checksums'@'10.10.10.10' IDENTIFIED BY 'checksums';
 
2.檢測sakila庫的film_actor表的數(shù)據(jù)主從是否一致
PTDEBUG=1 pt-table-checksum --no-check-binlog-format --no-check-replication-filters --recursion-method=processlist --replicate=test.checksums --databases=sakila --tables=film_actor -h 10.10.10.10 -P8888 -u checksums -p checksums
 
3,根據(jù)checksum的結(jié)果恢復(fù)所有從庫的film_actor數(shù)據(jù)
PTDEBUG=1 pt-table-sync --replicate=test.checksums --recursion-method=processlist --database=sakila   --tables=film_actor  h=10.10.10.10,P=8888,u=checksums,p=checksums --print --execute
 
 
------------------------------------------------------------------------------------------------------------------------------
二:檢測tmp庫數(shù)據(jù)是否一致
pt-table-checksum --no-check-binlog-format --no-check-replication-filters --recursion-method=processlist --replicate=test.checksums --databases=tmp  -h 10.10.10.10 -P8888 -u checksums -p checksums
 
1,根據(jù)checksum的結(jié)果恢復(fù)所有從庫的數(shù)據(jù)
PTDEBUG=1 pt-table-sync --replicate=test.checksums --recursion-method=processlist --no-check-triggers --no-check-child-tables --no-foreign-key-checks  h=10.10.10.10,P=8888,u=checksums,p=checksums --print --execute
(有外鍵約束要加參數(shù) --no-check-child-tables --no-foreign-key-checks,不然可能把子表所有的數(shù)據(jù)都刪除掉)
(--no-check-triggers,不檢測觸發(fā)器)
2,根據(jù)checksum的結(jié)果只恢復(fù)10.10.10.11的數(shù)據(jù)
pt-table-sync --print  --execute --replicate=test.checksums --sync-to-master h=10.10.10.11,P=8888,u=checksums,p=checksums
 
 
3,恢復(fù)從庫192.168.6.91的數(shù)據(jù)(這個從庫所有的數(shù)據(jù)都和主保持一致,除了系統(tǒng)表和checksums表)
pt-table-sync --execute --print --sync-to-master h=192.168.6.91,P=8888,u=checksums,p=checksums
 
----------------------------------------------------------------------------------------------------------------------------
執(zhí)行完pt-table-sync后可再執(zhí)行一次pt-table-checksum檢測主從數(shù)據(jù)是否一致,可以執(zhí)行下面的sql語句,如果結(jié)果為空則說明主從數(shù)據(jù)一致
select * from test.checksums where master_cnt <>this_cnt OR master_crc<>this_crc OR ISNULL(master_crc)<>ISNULL(this_crc);

http://blog.itpub.net/28939273/viewspace-1993010/


分享標(biāo)題:pt-table-checksum工具應(yīng)用
網(wǎng)站URL:http://bm7419.com/article20/ipoijo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、營銷型網(wǎng)站建設(shè)、網(wǎng)站改版、Google、小程序開發(fā)、網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)