集群 之 LVS-NAT模式配置

LVS集群常用的模式有三种,LVS-DR为最常用的一种,但有时LVS-NAT模式也会用到;该实验为NAT模式配置

仅实现负载均衡,高可用不再配置

三台服务器:

Director  server:

   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

 

[root@zhu4 ~]# nl /var/www/jiang/zhu.html
1  <html>
2  <h1>My name is192.168.70.136</h1>
3  </html>
[root@zhu4 ~]# route add default gw 192.168.132.130 #添加路由,网关为Director的内网ip地址
[root@zhu4 ~]# 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

 

[root@zhu3 ~]# nl /var/www/jiang/zhu.html
1  <html>
2  <h1>192.168.70.137 is my name</h1>
3  </html>
[root@zhu3 ~]# route add default gw 192.168.132.130
[root@zhu3 ~]# 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

 

[root@zhu2 ~]# ifconfig eth0:0 192.168.70.99
[root@zhu2 ~]# ipvsadm -A -t 192.168.70.99:80  -s rr
[root@zhu2 ~]# ipvsadm -a -t 192.168.70.99:80 -r 192.168.132.128 -m
[root@zhu2 ~]# ipvsadm -a -t 192.168.70.99:80 -r 192.168.132.129 -m
[root@zhu2 ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.70.99:80 rr
-> 192.168.132.129:80           Masq    1      0          0
-> 192.168.132.128:80           Masq    1      0          0

 

4.访问测试:

 

 

负载均衡实现完成

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(服务器,default,IP地址,Jiang,server1)