Azure Load Balancer(二) 基于内部的负载均衡来转发访问请求

一,引言

  上一节,咱们使用 Azure Load Balancer 类型为外部的,来转发咱们的 Web 服务。今天咱们看看另外一种类型为 “Internal” 的 Azure Load Balancer。接下来,咱们依旧先看看基础架构图。html

--------------------我是分割线--------------------nginx

Azure Web App 部署系列:web

1,Azure Web App(一)发布你的Net Core Web 项目

2,Azure Web App(二)使用部署槽切换部署环境代码

3,Azure Web App(三)切换你的Net Core Web 项目的数据库链接字符串

4,Azure 提供负载均衡(一)Azure Traffic Manager 为咱们的Web项目提供负载均衡

5,Azure Traffic Manager(二) 基于权重与基于优先级的路由策略为咱们的Web项目提供负载均衡 

6,Azure Load Balance(一) 为咱们的Web项目提供负载均衡 

7,Azure Load Balancer(二) 基于内部的负载均衡来转发访问请求

二,正文

1,建立VM03虚拟机

选择以前建立好的 CnBateBlogWeb_VNET 的虚拟网络,选择 ”Settings => Subnets“,进入子网页面,点击 ”+ Subnet“数据库

Name:“CnBateBlogWeb_VM_SubNET”windows

Address range(CIDR block) :10.1.1.0/24后端

点击 “OK”浏览器

 

回到 Azure Portal ,选择“Create a resource”,点击 “Windows Server 2016 Datacenter”,进行建立 VM03网络

Virtual machine name:“cnBateBastionHost01”架构

Region:“East Asia”负载均衡

UserName:“cnBateBastionHost01”

Password 和 Confirm password :根据本身的实际状况进行输入确认。

点击 “Next Disks” 设置磁盘,以及设置网络配置信息

2,建立类型为 “Internal” 的 Load Balancer

Azure Portal 中 点击 “Create a resource”,输入框中输入 “Load balancer”,建立 Load balancer

Name:“lb_internal_cnbateblogweb”

Region:“East Asia”

Type 选择:“Internal”

SKU 选择:“Standard”

Virtual network 选择:“CnBateBlogWeb_VNET”

Subnet 选择:“CnBateBlogWeb_VM_SubNET”

点击 “Review + create”,进行预校验操做

 提示 “Validation passed” 校验经过,咱们点击 “Create”,进行建立 Load Balancer 操做

 3,配置 Load Balancer

首先咱们先分配后端池----两个VM

 

Name:cnbateblogweb_internal_backgroundpool

点击 “+ Add” 添加 后端 Virtual machines,而且选择以前建立好的 “cnbateblogweb01” 和 “cnbateblogweb02” ,点击 “Add”

 以下图所示,咱们能够看到刚刚添加的两个VM,咱们点击 “Add” ,进行添加操做

接下来,咱们添加 “Load balancing rules” 负载均衡器的 “Health probes(健康检查)”,咱们点击 “+ Add” 进行添加

Name:cnbateblogweb_internal_healthcheck

Protocol 选择:HTTP

Port:80

Interval(健康检查间歇时间 单位:秒):15

点击 “OK”

如图所示,咱们能够看到刚刚建立好的 健康检查信息

 而后,咱们再添加 负载均衡器的 路由规则配置信息,选择 “Settings=>Load balancer rules”,点击 “+ Add” 

Name:"cnbateblogweb_internal_HttpRule"

Port:80

Backend port:80

点击 “OK”

 如图所示,圈起来就是刚刚添加好的 路由规则配置信息

 

 最后咱们登录到VM03 上,浏览器中输入当前 Load Balancer 的 "private ip",进行测试看看结果

咱们能够看到,目前经过 VM03,咱们能够看到负载均衡器将流量转发到 “cnbateblogweb02“ 这台VM上了

4,配置nginx

下载好 windows 版的 nginx 

咱们配置一下nginx 反向代理,监听 VM03 的8081 端口,反向代理到刚刚配置好的 Azure Load Balancer 的 "private ip"

同时,咱们须要设置一下VM03 的防火墙入栈规则,将 8081 添加进去(咱们我这边测试,为了方面,我是讲整个防火墙进行关闭操做,你们不要学我啊) 

 咱们启动nginx,本地访问 VM03 的 nginx 代理的地址

 

 

 bingo,成功!🎉🎉🎉🎉🎉,此次分享按照所示的基础设施架构图完成了配置

三,结尾

   ok,今天讲解关于内部的 Load Balancer 建立,配置后端池,配置健康检查,配置负载均衡规则等,以及外部流量经过 nginx 的反向代理功能,再将流量转发到内部的 Load Balancer,咱们可能直观的看到内部的负载均衡器将流量进行转发。

做者:Allen 

版权:转载请在文章明显位置注明做者及出处。如发现错误,欢迎批评指正。

相关文章
相关标签/搜索