English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When preparing a MongoDB deployment, it is advisable to understand how your application will maintain stability in the production environment. Developing consistent, repeatable methods to manage the deployment environment is a good idea, so that once it is put into production, you can minimize surprises to the greatest extent possible.
The best approach includes prototyping your setup, conducting load tests, monitoring key indicators, and using this information to scale your setup. The key part of this method is to actively monitor the entire system-This will help you understand how the production system will withstand before deployment and determine where to increase capacity. For example, delving into the potential peak memory usage may help extinguish write locks before starting.
To monitor your deployment, MongoDB provides the following commands-
This command checks the status of all running mongod instances and returns counters for database operations. These counters include inserts, queries, updates, deletes, and cursors. The command also displays the time you encountered page errors and shows the percentage of locks. This means your memory is insufficient, you have reached write capacity, or there are some performance issues.
To run this command, please start your mongod instance. In another command prompt, go tobin
Enter the MongoDB installation directory, then inputmongostat
.
D:\set up\mongodb\bin>mongostat
The following is the output of the command-
This command tracks and reports the read/write activities of MongoDB instances based on collection. By default,mongotop
information is returned every second, you can change it accordingly. You should check whether this read/write activity matches your application's intent, and you should not write to the database too frequently, read data from the disk too frequently, or exceed the size of the working set.
To run this command, please start your mongod instance. In another command prompt, go tobin
Enter the MongoDB installation directory, then inputmongotop
.
D:\set up\mongodb\bin>mongotop
The following is the output of the command-
To changemongotop
To reduce the frequency of returned information, please specify a specific number after the mongotop command.
D:\set up\mongodb\bin>mongotop 30
The above example will return every3values are returned every 0 seconds.
In addition to MongoDB tools,10gen also provides a free hosting monitoring service, MongoDB Management Service (MMS), which provides a dashboard and gives you a view of metrics from the entire cluster.