Follow by Email

Stopping and Starting the mongoDB replica set on linux servers

Stoping the MongoDB replication -

1) Go to mongo shell on Secondary servers

2)Stop the secondary servers by using below command :

   use admin
   db.shutdownServer()
  
2] Go to Linux shell- on secondary servers and type below command :

   sudo service mongod stop

Starting the MongoDB replication -

* Go to Linux shell - on secondary servers and type below command :

  sudo service mongod start
 Starting the MongoDB replication -

* Go to primary and type below commands to start the replication :

a] rs.initiate()

b] rs.add("Secondar -1:port no")

c] rs.add("Secondary-2:port no")
 
d] rs.add({ "_id" : 3, "host" : "Hidden_member:port no", "priority" : 0, 
"hidden" : true })

e] rs.status()