Using hidden members in sharded environments

109 views
Skip to first unread message

DDany

unread,
Apr 27, 2012, 7:05:57 AM4/27/12
to mongod...@googlegroups.com
Hi,
using replica sets I can configure a secondary node as hidden. I could use this node for backup, or to make heavy calculation
that I don't want to affect the production environment.
In a sharded environment, I can put a hidden secondary in every shard, but there is a way I can send my queries
only to the hidden member of every shard through a mongos?
I didn't find nothing to do something like this, maybe I missed something.

Thanks in advance to anyone who will answer,
bye

Kevin Matulef

unread,
Apr 27, 2012, 11:34:10 AM4/27/12
to mongod...@googlegroups.com
Hi there,

Hidden members are hidden by definition, so there is no way to explicitly send queries to them unless you directly connect to them. 

Perhaps you can set up a secondary in each shard that is not hidden, but has priority 0?  That will guarantee that the node never becomes primary, and you can use it for backups and the like. You can also make queries with the slaveOk setting on, to direct the queries to secondary nodes.  This isn't exactly what you're asking for, since it doesn't direct queries to a specific secondary from each set, but it still might work for you. 

-Kevin

DDany

unread,
May 2, 2012, 5:38:19 AM5/2/12
to mongod...@googlegroups.com
Hi Kevin, 
thank you for your answer and sorry if I answer only now.
I'm using slaveOk, but I was hoping there was a way to direct queries to a specific secondary,
for example for calculate statistic data, while other secondaries receives data for the "normal
activity" of the application.
Unfortunely seems there is not such a possibility.

Thanks again for you help, if anyone else have another idea... I'll thank him/her! :)

Bye

Kevin Matulef

unread,
May 2, 2012, 2:10:04 PM5/2/12
to mongod...@googlegroups.com
Hi there,

It is possible to query a single secondary by connecting directly to it, then setting the "slaveOk" parameter to true.  For instance you can start up a mongo connection from the command line directly to the machine

> mongo <address-of-secondary>

Then in the mongo shell, type 

> rs.slaveOk();
> db.users.find(...)  //do whatever queries you want here

However, mongos won't do the routing for you, so you'll need to directly connect to the "special" secondary in each shard yourself. Again, not a perfect solution, but perhaps it's workable for your needs.  

-Kevin
Reply all
Reply to author
Forward
0 new messages