Linux命令窗口直接Ctrl+C退出,那么mongod就会被关闭
$ mongod
2016-02-01T17:51:24.743+0800 I CONTROL [initandlisten] MongoDB
starting : pid=19587 port=27017 dbpath=/data/db 64-bit host=iZ28krk4xlkZ
在使用 mongod 的配置中运行 --fork 不行
mongod --fork
BadValue --fork has to be used with --logpath or --syslog
try 'mongod --help' for more information
根据提示 修改如下 还是error
mongod --fork --logpath '/data/log'
about to fork child process, waiting until server is ready for connections.
forked process: 28117
ERROR: child process failed, exited with error number 1
使用官方 的 安装 文档
如何 持久化运行 mongodb 服务
nohup mongod &
Set fork to true, it is best to create a configuration file, and then mongod -f mongo.conf, mongo.conf is the configuration file
port = 12345
dbpath = data
dblog = log/mongod.log #logpath
fork = true
It seems that the log path was renamed logpath in 3.0
Can use supervisor and nohup commands
If you follow the tutorial on the official website, you should see
sudo service mongod start
this command, so that mongodb will run as a service in the background.The above methods all bypass the cause of the error.
Under normal circumstances: mongod --fork --logpath '/data/log' can be started successfully in the background (available for personal testing)
It is recommended to check:
Is there a file /data/log
If yes, check the access permissions of the file to see if the current user has write permissions.