liuming794 发表于 2019-1-5 12:22:59

集群 之 LVS

  LVS集群常用的模式有三种,LVS-DR为最常用的一种,但有时LVS-NAT模式也会用到;该实验为NAT模式配置
  仅实现负载均衡,高可用不再配置
  三台服务器:
  Directorserver:
     eth0:192.168.70.135
     eth1:192.168.132.130
  
  Real server1:eth0:192.168.132.128
  Real server2:eth0 :192.168.132.129
  1.配置Realserver1
  
# nl /var/www/jiang/zhu.html
1
2My name is192.168.70.136
3
# route add default gw 192.168.132.130 #添加路由,网关为Director的内网ip地址
# route -n
Kernel IP routing table
Destination   Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.132.0   0.0.0.0         255.255.255.0   U   0      0      0 eth0
169.254.0.0   0.0.0.0         255.255.0.0   U   0      0      0 eth0
0.0.0.0         192.168.132.130 0.0.0.0         UG    0      0      0 eth0  
  2.配置Realserver2
  
# nl /var/www/jiang/zhu.html
1
2192.168.70.137 is my name
3
# route add default gw 192.168.132.130
# route -n
Kernel IP routing table
Destination   Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.132.0   0.0.0.0         255.255.255.0   U   0      0      0 eth0
169.254.0.0   0.0.0.0         255.255.0.0   U   0      0      0 eth0
0.0.0.0         192.168.132.130 0.0.0.0         UG    0      0      0 eth0  3.配置Director server
  
# ifconfig eth0:0 192.168.70.99
# ipvsadm -A -t 192.168.70.99:80-s rr
# ipvsadm -a -t 192.168.70.99:80 -r 192.168.132.128 -m
# ipvsadm -a -t 192.168.70.99:80 -r 192.168.132.129 -m
# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port         Forward Weight ActiveConn InActConn
TCP192.168.70.99:80 rr
-> 192.168.132.129:80         Masq    1      0          0
-> 192.168.132.128:80         Masq    1      0          0  
  4.访问测试:
  http://blog.运维网.com/attachment/201309/164650283.jpg
  
  http://blog.运维网.com/attachment/201309/164726365.jpg
  
  负载均衡实现完成
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  



页: [1]
查看完整版本: 集群 之 LVS