1. 程式人生 > >mongodb啟動腳本

mongodb啟動腳本

啟動腳本 mongodb

[[email protected] local]# cat /etc/init.d/mongod

#!/bin/sh

## chkconfig: 2345 65 38

source /etc/profile

CONFIG=/usr/local/mongodb/mongod.cnf

PROGRAM=/usr/local/mongodb/bin/mongod

MONGOPID=`ps -ef | grep ‘mongod --config‘ | grep -v grep | awk ‘{print $2}‘`

test -x $PROGRAM || exit 0

case "$1" in

start)

echo "Starting MongoDB Server..."

$PROGRAM --config $CONFIG &

;;

stop)

echo "Stopping MongoDB Server..."

if [ ! -z "$MONGOPID" ]; then

kill -15 $MONGOPID

fi

;;

status)

if [ -z "$MONGOPID" ]; then

echo "MongoDB is not running!"

else

echo "MongoDB is running!("$MONGOPID")"

fi

;;

restart)

echo "Shutting down MongoDB Server..."

if [ ! -z "$MONGOPID" ]; then

kill -15 $MONGOPID

fi

echo "Starting MongoDB..."

$PROGRAM --config $CONFIG &

;;

*)

log_success_msg "Usage:/etc/init.d/mongod {start|stop|status|restart}"

exit 1

esac

exit 0


mongodb配置文件:

[[email protected] local]# cat /usr/local/mongodb/mongod.cnf

logpath=/usr/local/mongodb/logs/log

logappend = true

#fork and run in background

fork = true

#port = 27017

dbpath=/usr/local/mongodb/data

#location of pidfile

pidfilepath=/usr/local/mongodb/mongod.pid

auth = true


本文出自 “10931853” 博客,請務必保留此出處http://wujianwei.blog.51cto.com/10931853/1962577

mongodb啟動腳本