安装 mongoDB(子进程失败,以错误号 100 退出)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15963147/
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-09 13:09:17  来源:igfitidea点击:

install mongoDB (child process failed, exited with error number 100)

macosmongodbinstall

提问by Juneyoung Oh

I tried to install mongoDB on my macbook air.

我试图在我的 macbook air 上安装 mongoDB。

I've downloaded zipped file from official website and extract that file and move to root directory. After that, under that directory, I've made /data/db and /log folder.

我已经从官方网站下载了压缩文件并解压缩该文件并移动到根目录。之后,在该目录下,我创建了 /data/db 和 /log 文件夹。

Here is my mongodb.configwhich describes the basic config for my DB.

这是我的mongodb.config,它描述了我的数据库的基本配置。

dbpath = /mongodb/data/db
logpath = /mongodb/log/mongo.log
logappend = true
#bind ip = 127.0.0.1
port = 27017

fork = true
rest = true
verbose = true
#auth = true
#noauth = true

Additionally, I want to know what the #means in the config file.

另外,我想知道#配置文件中的含义。

I put this file to /mongodb/bin, /mongodbis the directory I extracted the files into.

我把这个文件放到/mongodb/bin,/mongodb是我将文件解压到的目录。

I opened terminal and entered ./mongod --config mongodb.configand I got this back.

我打开终端并进入./mongod --config mongodb.config,我得到了这个。

Juneyoung-ui-MacBook-Air:bin juneyoungoh$ ./mongod --config mongodb.config
about to fork child process, waiting until server is ready for connections.
forked process: 1775
all output going to: /mongodb/log/mongo.log
ERROR: child process failed, exited with error number 100

How can I handle this error and what this means?

我该如何处理这个错误,这意味着什么?

回答by Frambot

The data folders you created were very likely created with sudo, yes? They are owned by rootand are not writable by your normal user. If you are the only user of your macbook, then change the ownership of the directories to you:

您创建的数据文件夹很可能是用 来创建的sudo,是吗?它们归root您的普通用户所有且不可写。如果您是 macbook 的唯一用户,请将目录的所有权更改为您:

sudo chown juneyoungoh /data
sudo chown juneyoungoh /data/db
sudo chown juneyoungoh /data/log

If you plan on installing this on a public machine or somewhere legit, then read more about mongo security practices elsewhere. I'll just get you running on your macbook.

如果您打算在公共机器或合法的地方安装它,请在其他地方阅读更多关于 mongo 安全实践的信息。我会让你在你的 macbook 上运行。

回答by goldenboy

I had a similar issue and it was not related to any 'sudo' problem. I was trying to recover from a kernel panic!

我有一个类似的问题,它与任何“sudo”问题无关。我试图从内核恐慌中恢复过来!

When I look at my data folder I found out a mongod.lock file was there. In my case this page helped a lot: http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/. As they explain,

当我查看我的数据文件夹时,我发现那里有一个 mongod.lock 文件。就我而言,此页面有很大帮助:http: //docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/。正如他们解释的那样,

if the mongod.lock is not a zero-byte file, then mongod will refuse to start.

如果 mongod.lock 不是零字节文件,则 mongod 将拒绝启动。

I tested this solution in my environment and it works perfectly:

我在我的环境中测试了这个解决方案,它工作得很好:

  1. Remove mongod.lockfile.
  2. Repair the database: mongod --dbpath /your/db/path --repair
  3. Run mongod: mongod --dbpath /your/db/path
  1. 删除mongod.lock文件。
  2. 修复数据库: mongod --dbpath /your/db/path --repair
  3. 运行 mongod: mongod --dbpath /your/db/path

回答by burseaner

There was the same problem on my machine. In the log file was:

我的机器上也有同样的问题。在日志文件中是:

Mon Jul 29 09:57:13.689 [initandlisten] ERROR: Insufficient free space for journal file
Mon Jul 29 09:57:13.689 [initandlisten] Please make at least 3379MB available in /var/mongoexp/rs2/journal or use --smallfiles

Mon Jul 29 09:57:13.689 [initandlisten] 错误:日志文件的可用空间不足
Mon Jul 29 09:57:13.689 [initandlisten] 请在 /var/mongoexp/rs2/journal 中至少提供 3379MB 可用空间或使用 --smallfiles

It was solved by using mongod --smallfiles. Or if you start mongod with --configoption than in a configuration file disable write-ahead journaling by nojournal=true(remove the beginning #). Some more disk space would also solve the above problem.

它是通过使用解决的mongod --smallfiles。或者,如果您使用--config选项启动 mongod 而不是在配置文件中禁用预写日志nojournal=true(删除开头的#)。增加一些磁盘空间也可以解决上述问题。

回答by kode

Similar issue with the same error - I was trying to run the repair script sudo -u mongodb mongod -f /etc/mongodb.conf --repair

相同错误的类似问题 - 我试图运行修复脚本 sudo -u mongodb mongod -f /etc/mongodb.conf --repair

Checked ps aux | grep mongoand see that the daemon was running. Stopped it and then the repair script run without an issue.

检查ps aux | grep mongo并查看守护程序是否正在运行。停止它,然后修复脚本运行没有问题。

Hope that could be helpful for someone else.

希望这对其他人有帮助。

回答by julien bouteloup

It's because you probably didn't shutdown mongodb properly and you are not starting mongodb the right way. According your mongodb.config, you have dbpath = /mongodb/data/db- so I assume you created the repository /mongodb/data/db? Let me clarify all the steps.

这是因为您可能没有正确关闭 mongodb 并且您没有以正确的方式启动 mongodb。根据你的mongodb.config,你有dbpath = /mongodb/data/db- 所以我假设你创建了存储库/mongodb/data/db?让我澄清所有步骤。

  1. TO START MONGODB
  1. 启动 MongoDB

In your mongodb.configchange the dbpath = /mongodb/data/dbto dbpath = /data/db. On your terminal create the db repository by typing: mkdir /data/db. Now you have a repository - you can start your mongo.

在您mongodb.config更改dbpath = /mongodb/data/dbdbpath = /data/db. 在你的终端创建通过键入DB库:mkdir /data/db。现在您有了一个存储库 - 您可以启动您的 mongo。

To start mongo in the background type: mongod --dbpath /data/db --fork --logpath /dev/null.

要在后台启动类型蒙戈:mongod --dbpath /data/db --fork --logpath /dev/null

  • /data/dbis the location of the db.
  • --forkmeans you want to start mongo in the background - deamon.
  • --logpath /dev/nullmeans you don't want to log - you can change that by replacing /dev/nullto a path like /var/log/mongo.log

    1. TO SHUTDOWN MONGODB
  • /data/db是数据库的位置。
  • --fork意味着你想在后台启动 mongo - deamon。
  • --logpath /dev/null意味着您不想记录 - 您可以通过替换/dev/null为类似的路径来更改它/var/log/mongo.log

    1. 关闭 MongoDB

Connect to your mongo by typing: mongoand then use adminand db.shutdownServer(). Like explain in mongoDB

通过键入:mongo然后use admin和连接到您的 mongo db.shutdownServer()。就像在mongoDB 中解释

If this technique doesn't work for some reason you can always kill the process.

如果此技术由于某种原因不起作用,您可以随时终止该进程。

Find the mongodb process PID by typing: lsof -i:27017assuming your mongodb is running on port 27017

输入以下命令查找 mongodb 进程 PID:lsof -i:27017假设您的 mongodb 正在端口上运行27017

Type kill <PID>, replace <PID>by the value you found the previous command.

键入kill <PID>,替换<PID>为您在上一个命令中找到的值。

回答by Nikhil Mohadikar

I had the same error on linux (Centos) and this worked for me

我在 linux (Centos) 上遇到了同样的错误,这对我有用

  1. Remove mongod.lock from the dbpath

    $ rm /var/lib/mongo/mongod.lock

  2. Repair the mongod process

    $ mongod --repair

  3. Run mongod config

    $ mongod --config /etc/mongod.conf

  1. 从 dbpath 中删除 mongod.lock

    $ rm /var/lib/mongo/mongod.lock

  2. 修复mongod进程

    $ mongod --repair

  3. 运行 mongod 配置

    $ mongod --config /etc/mongod.conf

回答by Narendra Maru

Generally, this error comes when the mongod.conf file is not able to find a certain path for Database store or log store or maybe processid store or maybe it's not getting the file permission to access the config directories and files which has been declared in mongod.conf

通常,当 mongod.conf 文件无法找到数据库存储或日志存储或 processid 存储的某个路径时,或者可能没有获得访问 mongod 中声明的配置目录和文件的文件权限时,就会出现此错误.conf

to resolve this error we need to observe the log generated by the MongoDB it will clearly indicate whether which file or directory you MongoDB is not able to access

要解决此错误,我们需要观察 MongoDB 生成的日志,它会清楚地表明您 MongoDB 无法访问哪个文件或目录

the above error may look like below screenshot enter image description here

上面的错误可能看起来像下面的截图 在此处输入图片说明

enter image description here

在此处输入图片说明

回答by Hamid Alinia

create folder "data" and "db" inside it, in "/" path of your server. actually you should create or modify permissions of folder that the data is going to be stored!

在服务器的“/”路径中,在其中创建文件夹“data”和“db”。实际上,您应该创建或修改将要存储数据的文件夹的权限!

回答by AnneTheAgile

I had the same error. I ran it interactively to see the log.

我有同样的错误。我以交互方式运行它以查看日志。

2014-10-21T10:12:35.418-0400 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017

Then I used lsofto find out which process was using my port.

然后我用来lsof找出哪个进程正在使用我的端口。

$ lsof -i:27017
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mongod  2106 MYUSERID   10u  IPv4 0x635b71ec3b65b4a1      0t0  TCP *:27017 (LISTEN)

It was a mongodthat I had forked previously and forgot to turn off (since I hadn't seen it running in my bash window). Simply killing it by running kill 2106, enabled my process to run without the error 100.

这是mongod我之前分叉并忘记关闭的(因为我没有看到它在我的 bash 窗口中运行)。只需通过运行杀死它kill 2106,就可以使我的进程运行而不会出现错误 100。