Replica set administration
The administration of a replica set can be significantly more complex than what is needed for single-server deployments. In this section, instead of trying to exhaustively cover all of the different cases, we will focus on some of the most common administrative tasks that we will have to perform and how to do them.
How to perform maintenance on replica sets
If we have some maintenance tasks that we have to perform in every member in a replica set, we always start with the secondaries. We perform maintenance by performing the following steps:
- First, we connect to one of the secondaries via the mongo shell. Then, we stop that secondary as follows:
> use admin > db.shutdownServer()
- Then, using the same user that was connected to the mongo shell in the preceding step, we restart the mongo server as a standalone server in a different port as follows:
> mongod --port 95658 --dbpath <wherever our mongoDB data resides in this host...