尋找 Aurora MySQL 主要版本升級失敗的原因 - Amazon Aurora

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

尋找 Aurora MySQL 主要版本升級失敗的原因

教學課程中,從 Aurora MySQL 第 2 版升級至第 3 版成功。但是,如果升級失敗,您會想知道原因。

您可以開始使用 describe-events AWS CLI 命令來查看資料庫叢集事件。此範例顯示過去 10 小時mydbcluster的事件。

aws rds describe-events \ --source-type db-cluster \ --source-identifier mydbcluster \ --duration 600

在此情況下,我們發生升級預先檢查失敗。

{ "Events": [ { "SourceIdentifier": "mydbcluster", "SourceType": "db-cluster", "Message": "Database cluster engine version upgrade started.", "EventCategories": [ "maintenance" ], "Date": "2024-04-11T13:23:22.846000+00:00", "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster" }, { "SourceIdentifier": "mydbcluster", "SourceType": "db-cluster", "Message": "Database cluster is in a state that cannot be upgraded: Upgrade prechecks failed. For more details, see the upgrade-prechecks.log file. For more information on troubleshooting the cause of the upgrade failure, see https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Upgrading.Troubleshooting.html", "EventCategories": [ "maintenance" ], "Date": "2024-04-11T13:23:24.373000+00:00", "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster" } ] }

若要診斷問題的確切原因,請檢查寫入器資料庫執行個體的資料庫日誌。當升級至 Aurora MySQL 第 3 版失敗時,寫入器執行個體包含名為 的日誌檔案upgrade-prechecks.log。此範例說明如何偵測該日誌是否存在,然後將其下載為本機檔案進行檢查。

aws rds describe-db-log-files --db-instance-identifier mydbcluster-instance \ --query '*[].[LogFileName]' --output text error/mysql-error-running.log error/mysql-error-running.log.2024-04-11.20 error/mysql-error-running.log.2024-04-11.21 error/mysql-error.log external/mysql-external.log upgrade-prechecks.log aws rds download-db-log-file-portion --db-instance-identifier mydbcluster-instance \ --log-file-name upgrade-prechecks.log \ --starting-token 0 \ --output text >upgrade_prechecks.log

upgrade-prechecks.log 檔案的JSON格式為 。我們會使用 --output text選項下載它,以避免在另一個JSON包裝內編碼JSON輸出。對於 Aurora MySQL 第 3 版升級,此日誌一律包含特定資訊和警告訊息。它只會在升級失敗時包含錯誤訊息。如果升級成功,則根本不會產生日誌檔案。

若要摘要所有錯誤並顯示相關聯的物件和描述欄位,您可以在upgrade-prechecks.log檔案的內容grep -A 2 '"level": "Error"'上執行 命令。這麼做會顯示每個錯誤行及其後兩行。其中包含對應資料庫物件的名稱,以及如何修正問題的指引。

$ cat upgrade-prechecks.log | grep -A 2 '"level": "Error"' "level": "Error", "dbObject": "problematic_upgrade.dangling_fulltext_index", "description": "Table `problematic_upgrade.dangling_fulltext_index` contains dangling FULLTEXT index. Kindly recreate the table before upgrade."

在此範例中,您可以在違規的資料表上執行下列SQL命令,以嘗試修正問題,也可以在沒有懸置索引的情況下重新建立資料表。

OPTIMIZE TABLE problematic_upgrade.dangling_fulltext_index;

然後重試升級。