RDS is fully managed Database service by AWS . Mysql is also available there. Relica - It is necessary to everyone for Backup the data, DR, Testing,etc. AWS also provide the Read replica option. Recently they launched cross region replica for Mysql and Postgresql. We are helping to you Replicate your On-prem MySQL database to RDS and replicate RDS to On-prem servers. Now we’ll guide you to replicate MySQL RDS to RDS. You can replicate it to any region.
Change Master and slave binlog_format to ROW.(It’ll skip some initial errors)
I have created an user called repl_user and its password repl_user.
CREATE USER 'rep_user'@'%' IDENTIFIED BY 'rep_user';
GRANT REPLICATION slave ON *.* TO 'rep_user'@'%' IDENTIFIED BY 'rep_user';
FLUSH PRIVILEGES;
Use PowerupDBA;
Create table rep_test (number int);
Insert into rep_test values (1);
Insert into rep_test values (2);
Insert into rep_test values (3);
Show master status;
Copy the database from the external instance to the Amazon RDS DB instance using mysqldump.
mysqldump --single-transaction --routines --triggers --events --databases PowerupDBA -h ******.ciqk2zkqxh3j.us-east-1.rds.amazonaws.com -u powerupdba -p > Powerupdba_bak.sql
mysql -h ****.ciqk2zkqxh3j.us-east-1.rds.amazonaws.com -u Powerupdba -p PowerupDBA < Powerupdba_bak.sql
Connect to the Slave Amazon RDS DB instance as the master user and identify the external MySQL or MariaDB database as the replication master by using the mysql.rdssetexternal_master command.
CALL mysql.rds_set_external_master ('Master_RDS_EndPoint', 3306, 'Replication_user_name', 'Replication_User_password', 'BinLog_FileName', BingLog_Position, 0);
On the Amazon RDS DB instance, issue the mysql.rdsstartreplication command to start replication
CALL mysql.rds_start_replication;
Show slave status will show the replication is working or not.
Show slave status\G;
I have inserted 3 more rows.
Insert into rep_test values (4);
Insert into rep_test values (5);
Insert into rep_test values (6);
Now check this slave.
select * from rep_test;
Yup, its replicated :)
转载自:http://blog.powerupcloud.com/2016/07/18/how-to-configure-replication-between-aws-mysql-rds-to-mysql-rds/