You must have:

  • An active replica set.
  • A new MongoDB system accessible by the replica set.
  • ClusterAdmin privileges.
Note:

absrs01 is the name of the replica set used in the following steps.

To add a node to an existing replica set:

  1. Create the MongoDB directory structure on the new MongoDB node:
    # mkdir -p /opt/pingidentity/mongo/data/opt/pingidentity/mongo/logs \ /opt/pingidentity/mongo/key
  2. Download MongoDB 4.2 on the node and extract it to /opt/pingidentity/mongo:
    # cd /opt/pingidentity/ /opt/pingidentity# wget \ https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.0.tgz \ -O mongodb.tgz && tar xzf mongodb.tgz -C /opt/pingidentity/mongo/ --strip-components=1
  3. Update the shell path variable and reload the shell:
    /opt/pingidentity# echo PATH=$PATH:/opt/pingidentity/mongo/bin >> ~/.bashrc; /opt/pingidentity# source ~/.bashrc
  4. Copy the contents of the /opt/pingidentity/mongo/key directory from the primary node to the new node into /opt/pingidentity/mongo/key.
  5. Start the MongoDB database on the new node:
    /opt/pingidentity# cd mongo /opt/pingidentity/mongo# mongod --auth --dbpath ./data/ --logpath ./logs/mongo.log --port 27017 --replSet absrs01 --fork --keyFile ./key/mongodb-keyfile -bind_ip 0.0.0.0
  6. Connect to the mongo shell of the primary node and run the following command:
    absrs01:PRIMARY> rs.add({"host": "<IP address of new node>:27017", "priority": 2})

    The state of the new node changes to STARTUP2. This indicates that the synchronization between the replica set and the new node has started.

  7. Verify that the new node is added as a secondary node to the replica set using the following command:
    absrs01:PRIMARY> rs.status()

For more information, see https://docs.mongodb.com/manual/tutorial/expand-replica-set/.