百度智能云

All Product Document

          Relational Database Service

          Cloud Migration on MySQL Database

          Overview of Best Practices for Data Migration

          Content below shows the users the cloud migration process on different databases mainly from three aspects, including [Cloud Migration on MySQL Database](#Cloud Migration on MySQL Database), [Cloud Migration on SQL Server Database](Cloud Migration on #SQL Server Database), and [Cloud Migration on PostgreSQL Database](#Cloud Migration on PostgreSQL Database) assisting users in migrating the data from local server or other virtual servers to the cloud as soon as possible.

          Cloud Migration on MySQL Database

          Introduction

          With the rise of cloud computing, an increasing number of enterprises, given database stability and OPS cost, plan to migrate the database from the local server or other virtual servers to the cloud. Currently, the methods for migration of database to RDS for MySQL include migration in shutdown and migration without shutdown. Here, here is a detailed description of different solutions in the two cloud migration methods. And, recommend you to use the DTS for migration.

          Migration Methods

          Migration in Shutdown

          If the application accepts the cessation of the server for a period, migration in the shutdown is the simplest method. Current, we provide two solutions for you:

          mysqldump

          The specific procedure is as follows:

          • Stop the write-in of applications, or disable the application server;
          • Back up all database tables using the "mysqldump" tool:
            mysqldump –u dbuser –p dbpass -h dbhost -Pdbport -A > data.sql
          • Connection via RDS domain name, and import of databases backups onto RDS using the "mysql" client tool
            mysql -u dbuser -p dbpass -h rdsdns -Pdbport < data.sql
          • Modify the database connection address in the applications, restart the application server, or enable the write-in.

          DTS data migration (Recommended)

          The specific procedure is as follows:

          • Stop the write-in of applications, or disable the application server;
          • On DTS, configure the source terminal and target terminal's database connection methods, select "Structure plus Full Migration", and enable the task. For detailed steps on DTS data migration, see Data Migration.
          • After the DTS migration task ends, modify the database connection address in the application, and restart the application server or enable the write-in;
          • End the DTS migration task.

          Migration Without Shutdown

          Usually, the application hopes to migrate the database onto the cloud without cessation of the server. What's more, if the data volume of the database in migration is massive, the cessation of the server lasts for a long time, which is unacceptable. Currently, there are two solutions for migration without shutdown:

          mysqldump + master-slave replications

          This solution is only applicable to MySQL with enabled GTID, and the specific steps are as follows:

          • Export all database table data using the "mysqldump" tool that has the same version as Mysql Server:
            mysqldump –u dbuser –p dbpass -h dbhost -Pdbport -A > data.sql
          • Apply for "Super" privilege on RDS, and connect via RDS domain name, and import the data backups using "Mysql" client tool:
            mysql -u dbuser -p dbpass -h rdsdns -Pdbport < data.sql
          • Use "Mysql" client for login, and execute "change master to master_host=xxx, master_port=xxx, master_user=xxx, master_password=xxx, master_auto_position=1;", and start to keep up with the increment;
          • Start stopping the application write-in, wait until keeping up with the old master database's data. Then, modify the application's database access address, and start to write, realizing the cloud migration via temporary write stop.

          xtrabackup

          In this solution, you need to send a ticket to contact RDS staff on duty for data recovery, and the specific steps are as follows:

          • Carry out the hot backup of the database using "xtrabackup" tool, and then upload the data backups onto Baidu AI Cloud BOS:
            innobackupex --user=dbuser --password=dbpass --host=dbhost --port=dbport /path/to/BACKUP-DIR/
          • By sending the ticket, you can provide RDS staff on duty with the backup data's BOS address for data recovery;
          • After completing the data recovery, you should apply for "Super" privilege on RDS, use "Mysql" client for login, and execute "change master". Here, you may carry out synchronous increment using "binlog file+position" or "gtid";
          • Start to stop the application write-in, wait till keeping up with the old master database's data, modify the application's database access address, and start to write, realizing the cloud migration.

          DTS increment migration (Recommended)

          The specific procedure is as follows:

          • Carry out "Structure plus Full plus Incremental Data Migration" using DTS. For specific operation steps, see Data Migration.
          • Start to stop the application write-in, wait till keeping up with the old master database's data, modify the application's database access address, and start to write.
          • End the DTS migration task, and complete the cloud migration.
          Previous
          Cloud Migration on SQL-Server
          Next
          Limitation for Use of Proxy Instance