簡體   English   中英

MongoDB YAML“無法識別的選項:安全性”

[英]MongoDB YAML “Unrecognized option: security”

我在Windows Server 2012上運行Mongo DB版本2.6。我在設置YAML配置文件以獲取安全性和授權時遇到問題。 當我具有以下配置文件時,我只會收到一條錯誤消息,提示“無法識別的選項:安全性”。 我的配置有什么問題?

mongod_test.conf:

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

命令行:

mongod.exe --config mongod_test.conf

我在文件中添加了空格,這解決了部分問題。 從上面更新的配置,我得到的當前錯誤是:

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

無法說出您的確切配置,但是Yaml需要冒號+空格來分隔鍵和值,否則會出現解析錯誤;

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

錯誤:

Unrecognized option: security.authenticationMechanisms

這是因為authenticationMechanisms不屬於“安全性”配置。

根據文檔: http : //docs.mongodb.org/manual/reference/configuration-options/#security

但是,根據此文檔,authenticationMechanisms是“ setParameter”的一個選項:

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

我發現文檔令人費解並且令人困惑,但是我還沒有發現任何與此矛盾的東西。

因此,鑒於以上所述,我認為您應該查看以下內容:

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

您可以確保鍵值對行的“:”后面有空格,並且還可以將字符串值(例如dbPath值)用引號引起來。

確保配置文件使用ASCII編碼。 mongod不支持使用非ASCII編碼的配置文件,包括UTF-8。

嘗試設置SSL時,我遇到一個極其相似的錯誤,搜索我的問題,這是唯一相關的結果,但不是所需的解決方案。

我的錯誤出現了問題:

“無法識別的選項:net.ssl.mode”

問題是mongodb版本。 我使用的是brew安裝,默認情況下不支持ssl的mongodb。 為了解決這個問題,我不得不使用--with-openssl標志。

brew install mongodb --with-openssl

還要確保您的標頭沒有被注釋掉security不是#security

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM