Injecting empty transactions. The master's global gtid_executed [2059] variable contains
the set of all transactions executed on the master. Rather than copy the binary logs when taking a
snapshot to provision a new server, you can instead note the content of gtid_executed on the
server from which the snapshot was taken. Before adding the new server to the replication chain,
simply commit an empty transaction on the new server for each transaction identifier contained in the
master's gtid_executed, like this:
SET GTID_NEXT='aaa-bbb-ccc-ddd:N';
BEGIN;
COMMIT;
SET GTID_NEXT='AUTOMATIC';
Once all transaction identifiers have been reinstated in this way using empty transactions, you must
flush and purge the slave's binary logs, as shown here, where N is the nonzero suffix of the current
binary log file name:
FLUSH LOGS;
PURGE BINARY LOGS TO 'master-bin.00000N';
You should do this to prevent this server from flooding the replication stream with false transactions in
the event that it is later promoted to master. (The FLUSH LOGS statement forces the creation of a new
binary log file; PURGE BINARY LOGS purges the empty transactions, but retains their identifiers.)
... zobacz całą notatkę
Komentarze użytkowników (0)