[Monogdb] MongoDB log system, monogdbmongodb

Source: Internet
Author: User

[Monogdb] MongoDB log system, monogdbmongodb

I remember a friend who was checking mongodb logs a few days ago may not be able to locate the problem. Today, the system will talk about mongodb's log system. Mongodb has four types of logs. These are system logs, Journal logs, oplog Master/Slave logs, and slow query logs. These logs record different convenient traces of the Mongodb database. The following describes the four types of logs:

1. System Logs

System logs are important in Mongdb data. They record mongodb start and stop operations and any exceptions that occur when the server is running. It is also very easy to configure system logs, you can add the logpath parameter when running mongod to set it;

For example, mongod-logpath = '/data/db/log/server. log'-logappend.



2. Journal logs

Jouranl logs provide additional reliability assurance for mongodb through pre-written redo logs. When this function is enabled, data updates are first written into the Journal log, regularly submitted in a centralized manner (currently submitted every ms), and then formally performed changes in the data. It is very easy to start the Journal function of the database. You only need to specify the journal parameter after mongod;

Enabling method: mongod-journal



3. Oplog Master/Slave logs

The high-availability replication policy of Mongodb is called Replica Sets. during ReplicaSet replication, one server acts as the master server, and one or more act as slave servers. The master service writes updates to a local collection, this collection record the update operations that occur on the master server. And distribute these operations to the slave server. This log is a Capped Collection. Use the following command to configure

Required D-oplogSize = 1024 unit: M

4. Slow query logs

The slow query records the operation statements whose execution time exceeds the set time threshold. Slow log query is very helpful for statements that discover performance problems. We recommend that you enable this function and analyze the log Content frequently.

To configure this function, you only need to set the profile parameter when mongod starts. For example, if you want to record all operations that exceed 5s, you can use the following statement:

Mongod -- profile = 1 -- slowms = 5








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.