- Oracle MySQL Database Serviceの使い方メモ〜その3
- MySQL Shell Dump Utility / Dump Loading Utility
- ローカル環境のMySQL 5.7からOracle MySQL Database Service (MySQL 8.0) へのデータ移行
はじめに
MySQL Shellを利用してローカル環境で稼働しているMySQLServerからOracle Cloud Infrastructure (OCI) でマネージドサービスとして利用可能なOracle MySQL Database Serviceへのデータ移行方法を確認しました。Bastion (踏み台) サーバーを経由した方法とOCI Object Storageを利用した方法の2パターンを検証しています。MySQL Shell Dump Utility / Dump Loading Utilityについては前回の記事でも取り上げています。コマンドのオプション変数などツールの使い方でお悩みの方は下記の記事も併せてご確認ください。
MySQL Shell Dump UtilityとDump Loading Utilityの使い方
MySQL Shellを利用したクラウドバックアップ/リストア
検証環境
- MySQLバージョン : 8.0.22-u2-cloud (Oracle MySQL Database Service)
- MySQL Shell 8.0.22 : Bastionサーバ上およびクライアント上で利用
- macOS 10.15.7 Catalina : クライアント環境
- MySQL 5.7.32 : クライアント上のローカル環境で稼働・移行元のソースMySQLインスタンスとして利用
Bastion (踏み台) サーバーを経由したデータ移行
この方法はローカル環境でMySQL Shellを使用してエクスポートしたダンプファイルをBastionサーバにSCPでコピーして、BastionサーバのMySQL Shellを使用してMySQL Database Serviceインスタンスデータロードを行います。こちらの方法ではローカル環境からOCI上のBastionサーバへのファイル転送を行う手順が必要になりますが、何かしらの方法でファイルをOCI上にアップロードできれば良いので、後述するObject Storageを経由する方法に比べてローカル環境のネットワーク構成の制約はなく、セキュリティ要件に応じたネットワーク経路・方式を選択することができる利点があります。
構成イメージ
MySQL Shellはローカル環境とBastionサーバ上の2箇所で稼働することになります。
検証環境の準備
OCI側のBastionサーバおよびMySQL Database Serviceインスタンスの準備、BastionサーバへのMySQL Shellのインストール方法については前回の記事を参照してください。
Oracle MySQL Database Serviceのインスタンスを作ってMySQL Workbenchから接続してみた
ローカル環境へのMySQL Shellのインストールは、公式のダウンロードサイトよりインストーラをダウンロードして実行してください。
ローカル環境での作業
dryRunによる検証とCompatibilityオプションの付与
ローカル環境で稼働しているMySQL 5.7にMySQL Shellでアクセスします。Dump Instance Utility (util.dumpInstance
) では、ocimds: true
オプションを付与することでMySQL Database Serviceインスタンスへの移行性のチェックを行います。ダンプファイルをエクスポートする前にocimds: true
に加えてdryRun: true
オプションを付与して実行、 Compatibility Issueが無いことを確認します。下記の実行例では、1回目の実行ではERROR: User 'root'@'localhost' is granted restricted privileges
が発生したため、2回目の実行コマンドでcompatibility: ["strip_restricted_grants"]}
オプションを追加しMySQL Database Service上で制約のある権限を取り除いています。
$ mysqlsh -uroot -p
MySQL Shell 8.0.22
Copyright (c) 2016, 2020, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@localhost'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 2
Server version: 5.7.32 Homebrew
No default schema selected; type \use <schema> to set one.
MySQL localhost test JS > util.dumpInstance("/Users/username/dumps", {dryRun: true, ocimds: true})
Acquiring global read lock
Global read lock acquired
All transactions have been started
Locking instance for backup
NOTE: Backup lock is not supported in MySQL 5.7 and DDL changes will not be blocked. The dump may fail with an error or not be completely consistent if schema changes are made while dumping.
Global read lock has been released
Checking for compatibility with MySQL Database Service 8.0.22
NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first. You can check for potential upgrade issues using util.checkForServerUpgrade().
ERROR: User 'root'@'localhost' is granted restricted privileges: RELOAD, SHUTDOWN, FILE, SUPER, CREATE TABLESPACE, PROXY (fix this with 'strip_restricted_grants' compatibility option)
Compatibility issues with MySQL Database Service 8.0.22 were found. Please use the 'compatibility' option to apply compatibility adaptations to the dumped DDL.
Util.dumpInstance: Compatibility issues were found (RuntimeError)
MySQL localhost test JS > util.dumpInstance("/Users/username/dump", {dryRun: true, ocimds: true, compatibility: ["strip_restricted_grants"]})
Acquiring global read lock
Global read lock acquired
All transactions have been started
Locking instance for backup
NOTE: Backup lock is not supported in MySQL 5.7 and DDL changes will not be blocked. The dump may fail with an error or not be completely consistent if schema changes are made while dumping.
Global read lock has been released
Checking for compatibility with MySQL Database Service 8.0.22
NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first. You can check for potential upgrade issues using util.checkForServerUpgrade().
NOTE: User 'root'@'localhost' had restricted privileges (RELOAD, SHUTDOWN, FILE, SUPER, CREATE TABLESPACE, PROXY) removed
Compatibility issues with MySQL Database Service 8.0.22 were found and repaired. Please review the changes made before loading them.
Writing global DDL files
Writing users DDL
Writing DDL for schema `test`
Writing DDL for table `test`.`revenue`
Writing DDL for table `test`.`users`
Preparing data dump for table `test`.`revenue`
Data dump for table `test`.`revenue` will be chunked using column `id`
Preparing data dump for table `test`.`users`
Data dump for table `test`.`users` will be chunked using column `id`
compatibility
オプションの変数一覧など、util.dumpInstance
の利用方法については前回の記事を参照ください。
MySQL Shell Dump UtilityとDump Loading Utilityの使い方
ダンプファイルのエクスポートとOCIへのアップロード
Compatibility Issueが無いことを確認後、util.dumpInstance
をdryRun
オプションなしで実行することでダンプファイルをエクスポートできます。下記手順ではエクスポートしたダンプ・ファイルをdump
ディレクトリごと圧縮し、OCI上で稼働するXXX.XXX.XXX.XXX
のパブリックIPを持つBastionサーバへscpでファイル転送を行っています。
MySQL localhost test JS > util.dumpInstance("/Users/username/dump", {ocimds: true, compatibility: ["strip_restricted_grants"]})
Acquiring global read lock
Global read lock acquired
All transactions have been started
Locking instance for backup
NOTE: Backup lock is not supported in MySQL 5.7 and DDL changes will not be blocked. The dump may fail with an error or not be completely consistent if schema changes are made while dumping.
Global read lock has been released
Checking for compatibility with MySQL Database Service 8.0.22
NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first. You can check for potential upgrade issues using util.checkForServerUpgrade().
NOTE: User 'root'@'localhost' had restricted privileges (RELOAD, SHUTDOWN, FILE, SUPER, CREATE TABLESPACE, PROXY) removed
Compatibility issues with MySQL Database Service 8.0.22 were found and repaired. Please review the changes made before loading them.
Writing global DDL files
Writing users DDL
Writing DDL for schema `test`
Writing DDL for table `test`.`revenue`
Writing DDL for table `test`.`users`
Preparing data dump for table `test`.`revenue`
Data dump for table `test`.`revenue` will be chunked using column `id`
Preparing data dump for table `test`.`users`
Data dump for table `test`.`users` will be chunked using column `id`
Running data dump using 4 threads.
NOTE: Progress information uses estimated values and may not be accurate.
Data dump for table `test`.`users` will be written to 2 files
Data dump for table `test`.`revenue` will be written to 2 files
1 thds dumping - 150% (6 rows / ~4 rows), 0.00 rows/s, 0.00 B/s uncompressed, 0.00 B/s compressed
Duration: 00:00:00s
Schemas dumped:1
Tables dumped: 2
Uncompressed data size: 61 bytes
Compressed data size: 0 bytes
Compression ratio: 61.0
Rows written: 6
Bytes written: 0 bytes
Average uncompressed throughput: 61.00 B/s
Average compressed throughput: 0.00 B/s
MySQL localhost test JS > \q
Bye!
$ tar -zcvf dump.tar.gz /Users/username/dump
scp -i /Users/username/SSHKeys/privateKey dump.tar.gz opc@XXX.XXX.XXX.XXX:/home/opc
$ tar -zcvf dump.tar.gz dump
a dump
a dump/@.sql
a dump/@.users.sql
a dump/test.sql
a dump/test@users@@1.tsv.zst.idx
a dump/test@users.json
a dump/test@revenue@@1.tsv.zst
a dump/test@users@@1.tsv.zst
a dump/test@revenue.json
a dump/test.json
a dump/@.done.json
a dump/test@users@0.tsv.zst.idx
a dump/test@users.sql
a dump/test@users@0.tsv.zst
a dump/@.post.sql
a dump/@.json
a dump/test@revenue.sql
a dump/test@revenue@@1.tsv.zst.idx
a dump/test@revenue@0.tsv.zst
a dump/test@revenue@0.tsv.zst.idx
$ scp -i /Users/username/SSHKeys/privateKey dump.tar.gz opc@XXX.XXX.XXX.XXX:/home/opc dump.tar.gz
OCI環境での作業
BastionサーバからMySQL Database Serviceインスタンスへのデータロード
OCIで稼働しているBastionサーバにアクセスし、アップロードしたファイルの確認と解凍を行います。ホームディレクトリ/home/opc/
にダンプファイル群が格納されたdump
ディレクトリが作成されたことを確認してください
$ ls
dump.tar.gz
$ tar -zxvf dump.tar.gz
dump/
dump/@.sql
dump/@.users.sql
dump/test.sql
dump/test@users@@1.tsv.zst.idx
dump/test@users.json
dump/test@revenue@@1.tsv.zst
dump/test@users@@1.tsv.zst
dump/test@revenue.json
dump/test.json
dump/@.done.json
dump/test@users@0.tsv.zst.idx
dump/test@users.sql
dump/test@users@0.tsv.zst
dump/@.post.sql
dump/@.json
dump/test@revenue.sql
dump/test@revenue@@1.tsv.zst.idx
dump/test@revenue@0.tsv.zst
dump/test@revenue@0.tsv.zst.idx
[opc@bastion ~]$ ls
dump dump.tar.gz
MySQL Shellを起動し、MySQL Database Serviceのユーザー名、エンドポイントのプライベートIPを使用してMySQL Database Serviceインスタンスへアクセスします。そして、Dump Loading Utility (util.loadDump
) をdryRun: true
オプションを付与して実行することでエラーの有無を確認します。下記の実行例では、1回目の実行ではMySQL version mismatch (RuntimeError)
が発生したため、2回目の実行コマンドでignoreVersion: true
オプションを追加しエラーが解消できていることを確認しました。
$ mysqlsh MDSUSERNAME@10.0.31.11
Please provide the password for 'MDSUSERNAME@10.0.31.11': **************
Save password for 'MDSUSERNAME@10.0.31.11'? [Y]es/[N]o/Ne[v]er (default No): y
MySQL Shell 8.0.22
Copyright (c) 2016, 2020, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'MDSUSERNAME@10.0.31.11'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 12 (X protocol)
Server version: 8.0.22-u2-cloud MySQL Enterprise - Cloud
No default schema selected; type \use <schema> to set one.
MySQL 10.0.31.11:33060+ ssl JS > util.loadDump("/home/opc/dump",{dryRun: true})
Loading DDL and Data from '/home/opc/dump' using 4 threads.
Opening dump...
dryRun enabled, no changes will be made.
Target is MySQL 8.0.22-u2-cloud. Dump was produced from MySQL 5.7.32
ERROR: Destination MySQL version is newer than the one where the dump was created. Loading dumps from different major MySQL versions is not fully supported and may not work. Enable the 'ignoreVersion' option to load anyway.
Util.loadDump: MySQL version mismatch (RuntimeError)
MySQL 10.0.31.11:33060+ ssl JS > util.loadDump("/home/opc/dump",{dryRun: true, ignoreVersion: true})
Loading DDL and Data from '/home/opc/dump' using 4 threads.
Opening dump...
dryRun enabled, no changes will be made.
Target is MySQL 8.0.22-u2-cloud. Dump was produced from MySQL 5.7.32
WARNING: Destination MySQL version is newer than the one where the dump was created. Loading dumps from different major MySQL versions is not fully supported and may not work. 'ignoreVersion' option is enabled, so loading anyway.
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL script for schema `test`
[Worker002] Executing DDL script for `test`.`users`
[Worker002] Executing DDL script for `test`.`revenue`
Executing common postamble SQL
No data loaded.
0 warnings were reported during the load.
util.loadDump
の利用方法の詳細については前回の記事を参照ください。
MySQL Shell Dump UtilityとDump Loading Utilityの使い方
さらに下記ではdryRun
オプションなしでDump Loading Utilityを実行し、test
スキーマ、users
およびrevenue
テーブルがインポートされていることを確認できました。
MySQL 10.0.31.11:33060+ ssl JS > util.loadDump("/home/opc/dump",{ignoreVersion: true})
Loading DDL and Data from '/home/opc/dump' using 4 threads.
Opening dump...
Target is MySQL 8.0.22-u2-cloud. Dump was produced from MySQL 5.7.32
WARNING: Destination MySQL version is newer than the one where the dump was created. Loading dumps from different major MySQL versions is not fully supported and may not work. 'ignoreVersion' option is enabled, so loading anyway.
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL script for schema `test`
[Worker002] Executing DDL script for `test`.`users`
[Worker000] Executing DDL script for `test`.`revenue`
[Worker002] test@users@@1.tsv.zst: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
[Worker000] test@revenue@@1.tsv.zst: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
[Worker001] test@revenue@0.tsv.zst: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
[Worker003] test@users@0.tsv.zst: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
Executing common postamble SQL
4 chunks (6 rows, 61 bytes) for 2 tables in 1 schemas were loaded in 1 sec (avg throughput 61.00 B/s)
0 warnings were reported during the load.
MySQL 10.0.31.11:33060+ ssl JS > \sql
Switching to SQL mode... Commands end with ;
MySQL 10.0.31.11:33060+ ssl SQL > SHOW SCHEMAS;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.0011 sec)
MySQL 10.0.31.11:33060+ ssl SQL > Use test;
Default schema set to `test`.
Fetching table and column names from `test` for auto-completion... Press ^C to stop.
MySQL 10.0.31.11:33060+ ssl test SQL > SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| revenue |
| users |
+----------------+
2 rows in set (0.0025 sec)
MySQL 10.0.31.11:33060+ ssl test SQL >
OCI Object Storageを利用したデータ移行
この方法は、MySQL Shellを利用してローカル環境からOCI Object Storageへ直接ダンプファイルをエクスポートします。こちらの方法ではローカル環境からOCI上のBastionサーバへのファイル転送を行う手順が不要になり、安価なObject Storageを中間ストレージとして利用できるメリットがありますが、ローカルのMySQL Shellの実行環境から直接Object Storageへアクセスするネットワーク経路が必要になります。また、Object Storageの事前認証済リクエストを使用するため、セキュリティポリシーの確認、配慮が必要になります1。
構成イメージ
この手法でもMySQL Shellはローカル環境とBastionサーバ上の2箇所で稼働することになります。
検証環境の準備
ローカル環境ならびにBastionサーバ上にSQL Shellのインストールに加えてOCI CLIインストールと構成が必要になります。OCI CLIのインストールについては下記のドキュメント・チュートリアル・Qiita記事をご参照ください。
Oracle Cloud Infrastructureドキュメント コマンドライン・インタフェース(CLI)
Oracle Cloud : コマンド・ライン・インタフェース(CLI) をインストールしてみた
OCI CLIの構成ファイルであるconfig内の記述、API Keyのファイルパスは絶対パスで記載しないとMySQL Shellでエラーが発生するので注意が必要です。
ローカル環境での作業
Object Storageバケットへのダンプファイルのエクスポート
ローカル環境で稼働しているMySQL 5.7にMySQL Shellでアクセスします。そして、ocimds: true
に加えてObject Storageへのアクセス情報をオプションで付与してDump Instance Utility (util.dumpInstance
) を起動します。下記では、オブジェクト接頭辞にdumpinstance_onp2mds
を指定し、osBucketName
にObject Storageのバケット名mdsdump
、osNamespace
にはObject Storageバケットの詳細コンソールから確認できるネームスペースを指定します。これらのオプション変数については前回の記事を参考にしてください。
MySQL Shellを利用したクラウドバックアップ/リストア
下記実行例では、前項のcompatibility
オプションを参考にdryRun
無しで実行していますが、実際の手順ではdryRun: true
オプションを付与して実行し、 Compatibility Issueが発生しないことを確認してください。
mysqlsh -uroot -p
MySQL Shell 8.0.22
Copyright (c) 2016, 2020, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@localhost'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 18
Server version: 5.7.32 Homebrew
No default schema selected; type \use <schema> to set one.
MySQL localhost test JS > util.dumpInstance("dumpinstance_onp2mds", {dryRun: true, osBucketName:"mdsdump", osNamespace:"NAMESPACE", ocimds:true, compatibility:["strip_restricted_grants"]})
Acquiring global read lock
Global read lock acquired
All transactions have been started
Locking instance for backup
NOTE: Backup lock is not supported in MySQL 5.7 and DDL changes will not be blocked. The dump may fail with an error or not be completely consistent if schema changes are made while dumping.
Global read lock has been released
Checking for compatibility with MySQL Database Service 8.0.22
NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first. You can check for potential upgrade issues using util.checkForServerUpgrade().
NOTE: User 'root'@'localhost' had restricted privileges (RELOAD, SHUTDOWN, FILE, SUPER, CREATE TABLESPACE, PROXY) removed
Compatibility issues with MySQL Database Service 8.0.22 were found and repaired. Please review the changes made before loading them.
Writing global DDL files
Writing users DDL
Writing DDL for schema `test`
Writing DDL for table `test`.`users`
Writing DDL for table `test`.`revenue`
Preparing data dump for table `test`.`revenue`
Data dump for table `test`.`revenue` will be chunked using column `id`
Preparing data dump for table `test`.`users`
Data dump for table `test`.`users` will be chunked using column `id`
MySQL localhost test JS > util.dumpInstance("dumpinstance_onp2mds", {osBucketName:"mdsdump", osNamespace:"NAMESPACE", ocimds:true, compatibility:["strip_restricted_grants"]})
Acquiring global read lock
Global read lock acquired
All transactions have been started
Locking instance for backup
NOTE: Backup lock is not supported in MySQL 5.7 and DDL changes will not be blocked. The dump may fail with an error or not be completely consistent if schema changes are made while dumping.
Global read lock has been released
Checking for compatibility with MySQL Database Service 8.0.22
NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first. You can check for potential upgrade issues using util.checkForServerUpgrade().
NOTE: User 'root'@'localhost' had restricted privileges (RELOAD, SHUTDOWN, FILE, SUPER, CREATE TABLESPACE, PROXY) removed
Compatibility issues with MySQL Database Service 8.0.22 were found and repaired. Please review the changes made before loading them.
Writing global DDL files
Writing users DDL
Writing DDL for schema `test`
Writing DDL for table `test`.`revenue`
Writing DDL for table `test`.`users`
Preparing data dump for table `test`.`revenue`
Data dump for table `test`.`revenue` will be chunked using column `id`
Preparing data dump for table `test`.`users`
Data dump for table `test`.`users` will be chunked using column `id`
Running data dump using 4 threads.
NOTE: Progress information uses estimated values and may not be accurate.
Data dump for table `test`.`revenue` will be written to 2 files
Data dump for table `test`.`users` will be written to 2 files
1 thds dumping - 150% (6 rows / ~4 rows), 1.00 row/s, 19.00 B/s uncompressed, 0.00 B/s compressed
Duration: 00:00:03s
Schemas dumped: 1
Tables dumped: 2
Uncompressed data size: 61 bytes
Compressed data size: 0 bytes
Compression ratio: 61.0
Rows written: 6
Bytes written: 0 bytes
Average uncompressed throughput: 19.77 B/s
Average compressed throughput: 0.00 B/s
MySQL localhost test JS > \q
Bye!
OCI環境での作業
Object StorageからMySQL Database Serviceインスタンスへのデータロード
OCIで稼働しているBastionサーバにアクセスし、MySQL Shellを起動します。上記手順でダンプファイルがアップロードされたObject Storageへのアクセス情報をオプションで付与してDump Loading Utility (util.dumpInstance
) を実行することでObject StorageからMySQL Database Serviceインスタンスへデータロードを行うことができます。下記手順では、ignoreVersion: true
も付与した上でdryRunを実行、エラーが発生しないことを確認した上でデータのロードを行っています。
$ mysqlsh MDSUSERNAME@10.0.31.11
MySQL Shell 8.0.22
Copyright (c) 2016, 2020, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'MDSUSERNAME@10.0.31.11'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 32 (X protocol)
Server version: 8.0.22-u2-cloud MySQL Enterprise - Cloud
No default schema selected; type \use <schema> to set one.
MySQL 10.0.31.11:33060+ ssl JS > util.loadDump("dumpinstance_onp2mds", {dryRun: true, osBucketName:"mdsdump", osNamespace:"NAMESPACE", ignoreVersion: true})
Loading DDL and Data from OCI ObjectStorage bucket=mdsdump, prefix='dumpinstance_onp2mds' using 4 threads.
Opening dump...
dryRun enabled, no changes will be made.
Target is MySQL 8.0.22-u2-cloud. Dump was produced from MySQL 5.7.32
WARNING: Destination MySQL version is newer than the one where the dump was created. Loading dumps from different major MySQL versions is not fully supported and may not work. 'ignoreVersion' option is enabled, so loading anyway.
Fetching dump data from remote location...
Fetching 2 table metadata files for schema `test`...
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL script for schema `test`
[Worker001] Executing DDL script for `test`.`revenue`
[Worker000] Executing DDL script for `test`.`users`
Executing common postamble SQL
No data loaded.
0 warnings were reported during the load.
MySQL 10.0.31.11:33060+ ssl JS > util.loadDump("dumpinstance_onp2mds", {osBucketName:"mdsdump", osNamespace:"NAMESPACE", ignoreVersion: true})
Loading DDL and Data from OCI ObjectStorage bucket=mdsdump, prefix='dumpinstance_onp2mds' using 4 threads.
Opening dump...
Target is MySQL 8.0.22-u2-cloud. Dump was produced from MySQL 5.7.32
WARNING: Destination MySQL version is newer than the one where the dump was created. Loading dumps from different major MySQL versions is not fully supported and may not work. 'ignoreVersion' option is enabled, so loading anyway.
Fetching dump data from remote location...
Fetching 2 table metadata files for schema `test`...
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL script for schema `test`
[Worker001] Executing DDL script for `test`.`revenue`
[Worker000] Executing DDL script for `test`.`users`
[Worker002] test@users@0.tsv.zst: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
[Worker003] test@revenue@0.tsv.zst: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
[Worker001] test@users@@1.tsv.zst: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
[Worker000] test@revenue@@1.tsv.zst: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
Executing common postamble SQL
4 chunks (6 rows, 61 bytes) for 2 tables in 1 schemas were loaded in 1 sec (avg throughput 61.00 B/s)
0 warnings were reported during the load.
MySQL 10.0.31.11:33060+ ssl JS > \sql
Switching to SQL mode... Commands end with ;
MySQL 10.0.31.11:33060+ ssl SQL > SHOW SCHEMAS;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.0040 sec)
MySQL 10.0.31.11:33060+ ssl SQL > USE test;
Default schema set to `test`.
Fetching table and column names from `test` for auto-completion... Press ^C to stop.
MySQL 10.0.31.11:33060+ ssl test SQL > SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| revenue |
| users |
+----------------+
2 rows in set (0.0015 sec)
まとめ
本記事では、MySQL Shellを利用したMySQL Database Serviceインスタンスへのデータ移行方式の検証を行いました。実際に移行作業を検討する際は、移行元のMySQLバージョン、ローカル環境のネットワーク構成、セキュリティ要件、許容される移行時間などを踏まえて、従来から存在するmysqldumpなども含めて最適なツールを選択することが必要になります。データ移行も掛かる時間に目が行きがちですが、アプリケーションの動作確認と改修箇所の洗い出し、環境の切り戻し方式を含めた移行方式の策定、入念なリハーサルがクラウド移行を成功に導く重要な要素となります。
関連情報
MySQL Shell Dump UtilityとDump Loading Utilityの使い方
MySQL Shellを利用したクラウドバックアップ/リストア
MySQL Technology Café #7 MySQL Shellを使ってみよう!
Oracle Cloud Infrastructureドキュメント オブジェクト・ストレージの概要
Oracle Cloud Infrastructure Documentation MySQL Database Importing and Exporting Databases
MySQL Shell 8.0 7.5 Instance Dump Utility, Schema Dump Utility, and Table Dump Utility