search

Home  >  Q&A  >  body text

mongodb - Ubuntu下 mongod 在shell 界面 按 ctrl +c 就退出服务了

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 服务

phpcn_u1582phpcn_u15822832 days ago970

reply all(5)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-02 09:19:46

    nohup mongod &

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:19:46

    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

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:19:46

    Can use supervisor and nohup commands

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-02 09:19:46

    If you follow the tutorial on the official website, you should see sudo service mongod startthis command, so that mongodb will run as a service in the background.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:19:46

    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:

    1. Is there a file /data/log

    2. If yes, check the access permissions of the file to see if the current user has write permissions.

    reply
    0
  • Cancelreply