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.
Refer to the Starting multiple instances as part of a replica set recipe in Chapter 1, Installing and Starting the MongoDB Server, for the prerequisites and to know about replica set basics. Go ahead and set up a simple three-node replica set on your computer, as mentioned in the recipe.
With the replica set up and running, we need to open a shell connected to the primary. You may randomly connect to any one member, execute
rs.status()
, and then determine the primary.With the shell opened, first switch to the
local
database and then view the collections in thelocal
database as follows:> use local switched to db local > show collections...