We are currently setting up a sharded cluster with MongoDB, config servers have been set up using a configuration file : mongod.conf pointing out alternative paths for data and logs folders :
systemLog:
destination: file
path: "/home/mongo/logs/mongod.log"
logAppend: true
storage:
journal:
enabled: true
dbpath: "/home/mongo/data"
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27019
sharding:
clusterRole:configsvr
Using the docs (https://docs.mongodb.org/manual/reference/configuration-options/), I've seen that it is possible to launch mongos using a similar file, problem is, I don't know if this file should be different from mongod.conf. So far I have not seen anyone use a mongos.conf file…
Should the file be identical?
Just changing paths, port and clusterRole?
And adding a "configDB:" lign?
Best Answer
Yes, you use a configuration file for the
mongos
, and many of the options are the same for themongos
as themongod
. You will need to consult the MongoDB configuration file options documentation for more explicit instructions on which options are viable for which MongoDB server role. I see that you already found that link, but all your answers are there.When launching the
mongos
(by hand or in your init script) you feed it the config file as a runtime parameter. You will need to tell themongos
things like what port to run on, the logpath (if you log out), and most importantlyconfigdb=[your config server URIs]
and your replica set key.