Mongodb定制启动服务bootup的脚本

编辑器加载中...

#!/bin/bash

#

# mongodb     Startup script for the mongodb server

#

# chkconfig: - 64 36

# description: MongoDB Database Server

#

# processname: mongodb

#



# Source function library

. /etc/rc.d/init.d/functions



if [ -f /etc/sysconfig/mongodb ]; then

        . /etc/sysconfig/mongodb

fi



prog="mongod"

mongod="/usr/local/mongodb/bin/mongod"

RETVAL=0



start() {

       echo -n $"Starting $prog: "

#      daemon $mongod "--fork --logpath /usr/local/mongodb/logs --logappend --port"

       daemon "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend  --auth  --port=27017 --fork"

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && touch /usr/local/mongodb/lock/$prog

        return $RETVAL

}



stop() {

        echo -n $"Stopping $prog: "

        killproc $prog

        RETVAL=$?

        echo

        [ $RETVAL -eq 0 ] && rm -f /usr/local/mongodb/lock/$prog

        return $RETVAL

}



reload() {

        echo -n $"Reloading $prog: "

        killproc $prog -HUP

        RETVAL=$?

        echo

        return $RETVAL

}



case "$1" in

start)

		start

		;;

	stop)

		stop

		;;

	restart)

		stop

		start

		;;

	condrestart)

		if [ -f /var/lock/subsys/$prog ]; then

			stop

			start

		fi

		;;

	reload)

		reload

		;;

	status)

		status $mongod

		RETVAL=$?

		;;

	*)

		echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"

		RETVAL=1

esac



exit $RETVAL

以上复制到cp 脚本 /etc/init.d/mongodb
 
并且芒果数据库的安装路径为/usr/local/mongodb,数据目录为data目录,日志文件为logs。

你可能感兴趣的:(mongodb)