简体   繁体   中英

MongoDB Error parsing YAML Config illegal map value for replica set

Here is my /etc/mongodb.conf - using MongoDB 3.6. I'm having a challenge with the config file being parsed when starting mongod. I have a single space after each colon and two spaces on each new line I took the replica set example from mongoDB docs here: https://docs.mongodb.com/manual/reference/configuration-options/#replication-options

dbpath=/home/ubuntu/data/db
logpath=/home/ubuntu/data/db/log/mongo.log
logappend=true
journal=true

replication:
  replSetName: rep

net:
  bindIp: 127.0.0.1
  port: 27017

The error is:

 Error parsing YAML config file: yaml-cpp: error at line 6, column 12: illegal map value

Command I'm sending is

 Error parsing YAML config file: yaml-cpp: error at line 6, column 12: illegal map value

try 'mongod --help' for more information

I don't know what you think the first four lines do but they are certainly not YAML; instead they use a format resembling .properties files, with a = separating property name from value.

Since a = in YAML is simply content, it parses the first six lines as multiline scalar, meaning the value of those lines in YAML is the scalar

dbpath=/home/ubuntu/data/db logpath=/home/ubuntu/data/db/log/mongo.log logappend=true journal=true
replication

(Single line breaks are folded into a space, an empty line generates a line break.)

Now the error happens because YAML disallows multiline scalars to be implicit keys of a mapping. Implicit keys are scalars preceding a : on the same line which form a mapping key.

You fix the error by removing the first four lines, or transforming them into proper YAML. It is unclear what your intention with those lines is since not every name has a corresponding setting in the documentation you linked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM