如果我在我的一台服务器上有一个表(叫作orders),例如,命名为local.我的另一个服务器也有这个表,例如,remote.
If I have a table (lets call it orders) on one server of mine, named, for example, local. And I have this same table one another server of mine, named, for example, remote.
我的问题是,同步这两个表的最佳方法是什么?
My problem is, what is the best way to sync these two tables?
我希望有一种解决方案,如果本地与远程不同,则可以替换注册表.如果本地表上不存在注册表,请插入注册表.
I would like a solution that replaces a registry if the local is different of the remote one. And insert the registry if it doesn't exist on the local table.
我曾尝试使用类似于此命令的dump dump命令,但未按预期工作:
I had tried using dump a dump command similar to this one, but didn't worked as expected:
/usr/bin/mysqldump --defaults-file=~/my/conff --skip-opt --skip-add-locks --default-character-set=latin1 --disable-keys --no-create-db --no-create-info --dump-date --compress --quick --replace --where='date > DATE_SUB(NOW(), INTERVAL 1 DAY)' mydb orders >> /backup/myDump我该怎么做?我该怎么做脚本来做到这一点?
How can I do this? How could I do a script to do this?
推荐答案pt-table-sync可以做到这一点: www.percona/doc/percona-toolkit/2.1/pt-table-sync.html
pt-table-sync can do this: www.percona/doc/percona-toolkit/2.1/pt-table-sync.html
另请参阅其他SO问题与解答提及pt-table-sync.
See also other SO questions and answers mentioning pt-table-sync.
更多推荐
如何同步两个MySQL表?
发布评论