After the installation of MongoDB, has been the following start, specify Dbpath,logpath, verify auth, etc.
./mongod--dbpath=/usr/bin/mongodb/mongodb/data--logpath=/usr/bin/mongodb/mongodb/log/mongodb.log--auth
But more and more trouble, write more parameters, and are prone to error, because decided to enable a MongoDB automatic script
Writing parameters to a configuration file
Vim/usr/bin/mongodb/init.d/mongodb.conf
port=27017 #端口dbpath =e:/mongodb/mongodb/db #数据库存储路径logpath =e:/mongodb/mongodb/log/mongodb.log #日志存储路径logappend =tr UE Auth=true #开启鉴权
At this point, after using the configuration file, the startup method is simple, as follows
./mongod--config=/usr/bin/mongodb/init.d/mongodb.conf #conf配置文件所在位置
2. Shell script, self-booting MongoDB
Vim/usr/bin/mongodb/init.d/mongodb
#!/bin/bash# #chkconfig: 2345 90#description:mongodbstart () {/usr/bin/mongodb/mongodb/bin/mongod-f/usr/bin/ Mongodb/mongodb/bin/mongodb.conf & Echo "MongoDB is running background ..."}stop () {/usr/bin/mongodb/mongodb/bin/ Mongod-f/usr/bin/mongodb/mongodb/bin/mongodb.conf--shutdown echo "MongoDB is stopped."} Case "$" in start) start; stop) stop;; restart) stop start;; *) echo $ "Usage: $ Start|stop|restart}" Exit 1esac
As above, the self-startup script is completed
MongoDB Boot
/usr/bin/mongodb/init.d/mongodb start
MongoDB off
/usr/bin/mongodb/init.d/mongodb stop
This article is from the "Bulajunjun" blog, make sure to keep this source http://5148737.blog.51cto.com/5138737/1650703
MongoDB Auto-Start script