MongoDB Enable profiling location problem

Source: Internet
Author: User
Tags log log

Recommended method Three, the simplest and easiest to view

A: If MongoDB has been running for a long time, the view mongod.log is very large, can not open to view the corresponding information

#ps-ef|grep Mongod

Find the PID of the corresponding Mongod process

Then kill-sigusr1 the PID so that Mongod will regenerate a log file

> Db.setprofilinglevel (2);
{"was": 0, "OK": 1}
> Db.getprofilinglevel ()
The above italic level can take 0,1,2 three values, they say the meaning is as follows:
0– not open

--Record slow command (default = >100ms)

--Record all orders

View in the log log of the Mongod node after profiling is turned on

Cat Mongod.log

or tail-300 Mongod.log.

Two.

In the future you have encountered this problem of some slow operation directly from the database to open the 5th level log under Small data, to see if it visited those tables, directly to see if there is no index in the PY
In general, as long as the system is not paralyzed, no index is a direct cause of slow
Db.admincommand ({logrotage:1})
KILL-SIGUSR1 xxx
Db.setloglevel (1, "query")
Db.setloglevel (1, "command")

Three

In order to locate the exclusive MongoDB problem as soon as possible, please help crawl the MongoDB log if you find out which operation or parallel operation is slow.

is divided into two aspects:

Profiling: If we define all database operations slower than 100ms to be slow, do the following:

Use MyDomain

Db.setprofilinglevel (1, 100), replace mydomain with the domain you tested

So all the slow operations will be shown here in Db.system.profile.

Db.setprofilinglevel (2) is the opening of all operation profiles, which can be experimentally used, or opened in a short time. But be sure to shut it down in time.

Show collections will see one more collection called System.profile.

Then Db.system.profile.find (). Pretty ()

LOG: You can see all the actions with Db.setloglevel (1,command), and the time of each operation will be recorded.

Remember to use Db.setloglevel (0,command) to change back after positioning.

MongoDB Enable profiling location problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.