mongodb Mongod 服务启动退出,代码为 100

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

Mongod Service start exits with code 100

mongodbserviceubuntu-16.04

提问by Jankapunkt

Problem

问题

My mongo service does not start anymore:

我的 mongo 服务不再启动:

root@machine ~ # service mongod start
root@machine ~ # service mongod status
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2017-08-15 12:03:51 CEST; 2s ago
     Docs: https://docs.mongodb.org/manual
  Process: 26942 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
 Main PID: 26942 (code=exited, status=100)

Aug 15 12:03:50 machine systemd[1]: Started High-performance, schema-free document-oriented database.
Aug 15 12:03:51 machine systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
Aug 15 12:03:51 machine systemd[1]: mongod.service: Unit entered failed state.
Aug 15 12:03:51 machine systemd[1]: mongod.service: Failed with result 'exit-code'.

Where exit code 100 is blurry defined as:

退出代码 100 的模糊定义为:

Returned by mongod when the process throws an uncaught exception.

当进程抛出未捕获的异常时由 mongod 返回。

What I did

我做了什么

First, I have installed my mongodb (3.4.7) on Ubuntu 16.04.2 LTS via the official guide.

首先,我已经通过官方指南在 Ubuntu 16.04.2 LTS 上安装了我的 mongodb (3.4.7) 。

Starting and stopping the service worked fine. So I continued to enable authentication (again via the official guide).

启动和停止服务工作正常。所以我继续启用身份验证(再次通过官方指南)。

Then I added the service to be able to run on server startup.

然后我添加了能够在服务器启动时运行的服务

root@machine ~ # systemctl enable mongod.service

mongod.conf

mongod.conf

I also edited my config file, which is passed a yaml linter:

我还编辑了我的配置文件,它传递了一个 yaml linter:

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true

#  engine: mmapv1
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

security:
  authorization: enabled

The ownership of the file is

该文件的所有权是

root@machine ~ # ls -la /etc/ | grep mongo
-rw-r--r--   1 root  root     599 Aug 15 11:42 mongod.conf

DbPath

数据库路径

I know there are issues with the dbpath so this is what /var/lib/mongodbhas in terms of ownership:

我知道 dbpath 存在问题,所以这就是/var/lib/mongodb所有权方面的问题:

root@ machine ~ # ls -la /var/lib/ | grep mongo
drwxr-xr-x  4 mongodb      mongodb      4096 Aug 15 11:54 mongodb

Service List

服务清单

When listing all services via service --status-allthere is no entry for any mongo related service.

通过列出所有服务时,service --status-all没有任何 mongo 相关服务的条目。

Somebody has a clue what could cause the issue?

有人知道可能导致问题的原因吗?



UPDATE

更新

As suggested I ran the following command (with a slight modification):

按照建议,我运行了以下命令(稍作修改):

root@machine ~ /usr/bin/mongod --verbose --config /etc/mongod.conf &
[1] 28495

When I get it right, this is a direct execute of the binary. This allows me now to at least login into mongo shell:

当我做对了,这是二进制文件的直接执行。这让我现在至少可以登录到 mongo shell:

root@machine ~ # mongo
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.7
> 

However, the service status is still remaining failed with exit code 100.

但是,服务状态仍然保持失败,退出代码为 100。



UPDATE UPDATE

更新 更新

When typing root@machine ~ # /usr/bin/mongod --verbose

打字时 root@machine ~ # /usr/bin/mongod --verbose

I receive the following error:

我收到以下错误:

2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] MongoDB starting : pid=28642 port=27017 dbpath=/data/db 64-bit host=machine
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] db version v3.4.7
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] modules: none
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] build environment:
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     distarch: x86_64
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] options: { systemLog: { verbosity: 1 } }
2017-08-15T13:45:40.973+0200 D -        [initandlisten] User Assertion: 29:Data directory /data/db not found. src/mongo/db/service_context_d.cpp 98
2017-08-15T13:45:40.973+0200 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-08-15T13:45:40.973+0200 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-08-15T13:45:40.973+0200 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] now exiting
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] shutting down with code:100

回答by rockettc

You may still have some problems with the permissions in your data directory. Especially if you have run mongod from the terminal to start with.

您的数据目录中的权限可能仍然存在一些问题。特别是如果您从终端运行 mongod 开始。

I find that the data files are created under root not the mongodb user when you run from the terminal. To fix ..

我发现当您从终端运行时,数据文件是在 root 下创建的,而不是在 mongodb 用户下创建的。修理 ..

cd /var/lib/mongodb
sudo chown -R mongodb:mongodb *

回答by A. Pascual

rm /var/lib/mongodb/mongod.lock
systemctl restart mongod
systemctl status mongod

Try this!

尝试这个!

回答by Alex

Remove the mongod.lockfile under 'dbath', and it should start without issues.

删除 下的mongod.lock文件'dbath',它应该可以正常启动。