【发布时间】:2021-10-01 11:30:43
【问题描述】:
当我写这个命令时
sudo service mongod start
这给了我这个错误
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
我在stackoverflow上搜索并找到它Mongodb not able to start in Ubuntu 15.04
但这对我不起作用,这个问题在 5 年前问过
当我写这个命令时
sudo service mongod status
给我
Redirecting to /bin/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 2021-07-24 22:49:47 UTC; 3min 49s ago
Docs: https://docs.mongodb.org/manual
Process: 4126 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=2)
Process: 4123 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 4120 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 4119 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal systemd[1]: Starting MongoDB Database Server...
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal mongod[4126]: Error parsing YAML config: duplicate key: replication.rep...Name
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal mongod[4126]: try '/usr/bin/mongod --help' for more information
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=2
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal systemd[1]: Unit mongod.service entered failed state.
Jul 24 22:49:47 ip-172-31-46-146.eu-central-1.compute.internal systemd[1]: mongod.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
还有这个命令
sudo systemctl disable mongod
给我
Removed symlink /etc/systemd/system/multi-user.target.wants/mongod.service.
而我在启用时会发生这种情况
sudo systemctl enable mongod
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
这是我的 mongod.conf 文件
GNU nano 2.9.8 /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: 34418
bindIp: 127.0.0.1,172.31.46.146 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll settin$
#security:
#authorization: "enabled"
#operationProfiling:
replication:
replSetName: "rs0"
#sharding:
## Enterprise-Only Options
#auditLog:
【问题讨论】:
-
你的 /etc/mongod.conf 是什么样子的?
-
我只分享绿色内容 systemLog: 目的地: 文件 logAppend: true path: /var/log/mongodb/mongod.log storage: dbPath: /var/lib/mongo journal: enabled: true processManagement: fork: true # fork 并在后台运行 pidFilePath: /var/run/mongodb/mongod.pid # pidfile 的位置 timeZoneInfo: /usr/share/zoneinfo net: port: 34418 bindIp: 127.0.0.1,172.31.46.146 # Enter 0.0 .0.0,:: 绑定到所有 IPv4 和 IPv6 地址,或者,使用 net.bindIpAll settin$ security: authorization: "enabled" @R2D2
-
你需要在 yaml 中了解它的来源:重复键:复制
-
当我禁用授权时问题已解决,但我必须使用授权@R2D2
-
添加完整的 conf 内容,以便我们检查问题出在哪里,但它肯定在 yaml 中
标签: linux mongodb amazon-web-services amazon-ec2