将 Azure Cosmos DB 帐户移到另一个区域Move an Azure Cosmos DB account to another region

适用于: SQL API

本文介绍了如何执行以下操作:This article describes how to either:

  • 在 Azure Cosmos DB 中移动一个可在其中复制数据的区域。Move a region where data is replicated in Azure Cosmos DB.
  • 将帐户(Azure 资源管理器)元数据和数据从一个区域迁移到另一个区域。Migrate account (Azure Resource Manager) metadata and data from one region to another.

将数据从一个区域移到另一个区域Move data from one region to another

Azure Cosmos DB 本身支持数据复制,因此,将数据从一个区域移到另一个区域非常简单。Azure Cosmos DB supports data replication natively, so moving data from one region to another is simple. 可以使用 Azure 门户、Azure PowerShell 或 Azure CLI 来完成此操作。You can accomplish it by using the Azure portal, Azure PowerShell, or the Azure CLI. 它涉及以下步骤:It involves the following steps:

  1. 将新区域添加到帐户。Add a new region to the account.

    若要将新区域添加到 Azure Cosmos DB 帐户,请参阅在 Azure Cosmos DB 帐户中添加/删除区域To add a new region to an Azure Cosmos DB account, see Add/remove regions to an Azure Cosmos DB account.

  2. 执行到新区域的手动故障转移。Perform a manual failover to the new region.

    当要删除的区域当前为帐户的写入区域时,你需要故障转移到上一步骤中添加的新区域。When the region that's being removed is currently the write region for the account, you'll need to start a failover to the new region added in the previous step. 此操作不需要停机。This is a zero-downtime operation. 如果要移动多区域帐户中的读取区域,则可以跳过此步骤。If you're moving a read region in a multiple-region account, you can skip this step.

    若要启动故障转移,请参阅在 Azure Cosmos 帐户上执行手动故障转移To start a failover, see Perform manual failover on an Azure Cosmos account.

  3. 删除原始区域。Remove the original region.

    若要从 Azure Cosmos DB 帐户中删除区域,请参阅在 Azure Cosmos DB 帐户中添加/删除区域To remove a region from an Azure Cosmos DB account, see Add/remove regions from your Azure Cosmos DB account.

迁移 Azure Cosmos DB 帐户元数据Migrate Azure Cosmos DB account metadata

Azure Cosmos DB 本身不支持将帐户元数据从一个区域迁移到另一个区域。Azure Cosmos DB does not natively support migrating account metadata from one region to another. 若要同时将帐户元数据和客户数据从一个区域迁移到另一个区域,必须在所需的区域中创建新帐户,然后手动复制数据。To migrate both the account metadata and customer data from one region to another, you must create a new account in the desired region and then copy the data manually.

SQL API 的几乎不停机的迁移需要使用更改源或一个使用它的工具。A near-zero-downtime migration for the SQL API requires the use of the change feed or a tool that uses it. 如果要迁移 MongoDB API、Cassandra API 或其他 API,或详细了解在帐户之间迁移数据的选项,请参阅将本地数据或云数据迁移到 Azure Cosmos DB 的选项If you're migrating the MongoDB API, the Cassandra API, or another API, or to learn more about options for migrating data between accounts, see Options to migrate your on-premises or cloud data to Azure Cosmos DB.

以下步骤演示了如何将 SQL API 的 Azure Cosmos DB 帐户及其数据从一个区域迁移到另一个区域:The following steps demonstrate how to migrate an Azure Cosmos DB account for the SQL API and its data from one region to another:

  1. 在所需区域中创建新的 Azure Cosmos DB 帐户。Create a new Azure Cosmos DB account in the desired region.

    若要通过 Azure 门户、PowerShell 或 Azure CLI 创建新帐户,请参阅创建 Azure Cosmos DB 帐户To create a new account via the Azure portal, PowerShell, or the Azure CLI, see Create an Azure Cosmos DB account.

  2. 创建新的数据库和容器。Create a new database and container.

    若要创建新的数据库和容器,请参阅创建 Azure Cosmos 容器To create a new database and container, see Create an Azure Cosmos container.

  3. 使用 Azure Cosmos DB 实时数据迁移器工具迁移数据。Migrate data by using the Azure Cosmos DB Live Data Migrator tool.

    若要在几乎不停机的情况下迁移数据,请参阅 Azure Cosmos DB 实时数据迁移器工具To migrate data with near zero downtime, see Azure Cosmos DB Live Data Migrator tool.

  4. 更新应用程序连接字符串。Update the application connection string.

    当实时数据迁移器工具仍在运行时,在应用程序的新部署中更新连接信息。With the Live Data Migrator tool still running, update the connection information in the new deployment of your application. 你可以从 Azure 门户检索应用程序的终结点和密钥。You can retrieve the endpoints and keys for your application from the Azure portal.

    Azure 门户中的访问控制,演示了 NoSQL 数据库安全性。

  5. 将请求重定向到新应用程序。Redirect requests to the new application.

    在新应用程序连接到 Azure Cosmos DB 后,可以将客户端请求重定向到新部署。After the new application is connected to Azure Cosmos DB, you can redirect client requests to your new deployment.

  6. 删除不再需要的任何资源。Delete any resources that you no longer need.

    现在,请求已完全重定向到新实例,你可以删除旧的 Azure Cosmos DB 帐户和实时数据迁移器工具了。With requests now fully redirected to the new instance, you can delete the old Azure Cosmos DB account and the Live Data Migrator tool.

后续步骤Next steps

有关如何管理 Azure Cosmos 帐户以及数据库和容器的详细信息和示例,请阅读以下文章:For more information and examples on how to manage the Azure Cosmos account as well as databases and containers, read the following articles: