InterviewSolution
| 1. |
What are different factors and conditions affecting elections when a primary replica set goes down? |
|
Answer» Monitoring is a critical component of all database administration. A firm grasp of MongoDB’s reporting will allow us to assess the state of the database and maintain deployment without crisis. Below are some of the utilities USED for MongoDB monitoring.
The mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance. mongostat is functionally similar to the UNIX/Linux file system utility vmstat but provides data REGARDING mongod and mongos instances. In order to run mongostat user must have the serverStatus privilege action on the cluster resources. Eg. To run mongostat every 2 minutes below command can be used. mongostat 120
mongotop provides a method to track the amount of time a MongoDB instance mongod spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns value every second. Eg. To run mongotop every 30 sec below command can be used. mongotop 30
MongoDB includes a number of commands that report on the state of the database.
The serverStatus command, or db.serverStatus() from the shell, return a general overview of the status of the database, detailing disk usage, memory use, connection, journaling, and index access. The command returns quickly and does not impact MongoDB performance.
The dbStats command, or db.stats() from the shell, returns a document that addresses storage use and data VOLUMES. The dbStats reflect the amount of storage used, the quantity of data contained in the database, and the object, collection, and index counters. We can use this data to monitor the state and storage capacity of a specific database. This output also allows to compare use between databases and to DETERMINE the average document size in a database.
The collStats or db.collection.stats() from the shell that provides statistics that resemble dbStats on the collection level, including a count of the objects in the collection, the size of the collection, the amount of disk SPACE used by the collection, and information about its indexes.
The replSetGetStatus command (rs.status() from the shell) returns an overview of replica set’s status. The replSetGetStatus document details the state and configuration of the replica set and statistics about its members. This data can be used to ensure that replication is properly configured, and to check the connections between the current host and the other members of the replica set.
Apart from the above tools MongoDB also provides an option for GUI based monitoring with ops-manager and cloud-manager. These are very efficient and are mostly used in large enterprise environments. |
|