Exploring the local database of a replica set
In this recipe, we will explore the local database from a replica set's perspective. The local database may contain collections that are not specific to replica sets, but we will focus only on the replica set specific collections and try to take a look at what's in them and what they mean.
Getting ready
Refer to the recipe Starting multiple instances as part of a replica set from Chapter 1, Installing and Starting the Server for the prerequisites and know about the replica set basics. Go ahead and set up a simple three-node replica set on your computer, as mentioned in the recipe.
How to do it…
With the replica set up and running, we need to open a shell connected to the primary. You may connect randomly to any one member; use
rs.status()
and then determine the primary.With shell open, first switch to
local
database and the view the collections in thelocal
database as follows:> use local switched to db local > show collections
You should...