简体   繁体   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

在此处输入图像描述 I am doing the course M103 from MongoDB University.我正在学习 MongoDB 大学的 M103 课程。 They're having a lab section that we need to solve.他们有一个我们需要解决的实验室部分。 I am stuck with Chapter 1: The Mongod Lab: Logging to a Different Facility我被第 1 章卡住了:Mongod 实验室:登录到不同的设施

Update your configuration file such that:更新您的配置文件,以便:

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

anyone can please explain to me the detailed procedure.任何人都可以向我解释详细的程序。 I am getting an error while solving it.我在解决它时遇到错误。

  1. mongod --logpath /var/mongodb/logs/mongod.log mongod --logpath /var/mongodb/logs/mongod.log
  2. mongod --config mongod.conf mongod --config mongod.conf
  3. Login with the user in order to validate your work以用户身份登录以验证您的工作

You can simply run in the shell the following line:您可以简单地在 shell 中运行以下行:

mongod --fork --logpath /var/mongodb/logs/mongod.log --config mongod.conf
  • --logpath /var/mongodb/logs/mongod.log to set the log file --logpath /var/mongodb/logs/mongod.log设置日志文件
  • --fork to run a mongod process as a daemon (ie fork) --fork将 mongod 进程作为守护进程运行(即 fork)

Apart from the previously given answers, you can simply add this to the conf file:除了之前给出的答案,您可以简单地将其添加到 conf 文件中:

... ...

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

And then execute然后执行

mongod --f mongod.conf mongod --f mongod.conf

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

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