简体   繁体   English

无法将日志发送到 /var/mongodb/logs/mongod.log 文件并且无法将 mongod 分叉并作为守护进程运行,我无法添加用户

[英]Not able to send logs to /var/mongodb/logs/mongod.log file and not able to mongod is forked and run as a daemon and i coudnt add user

Error when doing this I am taking course in MongoDB university, They're having a lab section that we need to solve.这样做时出错我正在 MongoDB 大学上课,他们有一个我们需要解决的实验室部分。 I am stuck with Chapter 1: The Mongod Lab: Logging to a Different Facility.我被第 1 章卡住了:Mongod 实验室:登录到不同的设施。

I tried using these commands "mongod --logpath /var/mongodb/logs/mongod.log" and "mongod --config mongod.conf" after running these couldnt add the user to validate the question我尝试使用这些命令“mongod --logpath /var/mongodb/logs/mongod.log”和“mongod --config mongod.conf”在运行这些命令后无法添加用户来验证问题

Can anyone help me detail procedure of the question?谁能帮我详细说明问题的过程?

  1. mongod sends logs to /var/mongodb/logs/mongod.log mongod 将日志发送到 /var/mongodb/logs/mongod.log
  2. mongod is forked and run as a daemon (this will not work without specifying logpath) mongod 被分叉并作为守护进程运行(如果不指定 logpath,这将不起作用)

I think you may use only the configuration file to achieve whatever you need, you can configure a mongo instance to use a certain log file and to fork properly mongodb.我想你可以只使用配置文件来实现你需要的任何东西,你可以配置一个 mongo 实例来使用某个日志文件并正确地 fork mongodb。 As you can see in thismongodb documentation section .正如您在此mongodb 文档部分中所见。 You can edit your configuration file like this:您可以像这样编辑配置文件:

systemLog:
   destination: file
   path: "/var/mongodb/logs/mongod.log "
   logAppend: true
processManagement:
   fork: true

And then execute mongodb using this command: mongod --config mongod.conf然后使用以下命令执行 mongodb: mongod --config mongod.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM