Migrating to MySQL GTID ReplicationIn managed services, we get requests to migrate from traditional to GTID-based replication. However, the customer does not want to first enable the GTID on the source node (production). Before MySQL 8.0.23, replication from the disabled GTID source to an enabled GTID replica was impossible.

In this blog, I will talk about a new MySQL feature introduced in 8.0.23, which allows MySQL to replicate from a GTID-disabled source to GTID-enabled replica. You can enable GTID assignment on a replication channel using the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS.

Note: The replica must have gtid_mode=ON set, which cannot be changed afterward unless you remove the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS setting. 

Acceptable inputs

OFF: As the name suggests, it keeps this feature turned off 

Local: Returns the local server UUID, same as server_uuid global variable

UUID: Specify a valid UUID which will be used while generating GTID transactions

Syntax 

Let’s demonstrate the feature  ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS.

Initially, we keep the GTID replication disabled on the source and replica node.

Source: GTID replication is disabled 

Replica: GTID replication disabled

Let’s create a table on the source and check binlog events.  

Replica: binlog events on replica node

Let’s enable the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS=local on the replica and insert a record.

Note: Make sure that gtid_mode=on before enabling the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS=local

Replica Node:

You can see the binlog has server UUID in replica binlogs. I hope this blog post will help you migrate to GTID replication even easier.

Reference:

https://dev.mysql.com/doc/refman/8.0/en/replication-gtids-assign-anon.html

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Thanks for blogging about this Gaurav. I missed this new feature release in 8.0.23 and I am learning about this via your post.

I find super interesting that this is included in MySQL 8 since January 2021 (8.0.23 released on 2021-01-18). This is basically implementing my trick to migrate to GTID online in 5.6. More about this trick in my 2018 post Unforeseen use case of my GTID work: replicating from AWS Aurora to Google CloudSQL.