本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWS自我管理資料庫來源的零 ETL 整合
AWS零 ETL 整合是一種全受管解決方案,可從多個操作和交易資料庫來源,在 Amazon Redshift、Amazon S3 和 Amazon S3 Tables 中提供交易和操作資料。使用零 ETL,您可以透過現有 AWS Database Migration Service(AWS DMS) 來源端點,將資料從 MySQL、PostgreSQL、SQL Server 和 Oracle 等自我管理來源資料庫複寫到 Amazon Redshift。自動同步可避免傳統擷取、轉換和載入 (ETL) 程序。它也可以啟用即時分析和 AI 工作負載。如需詳細資訊,請參閱《Amazon Redshift 管理指南》中的零 ETL 整合。
零 ETL 整合提供下列優點:
-
即時資料複寫 – 從 Oracle 資料庫持續資料同步至 Amazon Redshift,並將延遲降至最低。
-
消除複雜的 ETL 管道 – 不需要建置和維護自訂資料整合解決方案。
-
降低營運開銷 – 透過 AWSAPIs 自動化設定和管理。
-
簡化的資料整合架構 – 自我管理資料庫與AWS分析服務之間的無縫整合。
-
增強安全性 – 內建加密和 IAM 存取控制。
零 ETL 整合如何用於自我管理的資料庫來源
您可以使用先前為自我管理資料庫建立的現有AWS DMS端點,或建立新的端點。
-
使用 AWS Glue主控台或 CLI 建立與 Amazon Redshift 作為AWS Glue目錄中目標的零 ETL 整合。您可以在建立零 ETL 整合時指定結構描述和資料表篩選條件。
-
與整合相關的其他唯讀資源會自動在AWS DMS服務中建立。這些資源包括零 ETL 引擎,用於啟動完全載入和持續資料變更程序,以與 Amazon Redshift 目標資料庫同步資料。
-
您可以在建立整合來源、建立零 ETL 整合以及建立 Amazon Redshift 資料倉儲時,控制資料的加密。
-
整合會監控資料管道的運作狀態,並在可能的情況下從問題中復原。
-
您可以建立從相同類型的來源至單一 Amazon Redshift 資料倉儲的整合,以便跨多個應用程式衍生整體洞察。
複寫資料後,您可以使用 Amazon Redshift 的分析功能。例如,內建機器學習 (ML)、具體化視觀表、資料共用,以及直接存取多個資料存放區和資料湖。對於資料工程師,零 ETL 整合提供對時間敏感資料的存取,否則可能因複雜資料管道中的間歇性錯誤而延遲。您可以在交易資料上執行分析查詢和 ML 模型,以針對時效性事件和商業決策衍生及時的深入分析。
您可以建立 Amazon Redshift 事件通知訂閱,以便在任何零 ETL 整合發生問題時自動收到通知。若要檢視整合相關事件通知的清單,請參閱 Amazon EventBridge 的零 ETL 整合事件通知。建立訂閱最簡單的方法是使用 Amazon Simple Notification Service 主控台。如需建立和訂閱 Amazon SNS 主題的詳細資訊,請參閱《Amazon Simple Notification Service 開發人員指南》中的 Amazon SNS 入門。
設定零 ETL 整合的 IAM 許可和加密
若要建立和管理零 ETL 整合,您需要設定適當的 IAM 許可、 AWS Key Management Service(AWS KMS) 加密金鑰和資源政策。本節提供設定必要安全元件的指引。
先決條件
在建立零 ETL 整合之前,請確定您有下列項目:
-
具有適當許可的 IAM 使用者或角色,以建立和管理整合
-
自我管理資料庫的現有AWS DMS來源端點
-
做為目標的 Amazon Redshift 佈建叢集或無伺服器命名空間
-
網路組態,包括 VPC 子網路和安全群組
建立 KMS 金鑰
首先,建立客戶受管AWS KMS金鑰來加密零 ETL 整合中的資料。下列範例會建立對稱加密金鑰:
aws kms create-key \ --description "On-prem Zero-ETL Integration Encryption Key" \ --key-usage ENCRYPT_DECRYPT \ --key-spec SYMMETRIC_DEFAULT \ --regionregion
請注意Arn回應中的 KeyId和 ,因為在設定金鑰政策和建立整合時需要它們。
輸出範例:
{ "KeyMetadata": { "AWSAccountId": "account-id", "KeyId": "4e2c14f8-7abe-4aec-851a-379f6ed973a8", "Arn": "arn:aws:kms:region:account-id:key/4e2c14f8-7abe-4aec-851a-379f6ed973a8", "CreationDate": 1763155061.148, "Enabled": true, "Description": "Zero-ETL Integration Encryption Key", "KeyUsage": "ENCRYPT_DECRYPT", "KeyState": "Enabled", "Origin": "AWS_KMS", "KeyManager": "CUSTOMER", "CustomerMasterKeySpec": "SYMMETRIC_DEFAULT", "KeySpec": "SYMMETRIC_DEFAULT", "EncryptionAlgorithms": [ "SYMMETRIC_DEFAULT" ], "MultiRegion": false } }
設定 KMS 金鑰政策
建立 KMS 金鑰後,請設定金鑰政策,以允許 Amazon Redshift AWS Glue和服務使用金鑰進行加密和解密操作。金鑰政策必須將必要的許可授予服務主體,並包含將在整合建立期間使用的加密內容。
下列範例顯示零 ETL 整合的金鑰政策:
{ "Version": "2012-10-17", "Id": "key-default-1", "Statement": [ { "Sid": "Enable IAM User Permissions", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::account-id:root" }, "Action": "kms:*", "Resource": "*" }, { "Sid": "Allows the Redshift and glue service principal to add a grant to a KMS key", "Effect": "Allow", "Principal": { "Service": [ "redshift.amazonaws.com", "glue.amazonaws.com" ] }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "StringEquals": { "kms:EncryptionContext:context-key": "context-value" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Decrypt", "GenerateDataKey", "CreateGrant", "GenerateDataKeyWithoutPlaintext", "ReEncryptTo" ] } } } ] }
kms:EncryptionContext 條件必須符合您在建立整合時指定的其他加密內容。您可以使用 AWS KMS主控台或下列 CLI 命令來更新金鑰政策:
aws kms put-key-policy \ --key-idkey-id\ --policy-name default \ --policy file://kms-key-policy.json
建立 IAM 使用者並設定 AWSCLI
建立將用於管理零 ETL 整合的 IAM 使用者,並使用適當的登入資料設定 AWSCLI。
-
建立 IAM 使用者:
aws iam create-user --user-namecli-user -
為使用者建立存取金鑰:
aws iam create-access-key --user-namecli-userSecretAccessKey從輸出儲存AccessKeyId和 ,因為您需要它們來設定 AWSCLI。
建立和連接 IAM 政策
建立授予零 ETL 整合操作許可的 IAM 政策。政策應包含 AWS GlueAWS DMS、Amazon Redshift AWS KMS和 的許可。
將下列政策儲存至檔案 (例如 /tmp/zetl-policy.json):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ZetlGlueIntegrationAccess", "Effect": "Allow", "Action": [ "glue:CreateIntegration", "glue:ModifyIntegration", "glue:DeleteIntegration", "glue:DescribeIntegrations", "glue:DescribeInboundIntegrations" ], "Resource": "*" }, { "Sid": "DMSIntegrationAccess", "Effect": "Allow", "Action": [ "dms:CreateOutboundIntegration", "dms:ModifyOutboundIntegration", "dms:CreateEndpoint", "dms:DescribeEndpoints", "dms:ModifyEndpoint", "dms:DeleteEndpoint", "dms:TestConnection" ], "Resource": "*" }, { "Sid": "ZetlRedshiftFullAccess", "Effect": "Allow", "Action": [ "redshift:*", "redshift-serverless:*", "ec2:DescribeAccountAttributes", "ec2:DescribeAddresses", "ec2:DescribeAvailabilityZones", "ec2:DescribeSecurityGroups", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "ec2:DescribeInternetGateways", "sns:CreateTopic", "sns:Get*", "sns:List*", "cloudwatch:Describe*", "cloudwatch:Get*", "cloudwatch:List*", "cloudwatch:PutMetricAlarm", "cloudwatch:EnableAlarmActions", "cloudwatch:DisableAlarmActions", "tag:GetResources", "tag:UntagResources", "tag:GetTagValues", "tag:GetTagKeys", "tag:TagResources" ], "Resource": "*" }, { "Sid": "ZetlRedshiftDataAPI", "Effect": "Allow", "Action": [ "redshift-data:ExecuteStatement", "redshift-data:CancelStatement", "redshift-data:ListStatements", "redshift-data:GetStatementResult", "redshift-data:DescribeStatement", "redshift-data:ListDatabases", "redshift-data:ListSchemas", "redshift-data:ListTables", "redshift-data:DescribeTable" ], "Resource": "*" }, { "Sid": "ZetlKMSAccess", "Effect": "Allow", "Action": [ "kms:CreateKey", "kms:DescribeKey", "kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey", "kms:ListKeys", "kms:CreateAlias", "kms:ListAliases", "kms:CreateGrant" ], "Resource": "*" }, { "Sid": "ZetlSecretsManagerAccess", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:PutSecretValue", "secretsmanager:CreateSecret", "secretsmanager:UpdateSecret", "secretsmanager:DeleteSecret", "secretsmanager:DescribeSecret", "secretsmanager:ListSecrets", "secretsmanager:GetResourcePolicy", "secretsmanager:PutResourcePolicy", "secretsmanager:ValidateResourcePolicy" ], "Resource": "*" } ] }
建立政策並將其連接至 IAM 使用者:
aws iam create-policy \ --policy-name ZetlCustomPolicy \ --policy-document file:///tmp/zetl-policy.json aws iam attach-user-policy \ --policy-arn arn:aws:iam::account-id:policy/ZetlCustomPolicy \ --user-namecli-user
設定 CLI AWS設定檔
使用在先前步驟中建立的使用者登入資料來設定 AWSCLI 設定檔:
aws configure set aws_access_key_idACCESS_KEY_ID--profilecli-useraws configure set aws_secret_access_keySECRET_ACCESS_KEY--profilecli-useraws configure set regionregion--profilecli-useraws configure set output json --profilecli-user
測試設定檔組態:
aws sts get-caller-identity --profilecli-user
輸出應會顯示使用者帳戶 ID、使用者 ID 和 ARN,確認設定檔已正確設定。
建立 Redshift 資源政策
建立 Amazon Redshift 資源政策,以授權AWS DMS來源端點建立與您的 Amazon Redshift 命名空間的傳入整合。此政策會連接到 Amazon Redshift 命名空間,並控制哪些來源可以將資料複寫到其中。
下列範例示範如何為 Amazon Redshift 命名空間建立資源政策:
aws redshift put-resource-policy \ --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": ["redshift.amazonaws.com"] }, "Action": ["redshift:AuthorizeInboundIntegration"], "Condition": { "StringEquals": { "aws:SourceArn": "arn:aws:dms:region:account-id:endpoint:endpoint-id" } } }, { "Effect": "Allow", "Principal": { "AWS": "account-id" }, "Action": [ "redshift:CreateInboundIntegration", "redshift:ModifyInboundIntegration" ] } ] }' \ --resource-arn arn:aws:redshift:region:account-id:namespace:namespace-id\ --regionregion
取代下列預留位置:
-
region
– 資源所在的AWS區域 -
account-id– AWS您的帳戶 ID -
endpoint-id– AWS DMS來源端點的 ID -
namespace-id– Amazon Redshift 命名空間的 ID
範例:建立與加密的零 ETL 整合
設定必要的許可和加密金鑰之後,您可以使用 AWS GlueAPI 建立零 ETL 整合。下列範例示範如何使用 KMS 加密,從 MySQL 來源建立與 Amazon Redshift 目標的整合:
aws glue create-integration \ --integration-namemysql-onprem-integration\ --source-arn arn:aws:dms:region:account-id:endpoint:source-endpoint-id\ --target-arn arn:aws:redshift:region:account-id:namespace:namespace-id\ --description "MySQL to Redshift integration" \ --integration-config '{"SourceProperties":{"SubnetIds":"subnet-id1,subnet-id2,subnet-id3","VpcSecurityGroupIds":"sg-id"}}' \ --data-filter "include:mysql.*" \ --kms-key-id arn:aws:kms:region:account-id:key/key-id\ --additional-encryption-context '{"context-key": "context-value"}' \ --profilecli-user\ --regionregion
命令包含下列金鑰參數:
-
--integration-name– 整合的唯一名稱 -
--source-arn– AWS DMS來源端點的 ARN -
--target-arn– Amazon Redshift 命名空間的 ARN -
--integration-config– 網路組態,包括子網路 IDs和安全群組 -
--data-filter– 指定要複寫的結構描述和資料表 -
--kms-key-id– 加密AWS KMS金鑰的 ARN -
--additional-encryption-context– 加密內容金鑰/值對必須符合 KMS 金鑰政策 (例如{")context-key": "context-value"} -
--profile– 要使用的 AWSCLI 設定檔 (先前建立的 cli-user 設定檔)
成功建立後,命令會傳回整合詳細資訊,包括整合 ARN、狀態和組態參數。輸出範例:
{ "SourceArn": "arn:aws:dms:region:account-id:endpoint:endpoint-id", "TargetArn": "arn:aws:redshift:region:account-id:namespace:namespace-id", "IntegrationName": "mysql-onprem-integration", "IntegrationArn": "arn:aws:glue:region:account-id:integration:integration-id", "KmsKeyId": "arn:aws:kms:region:account-id:key/key-id", "AdditionalEncryptionContext": { "context-key": "context-value" }, "Status": "CREATED", "CreateTime": 1763234086.001, "DataFilter": "include: mysql.*", "IntegrationConfig": { "SourceProperties": { "SubnetIds": "subnet-id1,subnet-id2,subnet-id3", "VpcSecurityGroupIds": "sg-id" } } }
安全最佳實務
設定零 ETL 整合時,請遵循下列安全最佳實務:
-
使用最低權限存取 – 僅授予建立和管理整合所需的最低許可。盡可能考慮使用資源層級許可。
-
啟用加密 – 一律使用客戶受管AWS KMS金鑰來加密整合資料。指定加密內容以提供額外的安全性。
-
定期輪換憑證 – 如果使用 IAM 使用者存取金鑰,請定期輪換憑證。請考慮改為使用具有臨時登入資料的 IAM 角色。
-
監控存取 – AWS CloudTrail用於監控與整合建立和管理相關的 API 呼叫。
-
限制網路存取 – 設定 VPC 安全群組,將網路存取限制為僅必要資源。
-
使用資源政策 – 實作 Amazon Redshift 資源政策,以控制哪些來源可以建立與資料倉儲的整合。
-
標籤資源 – 將標籤套用至整合和相關資源,以獲得更好的組織和成本追蹤。