このトピックでは、Data Transmission Service (DTS) または mysqldump を使用して ApsaraDB for MariaDB インスタンス間でデータを移行する方法について説明します。
DTS の使用
「ApsaraDB for MariaDB インスタンス間でデータを移行する」で説明されている操作を実行します。
mysqldump の使用
このトピックでは、データを移行する RDS インスタンスは MariaDB 10.3 を実行していると想定しています。
前提条件
お使いのコンピューターまたは Elastic Compute Service (ECS) インスタンスに CentOS 7 と MySQL 5.7 がインストールされていること。
お使いのコンピューターまたは ECS インスタンスのパブリック IP アドレスが、2 つの RDS インスタンスのIP アドレス ホワイトリストに追加されていること。
2 つの RDS インスタンスに対してパブリック IP アドレスを申請済みであること。
手順
クライアントを使用して移行先の RDS インスタンスにログインし、データベースを作成します。
mysqldump を使用して、移行元 RDS インスタンスの移行するデータベースをデータファイルとしてエクスポートします。
mysqldump -h <Public IP address of the source RDS instance> -P <Port of the source RDS instance> -u <Privileged account of the source RDS instance> -p<Password of the privileged account> --opt --default-character-set=utf8 --hex-blob <Name of the database to be migrated> --skip-triggers > /tmp/<Name of the database to be migrated>.sql例
mysqldump -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test -pTestxxx --opt --default-character-set=utf8 --hex-blob testdb --skip-triggers > /tmp/testdb.sql重要エクスポート処理中はデータを更新しないでください。この手順では、データのみがエクスポートされます。ストアドプロシージャ、トリガー、または関数はエクスポートされません。
mysqldump を使用して、ストアドプロシージャ、トリガー、および関数をエクスポートします。
mysqldump -h <Public IP address of the source RDS instance> -P <Port of the source RDS instance> -u <Privileged account of the source RDS instance> -p<Password of the privileged account> --opt --default-character-set=utf8 --hex-blob <Name of the database to be migrated> -R > /tmp/<Name of the database to be migrated>trigger.sql例
mysqldump -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test -pTestxxx --opt --default-character-set=utf8 --hex-blob testdb -R > /tmp/testdbtrigger.sql説明データベースにストアドプロシージャ、トリガー、または関数が含まれていない場合は、この手順をスキップします。
以下の文を実行して、データファイル、ストアドプロシージャ、トリガー、および関数を移行先の RDS インスタンスにインポートします。
mysql -h <Public IP address of the destination RDS instance> -P <Port of the destination RDS instance> -u <Privileged account of the destination RDS instance> -p<Password of the privileged account> <Database name of the destination RDS instance> < /tmp/<Name of the database to be migrated>.sql mysql -h <Public IP address of the destination RDS instance> -P <Port of the destination RDS instance> -u <Privileged account of the destination RDS instance> -p<Password of the privileged account> <Database name of the destination RDS instance> < /tmp/<Name of the database to be migrated>trigger.sql例
mysql -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test2 -pTest2xxx test001 < /tmp/testdb.sql mysql -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test2 -pTest2xxx test001 < /tmp/testdbtrigger.sql