服务mongod无法在Centos8上启动

时间:2020-08-01 10:54:40

标签: mongodb service 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猫鼬

[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

1 个答案:

答案 0 :(得分:0)

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

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