DNS of the Cluster MongoDB

710 views
Skip to first unread message

Amel

unread,
May 28, 2015, 11:58:06 AM5/28/15
to mongod...@googlegroups.com

I want to create a cluster of two servers  ( each server has its own mongodb instance ).   I set up a replicaset between these two servers.

 The goal is when one server is down, the other server should work. I want to access to the mongo by the DNS of the Cluster and not the nodes ( servers).

How it should be ?  What should be my DNS for this cluster ?  Does Mongo supports this architecture ?






Tim Hawkins

unread,
May 28, 2015, 12:02:13 PM5/28/15
to mongod...@googlegroups.com

You can use the dns name of either server, the drivers will find the other server by interogating tbe one that you specify.


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/1d839e70-e753-46d3-8805-e57ed2427224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Steneker

unread,
May 28, 2015, 1:34:41 PM5/28/15
to mongod...@googlegroups.com, a.ham...@alfstore.com
On Thursday, 28 May 2015 08:58:06 UTC-7, Amel wrote:
I want to create a cluster of two servers  ( each server has its own mongodb instance ).   I set up a replicaset between these two servers.

 The goal is when one server is down, the other server should work. I want to access to the mongo by the DNS of the Cluster and not the nodes ( servers).
 
Hi Amel,

MongoDB replica sets are intended for data redundancy and high availability, but the minimal deployment to achieve this is three mongod instances: http://docs.mongodb.org/manual/core/replica-set-architectures/.

Election of a primary requires votes from a strict majority of configured replica set members. A two-node replica set has a strict majority of 2 votes (n/2 + 1) so a primary will only be elected if both nodes are available. A three node replica set has a majority of 2, which provides for fault tolerance if one node is unavailable. The third replica set node can either be a data-bearing node (aka a "secondary") or a voting-only node (aka an "arbiter").


What should be my DNS for this cluster ?  Does Mongo supports this architecture ? 

With a replica set deployment you provide a seed list of replica set members in your client/driver connection string: http://docs.mongodb.org/manual/reference/connection-string/. The seed list is usually two or more members of your replica set. If the first member isn't contactable the driver will attempt connections to each successive member. The current replica set configuration and member roles (eg. primary, secondary, ...) will automatically be discovered and monitored once the initial connection to one of the replica set members is established. If the replica set configuration or member status changes, the driver will adjust to the new replica set state.

The hostnames you provide in your connection string and replica set configuration have to be consistently resolvable. Drivers/clients and other replica set members will use the DNS names as specified in your replica set configuration.

It's also worth reading through the security checklist to help ensure your deployment follows best practices: http://docs.mongodb.org/manual/administration/security-checklist/.

Regards,
Stephen

Reply all
Reply to author
Forward
0 new messages