zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    洛谷 P1767 家族_NOI导刊2010普及(10)
    洛谷 P2919 [USACO08NOV]守护农场Guarding the Farm
    COGS 1619. [HEOI2012]采花
    UVA 11181 Probability|Given
    hdu 3336 Count the string
    洛谷 P2176 [USACO14FEB]路障Roadblock
    洛谷 P2691 逃离
    BZOJ 1040: [ZJOI2008]骑士
    vijos 1320 清点人数
    POJ 3417 Network
  • 原文地址:https://www.cnblogs.com/magmell/p/8610459.html
Copyright © 2011-2022 走看看