简体   繁体   中英

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

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;

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.

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

However, authenticationMechanisms is an option for "setParameter", as per this documentation:

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

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. mongod does not support configuration files with non-ASCII encoding, including 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.

I had a problem with the error:

"Unrecognized option: net.ssl.mode"

The issue was the mongodb version. I had installed using brew which does not default to mongodb with ssl support. To fix this the I had to use the --with-openssl flag.

brew install mongodb --with-openssl

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

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