For example in oracle we can define tns.ora so client can connect with logical name. Although mongos can run on client servers, but when there are many different partner applications we we will need to worry about running daemon on partner machines. Is there alternative to provide mongo connection in a logical way and not necessarily physical mongo sever and port number? Thanks!
Mongodb – Is there way to have logical connection in MongoDB
mongodb
Best Answer
If your client applications are connecting directly to MongoDB, they will typically use a connection string which varies depending on the type of deployment:
mongod
hostname (and optionally, port)mongod
hosts in the replica set as a "seed list" to discover the current configurationmongos
hosts to connect to the sharded clusterThere isn't a direct equivalent of the "logical connection" abstraction. However, since you are already connecting via
mongos
, it sounds like you have a sharded cluster which does abstract the connection details for the underlying shards. Allmongos
connecting to the same cluster have to use the same--configdb
list.If you deploy a
mongos
per application host, each application can connect to themongos
on localhost. Alternatively you could have a fixed set of sharedmongos
and expose these via DNS cnames that resolve to "local"mongos
for that application or data centre.If you want to further lockdown per-client access, each client application could authenticate using different credentials which limit their access/permissions per-database. MongoDB 2.6 adds further granularity including collection-level access. For more information see Security Concepts in the MongoDB manual.