您好,登录后才能下订单哦!
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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。