pt-table-sync笔记

--slave-to-host

         同步到主机,如果被指定的话,则只能有一个SLAVE DSN,slave会自动发现它自己的master,且会将该SLAVE的数据同步与MASTER保持一致;

通过修改master程序,然后master-slave机制会自动同步至slave;

 

--execute

          Execute queries to make the tables have identical data.

                  使更改生效

--lock

          type: int

 

          Lock tables: 0=none, 1=per sync cycle, 2=per table, or 3=globally.

 

          This uses "LOCK TABLES". This can help prevent tables being changed while you’re examiningthem. 

                  是否锁表:0不锁;

1,只锁检查的块,检查完毕解锁,为下个块加锁

                                   2,  加锁和解锁每单个要检查的表

                                   3,  使用命令FLUSH TABLES WITH READ LOCK进行全局读锁定;

--print

    Printqueries that will resolve differences

If you don’t trust"pt-table-sync", or just want to see what it will do, this is a goodway to be safe.  These queries are validSQL and you can run them yourself if you want to sync the tables manually.

 如果有print, 则输出的结果将会打印出待执行的REPLACE命令;

 

--[no]transaction

Use transactions instead of "LOCKTABLES".

It currently uses transactions on InnoDBtables, and table locks on all others.

 

--verbose

Print results of sync operations.输出表的差异数据;

 

--wait

How long to wait for slaves to catch up totheir master.

同步的时候,Master等待Slave赶上的时间,单位秒,

 

DSN

"option=value”, "option=value”,…

 

"—replicate

         如果用replicate参数,前提是已经用checksum发现了差异;

 

 

 

 

 

 

同步slave  server 至Master:

pt-table-sync --execute --verbose --print--sync-to-master --databases itdb h=10.8.135.156,u=copy2,p=jsddwcc

 

处理pt-table-checksum发现的所有差异数据,同步所有SLAVE:

pt-table-sync --execute --replicatepercona.checksums h=10.8.135.157,P=3306,u=copy2,p=jsddwcc

 

处理pt-table-checksum发现的所有差异数据,功能同上,只处理指定的slave

pt-table-sync --execute --replicatepercona.checksums --sync-to-master h=10.8.135.156,u=copy2,p=jsddwcc

 

pt-table-sync --execute --sync-to-master --charset=utf8dsn=u=root,p=root,h=172.172.178.76,P=3306 –print

 

 

 

pt-table-sync --execute --sync-to-master --lock1 --verbose --print --charset=utf8 --databases itdbu=copy2,p=jsddwcc,h=10.8.135.156,P=3306

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值