MySQL 删除复制relay-bin文件是否安全?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4796158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it safe to delete replication relay-bin files?
提问by HyderA
I've got a small database, around 50mb. It's a master replicating to a remote server. I noticed that the relay-bin files total to over 5GB. Is it safe to delete them?
我有一个小型数据库,大约 50MB。它是一个复制到远程服务器的主服务器。我注意到中继 bin 文件总共超过 5GB。删除它们是否安全?
采纳答案by programmer
No, do not delete the relay-bin files manually. What you can do is to purge the binary files using MySQL commands. See the MySQL 5.0 Manualfor more on the PURGE BINARY LOGS
command.
不,不要手动删除relay-bin 文件。您可以做的是使用 MySQL 命令清除二进制文件。有关该命令的更多信息,请参阅MySQL 5.0 手册PURGE BINARY LOGS
。
回答by Rodo
I think a better answer is relay logs can be 'deleted' but mysql should manage it automatically. One way to do this is to check for the value of relay_log_purge.
我认为更好的答案是可以“删除”中继日志,但 mysql 应该自动管理它。一种方法是检查relay_log_purge 的值。
It should be set to 1 if you want mysql to manage them:
如果您希望 mysql 管理它们,则应将其设置为 1:
set global relay_log_purge=1;
You would probably need to flush the logs:
您可能需要刷新日志:
flush logs;
This does not affect the binary logs.
这不会影响二进制日志。
回答by thibault ketterer
Maybe try to resync your master and slave.
也许尝试重新同步您的主从。
If possible, cleanup the slave by running a
如果可能,请通过运行
reset slave
reset slave
it will purge all relay binary logs.
它将清除所有中继二进制日志。
Then set the replication again with change master to
...
You may have too much lag between your master and slave.
然后再次设置复制change master to
...您的主从之间可能有太多延迟。
回答by the_nuts
From the MySQL manual:
从MySQL 手册:
The SQL thread automatically deletes each relay log file after it has executed all events in the file and no longer needs it. There is no explicit mechanism for deleting relay logs because the SQL thread takes care of doing so. However, FLUSH LOGS rotates relay logs, which influences when the SQL thread deletes them.
SQL 线程在执行完文件中的所有事件并且不再需要它后,会自动删除每个中继日志文件。没有明确的删除中继日志的机制,因为 SQL 线程负责这样做。但是,FLUSH LOGS 会轮换中继日志,这会影响 SQL 线程何时删除它们。