In this section, we will go over the most common deployment procedures to set up a replica set. These involve either converting a standalone server into a replica set or setting up a replica set from scratch.
Setting up a replica set
Converting a standalone server into a replica set
To convert a standalone server into a replica set, we first need to cleanly shut down the mongo server:
> use admin
> db.shutdownServer()
Then, we start the server with the --replSet configuration option via the command line (which we will do here), or by using a configuration file, as we will explain in the next section:
- First, we connect (via the mongo shell) to the new replica set enabled instance, as follows:
> rs.initiate()
- Now...