Amazon Redshift가 구성된 Amazon RDS 제로 ETL 통합 시작하기
Amazon Redshift가 구성된 제로 ETL 통합을 생성하기 전에 필수 파라미터와 권한을 사용하여 RDS 데이터베이스와 Amazon Redshift 데이터 웨어하우스를 구성합니다. 설정 중에 다음 단계를 완료해야 합니다.
이러한 작업을 완료한 후 Amazon Redshift가 구성된 Amazon RDS 제로 ETL 통합 생성으로 이동합니다.
작은 정보
통합을 생성하는 동안 수동으로 수행하는 대신 RDS가 이러한 설정 단계를 완료하도록 할 수 있습니다. 통합 생성을 바로 시작하려면 Amazon Redshift가 구성된 Amazon RDS 제로 ETL 통합 생성 섹션을 참조하세요.
1단계: 사용자 지정 DB 파라미터 그룹 생성
Amazon Redshift가 구성된 Amazon RDS 제로 ETL 통합은 이진 로깅(binlog)을 제어하는 DB 파라미터에 대한 특정 값을 필요로 합니다. 바이너리 로깅을 구성하려면 먼저 사용자 지정 DB 파라미터 그룹을 만든 다음 이를 소스 데이터베이스와 연결해야 합니다. 다음 파라미터 값을 구성합니다. 파라미터 그룹을 만드는 방법에 대한 지침은 Amazon RDS DB 인스턴스용 DB 파라미터 그룹 섹션을 참조하세요. 종속성 문제를 방지하기 위해 동일한 요청 내에서 모든 파라미터 값을 구성하는 것이 좋습니다.
-
binlog_format=ROW
-
binlog_row_image=full
또한 binlog_row_value_options
파라미터가 PARTIAL_JSON
으로 설정되어 있지 않아야 합니다. 소스 데이터베이스가 다중 AZ DB 클러스터인 경우 binlog_transaction_compression
파라미터가 ON
으로 설정되지 않아야 합니다.
2단계: 소스 데이터베이스 선택 또는 생성
사용자 지정 DB 파라미터 그룹을 만든 후 RDS for MySQL 데이터베이스를 선택하거나 만듭니다. 이 데이터베이스는 Amazon Redshift로의 데이터 복제 소스가 됩니다. 단일 AZ 또는 다중 AZ DB 인스턴스를 만드는 방법에 대한 지침은 Amazon RDS DB 인스턴스 생성 섹션을 참조하세요. 다중 AZ DB 클러스터를 생성하는 지침은 Amazon RDS용 다중 AZ DB 클러스터 생성 섹션을 참조하세요.
데이터베이스에서 지원되는 DB 엔진 버전을 실행 중이어야 합니다. 지원되는 버전 목록은 Amazon Redshift와 Amazon RDS 제로 ETL 통합을 지원하는 리전 및 DB 엔진 섹션을 참조하세요.
데이터베이스를 생성할 때 추가 구성에서 기본 DB 파라미터 그룹을 이전 단계에서 생성한 사용자 지정 파라미터 그룹으로 변경합니다.
참고
데이터베이스가 이미 생성된 후에 데이터베이스와 파라미터 그룹을 연결한다면 제로 ETL 통합을 만들기 전에 클러스터의 데이터베이스를 재부팅하여 변경 사향을 적용해야 합니다. 지침은 DB 인스턴스 재부팅 또는 Amazon RDS에서 다중 AZ DB 클러스터 및 리더 DB 인스턴스 재부팅 섹션을 참조하십시오.
또한 데이터베이스에서 자동 백업이 활성화되어 있는지 확인하세요. 자세한 내용은 자동 백업 활성화 섹션을 참조하세요.
3단계: 대상 Amazon Redshift 데이터 웨어하우스 생성
소스 데이터베이스를 생성한 후에는 Amazon Redshift에서 대상 데이터 웨어하우스를 생성하고 구성해야 합니다. 데이터 웨어하우스는 다음 요구 사항을 충족해야 합니다.
-
최소 2개 이상의 노드가 있는 RA3 노드 유형 또는 Redshift Serverless를 사용합니다.
-
암호화되어 있습니다(프로비저닝된 클러스터를 사용하는 경우). 자세한 내용은 Amazon Redshift 데이터베이스 암호화를 참조하세요.
데이터 웨어하우스를 만드는 방법에 대한 지침은 프로비전된 클러스터의 경우 클러스터 생성을, Redshift Serverless의 경우 네임스페이스가 있는 작업 그룹 생성을 참조하세요.
데이터 웨어하우스에서 대/소문자 구분 활성화
통합이 성공하려면 데이터 웨어하우스에서 대/소문자 구분 파라미터(enable_case_sensitive_identifier
)를 활성화해야 합니다. 기본적으로 모든 프로비저닝된 클러스터와 Redshift Serverless 작업 그룹에서 대/소문자 구분이 비활성화되어 있습니다.
대/소문자 구분을 활성화하려면 데이터 웨어하우스 유형에 따라 다음 단계를 수행하세요.
-
프로비저닝된 클러스터 - 프로비저닝된 클러스터에서 대/소문자 구분을 활성화하려면
enable_case_sensitive_identifier
파라미터가 활성화된 사용자 지정 파라미터 그룹을 생성합니다. 그런 다음 이 파라미터 그룹을 클러스터와 연결합니다. 자세한 지침은 콘솔을 사용한 파라미터 그룹 관리 또는 AWS CLI를 사용한 파라미터 값 구성을 참조하세요.참고
사용자 지정 파라미터 그룹을 연결한 후 클러스터를 재부팅해야 합니다.
-
Serverless 작업 그룹 - Redshift Serverless 작업 그룹에서 대/소문자 구분을 활성화하려면 AWS CLI를 사용해야 합니다. Amazon Redshift 콘솔은 현재 Redshift Serverless 파라미터 값 수정을 지원하지 않습니다. 다음 update-workgroup 업데이트 요청을 보냅니다.
aws redshift-serverless update-workgroup \ --workgroup-name
target-workgroup
\ --config-parameters parameterKey=enable_case_sensitive_identifier,parameterValue=true작업 그룹의 파라미터 값을 수정한 후 작업 그룹을 재부팅할 필요가 없습니다.
데이터 웨어하우스에 대한 권한 부여 구성
데이터 웨어하우스를 만든 후에는 소스 RDS 데이터베이스를 승인된 통합 소스로 구성해야 합니다. 자세한 지침은 Amazon Redshift 데이터 웨어하우스에 대한 권한 부여 구성을 참조하세요.
AWS SDK를 사용하여 통합 설정
각 리소스를 수동으로 설정하는 대신 다음 Python 스크립트를 실행하여 필요한 리소스를 자동으로 설정할 수 있습니다. 코드 예제에서는 AWS SDK for Python (Boto3)
필요한 종속성을 설치하려면 다음 명령을 실행합니다.
pip install boto3 pip install time
스크립트 내에서 필요에 따라 소스, 대상 및 파라미터 그룹의 이름을 수정할 수 있습니다. 최종 함수는 리소스 설정에 따라 my-integration
이름이 지정된 통합을 생성합니다.
import boto3 import time # Build the client using the default credential configuration. # You can use the CLI and run 'aws configure' to set access key, secret # key, and default Region. rds = boto3.client('rds') redshift = boto3.client('redshift') sts = boto3.client('sts') source_db_name = 'my-source-db' # A name for the source database source_param_group_name = 'my-source-param-group' # A name for the source parameter group target_cluster_name = 'my-target-cluster' # A name for the target cluster target_param_group_name = 'my-target-param-group' # A name for the target parameter group def create_source_db(*args): """Creates a source RDS for MySQL DB instance""" response = rds.create_db_parameter_group( DBParameterGroupName=source_param_group_name, DBParameterGroupFamily='mysql8.0', Description='RDS for MySQL zero-ETL integrations' ) print('Created source parameter group: ' + response['DBParameterGroup']['DBParameterGroupName']) response = rds.modify_db_parameter_group( DBParameterGroupName=source_param_group_name, Parameters=[ { 'ParameterName': 'binlog_format', 'ParameterValue': 'ROW', 'ApplyMethod': 'pending-reboot' }, { 'ParameterName': 'binlog_row_image', 'ParameterValue': 'full', 'ApplyMethod': 'pending-reboot' } ] ) print('Modified source parameter group: ' + response['DBParameterGroupName']) response = rds.create_db_instance( DBInstanceIdentifier=source_db_name, DBParameterGroupName=source_param_group_name, Engine='mysql', EngineVersion='8.0.32', DBName='mydb', DBInstanceClass='db.m5.large', AllocatedStorage=15, MasterUsername=
'username'
, MasterUserPassword='Password01**
' ) print('Creating source database: ' + response['DBInstance']['DBInstanceIdentifier']) source_arn = (response['DBInstance']['DBInstanceArn']) create_target_cluster(target_cluster_name, source_arn, target_param_group_name) return(response) def create_target_cluster(target_cluster_name, source_arn, target_param_group_name): """Creates a target Redshift cluster""" response = redshift.create_cluster_parameter_group( ParameterGroupName=target_param_group_name, ParameterGroupFamily='redshift-1.0', Description='RDS for MySQL zero-ETL integrations' ) print('Created target parameter group: ' + response['ClusterParameterGroup']['ParameterGroupName']) response = redshift.modify_cluster_parameter_group( ParameterGroupName=target_param_group_name, Parameters=[ { 'ParameterName': 'enable_case_sensitive_identifier', 'ParameterValue': 'true' } ] ) print('Modified target parameter group: ' + response['ParameterGroupName']) response = redshift.create_cluster( ClusterIdentifier=target_cluster_name, NodeType='ra3.4xlarge', NumberOfNodes=2, Encrypted=True, MasterUsername='username', MasterUserPassword='Password01**', ClusterParameterGroupName=target_param_group_name ) print('Creating target cluster: ' + response['Cluster']['ClusterIdentifier']) # Retrieve the target cluster ARN response = redshift.describe_clusters( ClusterIdentifier=target_cluster_name ) target_arn = response['Clusters'][0]['ClusterNamespaceArn'] # Retrieve the current user's account ID response = sts.get_caller_identity() account_id = response['Account'] # Create a resource policy granting access to source database and account ID response = redshift.put_resource_policy( ResourceArn=target_arn, Policy=''' { \"Version\":\"2012-10-17\", \"Statement\":[ {\"Effect\":\"Allow\", \"Principal\":{ \"Service\":\"redshift.amazonaws.com\" }, \"Action\":[\"redshift:AuthorizeInboundIntegration\"], \"Condition\":{ \"StringEquals\":{ \"aws:SourceArn\":\"%s\"} } }, {\"Effect\":\"Allow\", \"Principal\":{ \"AWS\":\"arn:aws:iam::%s:root\"}, \"Action\":\"redshift:CreateInboundIntegration\"} ] } ''' % (source_arn, account_id) ) return(response) def wait_for_db_availability(*args): """Waits for both databases to be available""" print('Waiting for source and target to be available...') response = rds.describe_db_instances( DBInstanceIdentifier=source_db_name ) source_status = response['DBInstances'][0]['DBInstanceStatus'] source_arn = response['DBInstances'][0]['DBInstanceArn'] response = redshift.describe_clusters( ClusterIdentifier=target_cluster_name ) target_status = response['Clusters'][0]['ClusterStatus'] target_arn = response['Clusters'][0]['ClusterNamespaceArn'] # Every 60 seconds, check whether the databases are available if source_status != 'available' or target_status != 'available': time.sleep(60) response = wait_for_db_availability( source_db_name, target_cluster_name) else: print('Databases available. Ready to create zero-ETL integration.') create_integration(source_arn, target_arn) return def create_integration(source_arn, target_arn): """Creates a zero-ETL integration using the source and target databases""" response = rds.create_integration( SourceArn=source_arn, TargetArn=target_arn, IntegrationName='my-integration
' ) print('Creating integration: ' + response['IntegrationName']) def main(): """main function""" create_source_db(source_db_name, source_param_group_name) wait_for_db_availability(source_db_name, target_cluster_name) if __name__ == "__main__": main()
다음 단계
소스 RDS 데이터베이스와 Amazon Redshift 대상 데이터 웨어하우스가 있으므로, 이제 제로 ETL 통합을 생성하고 데이터를 복제할 수 있습니다. 지침은 Amazon Redshift가 구성된 Amazon RDS 제로 ETL 통합 생성 단원을 참조하세요.