官术网_书友最值得收藏!

Diagnostic tools

One of the important tools of a database system is diagnostic tools. Fortunately, MongoDB has built-in diagnostic tools that enable developers to diagnose the server or get a brief report from the system.

We have the following utilities placed in this group:

  • mongostat
  • mongotop
  • mongosniff
  • mongoperf

In the next sections, you can read a brief description of each utility.

Learning about mongostat

This tool produces a brief summary of relevant statistics of the currently running MongoDB instances, either the mongod or mongos instance.

The following screenshot illustrates the output of this tool:

Learning about mongostat

The preceding screenshot shows you the number of queries, update, insert, and delete operations from the database every second.

The following bullet list gives you a brief description for each column:

  • insert: This refers to the number of insert operations per second.
  • query: This refers to the number of queries per second.
  • update: This refers to the number of update operations per second.
  • delete: This refers to the number of delete operations per second.
  • getmore: This refers to the number of getmore operations (that is, the it command in mongo shell) per second.
  • command: This refers to the number of executed commands since the last mongostat call.
  • flushes: This refers to the number of fsync operations at the time of the last mongostat execution. The fsync operation is a system call that flushes all dirty in-memory pages to the disk.
  • mapped: This refers to the total amount of data mapped in megabytes.
  • vsize: This refers to the amount of virtual memory in megabytes used by the process at the time of the last mongostat execution.
  • res: This refers to the amount of resident memory in megabytes used by the process at the time of the last mongostat execution.
  • locked: This refers to the percentage of time in a global write lock.
  • idx miss: This refers to the percentage of index access attempts that required a page fault.
  • qr: This refers to the number of clients in the queue that are waiting for read operations.
  • qw: This refers to the number of clients in the queue that are waiting for write operations.
  • ar: This refers to the number of clients that execute read operations.
  • aw: This refers to the number of clients that execute write operations.
  • netIn: This refers to the traffic received by the MongoDB instance in bytes.
  • netOut: This refers to the traffic sent by the MongoDB instance in bytes.
  • conn: This refers to the current total option connections.

The refresh interval can be changed using the following command:

mongostat [options] [sleep time] 

Utilizing mongotop

The mongotop utility provides you with a mechanism to get information about time spent on read/write operations. This command is similar to Unix's top command.

The following screenshot shows you a simple usage of mongotop:

Utilizing mongotop

Understanding mongosniff

The mongosniff is a tool that is used to fetch live MongoDB collection statistics. While inserting or querying data from the MongoDB instances, you can run the mongosniff command and connect it to your MongoDB instance to see what the database does.

Note

Please note that in order to use this utility, you should install the libpcap library first. To install the libpcap library, please visit its official website at http://www.tcpdump.org/#documentation.

A simple usage of the mongosniff tool is as follows:

sudo mongosniff --source NET lo0

The preceding command line will listen to the loopback interface (localhost). This interface is lo0 in Mac OS systems and lo for other operating systems, usually. You can get the list for your network interfaces using the ifconfig command. If you're using Windows as the operating system, you can get the list of network interfaces using the following command:

ipconfig /all

Utilizing mongoperf

The mongoperf tool represents the disk I/O performance. It checks the I/O in a specified interval and illustrates it. This utility can be used independent of MongoDB.

File storage (GridFS) tools

With the help of GridFS, MongoDB can be used as a filesystem. The processes in this section are used to manage and control the GridFS feature.

There is one process in this category, which is as follows:

  • mongofiles

Understanding mongofiles

This utility enables developers to retrieve files that are stored in the database in the GridFS collection. The mongofiles utility come in handy when developers need to interact with files stored in the database from the command-line environment.

The usage of this command looks like the following:

mongofiles <options> <commands> <filename>

The following example is a simple usage of this utility:

mongofiles -d mydb list

The preceding command line will retrieve all files in the GridFS collection from the mydb database.

Note

For more information on mongofiles, please visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongofiles/.

主站蜘蛛池模板: 南阳市| 伊通| 天祝| 太湖县| 调兵山市| 乐安县| 武陟县| 化州市| 株洲市| 泰宁县| 阿拉尔市| 象州县| 怀来县| 香格里拉县| 吴桥县| 都昌县| 克东县| 三穗县| 尚志市| 西乡县| 洪泽县| 江安县| 西宁市| 大石桥市| 商丘市| 正安县| 黄陵县| 鞍山市| 田阳县| 郧西县| 东宁县| 玉环县| 永吉县| 东光县| 兰州市| 曲松县| 武威市| 永宁县| 辛集市| 崇礼县| 青河县|