如何设置数据库主从循环复制的时间间隔?
我已经在我的两台数据库服务器上成功设置了主从复制。我还设置了主服务器在从服务器上进行复制,当主服务器关闭时,从服务器到主服务器的复制也可以工作。但是,我无法设置发生此情况的时间间隔。我尝试使用 master_delay 以及 master_heartbeat_period 。这些似乎都不起作用。
mysql> change master to master_host='192.168.0.2',
-> master_user='master',
-> master_password='masterpass',
-> master_log_file='mysql-bin.000008',
-> master_log_pos=3733
-> master_delay=30; //to set the time limit for the interval
mysql> change master to master_host='192.168.0.2',
-> master_user='master',
-> master_password='masterpass',
-> master_log_file='mysql-bin.000008',
-> master_log_pos=3733
-> master_heartbeat_period=30; //to set the time limit for the interval
复制仍然会立即发生。知道我做错了什么吗?
I have successfully set up the master- slave replication on my 2 database servers. I have also set up the master to replicate on the slave and when the master is down, the slave to master replication also works. However, i am unable to set up the time interval for this to take place. I tried using master_delay as well as master_heartbeat_period. None of these seem to be working.
mysql> change master to master_host='192.168.0.2',
-> master_user='master',
-> master_password='masterpass',
-> master_log_file='mysql-bin.000008',
-> master_log_pos=3733
-> master_delay=30; //to set the time limit for the interval
mysql> change master to master_host='192.168.0.2',
-> master_user='master',
-> master_password='masterpass',
-> master_log_file='mysql-bin.000008',
-> master_log_pos=3733
-> master_heartbeat_period=30; //to set the time limit for the interval
The replication still happens instantly.. Any idea what i am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你混淆了不同的 MySQL 命令及其用法。
...用于设置复制心跳的时间间隔,由Master发送。如果binlog中没有未设置的事件,则会发送心跳,只是为了确保连接。它们与复制延迟没有任何关系。
此外,MASTER_HEARTBEAT_PERIOD 仅在 MySQL Cluster NDB 上可用 > 6.3!
另请参阅: http://dev.mysql.com/ doc/refman/5.1/en/change-master-to.html
可能是您正在寻找的选项。 “从主站接收到的事件直到在主站上执行至少 N 秒后才会执行。”
但此选项仅在MySQL 5.6 或更高版本上可用!这是一个相当新的版本,...也许您不使用这个版本?
另请参阅: http://dev.mysql.com/doc/ refman/5.6/en/replication-delayed.html
I guess you confuse the different MySQL commands and their usage.
... is used to set the interval between the replication heartbeats, which are sent by the Master. Heartbeats are sent if there are no unset events in the binlog, just to ensure the connection. They don't have anything to do with a delay of the replication.
Also MASTER_HEARTBEAT_PERIOD is only available on MySQL Cluster NDB > 6.3!
See also: http://dev.mysql.com/doc/refman/5.1/en/change-master-to.html
Might be the option you are looking for. "An event received from the master is not executed until at least N seconds later than its execution on the master."
But this option is only available on MySQL 5.6 or later! It's a pretty new release,... maybe you don't use this version?
See also: http://dev.mysql.com/doc/refman/5.6/en/replication-delayed.html