• MongoDB安装与配置启动


    1、下载安装包。mongodb-linux-x86_64-rhel62-3.6.3.tgz

    2、解压。修改名字。

    3、修改配置文件:

    # mongodb.conf

    #where to log
    logpath=/eyuroot/mongodb/log/mongodb.log              

    # fork and run in background
    fork = true

    #port = 27017

    dbpath=/eyuroot/mongodb/data   

    pidfilepath=/eyuroot/mongodb/mongodb.pid

    4、启动脚本:

    #!/bin/sh
    #
    # mongodb init file for starting up the MongoDB server
    #
    # chkconfig: - 20 80
    # description: Starts and stops the MongDB daemon that handles all
    # database requests.

    # Source function library.
    . /etc/rc.d/init.d/functions

    exec="/usr/bin/mongod"
    prog="mongod"
    logfile="/eyuroot/mongodb/log/mongodb.log"
    options=" -f /etc/mongod.conf"

    [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

    lockfile="/var/lock/subsys/mongod"

    start() {
    [ -x $exec ] || exit 5
    echo -n $"Starting $prog: "
    #daemon --user mongod "$exec --quiet $options run >> $logfile 2>&1 &"

    daemon --user mongod "$exec --quiet $options run > /dev/null"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
    }

    stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
    }

    restart() {
    stop
    start
    }

    reload() {
    restart
    }

    force_reload() {
    restart
    }

    rh_status() {
    # run checks to determine if the service is running or use generic status
    status $prog
    }

    rh_status_q() {
    rh_status >/dev/null 2>&1
    }

    case "$1" in
    start)
    rh_status_q && exit 0
    $1
    ;;
    stop)
    rh_status_q || exit 0
    $1
    ;;
    restart)
    $1
    ;;
    reload)
    rh_status_q || exit 7
    $1
    ;;
    force-reload)
    force_reload
    ;;
    status)
    rh_status
    ;;
    condrestart|try-restart)
    rh_status_q || exit 0
    restart
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
    exit 2
    esac
    exit $?

    5、如果有报错,请检查目录权限。

    6、加入到开机启动中:

    chkconfig --add mongod

    chkconfig mongod on

  • 相关阅读:
    cocos2d-x 团队碰面有感
    2014年3月份 月会
    2014年特种兵训练营感想
    web 的简单框架
    【实用小技巧】virtual box 虚拟机复制
    flash的Socket通讯沙箱和安全策略问题
    Codeforces Round #237 (Div. 2)
    类的静态常量数组初始化
    关于自己的成长计划
    Android
  • 原文地址:https://www.cnblogs.com/magmell/p/8610459.html
Copyright © 2020-2023  润新知