本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
尋找 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;
然後重試升級。