By default, relay log file names have the form
,
where host_name
-relay-bin.nnnnnn
host_name
is the name of the
slave server host and nnnnnn
is a
sequence number. Successive relay log files are created using
successive sequence numbers, beginning with
000001
. The slave uses an index file to track
the relay log files currently in use. The default relay log
index file name is
.
By default, the slave server creates relay log files in its data
directory.
host_name
-relay-bin.index
The default file names for relay logs and relay log index files
can be overridden with, respectively, the
--relay-log
and
--relay-log-index
server options
(see Section 16.1.3, “Replication and Binary Logging Options and Variables”). For this reason,
changing a replication slave's host name can cause
replication to fail with the errors Failed to open
the relay log and Could not find target
log during relay log initialization. This is a known
issue which we intend to fix in a future MySQL release (see Bug#2122). If you anticipate that a slave's host name may
change in the future (for example, if networking is set up on
the slave such that its host name can be modified via DHCP),
then you can use these options to prevent this problem from
occurring. However, if you encounter this issue, one way to work
around it is to stop the slave server, prepend the contents of
the old relay log index file to the new one, then restart the
slave. On a Unix system, this can be done as shown here, where
new_host_name
is the new host name
and old_host_name
is the old one:
shell>cat
shell>new_host_name
-relay-bin.index >>old_host_name
-relay-bin.indexmv
old_host_name
-relay-bin.indexnew_host_name
-relay-bin.index
Relay logs have the same format as binary logs and can be read
using mysqlbinlog. The SQL thread
automatically deletes each relay log file as soon as 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.
A slave server creates a new relay log file under the following conditions:
Each time the I/O thread starts.
When the logs are flushed; for example, with
FLUSH LOGS
or mysqladmin flush-logs.
When the size of the current relay log file becomes too large. The meaning of “too large” is determined as follows:
If the value of
max_relay_log_size
is
greater than 0, that is the maximum relay log file size.
If the value of
max_relay_log_size
is
0, max_binlog_size
determines the maximum relay log file size.
User Comments
Add your own comment.