Pyae Phyoe Shein
Pyae Phyoe Shein

Reputation: 13847

How to make Read replica on MongoDB Replica in AWS

enter image description here

Above is my mongodb cross replication in AWS. In our project I've added following connection string mongodb://admin:[email protected]:27017,mongo2.mydatabase.db:27017,mongo3.mydatabase.db:27017,mongo4.mydatabase.db:27017,arbiter.mydatabase.db:27017/admin?replicaSet=rsadmin as read replica to all secondary including different region. But now, I don't want to make read replica to different region called seoul region but keep syncing with other members, can I remove mongo4.mydatabase.db:27017 from connection string.

Upvotes: 0

Views: 96

Answers (1)

Stennie
Stennie

Reputation: 65433

I don't want to make read replica to different region called seoul region but keep syncing with other members, can I remove mongo4.mydatabase.db:27017 from connection string.

Replica set members listed in the connection string are used as a seed list in order to connect and discover your replica set configuration. The seed list does not have to contain all members of the replica set, and does not prevent additional members from being discovered via the replica set config.

If you want your replica set member in Seoul to be hidden from client applications, you need to make it hidden and priority 0. The hidden option will ensure this replica set member is not discoverable, and priority 0 is required since hidden members are not eligible to become primary. It is still possible to connect to a hidden replica set member directly, if needed.

I would also consider making this hidden secondary non-voting and removing the arbiter, which would leave you with 3 voting members in Singapore. An arbiter is only required when you have an odd number of voting members. If your secondary in Seoul is strictly for offsite backup or disaster recovery it does not need to participate in elections.

Upvotes: 1

Related Questions