[英]MongoDB: "Unrecognized option: systemLog"
guys.伙计们。
I have a problem with the configuration files of MongoDB.我对 MongoDB 的配置文件有问题。 It seem that use the YAML syntax.似乎使用 YAML 语法。
I follow the instruction on the official website.我按照官方网站上的说明进行操作。 I read something about YAML and I tried to figure out what is wrong, but I don't got any result.This is the mongod.conf file我阅读了一些关于 YAML 的内容,并试图找出问题所在,但没有得到任何结果。这是 mongod.conf 文件
# mongod.conf
systemLog:
verbosity=5
traceAllExceptions=true
path="/var/log/mongodb/mongod.log"
destination=file
timeStampFormat=iso8601-utc
pidFilePath="/run/mongod.pid"
net:
port=[8040,8041,8042]
wiredObjectCheck=true
ssl.mode=preferSSL
ssl.PEMKeyFile="/var/lib/mongodb/mongo.pem"
serviceExecutor=adaptive
storage:
dbPath="/home/juny/nodeBox/data/db"
operationProfiling.mode=slowOp
It's suppose to work well, when you execute the following command:当您执行以下命令时,它应该可以正常工作:
service mongod start
But when you type following command:但是当你输入以下命令时:
service mongod status
The terminal display this:终端显示:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-05-25 20:12:24 AST; 2min 21s ago
Docs: https://docs.mongodb.org/manual
Process: 5093 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=2)
Main PID: 5093 (code=exited, status=2)
May 25 20:12:24 systemd[1]: Started MongoDB Database Server.
May 25 20:12:24 systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
May 25 20:12:24 systemd[1]: mongod.service: Unit entered failed state.
May 25 20:12:24 systemd[1]: mongod.service: Failed with result 'exit-code'.
I type the following command我输入以下命令
sudo mongod --config=/etc/mongod.conf
and this is the result这就是结果
Unrecognized option: systemLog
try 'mongod --help' for more information
Ok , I found the error. 好的,我发现了错误。 The configuration file its must be look like the same above, but changing the equal symbol '=' by a colon ':'. 配置文件必须与上面的相同,但是用冒号':'更改等号'='。 Also, some words in the configuration are wrong. 此外,配置中的某些单词是错误的。 I had to verify the manual to realize the failure. 我必须验证手册以实现失败。
In my case (with mongo v4.2) I had to replace all spaces indent with tabs.在我的情况下(使用 mongo v4.2)我不得不用制表符替换所有缩进的空格。
PS https://docs.mongodb.com/manual/reference/configuration-options/ says: PS https://docs.mongodb.com/manual/reference/configuration-options/说:
YAML does not support tab characters for indentation: use spaces instead. YAML 不支持用于缩进的制表符:请改用空格。
It looks that spaces are OK, but anyways, the problem was with whitespace (non-printable characters).看起来空格没问题,但无论如何,问题在于空格(不可打印的字符)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.