IAM 資料庫身分驗證的故障診斷 - Amazon Aurora

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

IAM 資料庫身分驗證的故障診斷

您可以在下面找到一些常見 IAM 資料庫身分驗證問題的疑難排解想法,以及 CloudWatch 日誌和 IAM 資料庫身分驗證指標的相關資訊。

將 IAM 資料庫身分驗證錯誤日誌匯出至 CloudWatch Logs

IAM 資料庫身分驗證錯誤日誌存放在資料庫主機上,您可以匯出 CloudWatch Logs 帳戶的這些日誌。使用此頁面中的日誌和修復方法對 IAM 資料庫身分驗證問題進行疑難排解。

您可以從 主控台 AWS CLI和 RDS API 啟用日誌匯出至 CloudWatch Logs。如需主控台說明,請參閱 將資料庫日誌發佈至 Amazon CloudWatch Logs

若要在從 建立資料庫叢集時,將您的 IAM 資料庫身分驗證錯誤日誌匯出至 CloudWatch Logs AWS CLI,請使用下列命令:

aws rds create-db-cluster --db-cluster-identifier mydbinstance \ --region us-east-1 \ --engine postgres \ --engine-version 16 \ --master-username master \ --master-user-password password \ --publicly-accessible \ --enable-iam-database-authentication \ --enable-cloudwatch-logs-exports=iam-db-auth-error

若要在從 修改資料庫叢集時,將您的 IAM 資料庫身分驗證錯誤日誌匯出至 CloudWatch Logs AWS CLI,請使用下列命令:

aws rds modify-db-cluster --db-cluster-identifier mydbcluster \ --region us-east-1 \ --cloudwatch-logs-export-configuration '{"EnableLogTypes":["iam-db-auth-error"]}'

若要驗證資料庫叢集是否正在將 IAM 資料庫身分驗證日誌匯出至 CloudWatch Logs,請檢查 EnabledCloudwatchLogsExports 參數是否在 describe-db-instances 命令的輸出iam-db-auth-error中設定為 。

aws rds describe-db-cluster --region us-east-1 --db-cluster-identifier mydbcluster ... "EnabledCloudwatchLogsExports": [ "iam-db-auth-error" ], ...

IAM 資料庫身分驗證 CloudWatch 指標

Amazon Aurora 為您的 Amazon CloudWatch 帳戶提供近乎即時的 IAM 資料庫身分驗證指標。下表列出使用 CloudWatch 可用的 IAM 資料庫身分驗證指標:

指標 描述

IamDbAuthConnectionRequests

使用 IAM 資料庫身分驗證提出的連線請求總數。

IamDbAuthConnectionSuccess

IAM 資料庫身分驗證請求成功總數。

IamDbAuthConnectionFailure

失敗的 IAM 資料庫身分驗證請求總數。

IamDbAuthConnectionFailureInvalidToken

由於字符無效而失敗的 IAM 資料庫身分驗證請求總數。

IamDbAuthConnectionFailureInsufficientPermissions

由於政策或許可不正確而失敗的 IAM 資料庫身分驗證請求總數。

IamDbAuthConnectionFailureThrottling

由於 IAM 資料庫身分驗證限流而失敗的 IAM 資料庫身分驗證請求總數。

IamDbAuthConnectionFailureServerError

IAM 資料庫身分驗證功能中因內部伺服器錯誤而失敗的 IAM 資料庫身分驗證請求總數。

常見問題與解決方案

使用 IAM 資料庫截斷時,您可能會遇到下列問題。使用表格中的修復步驟來解決問題:

錯誤 Metric(s) 原因 解決方案

[ERROR] Failed to authenticate the connection request for user db_user because the provided token is malformed or otherwise invalid. (Status Code: 400, Error Code: InvalidToken)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInvalidToken

連線請求中的 IAM 資料庫驗證字符不是有效的 SigV4a 字符,或者格式不正確。

檢查應用程式中的字符產生策略。在某些情況下,請確定您使用有效的格式傳遞權杖。截斷字符 (或不正確的字串格式) 會使字符無效。

[ERROR] Failed to authenticate the connection request for user db_user because the token age is longer than 15 minutes. (Status Code: 400, Error Code:ExpiredToken)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInvalidToken

IAM 資料庫身分驗證字符已過期。字符的有效時間為 15 分鐘。

檢查您的權杖快取和/或權杖在應用程式中重複使用邏輯。您不應重複使用超過 15 分鐘的字符。

[ERROR] Failed to authorize the connection request for user db_user because the IAM policy assumed by the caller 'arn:aws:sts::123456789012:assumed-role/ <RoleName>/ <RoleSession>' is not authorized to perform `rds-db:connect` on the DB instance. (Status Code: 403, Error Code:NotAuthorized)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureInsufficientPermissions

此錯誤可能由下列原因造成:

  • 應用程式擔任的 IAM 政策不會授權 rds-db:connect動作。

  • 您假設 db_user 連線到資料庫的角色/政策不正確。

  • 您假設 db_user 的政策正確,但您未連線到正確的資料庫。

驗證您在應用程式中擔任的 IAM 角色和/或政策。請確定您採用與 相同的政策來產生權杖,以連接至 資料庫。

[ERROR] Failed to authorize the connection request for user db_user due to IAM DB authentication throttling. (Status Code: 429, Error Code: ThrottlingException)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureThrottling

您在短時間內對資料庫提出太多連線請求。IAM 資料庫身分驗證限流限制為每秒 200 個連線。

降低使用 IAM 身分驗證建立新連線的速率。請考慮使用 RDS Proxy 實作連線集區,以便在應用程式中重複使用已建立的連線。

[ERROR] Failed to authorize the connection request for user db_user due to an internal IAM DB authentication error. (Status Code: 500, Error Code: InternalError)

IamDbAuthConnectionFailure

IamDbAuthConnectionFailureThrottling

使用 IAM 資料庫身分驗證授權資料庫 conneciton 時發生內部錯誤。

請聯絡 https://https://aws.amazon.com/premiumsupport/ 以調查問題。