前端机的执行命令和启动,这里我们采用nginx做前端机:
# /etc/init.d/lvsdr
# nginx机子
# 在/etc/init.d下创建lvsdr,内容如下:
# 修改脚本权限:chmod +x /etc/init.d/lvsdr
# 启动real server:service lvsdr start
# 停止real server:service lvsdr stop
# 在/etc/init.d下创建lvsdr,内容如下:
/etc/init.d/lvsdr:
########################
VIP=10.235.165.100 #虚拟ip,根据需求修改
. /etc/rc.d/init.d/functions
case $1 in
start)
echo "lo:0 port starting"
# 为了相应lvs调度器转发过来的包,需在本地lo接口上绑定vip
ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
# 限制arp请求
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
;;
stop)
echo "lo:0 port closing"
ifconfig lo:0 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
;;
*)
echo "Usage: $0 {start ¦ stop}"
exit 1
esac
转载请注明:SuperIT » 一步步教你lvs之教程四—nginx执行命令和启动