Mongos is not starting

When I did the first lab I could normally initiate mongos.
In the second lab, with the exact Config file for mongos, it is refusing to initiate:

mongos -f mongos.conf

I get the message:

2019-07-08T17:37:58.658+0000 W SHARDING [main] Running a sharded cluster with fewer than 3 config servers should only be done for testing purposes and is not recommended for production.
about to fork child process, waiting until server is ready for connections.
forked process: 2630

And nothing happens. Then I start a new terminal, initiate “vagrant ssh” and I try:

mongo --port 26000 --username m103-admin --password m103-pass --authenticationDatabase admin

This is what I get:

MongoDB shell version v3.6.12
connecting to: mongodb://
2019-07-08T17:48:17.868+0000 W NETWORK [thread1] Failed to connect to, in(checking socket for error after poll), reason: Connection refused
2019-07-08T17:48:17.869+0000 E QUERY [thread1] Error: couldn’t connect to server, connection attempt failed :
exception: connect failed

What is wrong ? and why the IP address is
Here is monogs configuration file:

configDB: m103-csrs/
keyFile: /var/mongodb/pki/m103-keyfile
bindIp: localhost,
port: 26000
destination: file
path: /var/mongodb/db/mongos.log
logAppend: true
fork: true

@Ridah_97796 is the IP address of your local machine (the Vagrant VM in this case), I don’t think there’s anything wrong with that.

The message about running a sharded cluster with fewer than 3 config servers means that there’s something wrong with your config server replica set. Try connecting mongo to that replica set and run rs.status().members. That’ll return an array of the nodes in the config server replica set.

If the array has fewer than 3 elements or any of the elements has a “stateStr” property other than “PRIMARY” or “SECONDARY” then that’s your problem, you need to check that the mongod processes for each of the nodes in the config server replica set are configured correctly and running.

I found initially that some of my mongod processes were stopping at some point after I started them. I never did work out why, but shutting down the vagrant VM with vagrant halt and then restarting it seemed to solve the problem.

Hope this helps :slight_smile:

1 Like

It turned out that I have to initiate CSRS files for mongos to work :no_mouth:

Thanks though. :slightly_smiling_face:

No worries, getting 9 mongods correctly configured into 3 replica sets and playing nicely with each other and a mongos isn’t a trivial task. I certainly didn’t find it easy.

Glad you worked it out :slight_smile:

1 Like