HA for mongos

34 views
Skip to first unread message

Sumit Thakur

unread,
Apr 20, 2018, 12:35:04 PM4/20/18
to mongodb-user
Dear Team,

I am new in MongoDB and now trying to set up its a cluster for evaluation purpose. 

Case: we are using only one instance of mongos and after some time run one more instance of it, but My java client is not able to send the request to the newly added mongos instance.
I think java client should add automatically new host IP of mongos in its connection pool.

Please suggest if any configuration is required for this.

Wan Bachtiar

unread,
May 21, 2018, 9:32:30 PM5/21/18
to mongodb-user

we are using only one instance of mongos and after some time run one more instance of it, but My java client is not able to send the request to the newly added mongos instance.

Hi Sumit,

You can specify a list of mongos instances, for example using ServerAddress:

MongoClient mongoClient = MongoClients.create(
        MongoClientSettings.builder()
                .applyToClusterSettings(builder ->
                        builder.hosts(Arrays.asList(
                                new ServerAddress("mongos_01", 27019),
                                new ServerAddress("mongos_02", 27019))))
                .build());

See also MongoDB Java Driver: Connect to a sharded cluster

Regards,
Wan

Reply all
Reply to author
Forward
0 new messages