Query secondaries via mongos in self hosted sharded cluster configuration on AWS EC2?

Hello Everyone,

I have a concern or doubt, I have a replica set configuration (PSSH) in my environment as below.

Production Replica Set

  • Node1 - (Primary)
  • Node2 - (Secondary)
  • Node3 - (Secondary)
  • Node4 - (Secondary-Hidden) - ( Only for developers to run some find operation, which will not impact the production (PSS) load )

Now we want to convert our replica-set to sharded cluster, I am proposing the below structure for sharded cluster.

Production Sharded Cluster :

Config Server :

  • prod-config01 (Primary)
  • prod-config02 (Secondary)
  • prod-config03 (Secondary)

MongoS Server :

  • prod-mongos01
  • prod-mongos02
  • prod-mongos03

Shard1 Server : shard01repl

  • prod-mongo-shard01repl01 (Primary)
  • prod-mongo-shard01repl02 (Secondary)
  • prod-mongo-shard01repl03 (Secondary)
  • prod-mongo-shard01repl04 (Secondary-hidden)

Shard2 Server : shard02repl

  • prod-mongo-shard02repl01 (Primary)
  • prod-mongo-shard02repl02 (Secondary)
  • prod-mongo-shard02repl03 (Secondary)
  • prod-mongo-shard02repl04 (Secondary-hidden)

Question 1 : We have a user named aditya.sharma with some secret password. This user have tool like mongo shell or robo3t or compass to connect to the database. How this aditya.sharma user will connect to mongodb sharded cluster via mongos to run below query on Secondary-Hidden node only?

use test
db.testColl.find({ name : “Aditya Kumar Sharma” })

Note : Sharding is already enabled on test database and the testColl collection is also sharded using _id field as shard key and the data is also distributed on both the shards evenly.

Please help me to understand, if anyone have any Idea.

Thank you so much in advance.

Aditya Sharma

In the hidden member documentation there is the following lines:

Clients will not distribute reads with the appropriate read preference to hidden members. As a result, these members receive no traffic other than basic replication. Use hidden members for dedicated tasks such as reporting and backups.

This means that you would need to connect to the hidden member directly to read from it as I understand things.

Shortly after that is the following line:

In a sharded cluster, mongos do not interact with hidden members.

Based on this, I don’t think that you can connect to hidden members via a connection to mongos.


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