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(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.