Replica set administration
Administration for 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 different cases we will focus on some of the most common administration 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 first. First we connect via mongo shell to one of the secondaries. Then we stop this secondary:
> use admin > db.shutdownServer()
Then, using the same user that was connected to the mongo shell in the previous step, we restart the mongo server as a standalone server in a different port:
> mongod --port 95658 --dbpath <wherever our mongoDB data resides in this host>
The next step is to connect to this mongod
server (which is using dbpath
):
> mongo --port 37017
At this point, we can safely...