Is it safe to delete replication relay-bin files?
Asked Answered
H

4

20

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?

Hoary answered 25/1, 2011 at 16:31 Comment(0)
C
-5

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 Manual for more on the PURGE BINARY LOGS command.

Crumpet answered 25/1, 2011 at 17:22 Comment(5)
Thanks, that's what i needed? Will purge ensure that replication is not affected?Hoary
Yes, replication will not be affected at any time.Crumpet
Can these files be deleted if replication has been turned off and won't be used again?Epanorthosis
"PURGE BINARY LOGS" only related to binary logs, not relay logsExuberate
This does something different as it wask asked, that might harm your mariadb setup. The proper answer is Rodo's.Trigg
T
37

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.

It should be set to 1 if you want mysql to manage them:

set global relay_log_purge=1;

You would probably need to flush the logs:

flush logs;

This does not affect the binary logs.

Territorialize answered 23/5, 2012 at 15:9 Comment(1)
This should be the accepted answer IMO. We just found a server that had apparently had relay_log_purge turned off manually several months ago and had been steadily filling up its disk with relay logs. Running these commands worked perfectly.Araujo
L
6

Maybe try to resync your master and slave.

If possible, cleanup the slave by running a

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.

Luting answered 26/6, 2019 at 19:22 Comment(1)
Worked where the other suggestions didn'tDozen
H
0

From the MySQL manual:

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.

Hermaphroditus answered 24/8, 2018 at 12:35 Comment(0)
C
-5

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 Manual for more on the PURGE BINARY LOGS command.

Crumpet answered 25/1, 2011 at 17:22 Comment(5)
Thanks, that's what i needed? Will purge ensure that replication is not affected?Hoary
Yes, replication will not be affected at any time.Crumpet
Can these files be deleted if replication has been turned off and won't be used again?Epanorthosis
"PURGE BINARY LOGS" only related to binary logs, not relay logsExuberate
This does something different as it wask asked, that might harm your mariadb setup. The proper answer is Rodo's.Trigg

© 2022 - 2024 — McMap. All rights reserved.