您好,登錄后才能下訂單哦!
LVS-DR部署腳本
#!/bin/bash
VIP=192.168.11.100
DIP=192.168.11.11
RIP1=192.168.11.12
RIP2=192.168.11.13
POST=80
lvs_dr() {
ifconfig eth0:0 $VIP netmask 255.255.255.0 up
route add -host $VIP dev eth0:0
rpm -q ipvsadm && echo "ipvsadm exists" || yum -y install ipvsadm &> /dev/null
echo 1 > /proc/sys/net/ipv4/ip_forward
ipvsadm -C
ipvsadm -At ${VIP}:${POST} -s wrr
ipvsadm -at ${VIP}:${POST} -r ${RIP1}:${POST} -g -w 1
ipvsadm -at ${VIP}:${POST} -r ${RIP2}:${POST} -g -w 3
ipvsadm -Ln
}
rs_web() {
ifconfig lo:0 $VIP netmask 255.255.255.255 up
route add -host $VIP dev lo:0
rpm -q httpd && echo "httpd already installd" || yum -y install httpd &>/dev/null
systemctl restart httpd
systemctl enable httpd
web_ip=$(ifconfig eth0 | awk '/netmask/{print $2}')
echo $web_ip > /var/www/html/index.html
curl $web_ip
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p
}
case $1 in
start)
lvs_dr
ipvsadm --save
;;
stop)
ipvsadm -C
ipvsadm -Ln
;;
rs_web)
rs_web
;;
*)
echo "usage : $0 [start|stop|rs_web]"
;;
esac
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。