M103 lab: Deploy a sharded cluster - edit configuration file

I am having trouble starting mongos. I followed the steps in the lecture and get the following error message:

user@M103# mongos -f mongos.conf
BadValue: error: no args for --configdb
try ‘mongos --help’ for more information
user@M103#

The instructions say I need to edit the “mongos” configuration file to add the sharding cluster role but I cannot access mongos.

You have to edit the configuration file before you can access mongos.

The configuration file is already loaded in the IDE editor. You just edit it with the appropriate configuration parameters.

That is also where I`ve bees stuck for the past day, how can I edit the config file? Can it be achievable through the CSRS or the Replica Set. I can run mongo --host and authenticate to access both. They are both running, but from there I get lost accessing

The mongos.conf file is a conf file on the server. So you would edit it with a text editor such as vi, or nano. You don’t have to login to mongo to edit the configs.

If you are using the built in editor/ide on Mongo University then the config file is in the “browse files section”.

You will need to add a few lines to this file before starting the mongos successfully which is why you’re getting

“BadValue: error: no args for --configdb”

Great, I was able to get it working by running

mongos -f --configdb <csrs/localhost:port#,…>
and
mongo --port ## -u -p --authenticationDatabase

Thank you @steevej and @tapiocaPENGUIN for your help

Great to hear that you got it working. Note: You can also add them to the config file:

sharding:
  configDB: <configReplSetName>/cfg1.example.net:27019, cfg2.example.net:27019,...

This will allow you to start the mongos with mongos -f /path/to/config

1 Like

Thank you @tapiocaPENGUIN and @steevej for your quick response to @Christian_Gomez_Mart and helping out him. We MongoDB Curriculum team highly appreciate your efforts. Thanks again!!

Kind Regards,
Kushagra