解决Error parsing YAML config file: yaml-cpp: error at line 32, column 1: end of map not found

mongodb使用配置文件启动

mongod --config /etc/mongod.conf

碰到的各种错误

Error parsing YAML config file: yaml-cpp: error at line 32, column 1: end of map not found

Error parsing command line: the required argument for option '--config' is missing

Unrecognized option: auth
try 'mongod --help' for more information

上面这些错误,都是因为配置文件格式的错误,很无语

mongodb 3.0之后配置文件采用YAML格式,这种格式非常简单,使用:表示,开头使用“空格”作为缩进。需要注意的是,“:”之后有value的话,需要紧跟一个空格,如果key只是表示层级,则无需在“:”后增加空格(比如:systemLog:后面既不需要空格)。按照层级,每行4个空格缩进,第二级则8个空格,依次轮推,顶层则不需要空格缩进。如果格式不正确,将会出现上面的错误

仔细读完这段文字就会找到解决办法

附我的配置文件:
 

# 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:
#  mmapv1:
#  wiredTiger:

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

# network interfaces
 net:
    port: 26178
    bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.

 security:
    authorization: enabled

注意复制过去可能会有格式问题,注意自己解决

你可能感兴趣的:(MongoDB)