mysql pt table sync_pt-table-sync 使用介绍
pt-table-sync:對兩個庫不一致的數(shù)據(jù)進行同步,他能夠自動發(fā)現(xiàn)兩個實例間不一致的數(shù)據(jù),然后進行sync操作,pt-table-sync無法同步表結(jié)構(gòu),和索引等對象,只能同步數(shù)據(jù)
一、表沒有主鍵
./pt-table-sync --ignore-databases=mysql,sys --no-check-slave dsn=u=checkq,p=123456,h=192.168.56.108,P=3306 dsn=u=checkq,p=123456,h=192.168.56.101,P=3306 --databases=bhs --tables=pp --print
INSERT INTO bhs.pp(id, name) VALUES ('1', 'ee') /percona-toolkit src_db:bhs src_tbl:pp src_dsn:P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:pp dst_dsn:P=3306,h=192.168.56.101,p=...,u=checkq lock:0 transaction:1 changing_src:0 replicate:0 bidirectional:0 pid:3704 user:root host:managed/;
--execute
./pt-table-sync --ignore-databases=mysql,sys --no-check-slave h=192.168.56.108,u=checkq,p=123456,P=3306 h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=pp --execute --print
INSERT INTO bhs.pp(id, name) VALUES ('1', 'ee') /percona-toolkit src_db:bhs src_tbl:pp src_dsn:P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:pp dst_dsn:P=3306,h=192.168.56.101,p=...,u=checkq lock:0 transaction:1 changing_src:0 replicate:0 bidirectional:0 pid:3747 user:root host:managed/;
二、表有主鍵
./pt-table-sync --sync-to-master --charset=utf8 --ignore-databases=mysql,sys --no-check-slave h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=test --print
REPLACE INTO bhs.test(id, name) VALUES ('3', 'd') /percona-toolkit src_db:bhs src_tbl:test src_dsn:A=utf8,P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:test dst_dsn:A=utf8,P=3306,h=192.168.56.101,p=...,u=checkq lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:3768 user:root host:managed/;
./pt-table-sync --execute --sync-to-master --charset=utf8 --ignore-databases=mysql,sys --no-check-slave h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=test --print
REPLACE INTO bhs.test(id, name) VALUES ('3', 'd') /percona-toolkit src_db:bhs src_tbl:test src_dsn:A=utf8,P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:test dst_dsn:A=utf8,P=3306,h=192.168.56.101,p=...,u=checkq lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:3775 user:root host:managed/;
總結(jié)
以上是生活随笔為你收集整理的mysql pt table sync_pt-table-sync 使用介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 出发吧,向着伟大航路是谁的经典语录
- 下一篇: 空运多少钱啊?