使用 Amazon Redshift 設定 Oracle Database@AWS integrations - Oracle Database@AWS

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Amazon Redshift 設定 Oracle Database@AWS integrations

若要設定 Oracle 資料庫與 Amazon Redshift 之間的零 ETL 整合,請完成下列步驟:

  1. 在 ODB 網路上啟用零 ETL。

  2. 設定 Oracle 資料庫先決條件。

  3. 設定 AWS Secrets Manager 和 AWS Key Management Service。

  4. 設定 IAM 許可。

  5. 設定 Amazon Redshift 資源政策。

  6. 建立零 ETL 整合。

  7. 在 Amazon Redshift 中建立目標資料庫。

步驟 1:為您的 ODB 網路啟用零 ETL

您可以為與來源 VM 叢集相關聯的 ODB 網路啟用零 ETL 整合。預設會停用此整合。

啟用零 ETL 整合
  1. 在 https://https://console.aws.amazon.com/odb/ 開啟 Oracle Database@AWS console。

  2. 在導覽窗格中,選擇 ODB 網路

  3. 選取您要啟用零 ETL 整合的 ODB 網路。

  4. 選擇 Modify (修改)。

  5. 選取零 ETL

  6. 選擇繼續,然後選擇修改

若要啟用零 ETL 整合,請使用 update-odb-network命令搭配 --zero-etl-access 參數:

aws odb update-odb-network \ --odb-network-id odb-network-id \ --zero-etl-access ENABLED

若要為與來源 VM 叢集相關聯的 ODB 網路啟用零 ETL 整合,請使用 update-odb-network命令。此命令會設定零 ETL 整合所需的網路基礎設施。

aws odb update-odb-network \ --odb-network-id your-odb-network-id \ --zero-etl-access ENABLED

步驟 2:設定 Oracle 資料庫

完成 Oracle 資料庫組態,如先決條件中所述:

  • 建立複寫使用者並授予必要的許可。

  • 啟用封存的重做日誌。

  • 設定 SSL (僅限 Oracle Exadata)。

  • 如果適用,請設定 ASM 使用者 (僅限 Oracle Exadata)。

步驟 3:設定 AWS Secrets Manager 和 AWS Key Management Service

建立客戶受管金鑰 (CMK) 並存放您的資料庫登入資料。

  1. 使用 create-key命令在 AWS Key Management Service 中建立 CMK。

    aws kms create-key \ --description "ODB Zero-ETL Integration Key" \ --key-usage ENCRYPT_DECRYPT \ --key-spec SYMMETRIC_DEFAULT
  2. 將您的資料庫登入資料儲存在 AWS Secrets Manager 中。

    aws secretsmanager create-secret \ --name "ODBZeroETLCredentials" \ --description "Credentials for Oracle Database@AWS Zero-ETL integration" \ --kms-key-id your-cmk-key-arn \ --secret-string file://secret-content.json
  3. 將資源政策連接至秘密,以允許 Oracle Database@AWS access。

    aws secretsmanager put-resource-policy \ --secret-id "ODBZeroETLCredentials" \ --resource-policy file://secret-resource-policy.json

    在上述命令中, secret-resource-policy.json包含下列 JSON。

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "zetl.odb.amazonaws.com" }, "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "*" } ] }
  4. 將資源政策連接至 CMK。CMK 資源政策必須包含 Oracle Database@AWS service 主體和 Amazon Redshift 服務主體的許可,以支援加密的零 ETL 整合。

    aws kms put-key-policy \ --key-id your-cmk-key-arn \ --policy-name default \ --policy file://cmk-resource-policy.json

    cmk-resource-policy.json 檔案應包含下列政策陳述式。第一個陳述式允許 Oracle Database@AWS service 存取,第二個陳述式允許 Amazon Redshift 在 KMS 金鑰上為加密的資料操作建立授予。

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "Allow ODB service access", "Effect": "Allow", "Principal": { "Service": "zetl.odb.amazonaws.com" }, "Action": [ "kms:Decrypt", "kms:GenerateDataKey", "kms:CreateGrant" ], "Resource": "*" }, { "Sid": "Allows the Redshift service principal to add a grant to a KMS key", "Effect": "Allow", "Principal": { "Service": "redshift.amazonaws.com" }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "StringEquals": { "kms:EncryptionContext:{context-key}": "{context-value}" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Decrypt", "GenerateDataKey", "CreateGrant" ] } } } ] }

步驟 4:設定 IAM 許可

建立並連接允許零 ETL 整合操作的 IAM 政策。

aws iam create-policy \ --policy-name "ODBZeroETLIntegrationPolicy" \ --policy-document file://odb-zetl-iam-policy.json aws iam attach-user-policy \ --user-name your-iam-username \ --policy-arn policy-arn

下列政策會授予必要的許可。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Sid": "ODBGlueIntegrationAccess", "Effect": "Allow", "Action": [ "glue:CreateIntegration", "glue:ModifyIntegration", "glue:DeleteIntegration", "glue:DescribeIntegrations", "glue:DescribeInboundIntegrations" ], "Resource": "*" }, { "Sid": "ODBZetlOperations", "Effect": "Allow", "Action": "odb:CreateOutboundIntegration", "Resource": "*" }, { "Sid": "ODBRedshiftFullAccess", "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": "ODBRedshiftDataAPI", "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": "ODBKMSAccess", "Effect": "Allow", "Action": [ "kms:CreateKey", "kms:DescribeKey", "kms:Encrypt", "kms:Decrypt", "kms:GenerateDataKey", "kms:ListKeys", "kms:CreateAlias", "kms:ListAliases" ], "Resource": "*" }, { "Sid": "ODBSecretsManagerAccess", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:PutSecretValue", "secretsmanager:CreateSecret", "secretsmanager:UpdateSecret", "secretsmanager:DeleteSecret", "secretsmanager:DescribeSecret", "secretsmanager:ListSecrets", "secretsmanager:GetResourcePolicy", "secretsmanager:PutResourcePolicy", "secretsmanager:ValidateResourcePolicy" ], "Resource": "*" } ] }

步驟 5:設定 Amazon Redshift 資源政策

在 Amazon Redshift 叢集上設定資源政策,以授權傳入整合。

aws redshift put-resource-policy \ --no-verify-ssl \ --resource-arn "your-redshift-cluster-arn" \ --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "redshift.amazonaws.com" }, "Action": [ "redshift:AuthorizeInboundIntegration" ], "Condition": { "StringEquals": { "aws:SourceArn": "your-vm-cluster-arn" } } }, { "Effect": "Allow", "Principal": { "AWS": "your-account-id" }, "Action": [ "redshift:CreateInboundIntegration" ] } ] }' \ --region us-west-2
提示

或者,您可以使用 主控台中的 AWS 「為我修正」選項。此選項會自動設定所需的 Amazon Redshift 政策,而不需要手動執行。

步驟 6:使用 建立零 ETL 整合 AWS Glue

使用 命令建立零 ETL AWS Glue create-integration整合。在此命令中,您可以指定來源 VM 叢集和目標 Amazon Redshift 命名空間。

下列範例會建立與名為 在 Exadata VM 叢集中pdb1執行之 PDB 的整合。您也可以在來源 ARN cloud-autonomous-vm-cluster中將 取代cloud-vm-cluster為 ,以建立自治 VM 叢集。指定 KMS 金鑰是選用的。如果您指定金鑰,它可以與您在 中建立的金鑰不同步驟 3:設定 AWS Secrets Manager 和 AWS Key Management Service

aws glue create-integration \ --integration-name "MyODBZeroETLIntegration" \ --source-arn "arn:aws:odb:region:account:cloud-vm-cluster/cluster-id" \ --target-arn "arn:aws:redshift:region:account:namespace/namespace-id" \ --data-filter "include: pdb1.*.*" \ --integration-config '{ "RefreshInterval": "10", "IntegrationMode": "DEFAULT", "SourcePropertiesMap": { "secret-arn": "arn:aws:secretsmanager:region:account:secret:secret-name" } }' \ --description "Zero-ETL integration for Oracle to Amazon Redshift" \ --kms-key-id "arn:aws:kms:region:account:key/key-id"

命令會傳回整合 ARN,並將狀態設定為 creating。您可以使用 describe-integrations命令監控整合狀態。

aws glue describe-integrations \ --integration-identifier integration-id
重要

每個整合僅支援一個 PDB。資料篩選條件必須指定單一 PDB,例如 include: pdb1.*.*。來源必須位於建立整合的相同 AWS 區域和帳戶中。

步驟 7:在 Amazon Redshift 中建立目標資料庫

整合處於作用中狀態後,請在 Amazon Redshift 叢集中建立目標資料庫。

-- Connect to your Amazon Redshift cluster psql -h your-redshift-endpoint -U username -d database -- Create database from integration CREATE DATABASE target_database_name FROM INTEGRATION 'integration-id' DATABASE "source_pdb_name";

建立目標資料庫之後,您可以查詢複寫的資料。

-- List databases to verify creation \l -- Connect to the new database \c target_database_name -- List tables to see replicated data \dt

驗證零 ETL 整合

透過在 中查詢整合狀態, AWS Glue 並確保您的 Oracle 變更正在複寫至 Amazon Redshift 來驗證整合是否正常運作。

驗證您的零 ETL 整合是否正常運作
  1. 檢查整合狀態。

    aws glue describe-integrations \ --integration-identifier integration-id

    狀態應為 ACTIVEREPLICATING

  2. 在 Oracle 資料庫中進行變更並檢查資料複寫是否出現在 Amazon Redshift 中,以驗證資料複寫。

  3. 在 Amazon CloudWatch 中監控複寫指標 (如果可用)。