在很多LOB场景中,除了要对WEB和APP做负载均衡外,很多情况下对数据库也需要负载均衡,才能让客户体验进一步提升,同时保证系统数据库可用性。

然后在为数据库做负载均衡时,同时又要保证访问和数据的安全,所以需要在内部实现负载均衡。目前Azure已经提供了内部负载均衡(ILB),与NSG(之前的文章)配合使用,既能负载流量,同时充分保证安全。

1 场景介绍

使用2个云服务的ILB拓扑:

clip_image002[7]

使用1个云服务的ILB拓扑:

clip_image004[4]

对于跨界 Azure 虚拟网络中的 Azure 虚拟机上运行的 Intranet LOB 应用程序,ILB 可以对来自 Intranet 客户端的流量执行负载平衡。

clip_image006[4]

2 配置ILB

数据库IP配置如下:

clip_image008[4]

2.1 创建 ILB 的一个实例

该实例将从云服务或虚拟网络的地址池中获取分配的虚拟 IP (VIP) 地址。

命令格式:

$svc="<Cloud Service Name>"

$ilb="<Name of your ILB instance>"

$subnet="<Name of the subnet within your virtual network-optional>"

$IP="<The IPv4 address to use on the subnet-optional>"

Add-AzureInternalLoadBalancer -ServiceName $svc -InternalLoadBalancerName $ilb –SubnetName $subnet –StaticVNetIPAddress $IP

clip_image010[4]

2. 添加与虚拟机对应的将接收负载平衡流量的终结点。

$svc="<Cloud service name>"

$vmname="<Name of the VM>"

$epname="<Name of the endpoint>"

$prot="tcp" or "udp"

$locport=<local port number>

$pubport=<public port number>

$ilb="<Name of your ILB instance>"

Get-AzureVM –ServiceName $svc –Name $vmname | Add-AzureEndpoint -Name $epname -Protocol $prot -LocalPort $locport -PublicPort $pubport –DefaultProbe -InternalLoadBalancerName $ilb | Update-AzureVM

clip_image012[4]

添加第二个实例

clip_image014[4]

查看负载平衡器

clip_image016[4]