在设置LVS客户端时,如果我们使用手工设置的话会比较麻烦。现在我们直接使用脚本来启动lvs-client就OK了,下面是一个简单的脚本。

VIP地址:10.0.0.230,把文件放到/etc/init.d/目录下,并受于755的权限就可以使用service来启动和停止了,同时也可以使用chkconfig添加为开机启动

#!/bin/bash
#author:luodi date://
#chkconfig:
#description:this script to start lvs client for the server
#version:1.0
. /etc/init.d/functions
#setting variable
VIP=10.0.0.230
#functions
start(){
ifconfig | grep $VIP >/dev/null >&
if [ $? -eq ];then
action "LVS client program already start"
exit
fi
ifconfig lo: $VIP/ up
route add -host $VIP eth0
echo "" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "" >/proc/sys/net/ipv4/conf/all/arp_announce
}
stop(){
ifconfig | grep $VIP >/dev/null >&
if [ $? -gt ];then
action "LVS client program already stop"
exit
fi
ifconfig lo: $VIP/ down
route del -host $VIP eth0
echo "" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "" >/proc/sys/net/ipv4/conf/all/arp_announce }
#loop setting
case $ in
start)
start
if [ $? -eq ];then
action "LVS client program starting successful" /bin/true
else
action "LVS client program starting successful" /bin/false
fi
;;
stop)
stop
if [ $? -eq ];then
action "LVS client program stoping successful" /bin/true
else
action "LVS client program stoping successful" /bin/false
fi
;;
status)
ifconfig | grep $VIP >/dev/null >&
if [ $? -eq ];then
echo "LVS client program is startd"
else
echo "LVS client program is stopd"
fi
;;
restart)
stop && { action "LVS client program stoping successful" /bin/true ||
action "LVS client program stoping failed" /bin/false
}
start&& { action "LVS client program starting successful" /bin/true ||
action "LVS client program starting failed" /bin/false
}
;;
*)
echo "Usage:$0 {start|stop|restart|status}"
;;
esac

LVS客户端启动脚本的更多相关文章

  1. 23:LVS客户端配置脚本案例

    [root@web03 scripts]# cat prevent_arp.sh #!/bin/bash lo_ip=$(ip a s lo|grep "10.0.0.1[3]/32&quo ...

  2. LVS Director端服务启动脚本

    #!/bin/bash # 手动安装lpvs前端管理工具 # chkconfig: - # # lvs启动脚本:director # lvs模式类型:nat.dr.ipip # lvs代理协议:tcp ...

  3. zookeeper源码分析之二客户端启动

    ZooKeeper Client Library提供了丰富直观的API供用户程序使用,下面是一些常用的API: create(path, data, flags): 创建一个ZNode, path是其 ...

  4. 老李推荐:第5章3节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 启动脚本

    老李推荐:第5章3节<MonkeyRunner源码剖析>Monkey原理分析-启动运行: 启动脚本   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性 ...

  5. rsync随机启动脚本

    服务端 #!/bin/sh # chkconfig: # description: Saves and restores system entropy pool for \ #create by xi ...

  6. mysql的启动脚本mysql.server及示例配置文件

    以MySQL-server-4.0.14-0.i3862881064151.rpm为例,放在/data目录下 cd /data rpm -ivh MySQL-server-4.0.14-0.i386. ...

  7. centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课

    centos  LNMP第一部分环境搭建 LAMP安装先后顺序  LNMP安装先后顺序 php安装 安装nginx  编写nginx启动脚本   懒汉模式  mv   /usr/local/php/{ ...

  8. linux自启动、定时启动脚本

    linux开机自启动 想让一个程序.脚本开机自启动,可以在/etc/rc.d目录下面找到rc.local文件,编辑该文件,在尾部加上需要运行的命令即可. 如: #cd /etc/rc.d #sudo ...

  9. (转)mysql5.6.7多实例安装、配置的详细讲解分析及shell启动脚本的编写

    一.mysql安装 1.下载mysql数据库源码包: wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz 2.安装mys ...

随机推荐

  1. 下拉菜单中的Option对象

    1.创建Option对象 1.1 var optionEle1 = document.createElement('option'); 1.2 var optionEle2 = new Option( ...

  2. WEB标准:标准定义、好处、名词解释、常用术语、命名习惯、浏览器兼容、代码书写规范

    1. WEB标准是什么? “WEB标准”是一系列标准的总称.一般的误区经常把WEB标准说成DIV+CSS.准确的说法应该是:采用W3C推荐的WEB标准中的XHTML1.1结合CSS2.0 样式表制作页 ...

  3. A - 高精度(大数)N次方(第二季水)

    Description Problems involving the computation of exact values of very large magnitude and precision ...

  4. 日志管理-NLog日志框架简写用法

    本文转载:http://www.blogjava.net/qiyadeng/archive/2013/02/27/395799.html 在.net中也有非常多的日志工具,今天介绍下NLog.NLog ...

  5. python解析xml

    python解析xml import xml.dom.minidom as minidom dom = minidom.parse("aa.xml") root = dom.get ...

  6. Spring中的DataBinding(一)

    DataBinding在Spring中应用. 第一点:使用ModelAttribute指定带绑定的数据内容 很重要的属性:@ModelAttribute([value=""])可以 ...

  7. WeUI

    从WeUI学习到的知识点   WeUI是微信Web服务开发的UI套件, 目前包含12个模块 (Button, Cell, Toast, Dialog, Progress, Msg, Article, ...

  8. 【配置】电信华为HG8245 无线路由器配置 有贴图

          引子:家里的电信无线路由器连接之后无法直接上上网,只能再次通过PPPoe方式拨号上网.经过网上查询和一番折腾之后,整理攻略如下. 1. 用超级用户登录192.168.1.1(默认密码) 用 ...

  9. CKEditor扩展插件:自动排版功能

    CKEditor是新一代的FCKeditor,是一个重新开发的版本.CKEditor是全球最优秀的网页在线文字编辑器之一,因其惊人的性能与可扩展性而广泛的被运用于各大网站. 如果还没接触过的可以看看, ...

  10. C#代码 json类

    using System; using System.Collections.Generic; using System.Collections; using System.Text; using S ...