I have the following config as mongod.cfg:
systemLog:
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
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:
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?
Turns out I needed spaces after the headers. It needed to be:
systemLog:<space>
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:<space>
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:<space>
http:<space>
enabled: true
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:\\mongodb\\log\\mongodb.log"
logAppend: true
storage:
dbPath: "D:\\mongodb"
journal:
enabled: true
engine: wiredTiger
net:
port: 27017
setParameter:
enableLocalhostAuthBypass: false
Save the file mongod.cfg.
Create folder C:\mongodb\data\,
then create subfolder C:\mongodbdata\log,
Copy the mongod.cfg file to related location of MongoDB bin, such as C:\ProgramFiles\MongoDB\Server\3.6\bin\.
Then set value enableLocalhostAuthBypass in mongod.cfg file to true.
Open cmd.exe with the administrator privilege:
"C:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.exe" "--config=c:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.cfg" --auth --install
If the mongodb service is not running, type 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.
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/).
Then all issues met can be completely solved.
Related
I have a mongodb server (v4.0) installed locally but I want to change the port it's listening on. I have read the docs and have created a mongod.cfg file in <install>/bin/ in ANSI format with valid YAML. The following is my config:
net:
bindIp: localhost
port: 30000
storage:
dbPath: C:\mongodb\data\db
journal:
enabled: true
systemLog:
destination: file
path: C:\mongodb\data\log\mongodb.log
quiet: true
logAppend: true
I can load that explicitly when I pass in the command mongod --config c:\MongoDB\bin\mongod.cfg but I want it to load every time I restart the service.
My issues:
When I run just mongod I get an error that it can't find the data in c:\data\... which is not what is set in the config. It is not loading the config from that file, how can I achieve this as default behavior (or at least change the default port in some other way)?
When I run mongod --config c:\MongoDB\bin\mongod.cfg it creates a new instance of mongodb which is listening on that port, but does not load my databases. In the c:\mongodb\data\db folder, I have a folder diagnostic.data and journal, as well as many .wt files with names like collection-[integer]-[randomNumber].wt and index-[integer]-[randomNumber].wt and _mdb.catalog.wt and some others (including a few WiredTiger files), so I believe this is the proper directory.
EDIT:
The results of running db.serverCmdLineOpts():
{
"argv": [
"c:\\MongoDB\\bin\\mongod.exe",
"--config",
"c:\\MongoDB\\bin\\mongod.cfg",
"--service"
],
"parsed": {
"config": "c:\\MongoDB\\bin\\mongod.cfg",
"net": {
"bindIp": "localhost",
"port": 30000
},
"processManagement": {
"windowsService": {
"description": "Service of MongoDB",
"displayName": "MongoDB Service",
"serviceName": "MongoDB"
}
},
"service": true,
"storage": {
"dbPath": "C:\\mongodb\\data\\db",
"journal": {
"enabled": true
}
},
"systemLog": {
"destination": "file",
"logAppend": true,
"path": "C:\\mongodb\\data\\log\\mongodb.log",
"quiet": true
}
},
"ok": 1
}
Install MongoDB as service with mongod --config c:\MongoDB\bin\mongod.cfg --install. Add Windows Service Options accordingly to your mongod.cfg:
processManagement:
windowsService:
serviceName: MongoDB
displayName: MongoDB Service
description: Service of MongoDB
Then start/stop MongoDB with your Service Manager or net start MongoDB and net stop MongoDB command. By default it will start with your Windows automatically.
To run BI on project we have used mongsqld to convert the JSON into tables.
On our first installation, everything was running fine and we were able to make analytics.
After installing the security on mongod, the monsqld failes to establish the connection with following error:
connection accepted from 127.0.0.1:44530 #11219 (1 connection now open)
handshake error: ERROR 1043 (08S01): MongoDB schema not yet available
end connection 127.0.0.1:44530 (0 connections now open)
Thanks in Advance.
It can also be the case that you haven't set up your mongosqld.conf correctly on your mongo bi connector side.
This will be evident if you check the log files for your mongosqld.conf and find that it has repeated entries for "[Sampler] sampling mongodb for schema permanently". In my case this happened all night until I fixed the config file.
In my particular case - I didnt configure authentication as per the following.
logAppend: false
path: "/var/log/mongosqld/mongosqld.log"
verbosity: 2
security:
enabled: true
mongodb:
net:
uri: "mongo.example.com:27017"
auth:
username: "root"
password: "changeme"
net:
bindIp: 192.0.2.14
port: 3307
As soon as I made the change, uninstalled mongosqld (sudo mongosqld uninstall), installed momgosqld with the new conf (sudo mongosqld install ), and restarted it - it worked.
More about the configuration here - https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#std-label-config-format
MongoDB v4 Ent, Windows Server 2016 Std
Starting mongodb from command line works fine:
mongod --enableEncryption --encryptionKeyFile c:\key\mongodb-keyfile
Now I need to change mongod.cfg so windows service starts with encryption enabled. After adding following parameters to file
security:
enableEncryption: true
encryptionKeyFile: c:\key\mongodb-keyfile
service throw error while starting
error 1067: the process terminated unexpectedly
Any ideas?
Environment Windows 2012 R2. MongoDB Enterprise 3.2.0, this is an evaluation version.
I am logged in as muser1.
Why it is looking for a field pwd?
How can I fix it?
c:\MongoDB\scripts>mongo.exe --authenticationMechanism=GSSAPI --authenticationDatabase='$external' --username muser1#TEST.MNG
MongoDB shell version: 3.2.0
connecting to: test
2016-01-14T14:03:37.572-0800 E QUERY [thread1] Error: Missing expected field "pwd" :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1395:16
#(auth):6:1
#(auth):1:2
exception: login failed
The user exists:
MongoDB Enterprise > user = db.system.users.findOne({user: "muser1#TEST.MNG"})
{
"_id" : "$external.muser1#TEST.MNG",
"user" : "muser1#TEST.MNG",
"db" : "$external",
"credentials" : {
"external" : true
},
"roles" : [
{
"role" : "readWrite",
"db" : "test"
}
]
}
Kerberos is correctly configured based on 3.2 documentation. DNS configured correctly.
MongoDB service is running with a domain account. SPN is there for the default and for the named service also. Tried to have just one of them configured alone then the other one, no luck.
c:\MongoDB\scripts>setspn -L m1svr
Registered ServicePrincipalNames for CN=Mongo1,CN=Users,DC=test,DC=mng:
mongodb/m1.test.mng
MongoDB_M1_D1/m1.test.mng
Here is the startup config file:
# Data Node, with minimal oplog and no jurnal
net:
port: 27017
systemLog:
verbosity: '0' #Debug level from 0-5
destination: file
path: C:\MongoDB\logs\m1-d1.log
logAppend: false
storage:
dbPath: C:\MongoDB\data\m1\D1
journal:
enabled: false
directoryPerDB : true
wiredTiger:
engineConfig:
cacheSizeGB: 1
statisticsLogDelaySecs: 1
journalCompressor: snappy
directoryForIndexes: true
collectionConfig:
blockCompressor: snappy
indexConfig:
prefixCompression: true
#replication:
# oplogSizeMB: 10
# replSetName: RSTest
security:
authorization: enabled
# sasl:
# hostName: m1.test.mng
# serviceName: MongoDB_M1_D1
# keyFile: F:\config\key1.txt
# clusterAuthMode: keyFile
setParameter:
authenticationMechanisms: GSSAPI,SCRAM-SHA-1
I tried to add a pwd field to the user document (just in case), but no luck.
I am out of ideas.
When using Kerberos Authentication, you need to define the fully qualified domain name for the server you are connecting to as part of the connection string. Note that the domain portion also needs to be in all caps. eg:
mongo.exe --host servername.TEST.MNG --authenticationMechanism=GSSAPI --authenticationDatabase='$external' --username muser1#TEST.MNG
I have a replica set with 3 Windows Server 2008 R2, and I can't get the MongoDB 2.6 Legacy service working in none of them (I had services with MongoDB 2.4 without any problem in these servers).
This is my YAML config file:
systemLog:
destination: file
path: Z:\MongoDB\log\db02.log
quiet: false
logAppend: true
net:
port: 28019
storage:
dbPath: Z:\MongoDB\data\db02
directoryPerDB: true
journal:
enabled: true
replication:
replSetName: rs0
Assumptions:
logpath and dbpath exist (and db02.log file).
I have access to Z drive
Steps:
1. Run command:
mongod --config "C:\Program Files\MongoDB 2.6 Standard Legacy\mongod.cfg" --install
2. Service is correctly created, and if I copy the ImagePath of the service and paste to a console without the --service option, mongo runs fine. ImagePath is:
"C:\Program Files\MongoDB 2.6 Standard Legacy\bin\mongod.exe" --config "C:\Program Files\MongoDB 2.6 Standard Legacy\mongod.cfg" --service
3. The service doesn't start, complaining with Error 1054 - Service did not respond in Timely Fashion. In Windows event viewer I have no more information than that (no access errors, no other relevant info).
Other attemps with no success and same result (1054):
Even though ImagePath is correct (with quotes for blankspaces and full paths), I tried with a "C:\mongo" installation to avoid blankspaces.
Tried putting quotes to paths in YAML file.
As YAML is a new format, I tried with this config file
port = 28019
logpath = Z:\MongoDB\log\db02.log
logappend = true
dbpath = Z:\MongoDB\data\db02
directoryperdb = true
journal = true
replSet = rs0
quiet = false
Any help would be very appreciated.
This is a known issue from version 2.6 onwards. A link in the docs explains how to create the service manually. I experienced the same issue, followed the documentation and it's now working:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#manually-create-windows-service