3.26. MongoDB monitoring

发布时间 :2025-10-25 12:33:01 UTC      

After you have installed and deployed and allowed the MongoDB service, you must understand the operation of MongoDB and check the performance of MongoDB. In this way, in the case of large traffic, we can deal with it well and ensure the normal operation of MongoDB.

Mongostat and mongotop commands are provided in MongoDB to monitor the operation of MongoDB.

3.26.1. Mongostat command

Mongostat is a status detection tool that comes with mongodb and is used on the command line. It gets the current running state of mongodb at regular intervals and outputs it. If you find that the database suddenly slows down or has other problems, your first-hand operation should consider using mongostat to check the status of mongo.

Start your Mongod service, go to the bin directory under the MongoDB directory where you installed it, and enter the mongostat command, as shown below:

D:\set up\mongodb\bin>mongostat

The output of the above command is as follows:

Image0

3.26.2. Mongotop command

Mongotop is also a built-in tool under mongodb, and mongotop provides a way to track an instance of MongoDB to see which time is spent reading and writing data. Mongotop provides statistics at the level of each collection. By default, mongotop returns every second of the value.

Start your Mongod service, go to the bin directory under the MongoDB directory where you installed it, and enter the mongotop command, as shown below:

D:\set up\mongodb\bin>mongotop

The output of the above command execution is as follows:

Image1

Instance with parameters

E:\mongodb-win32-x86_64-2.2.1\bin>mongotop 10

Image2

The last 10 is <sleeptime> Parameter, can not be used, the length of time to wait, in seconds, between mongotop waiting for the call. The default mongotop that passes returns every second of the data.

E:\mongodb-win32-x86_64-2.2.1\bin>mongotop --locks

Report the use of locks for each database, using mongotop-locks, which produces the following output:

Image3

Output result field description:

  • ns:

    Contains the database namespace, which combines the database name with the collection.

  • db:

    Contains the name of the database. It’s called. The database is for global locking, not for specific databases.

  • total:

    The time mongod spends working on this namespace provides the total amount.

  • read:

    A lot of time is provided, and this mongod spends on performing read operations in this namespace.

  • write:

    It takes a lot of time for mongod to provide this namespace for writing.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.