IAM 資料庫身分驗證的疑難排解 - Amazon Aurora

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

IAM 資料庫身分驗證的疑難排解

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

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

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

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

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

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

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

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 資料庫身分驗證時可能會遇到下列問題。使用資料表中的修補步驟來解決問題:

錯誤 指標 原因 解決方案

[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 資料庫身分驗證授權資料庫連線時發生內部錯誤。

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