在/etc/init.d/下面创建个mongod 的脚本即可
# vim /etc/init.d/mongod
#!/bin/sh
# mongod这个自带的脚本已经能快速实现启动和关闭了,下面只是做了一个service能使用的启关转换描述而已
start() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
}
stop() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf --shutdown
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
设置开机启动
# chkconfig --add mongod
# chkconfig --list //可以查看servic 列表状况