Backup MySQL Amazon RDS

后端 未结 6 1986
遇见更好的自我
遇见更好的自我 2021-02-01 06:16

I am trying to setup Replica outside of AWS and master is running at AWS RDS. And I do not want any downtime at my master. So I setup my slave node and now I want to backup my c

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 06:49

    Thanks Michael, I think the most correct solution and the recommended by AWS is do the replication using a read replica as a source as explained here.

    Having a RDS master, RDS read replica and an instance with MySQL ready, the steps to get an external slave are:

    1. On master, increase binlog retention period.

    mysql> CALL mysql.rds_set_configuration('binlog retention hours', 12);

    1. On read replica stop replication to avoid changes during the backup.

    mysql> CALL mysql.rds_stop_replication;

    1. On read replica annotate the binlog status (Master_Log_File and Read_Master_Log_Pos)

    mysql> SHOW SLAVE STATUS;

    1. On server instance do a backup and import it (Using mydumper as suggested by Max can speed up the process).

    mysqldump -h RDS_READ_REPLICA_IP -u root -p YOUR_DATABASE > backup.sql

    mysql -u root -p YOUR_DATABASE < backup.sql

    1. On server instance set it as slave of RDS master.

    mysql> CHANGE MASTER TO MASTER_HOST='RDS_MASTER_IP',MASTER_USER='myrepladmin', MASTER_PASSWORD='pass', MASTER_LOG_FILE='mysql-bin-changelog.313534', MASTER_LOG_POS=1097;

    Relace MASTER_LOG_FILE and MASTER_LOG_POS to the values of Master_Log_File Read_Master_Log_Pos you saved before, also you need an user in RDS master to be used by slave replication.

    mysql> START SLAVE;

    1. On server instance check if replication was success.

    mysql> SHOW SLAVE STATUS;

    1. On RDS read replica resume replication. mysql> CALL mysql.rds_start_replication;

提交回复
热议问题