fbpx

Delayed replica set Member in MongoDB

What is Delayed replica set member?

Delayed replica set member is a node that runs N number of seconds behind from the primary node. For example, if you have configured delayed node with one hour delay it will be always 60 minutes behind from the primary node. It means if you have created a new collection on the primary node it will appear in delayed node after 60 minutes. 

 

Delayed replica set Member in MongoDB

 

Why Do we need a delayed replica set member?

We configure delayed node for the following purposes:

  • Safeguard the data from human mistakes like wrong code push on the primary. Accidental data insert or update.
  • For backup and recovery purposes when you get a lot of concurrent data changes happen from the primary. At any given point in if you have to revert any specific data set.
  • It can used for point in time recovery.
  • It can also be used while making  BCP (Bussines Continuity Plan) setup.

 

How to configure it?

From primary node while adding a new delayed node just add ‘cfg.members[0].slaveDelay = 3600’ where 3600 demotes the seconds.

Full command
cfg = rs.conf()                                          Start the confiuration 
cfg.members[0].priority = 0                              Seting the node priority so that it never become primary  
cfg.members[0].hidden = true                             It Can’t vote in node eletion process 
cfg.members[0].slaveDelay = 3600                         Delay in seconds 
rs.reconfig(cfg)                                         Save the configuration

Important Note:

There might be a slight disconnection because ‘rs.config()’ may step down the primary and begin the node election process. You will see 5 to 10 seconds disconnect because this process will close all the application connection. The safer side you can perform delayed node addition in the downtime window.

 

Share:

Facebook
Twitter
Pinterest
LinkedIn

Social Media

Most Popular

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about new products, updates.

Categories