[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-26 (世界標準時間)。"],[[["\u003cp\u003eThis content pertains to Cloud Composer, specifically versions 1, 2, and 3.\u003c/p\u003e\n"],["\u003cp\u003eThe feature discussed in this document is not currently supported in Cloud Composer 3.\u003c/p\u003e\n"],["\u003cp\u003eThere is a link available to view related information for Cloud Composer 2.\u003c/p\u003e\n"]]],[],null,["# Perform failover tests for highly resilient environments\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n**Cloud Composer 3** \\| [Cloud Composer 2](/composer/docs/composer-2/perform-failover-tests \"View this page for Cloud Composer 2\") \\| Cloud Composer 1\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page describes how to perform a database failover test for\n[highly resilient (Highly Available) environments](/composer/docs/composer-3/set-up-highly-resilient-environments).\n\nFailover tests for your environment simulate a complete outage of a zone in a\ndata center. In such a scenario, a zonal outage of a database might happen. By\nperforming a failover test, you can monitor how your highly resilient\nenvironment performs a failover and check how this affects your DAGs and tasks.\n\n\nBefore you begin\n----------------\n\n- To perform failover tests, your Google Account must have the following roles\n and permissions:\n\n - `composer.environments.update` permission. See\n [Access control with IAM](/composer/docs/composer-3/access-control#user-account)\n for a list of roles with this permission.\n\n- In Cloud Composer 3, the environment's cluster is located in the tenant\n project of your environment and it's not possible to simulate a zonal\n outage for it.\n\nCheck that your environment is healthy\n--------------------------------------\n\nMake sure to perform failover tests only on healthy environments. To check that\nyour environment is healthy:\n\n1. In the Google Cloud console, go to the **Environments** page.\n\n [Go to Environments](https://console.cloud.google.com/composer/environments)\n2. In the list of environments, click the name of your environment.\n The **Environment details** page opens.\n\n3. Go to the **Monitoring** tab.\n\n4. Make sure that all health metrics are green.\n\nPerform a database failover test\n--------------------------------\n\nYou can perform a database failover test, which simulates a zonal outage, by\ntriggering it with a Google Cloud CLI command. For example, you might want to\ndo it to measure the amount of time it takes for your environment's database\nto switch to another zone.\n| **Note:** The database failover test is not intended for troubleshooting; it is not possible to fix issues with the database component of an environment with the failover test.\n\nTo perform a database failover test for your environment:\n\n1. Make sure that [your environment is healthy](#check-environment-health).\n\n2. Get the primary zone of your environment's database:\n\n gcloud composer environments fetch-database-properties \\\n \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n\n Replace the following:\n - `ENVIRONMENT_NAME`: the name of your Cloud Composer environment.\n - `LOCATION`: the region where the environment is located.\n\n Example: \n\n gcloud composer environments fetch-database-properties \\\n example-environment \\\n --location us-central1\n\n3. Start the database failover test:\n\n gcloud composer environments database-failover \\\n \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n\n Replace the following:\n - `ENVIRONMENT_NAME`: the name of your Cloud Composer environment.\n - `LOCATION`: the region where the environment is located.\n\n Example: \n\n gcloud composer environments database-failover \\\n example-environment \\\n --location us-central1\n\n4. Wait until the database failover test is finished. The process can take up\n to 3 minutes.\n\n5. Check that the primary zone of your environment's database is changed:\n\n gcloud composer environments fetch-database-properties \\\n \u003cvar translate=\"no\"\u003eENVIRONMENT_NAME\u003c/var\u003e \\\n --location \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n\n6. Check your environment's health metrics to make sure that\n [your environment is healthy](#check-environment-health).\n\n7. Your environment's database becomes ready for another failover when\n the **Database available for failover**\n (`composer.googleapis.com/environment/database/available_for_failover`)\n environment metric becomes `True`. For more information about viewing your\n environment's metrics in Cloud Monitoring, see\n [Monitor environments](/composer/docs/composer-3/monitor-environments#view-metrics).\n\nWhat's next\n-----------\n\n- [Create environments](/composer/docs/composer-3/create-environments)\n- [Monitor environments](/composer/docs/composer-3/monitor-environments)\n- [Disaster recovery with environment snapshots](/composer/docs/composer-3/disaster-recovery-with-snapshots)"]]