简体   繁体   English

MongoDB YAML“无法识别的选项:安全性”

[英]MongoDB YAML “Unrecognized option: security”

I am running Mongo DB version 2.6 on Windows Server 2012. I am having trouble setting up the YAML config file for for security and authorization. 我在Windows Server 2012上运行Mongo DB版本2.6。我在设置YAML配置文件以获取安全性和授权时遇到问题。 When I have the below config file I only receive an error saying "Unrecognized option: security". 当我具有以下配置文件时,我只会收到一条错误消息,提示“无法识别的选项:安全性”。 What is wrong with my config? 我的配置有什么问题?

mongod_test.conf: mongod_test.conf:

security:
    authorization: enabled
    authenticationMechanisms: MONGODB-CR
storage:
   dbPath: F:\MongoData

Command line: 命令行:

mongod.exe --config mongod_test.conf

I've added spaces back to my file and that fixes part of the problem. 我在文件中添加了空格,这解决了部分问题。 With the updated config from above the current error I am getting is: 从上面更新的配置,我得到的当前错误是:

c:\MongoDBFolder\bin>mongod.exe --config mongod_test.conf
    Unrecognized option: security.authenticationMechanisms
    try 'mongod.exe --help' for more information

Can't speak for your exact config, but Yaml requires colon+space to separate the keys and values, otherwise you'll get parse errors; 无法说出您的确切配置,但是Yaml需要冒号+空格来分隔键和值,否则会出现解析错误;

security:
    authorization: enabled
    authenticationMechanisms: MONGODB-CR
storage:
   dbPath: F:\MongoData

The error: 错误:

Unrecognized option: security.authenticationMechanisms

is because authenticationMechanisms is not part of the "security" configuration. 这是因为authenticationMechanisms不属于“安全性”配置。

As per the documentation: http://docs.mongodb.org/manual/reference/configuration-options/#security 根据文档: http : //docs.mongodb.org/manual/reference/configuration-options/#security

However, authenticationMechanisms is an option for "setParameter", as per this documentation: 但是,根据此文档,authenticationMechanisms是“ setParameter”的一个选项:

http://docs.mongodb.org/manual/reference/parameters/#param.authenticationMechanisms http://docs.mongodb.org/manual/reference/parameters/#param.authentication机制

I find the documentation convoluted and confusing, but I've not found anything to contradict this, yet. 我发现文档令人费解并且令人困惑,但是我还没有发现任何与此矛盾的东西。

So, given the above, I think you should be looking at the following: 因此,鉴于以上所述,我认为您应该查看以下内容:

security:
   authorization: enabled
setParameter:
   authenticationMechanisms: MONGODB-CR    
storage:
  dbPath: "F:\MongoData"

您可以确保键值对行的“:”后面有空格,并且还可以将字符串值(例如dbPath值)用引号引起来。

Ensure the configuration file uses ASCII encoding. 确保配置文件使用ASCII编码。 mongod does not support configuration files with non-ASCII encoding, including UTF-8. mongod不支持使用非ASCII编码的配置文件,包括UTF-8。

I had an extremely similar error when trying to setup SSL, searching for my problem this was the only relevant result, but was not the solution that was required. 尝试设置SSL时,我遇到一个极其相似的错误,搜索我的问题,这是唯一相关的结果,但不是所需的解决方案。

I had a problem with the error: 我的错误出现了问题:

"Unrecognized option: net.ssl.mode" “无法识别的选项:net.ssl.mode”

The issue was the mongodb version. 问题是mongodb版本。 I had installed using brew which does not default to mongodb with ssl support. 我使用的是brew安装,默认情况下不支持ssl的mongodb。 To fix this the I had to use the --with-openssl flag. 为了解决这个问题,我不得不使用--with-openssl标志。

brew install mongodb --with-openssl

还要确保您的标头没有被注释掉security不是#security

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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