Home  >  Article  >  Database  >  关于RelayLog无法自动删除的问题(Neither--relay-lognor--relay

关于RelayLog无法自动删除的问题(Neither--relay-lognor--relay

WBOY
WBOYOriginal
2016-06-07 15:59:071526browse

今天查看mysql err日志,发现mysql重启时总会有如下日志出现: [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use --relay-log

今天查看mysql err日志,发现mysql重启时总会有如下日志出现:

[Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=liytest-relay-bin' to avoid this problem.

这个警告提示本身的意思,作为slave,为防止因为主机名变更导致relay log文件名无效的问题,最好设置'--relay-log=liytest-relay-bin'

但问题时,我这机器根本就没有开启slave模式,而且数据目录下一直有liytest-relay-bin.000001,relay的出现并且堆积,上网搜索总结一下原因

该实例原先是一个Slave -------导致relay-log 和 relay-log.index的存在

该实例目前已经不是Slave -------由于没有了IO-Thread,导致relay-log-purge 没有起作用( 这也是其他Slave实例没有这种情况的原因,因为IO-thread会做自动rotate操作)。

该实例每天会进行日常备份 -------Flush logs的存在,导致每天会生成一个relay-log

该实例没有配置expire-logs-days ------导致flush logs时,也不会做relay-log清除

简而言之就是: 一个实例如果之前是Slave,而之后停用了(stop slave),且没有配置expire-logs-days的情况下,会出现relay-log堆积的情况。

顺带也和大家分享下MySQL 内部Logrotate的机制
Binary Log rotate机制:
Rotate:每一条binary log写入完成后,都会判断当前文件是否超过 max_binlog_size,如果超过则自动生成一个binlog file
Delete:expire-logs-days 只在 实例启动时 和 flush logs 时判断,如果文件访问时间早于设定值,则purge file

Relay Log rotate 机制:
Rotate:每从Master fetch一个events后,判断当前文件是否超过 max_relay_log_size 如果超过则自动生成一个新的relay-log-file
Delete:purge-relay-log 在SQL Thread每执行完一个events时判断,如果该relay-log 已经不再需要则自动删除

因此建议当slave不再使用时,一定要通过reset slave来取消relaylog,不然即使重启mysql,问题还是一样存在。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn