As you already learned in previous chapters, there are two main ways to deploy a MongoDB instance: using replica sets for deployment in a production environment and using a single mongod
instance for development or testing.
Although it's not a good idea to use a single mongod
instance for the production environment, we will introduce both methods to move a single mongod
instance and replica set.
First of all, there is a simple hack to migrate a replica set to another server. As you know, if you add a new member to an existing replica set, this member will synchronize its oplog
with the current primary
node. This is shown in the following diagram:
Let's assume we have a primary
node in our existing server, then we add a new node to the existing replica set. Obviously, initially it will be a secondary
node. This secondary
node is empty, but it synchronizes its oplog
with the primary server inside the existing server. This depends on the amount of data on the...