在设置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. iOS框架介绍

    iOS框架介绍      Cocoa Touch   GameKit  实现对游戏中心的支持,让用户能够在线共享他们的游戏相关的信息  iOS设备之间蓝牙数据传输   从iOS7开始过期   局域网游 ...

  2. Aandroid Error之 新导入工程报Unable to resolve target 'android-18'和R cannot be resolved

    有段时间没有写安卓了,今天导入以前的项目,结果看到控制台打印出了这样一句:Unable to resolve target 'android-18', 解决方法: 项目->属性->Andr ...

  3. js 跨域的使用

    try{document.domain="jincin.com"}catch(error){} 需要在被调用的函数和调用函数出都要加入上面相同的语句 下面看一下第二种跨域的解决方案 ...

  4. Servlet Examples

    Servlet Examples Servlet Examples 1.Hello World output: code: 1.import java.io.*;2.import javax.serv ...

  5. Android 底部Dialog显示

    public void showComplainDialog() { ComplainDialog complain_dialog = new ComplainDialog(OrderDetialAc ...

  6. SqlServer中代理作业实现总结

    今天弄SqlServer代理作业,弄了半天,把遇到的问题总结出来,主要是抨击一下Sql Server的Express版本.好了,看下面的正题. 首先,需要安装Sql Server Agent服务,该服 ...

  7. CentOS下安装Nginx并添加nginx_upload_module

    安装前,最好能保证依赖的系统软件已经升级.    yum update CentOS上安装Nginx,如果只是简单安装,不附加其他第三方模块,一句话可以搞定:    yum install nginx ...

  8. Learn LIBSVM---a practical Guide to SVM classification

    想学习一下SVM,所以找到了LIBSVM--A Library for Support Vector Machines,首先阅读了一下网站提供的A practical guide to SVM cla ...

  9. Windows服务安装完成后自动启动

    public ServiceInstaller() { //... Installer code here this.AfterInstall += new InstallEventHandler(S ...

  10. tcpdump 抓包让wireshark来分析

    在linux下面用tcpdump 抓包非常方便, 但是抓的包要提取出来进行分析, 还是得用wireshark来过滤分析比较方便. 下面先介绍一下 TCPDUMP 的使用 例:tcpdump host ...