RealServer脚本
#!/bin/bash # # 描述: LVS DR模型真实服务器配置 # . /etc/rc.d/init.d/functions VIP=192.168.168.100 case "$1" in start) /sbin/ifconfig lo:3 $VIP netmask 255.255.255.255 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 ;; stop) /sbin/ifconfig lo:3 down echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce ;; status) islothere=`/sbin/ifconfig lo:3 | grep $VIP` isrothere=`netstat -rn | grep "lo:3" | grep $VIP` if [ ! "$islothere" -o ! "isrothere" ];then echo "LVS-DR real server Stopped." else echo "LVS-DR real server Running." fi ;; *) echo "$0: Usage: $0 {start|status|stop}" exit 1 ;; esac
注:脚本如果是在window上编辑过后上传至linux的,需要做如下操作:
vim打开该sh文件,输入: :set ff 回车,显示fileformat=dos,重新设置下文件格式: :set ff=unix 保存退出: :wq
否则会出现No such file or directory问题
相关推荐
吴家应 2020-03-02
linuxwcj 2020-10-21
彼岸随笔 2020-10-20
yutou0 2020-10-17
jarrygao 2020-11-02
shipinsky 2020-09-23
touchfuture 2020-09-16
hongsheyoumo 2020-09-04
momoku 2020-09-11
ruancw 2020-08-27
TuxedoLinux 2020-08-18
vvu 2020-08-16
downtown 2020-08-11
luvzhan 2020-07-28
maxelliot 2020-06-28
cuixingwudi 2020-06-25
linuxdashencom 2020-06-21
旭灿 2020-06-16