网络配置
1 | +----------+ |
环境安装
配置Server
客户端路由指向LB
1
route add -net 192.168.43.0 netmask 255.255.255.0 gw 192.168.2.128
配置http server
1
2systemctl start nginx
echo "192.168.2.131" > /usr/share/nginx/html/index.html
配置LB
系统使用centos 7
安装ipvsadm
1
2
3
4yum -y install ipvsadm
# enable IP forward
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p配置ipvs
1 | export VIP=192.168.43.225 |
其中lc表示采用基于最小连接数的负载均衡算法
测试
在客户端上用浏览器或者curl 访问
1 | http://192.168.43.225 |
这时候会返回Real Server响应的内容
1 | # curl http://192.168.43.225 |