Should MongoDB arbiter be included in client connection configuration?

If the replica set is configured in Mongo with only two nodes, you must add an arbiter to ensure that there is always a majority in voting for a new master. The arbiter never becomes the master himself, he just has to provide a caste vote in other neck and neck choices.

When connecting the client (in my case Java) to the MongoDB cluster, we must specify all the nodes of the cluster in the Connection Configuration:

List addrs = new ArrayList(); addrs.add( new ServerAddress( "localhost" , 27017 ) ); addrs.add( new ServerAddress( "localhost" , 27018 ) ); Mongo mongo = new Mongo(addrs); 

Should an arbiter be included in the connection configuration? I do not think they are:

do not have a copy of the data and will never become the primary node (or even readable secondary)

(Taken from here )

... but I just wanted to double check!

+7
source share
2 answers

No, you do not need to include arbitrators in the connection.

In the end, as you suspected, it would make little sense in your code to try to connect to one of them, since there is no data there. They simply do their stuff behind the glasses to help them roll back automatically.

You do not even need to specify all the servers in the configuration of your connection (not even leading ones) - if one of the servers to which you refer returns a response, it can find a wizard from there. Although IMHO, the more you call, the better, just some of them are omitted.

+6
source

A list is just a list of seeds. The actual members of the replica set are determined after connecting to one. You could just specify one of them in 27017 (but it would be bad if this one were disabled).

+1
source

All Articles