AWS RDS Aurora MySQL (8) Primary (Master)-secondary replication

Primary Database: Aurora MySQL 8 (latest version)
Secondary database: MySQL On-premises databases version 8
AWS Site to Site VPN enabled on-premise and AWS VPC
I used the replication based on Binlog with GTID feature.
Set the following in the Primary database db cluster
gtid_mode = ON which is required if we need the auto position feature enabled in the secondary database.
enforce_gtid_consistency = ON
Reboot the cluster to apply the changes in the DB cluster parameters group.
while the cluster reboots, please login to the on-premise server and edit the my.cnf file and the following to the same
innodb_redo_log_capacity=1G
innodb_buffer_pool_size=8G
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=1
gtid_mode = ON
enforce_gtid_consistency = ON
log-replica-updates=ON
skip-replica-start=ON
log-bin=log-bin
binlog-format=MIXED
server-id=2000
relay-log=relay-bin
Restart the Mysql service.
Now back to the RDS, once the reboot is completed. Take a snapshot of the cluster.
Restore the snapshot.
Once the snapshot is restored you can see a binlog details from the logs and events of the restored instance. Which will be require if we are going to provide the position based on the binlog.
take a clean backup of the Database which needs to be restored to the secondary database on-premise.
mysqldump -h xxx-rds.cluster-xx.eu-west-1.rds.amazonaws.com -u xx_user -p xvbp_db --no-tablespaces --set-gtid-purged=OFF > db.sql
We can do this task while we are logged in to the on-premises server.
Once backup created. Create a DB with the same name in the local mysql(on-premise) and restore the backup to the DB.
mysql db < db.sql
Now we need to make this MySQL as the secondary database for that apply the command below.
CHANGE REPLICATION SOURCE TO
> SOURCE_HOST = 'masternode01.cluster-xx.ap-southeast-1.rds.amazonaws.com',
> SOURCE_PORT = 3306,
> SOURCE_USER = 'xx',
> SOURCE_PASSWORD = 'xx',
> SOURCE_AUTO_POSITION = 1;
The above method uses the Auto positioning. I used this method, and it is working fine.
Subscribe to my newsletter
Read articles from ARISLAN KAREEM directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
