LVS集群NAT DR模式

LVS集群nat模式

1、 lvs调度算法

常用的4种:rr wrr lc wlc

2、LVS-NAT负载均衡集群

环境配置:

LVS集群NAT DR模式

2.1、开启路由转发功能

在lvs 执行如下操作:

vim /etc/sysctl.conf

net.ipv4.ip_forward = 1


sysctl -p

2.2、web安装

yum install httpd -y

systemctl start httpd

echo web30 > /var/www/html/test.html

echo web40 > /var/www/html/test.html

访问网址:


http://192.168.139.118/test.html

2.3、设置网关地址(DIP)

route add default gw 192.168.139.116 #两台web

LVS集群NAT DR模式

route add default gw 192.168.0.14 #client

2.4、配置client

yum install elinks -y

elinks --dump

elinks --dump

2.5、配置lvs

yum -y install ipvsadm

ipvsadm

lsmod | grep ip_vs

LVS集群NAT DR模式

添加虚拟服务:

ipvsadm -A -t 192.168.0.14:80 -s rr

ipvsadm -ln

LVS集群NAT DR模式

添加realserver:

ipvsadm -a -t 192.168.0.14:80 -r 192.168.139.117:80 -m

ipvsadm -a -t 192.168.0.14:80 -r 192.168.139.118:80 -m

ipvsadm -ln

LVS集群NAT DR模式

保存lvs策略:

ipvsadm-save

2.6、客户端测试192.168.0.13

yum install elinks -y

elinks --dump


ipvsadm -Ln --stats

LVS集群NAT DR模式

3、 ipvsadm命令使用

ipvsadm -E -t 192.168.0.14:80 -s wrr

LVS集群NAT DR模式

ipvsadm -e -t 192.168.0.14:80 -r 192.168.139.117:80 -w 3 -m

LVS集群NAT DR模式

ipvsadm命令选项:

-A -E -e -w -a -d -C --stats

-m NAT模式

-g DR模式

-i TUN模式


ipvsadm -E -t 192.168.0.14:80 -s wrr

ipvsadm -e -t 192.168.0.14:80 -r 192.168.139.117:80 -w 3

ipvsadm -d -t 192.168.0.14:80 -r 192.168.139.117:80

ipvsadm -a -t 192.168.0.14:80 -r 192.168.139.117:80 -w 3


分享到:


相關文章: