centos中lvs安装和配置方法

这篇文章主要讲解了“centos中lvs安装和配置方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“centos中lvs安装和配置方法”吧!

五原网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联自2013年创立以来到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联

一、lvs-nat模式

网络配置:

代码如下:


lvs-server eth0 :host-only adapter 192.168.56.101
lvs-server eth2 :Internal 192.168.0.1
real-server-1 eth0:Internal 192.168.0.2
real-server-2 eth0:Internal 192.168.0.3


 
lvs-server:
1、安装ipvsadm软件

代码如下:


yum -y install ipvsadm*
echo 1 > /proc/sys/net/ipv4/ip_forward 路由器功能,ip转发
ipvsadm -C
ipvsadm -At 192.168.56.101:80 -s rr 轮叫模式
ipvsadm -at 192.168.56.101:80 -r 192.168.0.2 -m
ipvsadm -at 192.168.56.101:80 -r 192.168.0.3 -m
ipvsadm -L -n

2、real-server-1:

代码如下:


ifconfig eth0 192.168.0.2 netmask 255.255.255.0
route add default gw 192.168.0.1

3、real-server-2

代码如下:


ifconfig eth0 192.168.0.3 netmask 255.255.255.0
route add default gw 192.168.0.1
route -n 查看路由表


 
二、lvs-ipturn

网络配置:

代码如下:


lvs-server eth0:host-only adapter 192.168.56.101
real-server-1 eth0:host-only adapter 192.168.56.102
real-server-2 eth0:host-only adapter 192.168.56.103

lvs-server:
配置虚拟ip即vip

代码如下:


ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
route add -host 192.168.56.10 dev tunl0

ivsadm -C
ipvsadm -At 192.168.56.10:80 -s rr
ipvsadm -at 192.168.56.10:80 -r 192.168.56.102 -i
ipvsadm -at 192.168.56.10:80 -r 192.168.56.103 -i
ipvsadm -L -n

real-server-1:

代码如下:


ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
route add -host 192.168.56.10 dev tunl0
echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

real-server-2:

代码如下:


ifconfig tunl0 192.168.56.10 netmask 255.255.255.255 up
route add -host 192.168.56.10 dev tunl0
echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce


 
三、lvs-dr

网络配置:

代码如下:


lvs-server eth0:host-only adapter 192.168.56.101

real-server-1 eth0:host-only adapter 192.168.56.102

real-server-2 eth0:host-only adapter 192.168.56.103

lvs-server:

ifconfig eth0:0 192.168.56.10 netmask 255.255.255.255

route add -host 192.168.56.10 dev eth0:0

ipvs:

代码如下:


ipvsadm -C ipvsadm -At 192.168.56.10:80 -s rr ipvsadm -at 192.168.56.10:80 -r 192.168.56.102 -g ipvsadm -at 192.168.56.10:80 -r 192.168.56.103 -g ipvsadm -L -n

real-server-1: ifconfig lo:0 192.168.56.10 netmask 255.255.255.255 route add -host 192.168.56.10 dev lo:0 echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

real-server-2: ifconfig lo:0 192.168.56.10 netmask 255.255.255.255 route add -host 192.168.56.10 dev lo:0 echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

感谢各位的阅读,以上就是“centos中lvs安装和配置方法”的内容了,经过本文的学习后,相信大家对centos中lvs安装和配置方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


文章名称:centos中lvs安装和配置方法
分享地址:http://scjbc.cn/article/ppcodh.html

其他资讯