Posts

Showing posts from October, 2020

Remove Shards from the existing Sharded cluster

Important points to be considered  before removing the shard from the existing shard cluster Make sure that the shard data is migrated to the other shards successfully. Make sure the balancer is enabled before you run the remove shard. Step-1: find the shard name to be removed  To find the name of the shard, connect to mongos instance.  db.adminCommand( { listShards: 1 } ) Output: mongos> db.adminCommand( { listShards: 1 } ) { "shards" : [ { "_id" : "replicaset1", "host" : "replicaset1/mysql8.localdomain:27011,mysql8.localdomain:27012,mysql8.localdomain:27013", "state" : 1 }, { "_id" : "replicaset2", "host" : "replicaset2/mysql8.localdomain:27021,mysql8.localdomain:27022,mysql8.localdomain:27023", "state" : 1 }, { "_id" : "replicaset3", "host" : "replicaset3/mysql8.localdomain:27031,mysql8.lo...

Configure Delayed, hidden member and Arbiter in MongoDB

Steps to Configure Delayed, hidden member and Arbiter in MongoDB To configure replication please follow the below link. https://ferozmdba.blogspot.com/2020/07/mongodb-replication-and-sharding.html Points to remember Hidden member will always be a priority "0" Delayed member will be a hidden member and priority "0" member When you consider a hidden one, make sure that priority is also "0" When configuring a delayed on, make sure that it has priority "0" as well as it is hidden. Steps to make replica as hidden var config=rs.conf() config.members[3].priority=0; config.members[3].hidden=true; rs.reconfig(config); Steps to configure slave Delayed var config=rs.conf() config.members[4].slaveDelay=3600 rs.reconfig(config);

Steps to configure replica set priority in MongoDB

 Configure replica set priority in MongoDB T o 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);  ...

Configure Shard/Sharding mongodb

Steps to configure Sharding in MongoDB on Linux 1. Configure 9 different servers mongod --dbpath /home/replica11 --port 27011 --logpath /home/replica11/rep11.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica12 --port 27012 --logpath /home/replica12/rep12.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica13 --port 27013 --logpath /home/replica13/rep13.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica21 --port 27021 --logpath /home/replica21/rep21.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica22 --port 27022 --logpath /home/replica22/rep22.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica23 --port 27023 --logpath /home/replica23/rep23.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica31 -...