Mongod doesn't recognize net.http in yaml config?
Mongod doesn't recognize net.http in yaml config?
I have the following config as mongod.cfg:
systemLog:
destination: file
path: "C:Program FilesMongoDB 2.6 Standardlogsmongo.log"
logAppend: true
storage:
dbPath: "C:Program FilesMongoDB 2.6 Standarddata"
net:
http:
enabled: true
I'm running MongoDB 2.6.3 on Windows 7 64 bit by running: mongod --config mongod.cfg
I'm inside the folder and I know it's parsing the correct mongod.cfg. However, I'm getting the following output:
mongod --config mongod.cfg
Unrecognized option: net.http
try 'mongod --help' for more information
I am pulling my hair out wondering why it's not parsing. I'm reading straight from the configuration page on Mongo's site and I still can't make it work. Any ideas?
2 Answers
2
Turns out I needed spaces after the headers. It needed to be:
systemLog:<space>
destination: file
path: "C:Program FilesMongoDB 2.6 Standardlogsmongo.log"
logAppend: true
storage:<space>
dbPath: "C:Program FilesMongoDB 2.6 Standarddata"
net:<space>
http:<space>
enabled: true
May it be that you had a tab character at the last lite before "enabled:"? That would have caused your described behavior on windows.
– Andreas Lundgren
Jan 28 '16 at 5:37
I also met the similar issue when add auth to MongoDB admin user. When install MongoDB 3.0.8 or 3.0.15, the error appears:
CONTROL Hotfix kb2731284 or a later update is not installed, will zero-out files.
Fail to install kb2731284(obtained from MS's mail) in my PC whose OS is win7 enterprise version, no vaild resolution online.
Unrecognized option: net.http
try 'mongod --help' for more information
Then update MongoDB to v3.6 can avoid the error in the beginning, but now if want to add auth for MongoDB user using the mongod.cfg file, following content need to be used:
systemLog:
destination: file
path: "D:mongodblogmongodb.log"
logAppend: true
storage:
dbPath: "D:mongodb"
journal:
enabled: true
engine: wiredTiger
net:
port: 27017
setParameter:
enableLocalhostAuthBypass: false
mongod.cfg
C:mongodbdata
C:mongodbdatalog
C:ProgramFilesMongoDBServer3.6bin
Then set value enableLocalhostAuthBypass
in mongod.cfg
file to true.
enableLocalhostAuthBypass
mongod.cfg
Open cmd.exe with the administrator privilege:
"C:ProgramFilesMongoDBServer3.6binmongod.exe" "--config=c:ProgramFilesMongoDBServer3.6binmongod.cfg" --auth --install
If the mongodb service is not running, type net start mongodb
net start mongodb
C:Users{username}Desktop>netstart mongodb
> use admin
> db.createUser("admin", "yourpassword", roles: ["root"]})
> db.auth(user, yourpassword)
Restart MongoDB from commond line.
Set value enableLocalhostAuthBypass
to false
.
enableLocalhostAuthBypass
false
Since for MongoDB 3.6 (actually any version after v3.2) have removed the net.http
options (Refer: https://docs.mongodb.com/manual/reference/configuration-options/).
net.http
Then all issues met can be completely solved.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I doubt that was actually the issue. My config file works without spaces at all.
– i3arnon
Jul 7 '14 at 23:02