5

I'm trying to understand when/where using relay log is beneficial. According the documentation, mysql captures and writes events from the master's binary log as the result of the I/O thread. Then, the SQL thread executes the statements from the slave relay log.

Currently, I have the relay logs disabled on the slave but it hasn't affected replication. It still performs well.

If replication requires the SQL thread to read statements from the relay log so they can be executed, why is it still working without a relay log?

Thanks

4

Replication does require relay logs. IF you have a replicating slave then it does use relay logs, and you have not disabled them. Please check the following:

SHOW SLAVE STATUS \G

Do you have Slave_IO_Running: Yes? Then your replication seems to be running. Please look for the Relay_Log_File column - what does it say? It should point out the current relay log file.

Look for this file. It should be by default on your @@datadir. Is it there? There's your replication relay logs.

You say you've disabled the relay logs -- I suggest you haven't (I don't even recall there's a way to disable the relay logs). How in your opinion have you disabled the relay logs?

  • Thanks Shlomi! - Yes! Both, I/O and SQL thread read "yes". I assumed the relay logs were disabled since I did not set the path in my.cnf file. Perhaps they're turned on but in the default dir? I'll take a look at system variables and get back to you. – SillyRabbit Apr 26 '14 at 16:57
  • @SillyRabbit, Its been three years and havent you look at system vars. so far? – Fredrick Gauss Oct 9 '17 at 8:56
2

If you are looking for the relay logs and you did not configure a name for them, mysqld will use the server's hostname. Why ?

According to the MySQL Documentation on the relay-log option

The basename for the relay log. The default basename is host_name-relay-bin. The server writes the file in the data directory unless the basename is given with a leading absolute path name to specify a different directory. The server creates relay log files in sequence by adding a numeric suffix to the basename.

Due to the manner in which MySQL parses server options, if you specify this option, you must supply a value; the default basename is used only if the option is not actually specified. If you use the --relay-log option without specifying a value, unexpected behavior is likely to result; this behavior depends on the other options used, the order in which they are specified, and whether they are specified on the command line or in an option file. For more information about how MySQL handles server options, see Section 4.2.3, “Specifying Program Options”.

@Shlomi already said in his answer to look in the datadir. Login to mysql and run these

SHOW GLOBAL VARIABLES LIKE 'datadir';
SHOW GLOBAL VARIABLES LIKE 'hostname';

In the OS, go to that folder, run ls -l (or dir for you people using Windows) and look for any file that begins with the hostname followed by -relay-bin. followed by six digits.

The only way to disable relay logs is to disable replication completely. Otherwise, MySQL will generate relay logs once CHANGE MASTER TO is executed by hand or by a mysqld startup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.