View a markdown version of this page

監控串流 - Amazon Aurora DSQL

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

監控串流

重要

此功能以 AWS 預覽版形式提供,可能會有所變更。如需詳細資訊,請參閱 AWS 服務條款中的第 2 節 Beta 版和預覽版。若要進一步了解 CDC 串流的定價,請參閱 Aurora DSQL 定價頁面

在一般可用性之前,我們會將新的操作類型 ("op": "u" 用於更新) 新增至串流承載。為了確保您的應用程式在不修改的情況下處理這些變更,請套用after承載,將任何無法辨識op的值視為 upsert。如需詳細資訊,請參閱 了解 CDC 記錄

當 Aurora DSQL 遇到交付 CDC 記錄的錯誤時,串流會轉換為 IMPAIRED 狀態。受損的串流會繼續處理和交付其他記錄 - Aurora DSQL 只會重試失敗的記錄。Aurora DSQL 會測量最舊未交付記錄的複寫延遲,而且延遲會成長,直到您解決問題為止。Aurora DSQL 會在內部保留未交付的變更一週。

如果您在此視窗中解決基礎問題,下一次重試會成功,錯誤狀態會清除,而串流會轉換回 ACTIVE。修正外部問題 (IAM 政策、 AWS KMS 金鑰、Amazon Kinesis 容量等),Aurora DSQL 會自動重試。

如果複寫延遲超過失敗閾值,串流會轉換為 FAILED

重要

失敗的串流無法復原。您必須刪除失敗的串流,並建立新的串流。

串流生命週期

串流會在其生命週期內轉換下列狀態:

  • CREATING – Aurora DSQL 正在設定串流。Aurora DSQL 尚未交付 CDC 記錄。

  • ACTIVE – 串流可運作,並將 CDC 記錄交付至目標。

  • IMPAIRED – 串流遇到需要您動作的問題。Aurora DSQL 會以指數退避重試失敗的記錄,但其他記錄可以繼續交付。Aurora DSQL 會測量最舊未交付記錄的複寫延遲,而且延遲會成長,直到您解決問題為止。Aurora DSQL 會在內部緩衝未交付的變更一週。請參閱 錯誤碼參考

  • FAILED – 串流遇到持久性錯誤,不再提供 CDC 記錄。失敗的串流無法復原,您必須將其刪除。如需導致串流進入此狀態的條件,錯誤碼參考請參閱 。

  • DELETING – Aurora DSQL 正在移除串流資源。

  • DELETED – Aurora DSQL 已刪除串流。刪除完成後, 會GetStream傳回 ResourceNotFoundException

隨時呼叫 GetStream以檢視串流狀態。當串流為 IMPAIRED或 時FAILED,回應會包含具有錯誤碼和時間戳記的statusReason物件。如需GetStream回應欄位的詳細資訊,請參閱《Amazon Aurora DSQL API 參考》中的 GetStream

對受損或失敗的串流進行故障診斷

當 CDC 串流受損或失敗時,請遵循下列步驟。如果串流是 FAILED,則無法復原,請刪除串流、解決基礎問題,然後建立新的串流。

  1. 取得串流狀態。呼叫 GetStream並驗證 status 欄位。如果狀態為 ACTIVE,表示串流運作狀態良好。

    aws dsql get-stream \ --cluster-identifier cluster-id \ --stream-identifier stream-id \ --region region
  2. 讀取錯誤代碼。如果狀態為 IMPAIREDFAILED,則回應會包含statusReason物件。error 欄位包含錯誤代碼。

    { "status": "IMPAIRED", "statusReason": { "error": "KINESIS_THROUGHPUT_EXCEEDED", "updatedAt": "2025-01-15T14:30:00Z" } }
  3. 遵循修復。如果串流是 IMPAIRED,請查看下表中的錯誤代碼,並套用建議的修正。在您解決基礎問題後,Aurora DSQL 會自動重試。如果串流是 FAILED,請將其刪除、解決問題,然後建立新的串流。

錯誤碼參考

下表說明每個錯誤代碼、其原因、串流是否可以復原,以及解決它的步驟。

錯誤碼 原因 可復原? 如何解決
KINESIS_THROUGHPUT_EXCEEDED Your Kinesis data stream exceeded its throughput limit, or AWS KMS throttled encryption operations on the Kinesis data stream, and the replication lag has grown. Yes Increase the number of shards on your Kinesis data stream, or switch to on-demand capacity mode. If the Kinesis data stream uses an AWS KMS customer managed key, verify that the key's request quota is large enough. After you increase capacity, Aurora DSQL retries automatically.
KINESIS_STREAM_NOT_FOUND The target Kinesis data stream no longer exists. No The stream transitions directly to 失敗. Delete the CDC stream and create a new one pointing to a valid Kinesis data stream.
ROLE_ACCESS_DENIED Aurora DSQL can't assume the IAM role specified in the target definition. The AWS STS AssumeRole call returned AccessDenied. Yes Verify the role's trust policy allows the Aurora DSQL service principal (dsql.amazonaws.com) to assume it. Verify the aws:SourceAccount and aws:SourceArn conditions match your cluster. For details, see 服務角色信任政策. After you fix the trust policy, Aurora DSQL retries automatically.
KINESIS_ACCESS_DENIED The assumed role doesn't have permission to write to the Kinesis data stream. Kinesis returned AccessDeniedException. Yes Add kinesis:PutRecord and kinesis:PutRecords permissions to the role's policy for the target Kinesis data stream Amazon Resource Name (ARN). After you fix the policy, Aurora DSQL retries automatically.
KINESIS_KMS_ACCESS_DENIED The assumed role doesn't have permission to use the AWS KMS key that encrypts the Kinesis data stream. This error covers AWS KMS access denial and invalid key states. Yes Verify the role has kms:產生資料金鑰 permission on the AWS KMS key that the Kinesis data stream uses. Also verify that the AWS KMS key is in an enabled and valid state. This key is the encryption key on the Kinesis data stream, not the cluster's AWS KMS key. For details, see 服務角色許可政策. After you fix the permissions or key state, Aurora DSQL retries automatically.
KINESIS_OVERSIZE_RECORD A CDC record exceeded the maximum record size configured on the Kinesis data stream. Yes Increase MaxRecordSizeInKiB on the Kinesis data stream to 10240 (10 MiB). You can update this setting on an existing Kinesis data stream without deleting it. After you increase the limit, Aurora DSQL retries the oversized record automatically and the stream transitions back to ACTIVE.
CLUSTER_CMK_INACCESSIBLE The AWS KMS customer managed key that encrypts the Aurora DSQL cluster is inaccessible. Yes Verify the AWS KMS key policy and key state. Re-enable or restore access to the key. After the key becomes accessible again, the stream transitions back to ACTIVE.

上表列出每個StreamFailureErrorCode值。如需statusReason回應欄位的詳細資訊,請參閱《Amazon Aurora DSQL API 參考》中的 GetStream

復原受損的串流

大多數錯誤會先將串流轉換為 IMPAIRED。受損的串流會繼續處理其他記錄,並自動重試失敗的記錄。FAILED 串流無法復原 - 您必須將其刪除並建立新的串流。

  • 對於可復原的錯誤:修正外部問題 (IAM 政策、 AWS KMS 金鑰、Kinesis 容量或 Kinesis 記錄大小限制)。下一次成功重試會清除錯誤狀態,並將串流轉換回 ACTIVE

  • 對於 KINESIS_STREAM_NOT_FOUND串流會直接轉換為 FAILED。刪除失敗的串流,並建立新的串流,指向有效的 Kinesis 資料串流。

對於所有其他錯誤代碼,如果複寫延遲超過故障閾值,再解決問題,則串流會從 轉換為 IMPAIRED FAILED。失敗的串流無法轉換回 ACTIVE。刪除失敗的串流、解決基礎問題,並建立新的串流。

監控串流運作狀態

使用 CloudWatch 指標和 GetStream API 來監控串流運作狀態。CloudWatch 指標提供 CDC 管道效能的持續可見性,並在串流受損或失敗時GetStream提供特定的錯誤代碼。

如需 CDC 指標的完整清單,包括 IsImpairedPublishedBytesBehindSourceLagPublishedRecords,請參閱 CDC 串流的 CloudWatch 指標。如需GetStream回應欄位的詳細資訊,請參閱《Amazon Aurora DSQL API 參考》中的 GetStream

CDC 串流的 CloudWatch 指標

使用下列 CloudWatch 指標來監控每個 CDC 串流的運作狀態和輸送量。Aurora DSQL 會在AWS/AuroraDSQL具有維度 ClusterId和 的命名空間中發佈這些指標StreamId。最後一個指標是AWS/Kinesis命名空間中測量下游讀取延遲的標準 Amazon Kinesis 指標。

注意

Aurora DSQL 也會在 AWS/AuroraDSQL 命名空間中發佈 BytesStreamedStreamDPU指標,以用於用量和帳單追蹤。如需說明,請參閱 CDC 串流指標

指標名稱 有用的統計資料 說明
IsImpaired Maximum Indicates whether the stream is impaired. The value is 1 when the stream is in the 受損 state, and 0 when the stream is healthy. Aurora DSQL emits this metric continuously for each active or impaired stream. Use this metric to create a CloudWatch alarm that notifies you when a stream becomes impaired.
BehindSourceLag Average The delay, in milliseconds, between when a transaction commits in Aurora DSQL and when the CDC system processes the resulting record. A rising value indicates that the CDC pipeline is falling behind the write workload.
PublishedBytes Sum The total bytes of CDC records that Aurora DSQL wrote to the target during the period. Use this metric together with your Kinesis shard count to determine whether you've provisioned enough write capacity.
PublishedRecords Sum The total number of CDC records that Aurora DSQL wrote to the target during the period. Each committed row change produces one record.
GetRecords.IteratorAgeMilliseconds (AWS/Kinesis) Average A standard Kinesis metric that reports the age of the last record read from the Kinesis data stream by your downstream app, in milliseconds. Use the StreamName dimension. A rising value indicates that your downstream app can't keep up with the rate at which Aurora DSQL writes CDC records to Kinesis.

Aurora DSQL 主控台的監控索引標籤會顯示結合 BehindSourceLag(CDC 來源延遲) 和 (Kinesis 讀取器延遲) 的平均end-to-end延遲值。 GetRecords.IteratorAgeMilliseconds此合併值代表從資料庫遞交到下游讀取的總延遲。

監控最佳實務

使用以下實務,在 CDC 管道問題影響您的下游系統之前對其進行偵測和解決。

在 上設定警示 BehindSourceLag

建立 CloudWatch 警示,當 BehindSourceLag超過對工作負載重要的閾值時觸發。例如,為一分鐘延遲目標設定 60 秒。此指標的持續增加表示 CDC 管道落後。如果延遲達到失敗閾值,串流會轉換為 FAILED。截獲趨勢可讓您在串流降級之前,有時間增加 Kinesis 容量或調查輸送量瓶頸。

在 Kinesis GetRecords.IteratorAgeMilliseconds端監控

即使 Aurora DSQL 準時交付記錄,您的下游應用程式仍可能落後。在 上建立 CloudWatch 警示 GetRecords.IteratorAgeMilliseconds(AWS/Kinesis在命名空間中,維度 StreamName),以獨立偵測下游延遲。如果此指標上升並BehindSourceLag保持平穩,則瓶頸會在您的下游應用程式中,而不是在 Aurora DSQL 中。

PublishedBytes 針對 Kinesis 碎片容量進行追蹤

每個 Kinesis 碎片每秒最多支援 1 MiB 的寫入。將每分鐘PublishedBytes總和與您的碎片寫入容量 (碎片數量 × 60 MiB/分鐘) 進行比較。如果用量接近 80%,請在調節觸發 之前新增碎片或切換至隨需容量模式KINESIS_THROUGHPUT_EXCEEDED

上的警示,IsImpaired用於即時損害偵測

建立 CloudWatch 警示,當IsImpaired上限大於或等於1一個評估期間時觸發。這會在串流進入 IMPAIRED 狀態時為您提供直接訊號,而不會輪詢 API。警示觸發後,請呼叫 GetStream 以讀取 statusReason.error 欄位,並遵循 中的修復步驟對受損或失敗的串流進行故障診斷

GetStream 輪詢詳細狀態

IsImpaired 指標會通知您串流受損,但 GetStream API 會提供特定的錯誤代碼和時間戳記。GetStream 依排程輪詢 (例如,每五分鐘) 或回應IsImpaired警示。statusReason.error 欄位會告訴您出了什麼問題。將此與 中的疑難排解步驟配對,對受損或失敗的串流進行故障診斷以快速解決此問題。

使用儀表板來關聯指標

建立 CloudWatch 儀表板,並GetRecords.IteratorAgeMilliseconds排顯示 IsImpairedPublishedBytes、、 BehindSourceLag PublishedRecords和 。關聯這些指標可協助您區分 CDC 管道問題 (突增 BehindSourceLag) 和下游讀取問題 (突增IteratorAge穩定 BehindSourceLag)。