首页 > 系统服务 > 详细

Shell之企业实际工作案例2

时间:2018-04-01 16:55:24      阅读:193      评论:0      收藏:0      [点我收藏+]
案例一:

【LVS客户端节点】开发LVS客户端设置VIP以及抑制ARP的管理脚本

脚本内容:

#!/bin/bash
##############################################################
# File Name: lvs_client.sh
# Version: V1.0
# Author: da ya
# Organization: 12345@qq.com
# Created Time : 2018
# Description:
##############################################################

. /etc/init.d/functions
Vip=`ip a s lo|grep 10.0.0.13|wc -l`

function Start(){
  if [ $Vip -eq 1 ];then
    action 'Vip is alreadly exists' /bin/true
  else
    ip addr add 10.0.0.13/32 dev lo
    echo -e 'net.ipv4.conf.all.arp_ignore = 1\nnet.ipv4.conf.all.arp_announce = 2\nnet.ipv4.conf.lo.arp_ignore = 1\nnet.ipv4.conf.lo.arp_announce = 2' >/etc/sysctl.conf
    sysctl -p &>/dev/null
    action 'Vip is started' /bin/true
  fi
}

function Stop(){
  ip addr del 10.0.0.13/32 dev lo &>/dev/null
  action 'Vip is delete' /bin/true
}

case $1 in
start)
  Start
;;
stop)
  Stop
;;
restart)
  Stop
  sleep 1
  Start
;;
*)
  echo "Please Input $0 { start|stop|restart }"
;;
esac

进行测试:

技术分享图片

案例二:

【LVS主节点】模拟keepalived健康检查功能管理LVS节点,

当节点挂掉(检测2次,间隔2秒)从服务器池中剔除,好了(检测2次,间隔2秒)加进来

提示:利用ipvsadm命令实现添加和减少LVS节点。

脚本内容:



Shell之企业实际工作案例2

原文:http://blog.51cto.com/13520772/2093546

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!