问题描述
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个。
(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