成都网站建设设计

将想法与焦点和您一起共享

LVS-DR部署

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

创新互联公司成都企业网站建设服务,提供网站制作、成都网站建设网站开发,网站定制,建网站,网站搭建,网站设计,成都响应式网站建设,网页设计师打造企业风格网站,提供周到的售前咨询和贴心的售后服务。欢迎咨询做网站需要多少钱:18982081108

}
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


新闻名称:LVS-DR部署
文章地址:http://chengdu.cdxwcx.cn/article/igjcdc.html