- #!/bin/bash
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- OPTIONS=" -f /usr/local/mongodb/etc/mongod.conf"
- SYSCONFIG="/var/lib/mongodb/mongod.lock"
- mongod="/usr/local/bin/mongod"
- LOGDIR=/var/log/mongodb
- LOCKFILE=/var/lib/mongodb/mongod.lock
- IP=192.168.0.48
- MONGO_USER=mongod
- MONGO_GROUP=mongod
- start()
- {
- echo -n $"Starting mongod "
- $mongod --maxConns 30000 --bind_ip $IP --dbpath $LOGDIR --directoryperdb --logpath /var/log/mongodb/mongodb.log --logappend &
- }
- stop()
- {
- echo -n $"stop mongod"
- pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`; if [ "${pid}" != "" ]; then kill -2 ${pid}; fi
- }
- restart () {
- stop
- start
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload|force-reload)
- restart
- ;;
- condrestart)
- [ -f /var/lock/subsys/mongod ] && restart || :
- ;;
- status)
- status $mongod
- RETVAL=$?
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- RETVAL=1
- esac
本文转自 ppabc 51CTO博客,原文链接:http://blog.51cto.com/ppabc/817176