mongodb 启动 mongod fork,错误:子进程失败,以错误号 1 退出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28591101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:18:31  来源:igfitidea点击:

Starting mongod fork, ERROR: child process failed, exited with error number 1

mongodbunixamazon-ec2

提问by Ryder Bergerud

In attempting to run the command

在尝试运行命令时

mongod --fork --logpath /var/log/mongodb.log

On a amazon ec2 32 bit instance (Amazon Linux AMI release 2014.09), I run into the following error:

在 amazon ec2 32 位实例(Amazon Linux AMI 版本 2014.09)上,我遇到以下错误:

2015-02-18T18:14:09.007+0000 
2015-02-18T18:14:09.007+0000 warning: 32-bit servers don't have journaling    
enabled by default. Please use --journal if you want durability.
2015-02-18T18:14:09.007+0000 
about to fork child process, waiting until server is ready for connections.
forked process: 17116
ERROR: child process failed, exited with error number 1

I also notice no log file is created in the process.

我还注意到在此过程中没有创建日志文件。

回答by onetwopunch

I had the same thing and it turned out to be a permissions issue. If the owner of the child process cannot access the log path or the log path does not exist, it will fail.

我有同样的事情,结果证明是权限问题。如果子进程的所有者无法访问日志路径或日志路径不存在,则会失败。

What I did was put the log directory in my home directory:

我所做的是将日志目录放在我的主目录中:

mkdir ~/log
mongod --fork --logpath ~/log/mongodb.log

If you really want to put it in your /var/log directory, just change the permissions.

如果你真的想把它放在你的 /var/log 目录中,只需更改权限即可。

回答by Nathan L.

I also had the same error, however I used sudo it and ran sudo mongod --fork --logpath /var/log/mongodb.log. As @jryancanty mentioned, it's simply a permissions error.

我也有同样的错误,但是我使用了 sudo it 并运行了sudo mongod --fork --logpath /var/log/mongodb.log. 正如@jryancanty 所提到的,这只是一个权限错误。

回答by parsethis

For anyone else running into this error [even if you run it with sudo] make sure that you state the filename of the log file as in: /var/log/mongodb.log. I had just the directory path as in /var/log/ since I miss read the mongo docs.

对于遇到此错误的任何其他人[即使您使用 sudo 运行它],请确保将日志文件的文件名声明为:/var/log/mongodb.log。我只有 /var/log/ 中的目录路径,因为我错过了阅读 mongo 文档。

回答by rlib

I have deleted old

我删除了旧的

/var/run/mongodb/mongod.pid

and all worked.

和所有的工作。

回答by Patience Mpofu

I incorrectly set the log path to var/mongodb/db/mongo.log instead of /var/mongodb/db/mongo.log so Mongo was trying to access a non-existent folder in /home.

我错误地将日志路径设置为 var/mongodb/db/mongo.log 而不是 /var/mongodb/db/mongo.log,因此 Mongo 试图访问 /home 中不存在的文件夹。

回答by Alexander

I have same issue after remove mongo from EPEL repo (2.x) and install mongo from mongo repo (4.x).

从 EPEL 存储库 (2.x) 中删除 mongo 并从 mongo 存储库 (4.x) 安装 mongo 后,我遇到了同样的问题。

journalctl -xe says:

journalctl -xe 说:

ERROR: child process failed, exited with error number 1

In my case I have old log file with root permissions. Just set correct permission or delete log and check log directory permission.

就我而言,我有具有 root 权限的旧日志文件。只需设置正确的权限或删除日志并检查日志目录权限。

回答by Raghav Gupta

This error is also generated if you are already having folder for dbpath where db data is being stored and in conf file you gave a new path for dbpath. When you are creating new folders for dbpath, logs and PID then delete the old ones, if they are there.

如果您已经拥有存储 db 数据的 dbpath 文件夹,并且在 conf 文件中为 dbpath 提供了新路径,也会生成此错误。当您为 dbpath、logs 和 PID 创建新文件夹时,请删除旧文件夹(如果它们在那里)。

回答by masterforker

If you have a keyfile, it is also possible that the permissions are too open. Make sure you set it to 0400

如果您有密钥文件,也可能是权限太开放。确保将其设置为 0400

回答by kgs

this might work if you see issues with /tmp/mongodb-27017.sock in the log file

如果您在日志文件中看到 /tmp/mongodb-27017.sock 的问题,这可能会起作用

sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

须藤 chown mongodb:mongodb /tmp/mongodb-27017.sock

回答by zKaj

sudo mongod --fork --logpath /var/log/mongodb.log

须藤 mongod --fork --logpath /var/log/mongodb.log

In ubuntu no need to change permissions in /var, use full logfile name in logpath

在 ubuntu 中无需更改 /var 中的权限,在日志路径中使用完整的日志文件名