编写启动关闭脚本
目前来看,启动关闭mongoDB,因为要读取配置文件,所以感觉特别麻烦,所以编写一个脚本。
进入mongdb的bin目录下,创建脚本
vim mongodb.sh
1
编写脚本
start() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/etc/mongodb.conf
}
stop() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/etc/mongodb.conf --shutdown
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit
esac
保存退出。
修改脚本文件为可执行文件
chmod +x mongodb.sh
验证脚本
sh mongodb.sh start
sh mongodb.sh stop
sh mongodb.sh restart
版权声明:本文为CSDN博主「E_Eric12138」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/E_Eric12138/article/details/89606950