如何配置mongod.conf?

时间:2019-09-30 13:45:45

标签: mongodb ubuntu-18.04

大家好,我想使用sudo service mongod start开始我的mongod,但是在此之后,当我使用此命令查找状态sudo service mongod status时,我得到以下信息

mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-09-30 13:40:27 UTC; 4s ago
     Docs: https://docs.mongodb.org/manual
  Process: 28314 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=2)
 Main PID: 28314 (code=exited, status=2)

Sep 30 13:40:27 ip-172-31-26-190 systemd[1]: Started MongoDB Database Server.
Sep 30 13:40:27 ip-172-31-26-190 mongod[28314]: Error parsing YAML config file: yaml-cpp: error at line 10, column 3: end of map not found
Sep 30 13:40:27 ip-172-31-26-190 mongod[28314]: try '/usr/bin/mongod --help' for more information
Sep 30 13:40:27 ip-172-31-26-190 systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Sep 30 13:40:27 ip-172-31-26-190 systemd[1]: mongod.service: Failed with result 'exit-code'.

这是我的mongod.conf文件

# mongod.conf

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

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  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


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

可以请任何人帮助我了解这有什么问题吗?我还要提及的是,如果我只输入mongod,一切都很好

**编辑**

解决上述问题后,尝试连接到端口6379

mongod.service文件

[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target

[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
PIDFile=/var/run/mongodb/mongod.pid
# 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 for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings

[Install]
WantedBy=multi-user.target

0 个答案:

没有答案