We are trying to set up mongodb's remote access by using a config file, and are having trouble running the config file in the bin folder.
When we put our script through YAML Lint it says its valid, but when we run our file in command prompt it interchanges two errors 1) Unrecognized Option: Storage and 2) Unrecognized Option: SystemLog
This is our config file
storage:
dbPath: C:\\data\\db
enabled: true
systemLog:
destination: file
logAppend: true
logpath: C:\\data\\log\\mongo.log
net:
port: 27017
bindIp: 127.0.0.1
our command in command prompt is
mongod -f mongo.config.txt
Please Help <3
You have a couple of errors in your config (for MongoDB 3.2):
There is no storage.enabled option, I think you meant storage.journal.enabled
There is no systemLog.logpath option, this should be systemLog.path
This modified config file seems to work as expected:
storage:
dbPath: C:\\data\\db
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: C:\\data\\log\\mongo.log
net:
port: 27017
bindIp: 127.0.0.1
You can browse for more options in the Configuration File Options page
This happen due to invalid yaml syntax. In my case, i missed the space between dbPath and value
Incorrect
storage:
dbPath:"./data/db"
Correct
storage:
dbPath: "./data/db"
This happened with me because I deleted a space in the configuration file.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
I got this error, when the configuration file had the below state, note the gap before enabled:
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
Related
I am trying simply to use mongo with custom configuration file placed in my host machine. I obtain 100 error code, I tested this in debian 10 and on a windows 10 machine (docker desktop). I think that its a permission issue, may be mongo has not permission to use those files.
docker-compose.yml
version: "3.7"
services:
mongod:
image: mongo:4.1.13
# restart: always
ports:
- "27017:27017"
volumes:
- ./config/mongo/mongod.conf:/etc/mongod.conf
- ./data/mongo:/data/db
# - ./log/mongo:/var/log/mongodb
entrypoint: ["mongod","--config","/etc/mongod.conf","--verbose"]
mongod.conf (default)
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Error:
This, this image does not create a log file under /var/log/mongodb.
Your docker-compose.yml and mongod.conf has inconsistent options:
docker-compose.yml specifies /data/db as a folder for DB files, but mongod.conf tries to use dbPath: /var/lib/mongodb (which is missing in your container). Fix your mongod.conf to point to /data/db/ folder and it should fix your error.
To debug such kind of error, your can run your image (mongo) by hand (docker run ...) with bash, instead of using docker-compose and you will be able to see all error in logs.
So this is the weirdest thing.
I have two centOS 7 servers running mongo. I now wanted to enforce authentication so I added the security.authorization: enabled to the mongod.conf file.
I already have a user on database "buzzztv".
So when I ran mongod --conf /etc/mongod.conf on the first server everything went fine.
Then I did the exact same thing on the second server and whenever I try to connect with one of the users I get the following error:
connecting to: mongodb://127.0.0.1:27017/?authSource=buzzztv&compressors=disabled&gssapiServiceName=mongodb
2020-02-20T13:02:35.166+0000 E QUERY [js] Error: Authentication failed. :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-02-20T13:02:35.168+0000 F - [main] exception: connect failed
2020-02-20T13:02:35.168+0000 E - [main] exiting with code 1
Now if I run mongod --fork --logpath /var/log/mongodb/mongod.log --auth the login works perfectly fine.
So obiously I could just run this command, but I want to use the mongod.conf.
Here is my mongod.conf file, I checked and it is a perfect copy of the file from the server in which it does work.
Any ideas?
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
So after several hurtful hours of looking into it, I neede to change the
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
Apparently something was wrong with my /var/lib/mongo so I backed up the data, and created a new folder /var/lib/mongodb
Then edited the mongod.conf file to:
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
Then it all worked fine. Now I'll just re-create the users and re-insert all the data and I'm good to go.
Hope this saves someone the wasteful hours I've lost
I am not able to start mongod servers with replication using config file.
when issue the command
mongod --config /etc/mongod1.conf
throws an error-
Unrecognized option: replSet
Unrecognized option: oplogSizeMB
MongoDB Version: 3.0
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo/test
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
# network interfaces
net:
port: 27030
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
#security:
#operationProfiling:
replication:
replSet: testrep
oplogSizeMB: 1024
#sharding:
## Enterprise-Only Options
please help me.
Just ident replSet and oplogSizeMB lines two spaces to the right. That's the thing with yaml
My mongodb replica set server is failing on start. followin is my config file:
# mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
# bindIp: 127.0.0.1
security:
authorization: enabled
keyFile: /home/gurbakhshish/dbKey/mongodb.key
replication:
replSetName: "nm-prd-dbs"
is this config correct. I dont have the issue if i comment security section of config file
I am trying to start mongos using config file with YAML format. it is throwing error saying "Unrecognized option: sharding.configDB". I am running this on centos6.
Any help will be highly appreciated.
Config file:
systemLog:
destination: file
path: REPLACEWITHLOGPATH
quiet: true
processManagement:
fork: true
net:
bindIp: REPLACEWITHIP
port: REPLACEWITHPORT
storage:
dbPath: REPLACEWITHDBPATH
sharding:
clusterRole: shardsvr
configDB: "172.16.4.61:27019"
I believe you need to remove the clusterRole: shardsvr from your mongos configuration file