zoukankan      html  css  js  c++  java
  • 使用脚本管理mongodb服务

    [root@MongoDB ~]# cat /etc/init.d/mongod  
    #!/bin/bash
     
     
    MONGODIR=/usr/local/mongodb
    MONGOD=$MONGODIR/bin/mongod
    MONGOCONF=/etc/mongodb.conf
    InfoFile=/tmp/start.mongo
     
    . /etc/init.d/functions 
     
    status(){
      PID=`awk 'NR==2{print $NF}' $InfoFile`
      Run_Num=`ps -p $PID|wc -l`
      if [ $Run_Num -eq 2 ]; then
        echo "MongoDB is running"
      else 
        echo "MongoDB is shutdown"
        return 3
      fi
    }
     
    start() {
      status &>/dev/null
      if [ $? -ne 3 ];then 
        action "启动MongoDB,服务运行中..." /bin/false 
        exit 2
      fi
      $MONGOD -f $MONGOCONF
      if [ $? -eq 0 ];then 
        action "启动MongoDB" /bin/true
      else
        action "启动MongoDB" /bin/false
      fi
    }
     
     
    stop() {
      $MONGOD -f $MONGOCONF --shutdown
      if [ $? -eq 0 ];then
        action "停止MongoDB" /bin/true
      else 
        action "停止MongoDB" /bin/false
      fi 
    }
     
     
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      restart)
        stop
        sleep 2
        start
        ;;
      status)
        status
        ;;
      *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
    esac
  • 相关阅读:
    Nginx简单认识
    Redis简单入门认识
    用户体验报告——脉脉
    zine结构图
    猫眼电影原型图
    关于共享单车的一点思考
    用户体验报告——网易严选
    Zine和石墨文档竞品分析
    用户体验报告——石墨文档
    集合框架2
  • 原文地址:https://www.cnblogs.com/liang545621/p/12605846.html
Copyright © 2011-2022 走看看