您好,登錄后才能下訂單哦!
這篇文章主要講解了“centos中lvs安裝和配置方法”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“centos中lvs安裝和配置方法”吧!
一、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</p>
<p>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</p>
<p>real-server-1 eth0:host-only adapter 192.168.56.102</p>
<p>real-server-2 eth0:host-only adapter 192.168.56.103</p>
<p>lvs-server:</p>
<p>ifconfig eth0:0 192.168.56.10 netmask 255.255.255.255</p>
<p>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</p>
<p>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</p>
<p>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安裝和配置方法這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。