設定 Premium Azure Cache for Redis 實例的異地複寫Configure geo-replication for Premium Azure Cache for Redis instances

在本文中,您將瞭解如何使用 Azure 入口網站來設定異地複寫的 Azure 快取。In this article, you'll learn how to configure a geo-replicated Azure Cache using the Azure portal.

異地複寫會將兩個 Premium Azure Cache for Redis 實例連結在一起,並建立資料複寫關聯性。Geo-replication links together two Premium Azure Cache for Redis instances and creates a data replication relationship. 這些快取實例通常位於不同的 Azure 區域中,但不是必要的。These cache instances are usually located in different Azure regions, though they aren't required to. 一個實例可作為主要,另一個則做為次要。One instance acts as the primary, and the other as the secondary. 主要會處理讀取和寫入要求,並將變更傳播至次要複本。The primary handles read and write requests and propagates changes to the secondary. 此程式會繼續進行,直到移除兩個實例之間的連結為止。This process continues until the link between the two instances is removed.

注意

異地複寫是設計為損毀修復解決方案。Geo-replication is designed as a disaster-recovery solution.

異地複寫的必要條件Geo-replication prerequisites

若要設定兩個快取之間的異地複寫,必須符合下列必要條件:To configure geo-replication between two caches, the following prerequisites must be met:

  • 這兩個快取都是 Premium 層 快取。Both caches are Premium tier caches.
  • 這兩個快取都位於相同的 Azure 訂用帳戶中。Both caches are in the same Azure subscription.
  • 次要連結快取的快取大小,或較大的快取大小,與主要連結快取的大小相同。The secondary linked cache is either the same cache size or a larger cache size than the primary linked cache.
  • 這兩個快取都會建立並處於執行中狀態。Both caches are created and in a running state.

異地複寫不支援某些功能:Some features aren't supported with geo-replication:

  • 異地複寫不支援持續性。Persistence isn't supported with geo-replication.
  • 如果這兩個快取已啟用叢集,且具有相同的分區數目,則支援叢集。Clustering is supported if both caches have clustering enabled and have the same number of shards.
  • 支援相同 VNET 中的快取。Caches in the same VNET are supported.
  • 不同 Vnet 中的快取會受到支援,但有一些注意事項。Caches in different VNETs are supported with caveats. 如需詳細資訊,請參閱 我可以在 VNET 中使用異地 複寫搭配我的快取?。See Can I use geo-replication with my caches in a VNET? for more information.

設定異地複寫之後,下列限制適用于您的連結快取配對: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 later removed however, the replicated data remains in the secondary linked cache.
  • 當快取連結時,您無法 調整 其中一個快取。You can't scale either cache while the caches are linked.
  • 如果快取已啟用叢集,您就無法 變更分區數目You can't change the number of shards if the cache has clustering enabled.
  • 您無法啟用任一個快取的持續性。You can't enable persistence on either cache.
  • 您可以從任一快取 匯出You can Export from either cache.
  • 您無法匯 至次要連結快取。You can't Import into the secondary linked cache.
  • 您無法刪除連結快取或包含它們的資源群組,直到您取消連結快取為止。You can't delete either linked cache, or the resource group that contains them, until you unlink the caches. 如需詳細資訊,請參閱當我嘗試刪除連結快取時,作業失敗的原因?For more information, see Why did the operation fail when I tried to delete my linked cache?
  • 如果快取位於不同的區域,則會將網路輸出成本套用至跨區域移動的資料。If the caches are in different regions, network egress costs apply to the data moved across regions. 如需詳細資訊,請參閱跨 Azure 區域複寫我的資料需要多少費用?For more information, see How much does it cost to replicate my data across Azure regions?
  • 主要與次要連結快取之間不會進行自動容錯移轉。Automatic failover doesn't occur between the primary and secondary linked cache. 如需有關如何容錯移轉用戶端應用程式的詳細資訊和詳細資訊,請參閱 容錯移轉至次要連結快取如何運作?For more information and information on how to failover a client application, see How does failing over to the secondary linked cache work?
  1. 若要將兩個快取連結在一起以進行異地複寫,請第一個從您想要作為主要連結快取的快取的 [資源] 功能表中,按一下 [ 異地 複寫]。To link two caches together for geo-replication, fist click Geo-replication from the Resource menu of the cache that you intend to be the primary linked cache. 接著,按一下 [新增 異地 複寫] 分頁的 [新增快取複寫]連結Next, click Add cache replication link from the Geo-replication blade.

    新增連結

  2. 相容 的快取清單中,按一下您想要的次要快取名稱。Click the name of your intended secondary cache from the Compatible caches list. 如果您的次要快取未顯示在清單中,請確認已符合次要快取的 異地複寫必要條件If your secondary cache isn't displayed in the list, verify that the Geo-replication prerequisites for the secondary cache are met. 若要依區域篩選快取,請按一下對應中的區域,只顯示 相容 快取清單中的快取。To filter the caches by region, click the region in the map to display only those caches in the Compatible caches list.

    異地複寫相容的快取

    您也可以使用操作功能表來啟動連結程式,或查看次要快取的詳細資料。You can also start 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.

    快取狀態

    主要連結快取在連結程式期間仍可供使用。The primary linked cache remains available for use during the linking process. 在連結處理常式完成之前,無法使用次要連結快取。The secondary linked cache isn't 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, the primary linked cache remains available while the linking process completes.
  • 連結時,在連結處理常式完成之前,無法使用次要連結快取。When linking, the secondary linked cache isn't available until the linking process completes.
  • 取消連結時,在取消連結的程式完成時,這兩個快取會保持可用。When unlinking, both caches remain available while the unlinking process completes.

否,您只能將兩個快取連結在一起。No, 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 is supported with caveats:

  • 支援在相同 VNET 中多個快取之間的異地複寫。Geo-replication between caches in the same VNET is supported.
  • 也支援不同 Vnet 中的快取之間的異地複寫。Geo-replication between caches in different VNETs is also supported.
    • 如果 Vnet 位於相同的區域,您可以使用 vnet 對等互連VPN 閘道 vnet 對 vnet 連線來進行連接。If the VNETs are in the same region, you can connect them using VNET peering or a VPN Gateway VNET-to-VNET connection.
    • 如果 Vnet 位於不同的區域,則會支援使用 VNET 對等互連的異地複寫,但是 VNET 1 (區域 1) 的用戶端 VM 將無法透過其 DNS 名稱存取 VNET) (2 中的快取,因為基本的內部負載平衡器具有條件約束。If the VNETs are in different regions, geo-replication using VNET peering is supported, but a client VM in VNET 1 (region 1) will not be able to access the cache in VNET 2 (region 2) via it's DNS name because of a constraint with Basic internal load balancers. 如需 VNET 對等互連條件約束的詳細資訊,請參閱 虛擬網路對等互連-需求和條件約束For more information about VNET peering constraints, see Virtual Network - Peering - Requirements and constraints. 建議的解決方案是使用 VPN 閘道的 VNET 對 VNET 連線。The recommended solution is to use a VPN Gateway VNET-to-VNET connection.

您可以使用 此 Azure 範本,快速地將兩個異地複寫的快取部署到與 VPN 閘道 VNET 對 vnet 連線連線的 VNET 中。Using this Azure template, you can quickly deploy two geo-replicated caches into a VNET connected with a VPN Gateway VNET-to-VNET connection.

哪個複寫排程適用於 Redis 異地複寫?What is the replication schedule for Redis geo-replication?

複寫是連續且非同步,且不會在特定排程上進行。Replication is continuous and asynchronous and doesn't happen on a specific schedule. 所有對主資料庫所做的寫入都會立即以非同步方式複寫到次要複本。All the writes done to the primary are instantaneously and asynchronously replicated on the secondary.

異地複寫需要花費多久的時間?How long does geo-replication replication take?

複寫是累加、非同步和連續的,而所花費的時間與跨區域的延遲並無太大差異。Replication is incremental, asynchronous, and continuous and the time taken isn't much different from the latency across regions. 在某些情況下,次要快取可能需要從主要複本進行完整的資料同步處理。Under certain circumstances, the secondary cache may be required to do a full sync of the data from the primary. 在此情況下,複寫時間取決於下列因素的數目:主要快取上的負載、可用的網路頻寬,以及區域間延遲。The replication time in this case is dependent on number of factors like: load on the primary cache, available network bandwidth, and inter-region latency. 我們找到完整 53 GB 異地複寫配對的複寫時間可以在5到10分鐘之間的任何位置。We have found replication time for a full 53-GB geo-replicated pair can be anywhere between 5 to 10 minutes.

是否保證複寫復原點?Is the replication recovery point guaranteed?

若是異地複寫模式中的快取,則會停用持續性。For caches in a geo-replicated mode, persistence is disabled. 如果未連結異地複寫的配對(例如客戶起始的容錯移轉),次要連結快取就會將其同步處理的資料保留到該時間點。If a geo-replicated pair is unlinked, such as a customer-initiated failover, the secondary linked cache keeps its synced data up to that point of time. 在這種情況下,不保證復原點。No recovery point is guaranteed in such situations.

若要取得復原點,請從任一快取 匯出To obtain a recovery point, Export from either cache. 您稍後可以在主要連結快取中匯 You can later Import into the primary linked cache.

我可以使用 PowerShell 或 Azure CLI 來管理異地複寫嗎?Can I use PowerShell or Azure CLI to manage geo-replication?

是的,您可以使用 Azure 入口網站、PowerShell 或 Azure CLI 來管理異地複寫。Yes, geo-replication can be managed using the Azure portal, PowerShell, or Azure CLI. 如需詳細資訊,請參閱 PowerShell 檔或 Azure CLI檔。For more information, see the PowerShell docs or Azure CLI docs.

跨 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. 如果兩個連結快取位於相同的區域,則資料傳輸不會收取任何費用。There's no charge for the data transfer if the two linked caches are in the same region. 如果兩個連結快取位於不同的區域,則資料傳輸費用是資料在任一區域間移動的網路輸出成本。If the two linked caches are in different regions, the data transfer charge is the network egress cost of data moving across either region. 如需詳細資訊,請參閱 頻寬定價詳細資料For more information, see Bandwidth Pricing Details.

當我嘗試刪除連結快取時,作業失敗的原因?Why did the operation fail when I tried to delete my linked cache?

除非您移除異地複寫連結,否則無法在連結時刪除異地複寫的快取和其資源群組。Geo-replicated caches and their resource groups can't be deleted while linked 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 completely delete the resource group and the linked caches within it, unlink the caches as described in Remove a geo-replication link.

要將次要連結快取用於哪個區域?What region should I use for my secondary linked cache?

一般情況下,建議您的快取存在於與存取它的應用程式相同的 Azure 區域中。In general, it's recommended for your cache to exist in the same Azure region as the application that accesses it. 針對具有個別主要和備用區域的應用程式,建議您的主要和次要快取存在於這些相同區域中。For applications with separate primary and fallback regions, it's recommended your primary and secondary caches 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 區域自動容錯移轉。Automatic failover across Azure regions isn't supported for geo-replicated caches. 在嚴重損壞修復案例中,客戶應該以協調的方式在其備份區域中顯示整個應用程式堆疊。In a disaster-recovery scenario, customers should bring up the entire application stack in a coordinated manner in their backup region. 讓個別應用程式元件決定何時自行切換至其備份,可能會對效能造成負面影響。Letting individual application components decide when to switch to their backups on their own can negatively impact performance. Redis 的主要優點之一是,它是非常低延遲的存放區。One of the key benefits of Redis is that it's a very low-latency store. 如果客戶的主應用程式與其快取位於不同的區域,則新增的往返時間會對效能造成明顯的影響。If the customer's main application is in a different region than its cache, the added round-trip time would have a noticeable impact on performance. 基於這個理由,我們會避免因為暫時性可用性問題而自動容錯移轉。For this reason, we avoid failing over automatically because of transient availability issues.

若要啟動客戶起始的容錯移轉,請先取消連結快取。To start a customer-initiated failover, first unlink the caches. 然後,將您的 Redis 用戶端變更為使用先前連結) 次要快取 (的連接端點。Then, change your Redis client to use the connection endpoint of the (formerly linked) secondary cache. 當兩個快取都未連結時,次要快取會再次變成一般讀寫快取,並直接接受來自 Redis 用戶端的要求。When the two caches are unlinked, the secondary cache becomes a regular read-write cache again and accepts requests directly from Redis clients.

我可以使用異地複寫來設定防火牆嗎?Can I configure a firewall with geo-replication?

是,您可以使用異地複寫來設定 防火牆Yes, you can configure a firewall with geo-replication. 若要讓異地複寫與防火牆一起運作,請確定已將次要快取的 IP 位址新增至主要快取的防火牆規則。For geo-replication to function alongside a firewall, ensure that the secondary cache's IP address is added to the primary cache's firewall rules.

下一步Next steps

深入瞭解 Azure Cache for Redis 功能。Learn more about Azure Cache for Redis features.