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 :

   destination: file
   path: "/home/mongo/logs/mongod.log"
   logAppend: true
      enabled: true
      dbpath: "/home/mongo/data"
   fork: true
   port: 27019


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?

1 Answer 1


Yes, you use a configuration file for the mongos, and many of the options are the same for the mongos as the mongod. 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 the mongos things like what port to run on, the logpath (if you log out), and most importantly configdb=[your config server URIs] and your replica set key.

  • Ok then, I'll keep that in mind, thank you very much!
    – Irrational
    Dec 31, 2015 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.