Configuring Replication - Mongo DB

Overview

This article explains how to configure replication for Mongo DB.

Procedure

Enable Replication

1. Edit /etc/mongod.conf: add the following lines

replication:
  replSetName: rsProd
  oplogSizeMB: 200

2. On the Primary server only

mongo

Then in the Mongo shell

rs.add("host-name:27017")
. . .
rs.initiate()

Disable Replication

1. On the Primary server only

mongo

2. For each host name in the replica set, within the Mongo shell, type the following command.

rs.remove("host-name:27017")