すべてのプロダクト
Search
ドキュメントセンター

ApsaraDB RDS:ApsaraDB for MariaDB インスタンス間でのデータの移行

最終更新日:May 31, 2025

このトピックでは、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 アドレスを申請済みであること。

手順

  1. クライアントを使用して移行先の RDS インスタンスにログインし、データベースを作成します。

  2. 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
    重要

    エクスポート処理中はデータを更新しないでください。この手順では、データのみがエクスポートされます。ストアドプロシージャ、トリガー、または関数はエクスポートされません。

  3. 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
    説明

    データベースにストアドプロシージャ、トリガー、または関数が含まれていない場合は、この手順をスキップします。

  4. 以下の文を実行して、データファイル、ストアドプロシージャ、トリガー、および関数を移行先の 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