MongoDB can be started by command line and configuration file, the specific command is as follows:
Command line:
[[email protected] MongoDB] # ./bin/mongod--dbpath=/data/db
Configuration file:
[[email protected] MongoDB] # ./bin/mongod-f mongodb.conf
However, both of these methods start the MongoDB process in the foreground, and if the session window is closed, the MongoDB process also stops. But MongoDB also provides a background daemon way to start, only need to add a "--fork" parameter, it is worth noting that the "--fork" parameter must be enabled "--logpath" parameter. As shown below:
[[email protected] MongoDB] # ./bin/mongod--dbpath=data/db--fork--fork have to being used with--logpath[[email protected] MongoDB]
#
all output going to:/opt/mongodb/log/
3300
[[email protected] MongoDB]
#
The fork parameter that the daemon mode starts can also be configured in the configuration file as follows:
port=27017dbpath=data/dblogpath=log/mongodb.loglogappend=truefork=true
Then the configuration file starts after MongoDB is also started in the background:
[[email protected] MongoDB] # all output going to:/opt/mongodb/log/3377
Reference: http://chenzhou123520.iteye.com/blog/1634676
MongoDB Background Daemon mode start