zoukankan      html  css  js  c++  java
  • LVS Director端服务启动脚本

     1 #!/bin/bash
     2 # 手动安装lpvs前端管理工具
     3 # chkconfig:    -    85     15
     4 # 
     5 # lvs启动脚本:director
     6 # lvs模式类型:nat、dr、ipip
     7 # lvs代理协议:tcp、udp、mark
     8 
     9 # 检测输入类型是否为tcp/udp/mark
    10 function check_type()
    11 {
    12     while true
    13         do
    14             read -p "tcp/udp/mark:" TYPE
    15                 if [[ $TYPE == tcp ]]
    16                 then
    17             type=t
    18                         break
    19                 elif [[ $TYPE == udp ]]
    20                 then
    21             type=u
    22                         break
    23                 elif [[ $TYPE == mark ]]
    24                 then
    25             type=f
    26                            break
    27                 else
    28                         echo "Type Error"
    29                         continue
    30                 fi
    31         done
    32 }
    33 
    34 # 检测输入模式是否为nat/dr/ipip
    35 function check_mode()
    36 {
    37         while true
    38         do
    39                 read -p "nat/dr/ipip:" MODE
    40                 if [[ $MODE == nat ]]
    41                 then
    42                         mode=m
    43                         break
    44                 elif [[ $MODE == dr ]]
    45                 then
    46                         mode=g
    47                         break
    48                 elif [[ $MODE == ipip ]]
    49                 then
    50                         mode=i
    51                         break
    52                 else
    53                         echo "Mode Error"
    54                         continue
    55                 fi
    56         done
    57 }
    58 
    59 
    60 case $1 in
    61 start)
    62 # 虚拟物理接口
    63 #       ifconfig ethX:0 $VIP netmask 255.255.255.255 up   
    64         read -p "input the IP what you will do lvs:" VIP
    65         read -p "input the PORT what you will do lvs:" PORT
    66         check_type  
    67         check_mode
    68         read -p "how many RIP you need:" RIPNUM
    69 # 打开转发
    70 #    echo "1" > /proc/sys/net/ipv4/ip_forward     
    71     ipvsadm -A -$type $VIP:$PORT -s rr
    72     for ((i=1;i<=$RIPNUM;i++))
    73          do
    74         read -p "请输入第$i个RIP:" RIP
    75               ipvsadm -a -$type $VIP:$PORT -r $RIP -$mode
    76          done
    77          echo "lvs $MODE on $VIP:$PORT start success"
    78          ;;
    79 stop)
    80 # 虚拟物理接口
    81 #    ifconfig ethX:0 down    
    82          read -p "input the IP what you will do lvs:" VIP
    83          read -p "input the PORT what you will do lvs:" PORT
    84         check_type
    85 # 关闭转发
    86 #    echo "0" > /proc/sys/net/ipv4/ip_forward
    87          ipvsadm -D -$type $VIP:$PORT
    88     echo "lvs on $VIP:$PORT is down"
    89          ;;
    90 esac
  • 相关阅读:
    io
    api 类库
    文档生成工具
    数据存储
    uml vs2010
    IE,firefox下jquery获取一组checkbox选中值的问题
    如何通过Jquery简单又快速的获取一组radio的取值呢?
    WCF重载的方式
    Jquery文本框赋值
    Jquery以name获取值
  • 原文地址:https://www.cnblogs.com/armo/p/7085669.html
Copyright © 2011-2022 走看看