Relay Log

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Il relay log è un insieme di file creati da uno slave durante la replica.

Utilizza lo stesso formato del log binario, e contiene la registrazione degli eventi che riguardano i dati o la struttura. Consiste di un insieme di file di log e un file indice che contiene un elenco dei log.

Gli eventi vengono letti dal log binario del master e scritti nel relay log dello slave. Vengono poi eseguiti sullo slave. I vecchi file del relay log vengono rimossi automaticamente quando non sono più necessari.

Siccome i file del relay log usano lo stesso formato del log binario, possono essere letti con il programma mysqlbinlog.

Creating relay log files

New relay log files are created by the slave at the following times:

Relay log names

By default, the relay log will be given a name host_name-relay-bin.nnnnnn, with host_name referring to the server's host name, and #nnnnnn the sequence number.

This will cause problems if the slave's host name changes, returning the error Failed to open the relay log and Could not find target log during relay log initialization. To prevent this, you can specify the relay log file name by setting the relay_log and relay_log_index system variables.

If you need to overcome this issue while replication is already underway,you can stop the slave, prepend the old relay log index file to the new relay log index file, and restart the slave.

For example:

shell> cat NEW_relay_log_name.index >> OLD_relay_log_name.index
shell> mv NEW_relay_log_name.index OLD_relay_log_name.index

Removing old relay logs

Old relay logs are automatically removed once all events have been implemented on the slave, and the relay log file is no longer needed. This behavior can be changed by adjusting the relay_log_purge system variable from its default of 1 to 0, in which case the relay logs will be left on the server.

If the relay logs are taking up too much space on the slave, the relay_log_space_limit system variable can be set to limit the size. The IO thread will stops until the SQL thread has cleared the backlog. By default there is no limit.

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.