Mongos router not opening a port

steevej
Sun, 01 May 2022 14:02:00 +0000

This should not be done.

R_Birtles:

The systemd entry for mongodb has been edited to start mongos:

You should create a systemd entry for mongos because

R_Birtles:

sudo systemctl restart mongod

fools everyone by letting us think your start mongod.

Starting mongos or mongod in a inconsistent way is error prone. Choose one of the following and stick to it:

R_Birtles:

sudo -u mongodb mongos --config /etc/mongod.conf

or

R_Birtles:

sudo systemctl restart mongod

The systemctl way should be the prefered way.

The configuration for mongos should be called /etc/mongos.conf, mongos not mongod. It is error prone to name it like you did.

Share your ss command without grep. Also share the command ip addr.

Despite the fact that your mongos seems to connect to your configuration server, something is wrong with it because:

Error initializing sharding state, sleeping for 2 seconds and retrying",
"attr":{"error":{"code":133,
  "codeName": "FailedToSatisfyReadPreference",
  "errmsg":"Error loading clusterID :: caused by :: Could not find host matching read preference { mode: \"nearest\" } for set ConfigReplSet"}}}

Mongos will retried until it is fixed before starting to listen.

I suspect your config server replica set is not initialized correctly. Share rs.status of your configuration server.