The Relay Log cannot be automatically deleted (Neither, relayneither

Source: Internet
Author: User

The Relay Log cannot be automatically deleted (Neither, relayneither

Check the mysql err log today and find that the following logs will always appear during mysql restart:

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


The warning itself means that, as slave, it is best to set '-- relay-log = liytest-relay-bin' to prevent invalid relay log file names due to host name changes'

But the problem, I am this machine does not enable the slave mode, and the data directory has been a liytest-relay-bin.000001, the emergence of relay and accumulation, internet search to summarize the reasons

This instance was originally a Slave ------- resulting in the existence of relay-log and relay-log.index

This instance is no longer Slave ------- because I/O-Thread is absent, the relay-log-purge does not work (this is also the reason why other Slave instances do not, because IO-thread will perform the automatic rotate operation ).

This instance performs daily backup ------- Flush logs every day, resulting in a relay-log generated every day.

This instance is not configured with expire-logs-days ------, causing flush logs, no relay-log cleanup will be performed.

In short, a relay-log accumulation occurs when an instance is a server Load balancer instance and the stop Server Load balancer instance is stopped and expire-logs-days is not configured.


We also share with you the internal Logrotate mechanism of MySQL.
Binary Log rotate mechanism:
Rotate: after each binary log is written, it determines whether the current file has exceeded max_binlog_size. if it exceeded, A binlog file is automatically generated.
Delete: expire-logs-days is determined only when the instance is started and flush logs. If the file access time is earlier than the set value, purge file
 
Relay Log rotate mechanism:
Rotate: each time an events is fetch from the Master, a new relay-log-file is automatically generated if the current file exceeds max_relay_log_size.
Delete: purge-relay-log is determined every time an SQL Thread executes an events. If this relay-log is no longer needed, it is automatically deleted.

Therefore, we recommend that you use reset slave to cancel relaylog when slave is no longer used. Otherwise, even if you restart mysql, the problem still exists.


How to delete relay-log mysql

It will automatically delete the slave if there is no delay with the master database.
Show slave status \ G
Check whether there is any delay. If there is any delay, try to catch up with it.
If there is no latency or relay-log, simply delete it.

Help: In the MASTER-SLAVE configuration of MYSQL, the relay-binfile on the server Load balancer can be saved. If you do not want to delete it automatically, how can you configure it?

Set in my. ini (window) or my. cnf (linux)
[Mysqld]
Relay_log_purge = 0
(1 indicates automatic deletion, and 0 indicates no)
Remember to restart

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.