如何设置数据库主从循环复制的时间间隔?

发布于 2025-01-07 20:53:47 字数 724 浏览 8 评论 0原文

我已经在我的两台数据库服务器上成功设置了主从复制。我还设置了主服务器在从服务器上进行复制,当主服务器关闭时,从服务器到主服务器的复制也可以工作。但是,我无法设置发生此情况的时间间隔。我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和影子一齐双人舞 2025-01-14 20:53:47

我猜你混淆了不同的 MySQL 命令及其用法。

MASTER_HEARTBEAT_PERIOD

...用于设置复制心跳的时间间隔,由Master发送。如果binlog中没有未设置的事件,则会发送心跳,只是为了确保连接。它们与复制延迟没有任何关系。

此外,MASTER_HEARTBEAT_PERIOD 仅在 MySQL Cluster NDB 上可用 > 6.3!

另请参阅: http://dev.mysql.com/ doc/refman/5.1/en/change-master-to.html

MASTER_DELAY=N

可能是您正在寻找的选项。 “从主站接收到的事件直到在主站上执行至少 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.

MASTER_HEARTBEAT_PERIOD

... 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

MASTER_DELAY=N

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文