服务mongod在Centos8上没有启动

Service mongod does not start on Centos8

我尝试在 Centos8 上安装 mongoDB,但是当我 运行 命令

systemctl status mongod.service

我收到这个错误:

● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2020-08-01 14:26:53 CEST; 11min ago
     Docs: https://docs.mongodb.org/manual
  Process: 1875 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
  Process: 1873 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 1871 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 1869 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Aug 01 14:26:53 db.localhost systemd[1]: Starting MongoDB Database Server...
Aug 01 14:26:53 db.localhost mongod[1875]: about to fork child process, waiting until server is ready for>
Aug 01 14:26:53 db.localhost mongod[1875]: forked process: 1877
Aug 01 14:26:53 db.localhost mongod[1875]: ERROR: child process failed, exited with 14
Aug 01 14:26:53 db.localhost mongod[1875]: To see additional information in this output, start without th>
Aug 01 14:26:53 db.localhost systemd[1]: mongod.service: Control process exited, code=exited status=14
Aug 01 14:26:53 db.localhost systemd[1]: mongod.service: Failed with result 'exit-code'.
Aug 01 14:26:53 db.localhost systemd[1]: Failed to start MongoDB Database Server.

我尝试检查以下文件夹的权限:/var/lib/mongo 和 /var/log/mongodb

#/var/lib/
drwxr-xr-x.  4 mongod  mongod  4096 Aug  1 14:44 mongo
#/var/log/
drwxr-xr-x.  2 mongod  mongod    50 Aug  1 14:14 mongodb

在其他一些帖子中,人们被告知要尝试这个命令:

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

但在没有用户 mongodb 的情况下,我收到错误消息:无效用户:'mongodb:mongodb'!

在我的 /etc/passwd 文件中,mongo 的唯一用户是:

mongod:x:994:992:mongod:/var/lib/mongo:/bin/false

有什么问题吗? 为什么我不能 运行 mongod.service?

感谢您的支持。


添加了更多信息: systemctl cat mongod

[root@db tmp]# systemctl cat mongod
# /usr/lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target

[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings

[Install]
WantedBy=multi-user.target

mongod.conf

[root@db tmp]# cat /etc/mongod.conf
# ..
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

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

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

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

/usr/bin/mongod -f /etc/mongod.conf

[root@db mongodb]# /usr/bin/mongod -f /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1959
child process started successfully, parent exiting

出于某种原因,mongod 想要文件夹 /data/db 而忽略文件 mongod.conf

创建这些文件夹后,如果我 运行 mongod 命令(使用 sudo),程序将“正确”启动。 但是,如果我重新启动系统,服务将在启动时失败并继续出现问题。