當 Redshift 叢集作為 DMS 中的 目标端 時, IAM Role的這一步經常會被忽略。
導緻在執行DMS任務時,發現 表已經被建立在目标端了,但是資料确沒過去。
檢視日志,隻有一條
Warning,Table 'public'.'tablename' (subtask 1 thread 1) is suspended (replicationtask.c:2471)。
再無其他資訊。這時我們束手無策。傳回頭去查文檔,發現沒什麼問題啊。同賬号,同區域,網絡都通,Role建立了,沒有LOB。
AWS DMS 使用 Amazon S3 存儲桶将資料傳輸到 Amazon Redshift 資料庫。 這樣就像在 Redshift中使用S3外部表一樣。需要關聯Role。
對于 AWS DMS 建立存儲桶,DMS 控制台使用 IAM 角色 dms-access-for-endpoint。
那麼這個 IAM 角色 dms-access-for-endpoint 尤為重要。
下面說一下最容易忽視的一點: IAM 角色 dms-access-for-endpoint。
如果這個Role 之前沒有手工建立的話, DMS會自動建立。自動建立的 Role 是有問題的。 他隻關聯了DMS service。類似于
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"PrincipalGroup": {
"AWS": "svc:dms.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
由于服務中沒涉及到 Redshift,是以當Redshift 想要綁定 Role 的時候就會發現有問題。 Redshift 就會報錯
error: User arn:aws-cn:redshift:cn-northwest-1:000000000000:dbuser:chen-test/dbadmin is not authorized to assume IAM Role arn:aws-cn:iam::000000000000:role/dms-access-for-endpoint
(Debug時才能看到)
是以我們實際需要這個Role是關聯兩個服務的。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"Service": "dms.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Sid": "2",
"Effect": "Allow",
"Principal": {
"Service": "redshift.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
是以就要重新設定這個 Role。
- 檢查 Redshift 叢集中是否關聯了 dms-access-for-endpoint , 如果有,先删除。
- 進入 IAM 控制台, 将目前 dms-access-for-endpoint 删除。
- 按照文檔[2]中 《建立 dms-access-for-endpoint IAM 角色以用于将 Amazon Redshift 作為目标資料庫》 步驟,進行配置。
- 将 dms-access-for-endpoint 關聯至 Redshift 叢集。
之後重新執行 DMS 任務,就可以了。
如何Debug。參照文檔[3]
參考文檔:
[1] https://docs.amazonaws.cn/dms/latest/userguide/CHAP_Target.Redshift.html#CHAP_Target.Redshift.Prerequisites
[2] https://docs.amazonaws.cn/dms/latest/userguide/CHAP_Security.html#CHAP_Security.APIRole
[3] https://amazonaws-china.com/cn/premiumsupport/knowledge-center/dms-enable-debug-logging/?nc1=h_ls