您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何为 Azure Redis 缓存配置异地复制功能How to configure Geo-replication for Azure Redis Cache

异地复制提供一种用于链接两个高级层 Azure Redis 缓存实例的机制。Geo-replication provides a mechanism for linking two Premium tier Azure Redis Cache instances. 一个缓存指定为主链接缓存,另一个缓存指定为辅助链接缓存。One cache is designated as the primary linked cache, and the other as the secondary linked cache. 辅助链接缓存将变为只读,写入主缓存的数据将复制到辅助链接缓存。The secondary linked cache becomes read-only, and data written to the primary cache is replicated to the secondary linked cache. 此功能可用于跨 Azure 区域复制缓存。This functionality can be used to replicate a cache across Azure regions. 本文提供了为高级层 Azure Redis 缓存实例配置异地复制的指南。This article provides a guide to configuring Geo-replication for your Premium tier Azure Redis Cache instances.

异地复制先决条件Geo-replication prerequisites

若要在两个缓存之间配置异地复制,必须满足以下先决条件:To configure Geo-replication between two caches, the following prerequisites must be met:

  • 这两个缓存必须是高级层缓存。Both caches must be Premium tier caches.
  • 这两个缓存必须在同一 Azure 订阅中。Both caches must be in the same Azure subscription.
  • 辅助链接缓存必须是相同的定价层或比主链接缓存更高的定价层。The secondary linked cache must be either the same pricing tier or a larger pricing tier than the primary linked cache.
  • 如果主链接缓存已启用群集,辅助链接缓存必须启用分片数量与主链接缓存相同的群集。If the primary linked cache has clustering enabled, the secondary linked cache must have clustering enabled with the same number of shards as the primary linked cache.
  • 两个缓存都必须已创建且都处于运行状态。Both caches must be created and in a running state.
  • 任一缓存都不能启用暂留。Persistence must not be enabled on either cache.
  • 支持在同一 VNET 中的缓存间进行异地复制。Geo-replication between caches in the same VNET is supported.
  • 目前,同一区域内对等互连的 VNET 中的缓存间的异地复制是预览功能。Geo-replication between caches in peered VNETs within the same region is currently a preview feature. 需要以这样的方式配置两个 VNET:使得 VNET 中的资源能够通过 TCP 连接彼此访问。The two VNETs need to be configured in such a way that resources in the VNETs are able to reach each other via TCP connections.
  • 目前尚不支持在不同区域的对等互连 VNET 中的缓存之间进行异地复制,但此功能不久将以预览版提供。Geo-replication between caches in peered VNETs in different regions is not yet supported, but will be in preview soon.

完成异地复制配置后,链接缓存对会有以下限制:After Geo-replication is configured, the following restrictions apply to your linked cache pair:

  • 辅助链接缓存为只读状态;这意味着只能从中读取,但不能向其写入任何数据。The secondary linked cache is read-only; you can read from it, but you can't write any data to it.
  • 添加链接前辅助链接缓存中的任何数据都会被删除。Any data that was in the secondary linked cache before the link was added is removed. 但如果随后删除了异地复制,复制的数据则会保留在辅助链接缓存中。If the Geo-replication is subsequently removed however, the replicated data remains in the secondary linked cache.
  • 如果缓存启用了群集,则无法在任一缓存上启动缩放操作更改分片数You can't initiate a scaling operation on either cache or change the number of shards if the cache has clustering enabled.
  • 无法在任一缓存上启用暂存。You can't enable persistence on either cache.
  • 可通过任一缓存使用导出,但只能导入到主链接缓存。You can use Export with either cache, but you can only Import into the primary linked cache.
  • 除非删除异地复制链接,否则无法删除任一链接缓存或包含它们的资源组。You can't delete either linked cache, or the resource group that contains them, until you remove the Geo-replication link. 有关详细信息,请参阅尝试删除链接缓存时为何操作会失败?For more information, see Why did the operation fail when I tried to delete my linked cache?
  • 如果两个缓存位于不同的区域中,当数据跨地区复制到辅助链接缓存时,将收取网络流出量费用。If the two caches are in different regions, network egress costs will apply to the data replicated across regions to the secondary linked cache. 有关详细信息,请参阅跨 Azure 区域复制数据的费用是多少?For more information, see How much does it cost to replicate my data across Azure regions?
  • 如果主缓存(及其副本)停止运行,则没有针对辅助链接缓存的自动故障转移。There is no automatic failover to the secondary linked cache if the primary cache (and its replica) go down. 若要故障转移客户端应用程序,建议手动删除异地复制链接并将客户端应用程序指向曾是辅助链接缓存的缓存。In order to failover client applications, you would need to manually remove the Geo-replication link and point the client applications to the cache that was formerly the secondary linked cache. 有关详细信息,请参阅辅助链接缓存如何进行故障转移?For more information, see How does failing over to the secondary linked cache work?
  1. 若要将两个高级缓存链接在一起进行异地复制,请从作为主链接缓存的缓存“资源”菜单,单击“异地复制”,再从“异地复制”边栏选项卡,单击“添加缓存复制链接”。To link two premium caches together for geo-replication, click Geo-replication from the Resource menu of the cache intended as the primary linked cache, and then click Add cache replication link from the Geo-replication blade.

    添加链接

  2. 从“兼容缓存”列表,单击所需的辅助缓存的名称。Click the name of the desired secondary cache from the Compatible caches list. 如果列表中未显示所需缓存,请验证是否已满足所需辅助缓存的异地复制先决条件If your desired cache isn't displayed in the list, verify that the Geo-replication prerequisites for the desired secondary cache are met. 若要按区域筛选缓存,单击地图中的所需区域,只显示“兼容缓存”列表中的缓存。To filter the caches by region, click the desired region in the map to display only those caches in the Compatible caches list.

    异地复制兼容缓存

    还可使用上下文菜单启动链接过程或查看辅助缓存的详细信息。You can also initiate the linking process or view details about the secondary cache by using the context menu.

    异地复制上下文菜单

  3. 单击“链接”将两个缓存链接在一起并开始复制过程。Click Link to link the two caches together and begin the replication process.

    链接缓存

  4. 可以在“异地复制”边栏选项卡上查看复制过程的进度。You can view the progress of the replication process on the Geo-replication blade.

    链接状态

    还可以在主缓存和辅助缓存的“概述”边栏选项卡上查看链接状态。You can also view the linking status on the Overview blade for both the primary and secondary caches.

    缓存状态

    复制过程完成后,“链接状态”改为“成功”。Once the replication process is complete, the Link status changes to Succeeded.

    缓存状态

    链接过程中,主链接缓存仍然可用,但辅助链接缓存将不可用,直到链接过程完成为止。During the linking process, the primary linked cache remains available for use but the secondary linked cache is not available until the linking process completes.

  1. 若要删除两个缓存之间的链接并停止异地复制,请在“异地复制”边栏选项卡中,单击“取消链接缓存”。To remove the link between two caches and stop Geo-replication, click Unlink caches from the Geo-replication blade.

    取消链接缓存

    取消链接过程完成后,辅助缓存可用于读取和写入。When the unlinking process completes, the secondary cache is available for both reads and writes.

备注

在删除异地复制链接后,从主链接缓存复制的数据保留在辅助缓存中。When the Geo-replication link is removed, the replicated data from the primary linked cache remains in the secondary cache.

异地复制常见问题解答Geo-replication FAQ

是否可以通过标准层或基本层缓存使用异地复制?Can I use Geo-replication with a Standard or Basic tier cache?

不可以,异地复制仅适用于高级层缓存。No, Geo-replication is only available for Premium tier caches.

在链接或取消链接过程中是否可以使用缓存?Is my cache available for use during the linking or unlinking process?

  • 链接两个缓存进行异地复制时,主链接缓存仍然可用,但辅助链接缓存将不可用,直到链接过程完成为止。When linking two caches together for Geo-replication, the primary linked cache remains available for use but the secondary linked cache is not available until the linking process completes.
  • 当删除两个缓存间的异地复制链接后,两个缓存仍然可用。When removing the Geo-replication link between two caches, both caches remain available for use.

不可以,使用异地复制时,只能将两个缓存链接到一起。No, when using Geo-replication you can only link two caches together.

不可以,这两个缓存必须在同一 Azure 订阅中。No, both caches must be in the same Azure subscription.

可以,但辅助链接缓存必须大于主链接缓存。Yes, as long as the secondary linked cache is larger than the primary linked cache.

是否可以在启用群集时使用异地复制?Can I use Geo-replication with clustering enabled?

可以,但两个缓存的分片数必须相同。Yes, as long as both caches have the same number of shards.

当缓存位于 VNET 中时是否可以使用异地复制?Can I use Geo-replication with my caches in a VNET?

可以,支持对 VNET 中的缓存进行异地复制。Yes, Geo-replication of caches in VNETs are supported.

  • 支持在同一 VNET 中的缓存间进行异地复制。Geo-replication between caches in the same VNET is supported.
  • 也支持不同 VNET 中的缓存间异地复制,只要两个 VNET 都以这样一种方式进行配置,即最终 VNET 中的资源可以通过 TCP 连接到达彼此。Geo-replication between caches in different VNETs is also supported, as long as the two VNETs are configured in such a way that resources in the VNETs are able to reach each other via TCP connections.

什么是 Redis 异地复制的复制计划?What is the replication schedule for Redis geo-replication?

复制不按特定计划进行,而是以连续和异步方式进行,即Replication does not happen on a specific schedule, it is continuous and asynchronous i.e 对主缓存进行的所有写入都会即时地异步复制到辅助缓存。all the writes done to the primary are instantaneously asynchronously replicated on the secondary.

异地复制需要多长时间?How long does geo-replication replication take?

复制以递增、异步和连续方式进行,所用时间通常不会与区域间的延迟相差太多。Replication is incremental, asynchronous and continuous and the time taken is usually not much different from the latency across regions. 在特定情况下的特定时间,辅助缓存可能需要从主缓存执行数据的完全同步。Under certain circumstances, at certain times, the secondary may be required to do a full sync of the data from the primary. 在这种情况下,复制时间取决于多种因素,如:主缓存上的负载、缓存计算机上的可用带宽、区域间延迟等。例如,基于某种测试,我们发现美国东部和美国西部区域中完整 53 GB 异地复制对的复制时间可能是介于 5 到 10 分钟之间的任何值。The replication time in this case is dependent on number of factors like: load on the primary cache, bandwidth available on the cache machine, inter region latency etc. As an example, based on some testing we have found out that replication time for a full 53 GB geo-replicated pair in East US and West US regions can be anywhere between 5 to 10 minutes.

复制恢复点是否受保证?Is the replication recovery point guaranteed?

当前,对于异地复制模式下的缓存,持久性和导入/导出功能处于禁用状态。Currently, for caches in a geo-replicated mode, persistence and import/export functionality is disabled. 因此,在客户启动故障转移情况下,或在异地复制对之间的复制链接中断的情况下,辅助缓存会保留到该时间点为止从主缓存同步的内存中数据。So in case of a customer initiated failover or in cases where a replication link has been broken between the geo-replicated pair, the secondary will retain the in memory data that it has synced from the primary until that point of time. 在这种情况下不提供任何恢复点保证。There is no recovery point guarantee provided in such situations.

是否可以使用 PowerShell 或 Azure CLI管理异地复制?Can I use PowerShell or Azure CLI to manage Geo-replication?

当前只能使用 Azure 门户管理异地复制。At this time you can only manage Geo-replication using the Azure portal.

跨 Azure 区域复制数据的费用是多少?How much does it cost to replicate my data across Azure regions?

使用异地复制时,主链接缓存中的数据会被复制到辅助链接缓存中。When using Geo-replication, data from the primary linked cache is replicated to the secondary linked cache. 如果两个链接缓存位于同一 Azure 区域,则此数据传输不产生任何费用。If the two linked caches are in the same Azure region, there is no charge for the data transfer. 如果两个链接缓存位于不同 Azure 区域,则异地复制数据传输费用就是将该数据复制到其他 Azure 区域的带宽成本。If the two linked caches are in different Azure regions, the Geo-Replication data transfer charge is the bandwidth cost of replicating that data to the other Azure region. 有关详细信息,请参阅带宽定价详细信息For more information, see Bandwidth Pricing Details.

尝试删除链接缓存时为何操作会失败?Why did the operation fail when I tried to delete my linked cache?

两个缓存链接到一起时,除非删除异地复制链接,否则无法删除任一链接缓存或包含它们的资源组。When two caches are linked together, you can't delete either cache or the resource group that contains them until you remove the Geo-replication link. 如果尝试删除包含一个或两个链接缓存的资源组,则会删除该资源组中的其他资源,但该资源组保持 deleting 状态,而资源组中的任意链接缓存则保持 running 状态。If you attempt to delete the resource group that contains one or both of the linked caches, the other resources in the resource group are deleted, but the resource group stays in the deleting state and any linked caches in the resource group remain in the running state. 若要删除资源组及其链接缓存,请按照删除异地复制链接中所述断开异地复制链接。To complete the deletion of the resource group and the linked caches within it, break the Geo-replication link as described in Remove a Geo-replication link.

应为辅助链接缓存选择哪个区域?What region should I use for my secondary linked cache?

一般而言,建议将缓存保存在应用程序所在的相同 Azure 区域,便于应用程序访问。In general, it is recommended for your cache to exist in the same Azure region as the application that accesses it. 如果应用程序有主区域和备用区域,那么主缓存和辅助缓存应保存在这些相同区域中。If your application has a primary and fallback region, then your primary and secondary caches should exist in those same regions. 有关配对区域的详细信息,请参阅最佳做法 – Azure 配对区域For more information about paired regions, see Best Practices – Azure Paired regions.

辅助链接缓存如何进行故障转移?How does failing over to the secondary linked cache work?

在异地复制的初始版本中,Azure Redis 缓存不支持跨 Azure 区域自动故障转移。In the initial release of Geo-replication, Azure Redis Cache does not support automatic failover across Azure regions. 异地复制主要用于灾难恢复方案。Geo-replication is used primarily in a disaster recovery scenario. 在灾难恢复方案中,客户需要在备份区域中以协同的方式提供完整的应用程序堆叠,而不是让独立的应用程序组件自行决定切换到其备份区域的时间。In a distater recovery scenario, customers should bring up the entire application stack in a backup region in a coordinated manner rather than letting individual application components decide when to switch to their backups on their own. 这与 Redis 尤其相关。This is especially relevant to Redis. Redis 的主要优点之一是,它是一个低延迟存储。One of the key benefits of Redis is that it is a very low-latency store. 如果应用程序使用的 Redis 故障转移到不同的 Azure 区域,但计算机层不转移,增加的往返时间可能会对性能产生显著影响。If Redis used by an application fails over to a different Azure region but the compute tier does not, the added round trip time would have a noticeable impact on performance. 因此,我们希望能够避免因暂时可用性问题而进行的 Redis 自动故障转移。For this reason, we would like to avoid Redis failing over automatically due to transient availability issues.

目前,若要启动故障转移,需要删除 Azure 门户中的异地复制链接,然后将 Redis 客户端中的连接终结点从主链接缓存更改为(以前链接的)辅助缓存。Currently, to initiate the failover, you need to remove the Geo-replication link in the Azure portal, and then change the connection end-point in the Redis client from the primary linked cache to the (formerly linked) secondary cache. 当两个缓存都解除关联时,副本再次变为常规的读取写入缓存并直接从 Redis 客户端接受请求。When the two caches are disassociated, the replica becomes a regular read-write cache again and accepts requests directly from Redis clients.

后续步骤Next steps

了解有关 Azure Redis 缓存高级层的更多信息。Learn more about the Azure Redis Cache Premium tier.