IDE in M103 slow to respond

hello, I am trying to complete the “deploy a sharded cluster” lab. I made updates to the mongos.conf file, but when I try to run mongos -f mongos.conf, the IDE never returns so I can see if it is correct.

Is there any way to tell if there is an error in the .conf file which is causing the IDE to not respond?

Did you check mongos.log?
Show us your config file
May be you forgot to add fork and it is running in foreground(by IDE never returns i understood it you are not getting the prompt back)
Paste a screenshot of your IDE

mongos.conf:
sharding:
configDB: shard1/localhost:27001,localhost:27002,localhost:27003
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: localhost
port: 26000
systemLog:
destination: file
path: /var/mongodb/logs/mongos.log
logAppend: true
processManagement:
fork: true

Screen Shot 2022-07-28 at 10.19.35 AM

from the mongos.log:
2022-07-28T17:20:59.282+0000 I ASIO [ShardRegistry] Failed to connect to localhost:27001 - InvalidOptions: Surprised to discover that localhost:27001 does not believe it is a config server
2022-07-28T17:20:59.282+0000 I ASIO [ShardRegistry] Dropping all pooled connections to localhost:27001 due to InvalidOptions: Surprised to discover that localhost:27001 does not believe it is a config server
2022-07-28T17:20:59.283+0000 W SHARDING [mongosMain] Error initializing sharding state, sleeping for 2 seconds and trying again :: caused by :: InvalidOptions: Error loading clusterID :: caused by :: Surprised to discover that localhost:27001 does not believe it is a config server

The problem statement:

Problem:

Deploy a sharded cluster with 1 shard.

Some components have already been configured for you:

  • the Configuration Server Replica Set csrs is running on csrs/localhost:27004,localhost:27005,localhost:27006
  • a replica set shard1 is running on shard1/localhost:27001,localhost:27002,localhost:27003
  • the m103-admin user has been created on both replica sets with password m103-pass

You will only need to edit the mongos configuration file.

  1. Start up a mongos process to provide an interface to your sharded cluster. You can find an unfinished configuration file for mongos in the IDE file browser.The configuration servers should already be running on the csrs replica set. Remember that mongos inherits database users from the CSRS.
  2. Add shard1 as the first shard in the cluster.
  3. Once you’ve run the proper commands, click “Run Tests” to run a suite of tests that will check the configuration of mongos. The results of these tests will let you know which steps you’ve yet to complete.

Review configDB parameter in your mongos config file
It should be pointing to csrs replicaset
Also only one mongos instance should be running

Thanks Ramachandra,

I changed the mongos config file as you suggested and am not getting the following error message in the mongos.log:

2022-07-28T20:12:52.255+0000 W NETWORK [mongosMain] node: localhost:27006 isn’t a part of set: shard1 ismaster: { hosts: [ “localhost:27004”, “localhost:27005”, “localhost:27006” ], setName: “csrs”, setVersion: 3, ismaster: false, secondary: true, primary: “localhost:27004”, me: “localhost:27006”, lastWrite: { opTime: { ts: Timestamp(1659039170, 1), t: 1 }, lastWriteDate: new Date(1659039170000), majorityOpTime: { ts: Timestamp(1659039170, 1), t: 1 }, majorityWriteDate: new Date(1659039170000) }, configsvr: 2, maxBsonObjectSize: 16777216, maxMessageSizeBytes: 48000000, maxWriteBatchSize: 100000, localTime: new Date(1659039172255), logicalSessionTimeoutMinutes: 30, minWireVersion: 7, maxWireVersion: 7, readOnly: false, compression: [ “snappy” ], ok: 1.0, operationTime: Timestamp(1659039170, 1), $gleStats: { lastOpTime: Timestamp(0, 0), electionId: ObjectId(‘000000000000000000000000’) }, lastCommittedOpTime: Timestamp(1659039170, 1), $clusterTime: { clusterTime: Timestamp(1659039170, 1), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } } }
2022-07-28T20:12:52.255+0000 W NETWORK [mongosMain] Unable to reach primary for set shard1

What am I missing?

What other steps you did after editing the mongos.conf
Show the config file details again

sharding:
configDB: shard1/localhost:27004,localhost:27005,localhost:27006
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: localhost
port: 26000
systemLog:
destination: file
path: /var/mongodb/logs/mongos.log
logAppend: true
processManagement:
fork: true

I used mongo --port to connect to both the csrs and the replica set. I verified that each has 3 members

Replicaset that is running on ports 27004,27005&27006 is csrs not shard1 as you have added under configDB param
Please correct and try again

Got it working… I was getting confused where to run the sh.addShard()

Thanks for your help

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.