您好,登錄后才能下訂單哦!
這篇文章主要講解了“centos中l(wèi)vs安裝和配置方法”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“centos中l(wèi)vs安裝和配置方法”吧!
一、lvs-nat模式
網(wǎng)絡(luò)配置:
代碼如下:
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轉(zhuǎn)發(fā)
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
網(wǎng)絡(luò)配置:
代碼如下:
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
網(wǎng)絡(luò)配置:
代碼如下:
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中l(wèi)vs安裝和配置方法”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)centos中l(wèi)vs安裝和配置方法這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。