清风听雨 发表于 2019-1-5 12:39:10

LVS群集的负载均衡技术

  LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统。使用集群技术和Linux操作系统实现一个高性能、高可用的服务器. 很好的可伸缩性(Scalability) 很好的可靠性(Reliability) 很好的可管理性(Manageability)。
  拟网络服务的主要技术,指出IP负载均衡技术是在负载调度器的实现技术中效率最高的。在已有的IP负载均衡技术中,主要有通过网络地址转换(Network Address Translation)将一组服务器构成一个高性能的、高可用的虚拟服务器,我们称之为VS/NAT技术(Virtual Server via Network Address Translation)。在分析VS/NAT的缺点和网络服务的非对称性的基础上,我们提出了通过IP隧道实现虚拟服务器的方法VS/TUN (Virtual Server via IP Tunneling),和通过直接路由实现虚拟服务器的方法VS/DR(Virtual Server via Direct Routing),它们可以极大地提高系统的伸缩性。VS/NAT、VS/TUN和VS/DR技术是LVS集群中实现的三种IP负载均衡技术。
  我想最常用的是vs/nat和vs/dr技术吧。
  下面进行vs/nat的配置,如以下简易图:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561023WqBs.png
  环境描述:本文在配置LVS时使用三台linux,虚拟VIP:192.168.145.100
  一台做Directorserver
两台做realserver
  一台xp系统的客户机
  先进行Directorserver的 配置:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610318nOl.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561034tnKn.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561035xyfu.png
  打开路由转发功能:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561044zqDo.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561044AUhG.png
  让其生效;
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561045VH7d.png
  查看ip_vs信息:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610454CYM.png
  创建光盘挂载点,并挂载:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561046y0Cl.png
  编辑yum:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561046wjme.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561047w58F.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610473brM.png
  查看ipvs有哪些工具:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610475hVl.png
  然后安装这个(管理工具)软件包:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610483rka.png
  使用命令可以用man命令来查看
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561048hbLd.png
  虚拟的web服务,并使用rr轮回算法:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561049LrhW.png
  把访问的虚拟web时候,转发给真实的站点,-m是表示做nat模型:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610492SC3.png
  然后保存这些服务,不然启动不了ipvsadm服务:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561050EYeH.png
  启动服务:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561050Vofr.png
  查看链接信息:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561051VBR8.png
  再启动两台服务器(realserver):
  配置相关信息:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561052WpM6.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561052tOZC.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561053pWbD.png
  然后安装httpd服务:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561054MfOp.png
  然后编辑一个简单的网页,并启动http服务:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561055CY95.png
  再编辑另一台服务器:
  配置ip和网关:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561055ZDns.png
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561055bvlK.png
  安装http:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561057zoe9.png
  启动服务并编辑网页;:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561060yGEu.png
  配置完成,进行测试:
  客户机xp浏览器访问虚拟ip:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610653B35.png
  可看到在真实服务器中的信息,点击刷新:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561074PLbL.png
  可以看到轮询的结果了;
  我们把rr轮询模式变成dh目标哈希模式:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561079e90L.png
  访问试试看:
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_1350561081c96E.png
  一直刷新也一直是web1,并不会变成web2.可以看到连接的信息2.100服务器连接数从9变成了16,而2.101服务器连接数还是5,并没有变。
http://运维网blog.blog.运维网.com/attachment/201210/18/5627295_13505610824E1u.png
  当另一个客户来访问时,就会直接访问web2了,并且一直访问web2.
  Dh目标哈希就是把客户请求固定给某个服务器。



页: [1]
查看完整版本: LVS群集的负载均衡技术