sh.addShard not finding primary

I have verified multiple times my replica set is running and 27001 is the primary.

MongoDB Enterprise mongos> sh.addShard(“m103-repl/”)
“ok” : 0,
“errmsg” : “Could not find host matching read preference { mode: “primary” } for set m103-repl”,
“code” : 133,
“codeName” : “FailedToSatisfyReadPreference”,
“operationTime” : Timestamp(1568074103, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1568074103, 1),
“signature” : {
“hash” : BinData(0,“EKbt9g2y9YA3YhSJ4Gazr7Pbsyc=”),
“keyId” : NumberLong(“6734501740806144026”)

Is the issue I am using the same MongoS and CSRS server as the lectures have you create? The lab instruction have the same config and ports as the lecture servers so I am not sure if I am just adding another shard to the server (m103-example and m103-repl).

What does rs.status() show
Please check your setup again.Check your config files if any param lie clusterrole etc missing
May be some mixup in configfiles from previous labs or a replicaset was already initiated on same port or some hostname/IP resolution issues
m103-repl and m103-example are from different labs
For sharding you will be using m103-repl and m103-repl-2
Best would be to cleanup all old instances and start from begin your sharding lab steps

1 Like