天天看點

【Azure Redis 緩存】Azure Redis Cluster 在增加分片數時失敗分析

問題描述

Azure Redis Cluster 在增加分片數時失敗,錯誤消息為:

ResponseBody: { 
	"error": {
		"details": [],
		"code": "SubnetIsFull",
		"message": "Subnet Redis with address prefix 12.12.12.0/28 does not have enough capacity for 2 IP addresses."
	}
}      

問題分析

根據錯誤消息裡面的Address Prefix 12.12.12.0/28 計算出子網中的IP位址數量隻有15個。

【Azure Redis 緩存】Azure Redis Cluster 在增加分片數時失敗分析

(Source : https://jodies.de/ipcalc?host=12.12.12.0&mask1=28&mask2= )

因為Azure服務會保留5個IP位址,是以當把Redis Cluster服務內建到這個子網後,Redis服務可用的IP位址隻剩下10個。而Redis叢集至少包含一個分片和一個Load Balancer(負載均衡器)。每一個分片包含兩個VM執行個體,是以需要占用3個IP位址。如此計算,上面的子網中,最多能承載的Redis叢集分片數目為 4 (15-5-1- 2*4 =1)。是以剩下的一個不足以添加第五個分片,就會報出 “SubnetIsFull” 異常。

由于Azure VNET Subnet在添加後就不能在修改IP位址範圍,是以無法動态擴容(添加更多IP位址),隻能删除重建子網。

Azure服務保留IP介紹:

Are there any restrictions on using IP addresses within these subnets?

Yes. Azure reserves 5 IP addresses within each subnet. These are x.x.x.0-x.x.x.3 and the last address of the subnet. x.x.x.1-x.x.x.3 is reserved in each subnet for Azure services.

  • x.x.x.0: Network address
  • x.x.x.1: Reserved by Azure for the default gateway
  • x.x.x.2, x.x.x.3: Reserved by Azure to map the Azure DNS IPs to the VNet space
  • x.x.x.255: Network broadcast address for subnets of size /25 and larger. This will be a different address in smaller subnets.

參考資料

Configure virtual network support for a Premium Azure Cache for Redis instance:https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-how-to-premium-vnet

Azure Virtual Network frequently asked questions (FAQ) : https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-faq#are-there-any-restrictions-on-using-ip-addresses-within-these-subnets

當在複雜的環境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 雲中,恰是如此!

繼續閱讀