Amazon Aurora MySQL への物理的な移行にかかる時間の短縮 - Amazon Aurora

Amazon Aurora MySQL への物理的な移行にかかる時間の短縮

Amazon Aurora MySQL へのデータベース移行プロセスをスピードアップするために、以下のデータベース修正を行うことができます。

重要

これらのアップデートは、本稼働データベースではなく、そのコピーに対して実行するようにしてください。このコピーをバックアップし、Aurora MySQL DB クラスターに復元することで、本稼働データベースのサービス停止を回避できます。

サポートされていないテーブルタイプ

Aurora MySQL はデータベーステーブル用の InnoDB エンジンのみをサポートしています。データベース内に MyISAM テーブルがある場合は、Aurora MySQL に移行する前にそれらのテーブルを変換する必要があります。移行中の MyISAM から InnoDB への変換プロセスには、追加領域が必要です。

領域不足が発生する可能性を低く抑えて移行プロセスを高速化するには、すべての MyISAM テーブルを移行前に InnoDB テーブルに変換しておきます。処理後の InnoDB テーブルのサイズは、Aurora MySQL がそのテーブルに対して必要とするサイズと同じになります。MyISAM テーブルを InnoDB に変換するには、次のコマンドを実行します。

ALTER TABLE schema.table_name engine=innodb, algorithm=copy;

Aurora MySQL では、圧縮テーブルまたはページ (ROW_FORMAT=COMPRESSED または COMPRESSION = {"zlib"|"lz4"} を使用して作成されたテーブル) をサポートしていません。

スペースが不足する可能性を減らしたり、移行処理を高速化するには、ROW_FORMATDEFAULTCOMPACTDYNAMIC または REDUNDANT に設定して圧縮テーブルを展開します。圧縮ページの場合は、COMPRESSION="none" を設定します。

詳細については、MySQL ドキュメントの「InnoDB 行形式」および「InnoDB テーブルおよびページ圧縮」を参照してください。

既存の MySQL DB インスタンスで以下の SQL スクリプトを使用して、データベースの MyISAM テーブルまたは圧縮テーブルのリストを表示できます。

-- This script examines a MySQL database for conditions that block -- migrating the database into Aurora MySQL. -- It must be run from an account that has read permission for the -- INFORMATION_SCHEMA database. -- Verify that this is a supported version of MySQL. select msg as `==> Checking current version of MySQL.` from ( select 'This script should be run on MySQL version 5.6 or higher. ' + 'Earlier versions are not supported.' as msg, cast(substring_index(version(), '.', 1) as unsigned) * 100 + cast(substring_index(substring_index(version(), '.', 2), '.', -1) as unsigned) as major_minor ) as T where major_minor <> 506; -- List MyISAM and compressed tables. Include the table size. select concat(TABLE_SCHEMA, '.', TABLE_NAME) as `==> MyISAM or Compressed Tables`, round(((data_length + index_length) / 1024 / 1024), 2) "Approx size (MB)" from INFORMATION_SCHEMA.TABLES where ENGINE <> 'InnoDB' and ( -- User tables TABLE_SCHEMA not in ('mysql', 'performance_schema', 'information_schema') or -- Non-standard system tables ( TABLE_SCHEMA = 'mysql' and TABLE_NAME not in ( 'columns_priv', 'db', 'event', 'func', 'general_log', 'help_category', 'help_keyword', 'help_relation', 'help_topic', 'host', 'ndb_binlog_index', 'plugin', 'proc', 'procs_priv', 'proxies_priv', 'servers', 'slow_log', 'tables_priv', 'time_zone', 'time_zone_leap_second', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'user' ) ) ) or ( -- Compressed tables ROW_FORMAT = 'Compressed' );

サポートされていない権限を持つユーザーアカウント

Aurora MySQL でサポートされていない権限を持つユーザーアカウントは、サポートされていない権限なしでもインポートされます。サポートされている権限のリストについては、「ロールベースの特権モデル」を参照してください。

ソースデータベースで次の SQL クエリを実行すると、サポートされていない権限を持つユーザーアカウントを一覧表示できます。

SELECT user, host FROM mysql.user WHERE Shutdown_priv = 'y' OR File_priv = 'y' OR Super_priv = 'y' OR Create_tablespace_priv = 'y';

Aurora MySQL バージョン 3 に対する動的権限

動的権限はインポートされません。Aurora MySQL バージョン 3 は、以下の動的権限をサポートしています。

'APPLICATION_PASSWORD_ADMIN', 'CONNECTION_ADMIN', 'REPLICATION_APPLIER', 'ROLE_ADMIN', 'SESSION_VARIABLES_ADMIN', 'SET_USER_ID', 'XA_RECOVER_ADMIN'

次のサンプルスクリプトは、サポートされている動的権限を Aurora MySQL DB クラスターのユーザーアカウントに付与します。

-- This script finds the user accounts that have Aurora MySQL supported dynamic privileges -- and grants them to corresponding user accounts in the Aurora MySQL DB cluster. /home/ec2-user/opt/mysql/8.0.26/bin/mysql -uusername -pxxxxx -P8026 -h127.0.0.1 -BNe "SELECT CONCAT('GRANT ', GRANTS, ' ON *.* TO ', GRANTEE ,';') AS grant_statement FROM (select GRANTEE, group_concat(privilege_type) AS GRANTS FROM information_schema.user_privileges WHERE privilege_type IN ( 'APPLICATION_PASSWORD_ADMIN', 'CONNECTION_ADMIN', 'REPLICATION_APPLIER', 'ROLE_ADMIN', 'SESSION_VARIABLES_ADMIN', 'SET_USER_ID', 'XA_RECOVER_ADMIN') AND GRANTEE NOT IN (\"'mysql.session'@'localhost'\",\"'mysql.infoschema'@'localhost'\",\"'mysql.sys'@'localhost'\") GROUP BY GRANTEE) AS PRIVGRANTS; " | /home/ec2-user/opt/mysql/8.0.26/bin/mysql -u master_username -p master_password -h DB_cluster_endpoint

定義者として 'rdsadmin'@'localhost' を使用して保存されたオブジェクト

'rdsadmin'@'localhost' が定義子である関数、プロシージャ、ビュー、イベント、トリガーは、インポートされません。

ソース MySQL データベースで以下の SQL スクリプトを使用すると、サポートされていない定義子を持つストアド オブジェクトを一覧表示できます。

-- This SQL query lists routines with `rdsadmin`@`localhost` as the definer. SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM information_schema.routines WHERE definer = 'rdsadmin@localhost'; -- This SQL query lists triggers with `rdsadmin`@`localhost` as the definer. SELECT TRIGGER_SCHEMA, TRIGGER_NAME, DEFINER FROM information_schema.triggers WHERE DEFINER = 'rdsadmin@localhost'; -- This SQL query lists events with `rdsadmin`@`localhost` as the definer. SELECT EVENT_SCHEMA, EVENT_NAME FROM information_schema.events WHERE DEFINER = 'rdsadmin@localhost'; -- This SQL query lists views with `rdsadmin`@`localhost` as the definer. SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.views WHERE DEFINER = 'rdsadmin@localhost';