기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS글루와 Amazon Redshift 간 데이터 이동
AWSGlue ETL 작업 스크립트에서 Amazon Redshift Spark 커넥터 사용
ETL 스크립트에서 Amazon Redshift Spark 커넥터를 사용하는 작업은 DynamicFrame 클래스를 통해 수행됩니다. Spark 커넥터를 사용하려면 Spark 커넥터를 만들거나 쓸 때 특정 구성 옵션을 설정해야DynamicFrame
합니다.
AWSGlue Spark 커넥터에서 Amazon Redshift 사용하는 데 필요한 키 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
키 | 설명 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url |
AWSGlue Spark 커넥터가 연결하는 데 사용하는 아마존 레드시프트 지원 JDBC의 URL입니다. Amazon Redshift 콘솔 디스플레이에서 일반 정보 패널의 Amazon Redshift 워크그룹 구성을 위해 이 URL을 복사할 수 있으며, 이 URL은 항상 양식에 있어야 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dbtable |
데이터 원본을 사용할 Amazon Redshift 테이블의 이름입니다. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
redshiftTmpDir [선택 사항] |
작업 실행 중에AWS Glue Spark 커넥터에서 사용하는 임시 데이터를 저장할 디렉터리입니다. 기본값은 Amazon Redshift 작업 을 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aws_iam_role |
Amazon Redshift 리소스에 연결할 때 사용할 IAM 역할 (ARN에서 지정). AWS계정 ID와 IAM 역할 이름을 사용하여 이 ARN을 구성하는 방법은 이 주제의 예를 읽어보세요. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
사용자 |
Amazon Redshift 데이터베이스에 연결하는 데 사용할 사용자 이름과 암호입니다. 커넥터에서 사용하는 다른 리소스에 액세스하려면 여전히 연결된 IAM 역할이 있어야 합니다. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
password |
참고
에서 Amazon Redshift 테이블에 쓸 때 스키마 (열 이름 및 해당 데이터 유형) 와 Amazon Redshift 테이블DynamicFrame
스키마가 일치하지 않는 경우 추가 열이 추가될 수 있습니다.DynamicFrame
이 동작은
DynamicFrame
객체가 Amazon Redshift Redshift에 다양한 데이터 유형을 유연하게 쓸 수 있도록 의도된 것입니다.
Spark 커넥터에서 지원되는 Amazon Redshift 데이터 형식 에 대한 자세한 내용은 ApacheAWS Spark용 Amazon Redshift 통합 을 참조하세요.
예제 코드 조각
다음 예제 스니펫은 (데이터 로드) 및create_dynamic_frame_from_options
(데이터 쓰기) 중 하나를 사용하여 Amazon Redshift Redshift에 연결된DynamicFrame
객체를 구성, 로드 및write_dynamic_frame_from_jdbc_conf
쓰는 방법을 보여줍니다. JDBC 엔드포인트의 연결 속성에 대한 정보는 에서 확인할 수AWS Glue JDBC 연결 속성 있습니다.
예 Amazon Redshift Redshift를 ETL 작업을 위한 데이터 소스로 구성 및 사용
다음 스니펫은 Amazon Redshift Redshift에서AWS Glue ETL 스크립트의 데이터를 로드하거나 저장하는 데 사용할 수 있습니다. Amazon Redshift 데이터 스토어에 연결하려면 설명대로 스니펫에서 주석 처리된 값을 바꾸십시오.
redshift_connection_options = { # JDBC URL to Amazon Redshift Workgroup, available from the Amazon Redshift console "url": "jdbc:redshift://
host:port
/redshift-database-name
", # `table-name`: Amazon Redshift table to load data from, in the JDBC schema.table-name or table-name format "dbtable": "table-name
", "redshiftTmpDir": args["TempDir"], # `account-id`: Your AWS account ID # `role-name`: Name of the IAM role configured for COPY, UNLOAD, and CREATE LIBRARY permissions on the table "aws_iam_role": "arn:aws:iam::account-id
:role/role-name
" } # In the following, glueContext is your Glue Context for the ETL job. # To load from Amazon Redshift load_rs_dynamicframe = glueContext.create_dynamic_frame_from_options("redshift", redshift_connection_options) # To write data to Amazon Redshift glueContext.write_dynamic_frame_from_jdbc_conf( # `frame-to-write`: The `DynamicFrame` object to write to Amazon Redshift frame =frame-to-write
, # `connection-name`: The catalog connection to use. catalog_connection =connection-name
, connection_options = redshift_connection_options, redshift_tmp_dir = args["TempDir"] )