Steps to configure replica set priority in MongoDB

 Configure replica set priority in MongoDB


To configure replication please follow the below link.

https://ferozmdba.blogspot.com/2020/07/mongodb-replication-and-sharding.html

1. Add a few more mongo instances, since we have 3 mongo instances running on ports 27107,27108 and 27109. So add two more instances.


mkdir -p /home/replica04

mkdir -p /home/replica05


2. start the 3 mongod server


mongod --dbpath /home/replica04 --port 27107 --logpath /home/logs/replica04_log --logappend --fork --bind_ip_all -replSet replicaset01

mongod --dbpath /home/replica05 --port 27108 --logpath /home/logs/replica05_log --logappend --fork --bind_ip_all -replSet replicaset01


3. connect to primary mongod db and run the below commands

var config=rs.conf()

config.members[1].priority=6;  --- it sets the highest priority

config.members[3].priority=0;  ---- this will never become primary whenever there is a primary replica crashes (because now (its bacame as a hidden member)

rs.reconfig(config);  ----- apply the configuration 

Comments

Popular posts from this blog

Auditing in Oracle database

rs.stepDown() in MongoDB replication

Tuples in Python