Adding new member for existing Replica Set

Good morning!

I am mounting a Replica Set environment with mongo 4.4. I already have a replica set environment with 3 members working correctly. Now what I want to do is add two more members to the replica set environment.

I have the configuration of Replica Set with internal authentication through a keyfile file as well as external authentication to have administrator users who can access and manage the databases.

The two members that are going to be part of the Replica Set that already exists, I already have MongoDB installed in them, which I would need to know how to add to the replica set that I already have running.

I have read the documentation and there are steps that are not clear to me. I would like you to tell me how to solve it step by step.

Thank you very much in advance!

Hello @Eduardo_HM,

This is the main documentation you need to follow for adding new members to the existing replica-set: Add Members to a Replica Set.

I have highlighted some sub-headings from the documentation for you to go through and understand. See these topics:

  • Data Files
    This specifies how you can quickly add data to your new members.
  • Requirements
    You already are ready with these, as per your post.
  • Procedures
    – Prepare the Data Directory (There are two ways to populate the data into the new member being added. You can use any of the two strategies).
    – Add a Member to an Existing Replica Set (There are five steps - you need to follow those steps to complete the adding of each new member)

Additional Info About Configuring the New Members:

The new member configuration file should include these in addition to the other configuration parameters like - storage, net, systemLog, etc., depending upon your setup. For example:

security:
  authorization: enabled
  keyFile: /path/your-replica-keyfile
replication:
  replSetName: your-repl-set-name

You will be using the same key file which was used for the existing members of the replica-set.

2 Likes

Thank you very much for the reply,

Then following the documentation the steps would be the following:

  • Stop the mongodb instance of the new member. Delete the data in / var / lib / mongo and copy the data from any of the replica set members to the new member’s / var / lib / mongo.
  • Copy also the mongo.conf file and the keyfile of one of the members that are already in the replica to the new member.
  • Start the mongo service in the new member with the new configuration loaded and the data copied from another member.
  • Go to the primary node and do the rs.add to add the new member to the replicaset.

Right?

Thanks in advanced!!!

Then following the documentation the steps would be the following: …

Yes, in summary. Please do follow the detailed steps from the provided links from my post.

Thank you very much for the answer.

What is still not clear to me is what difference there is between the first point “Data Files” and the point of “Prepare the data dictionary”.
In the first point “Data Files” tells me that what we have to do is copy the data that is in the path of one of the members of the Replicaset. At the point of preparing the data dictionary, according to the documentation, there are two ways to do it, check that there is nothing in the data directory, or manually copy data from one of the members to the new member. To copy the data, I understand that it will be enough to do a scp from a member node of the replicaset to the new member, right?

Thank you very much in advance

In the first point “Data Files” tells me that what we have to do is copy the data that is in the path of one of the members of the Replica-set.

Data Files:

This is not a step in the process, but is a note about data files and making a copy of them.

In general, in a replica-set’s each member has is own copy of data (replicated data). The new members being added initially will not have any data. To get the replicated data initially into a new member you can have the existing member’s data copied.

The documentation says:

If you have a backup or snapshot of an existing member, you can move the data files (e.g. the dbPath directory) to a new system and use them to quickly initiate a new member.

IMPORTANT
Always use filesystem snapshots to create a copy of a member of the existing replica set.

See Back Up and Restore with Filesystem Snapshots


Prepare the Data Directory:

At the point of preparing the data dictionary, according to the documentation, there are two ways to do it, check that there is nothing in the data directory, or manually copy data from one of the members to the new member. To copy the data, I understand that it will be enough to do a scp from a member node of the replicaset to the new member, right?

See above link on Back Up and Restore.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.