Amazon Aurora MySQL로의 물리적 마이그레이션에 걸리는 시간 단축 - Amazon Aurora

Amazon Aurora MySQL로의 물리적 마이그레이션에 걸리는 시간 단축

다음 데이터베이스 수정 사항을 반영하여 Amazon Aurora MySQL로 데이터베이스를 마이그레이션하는 데 필요한 프로세스를 단축할 수 있습니다.

중요

이러한 업데이트는 프로덕션 데이터베이스가 아닌 프로덕션 데이터베이스의 복제본에서 수행해야 합니다. 그런 다음, 복제본을 백업하고 Aurora 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_FORMATDEFAULT, COMPACT, DYNAMIC 또는 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';