Log system for "Monogdb" MongoDB

Source: Internet
Author: User
Tags set time system log

I remember a few days ago a small partner to check the MongoDB log, so as to troubleshoot problems, may not find the log where the logs, today, the system said MongoDB log system. There are four main types of logs in MongoDB. are system log, journal log, Oplog master-slave log, slow query log, etc. These logs record the different handy traces of the MongoDB database. These four types of logs are described below:

1. System Log

The system log is very important in mongdb data, it records MongoDB start and stop operations, and the server in the process of running any exception information, configuration system log is very simple, in the run Mongod time add a parameter logpath, you can set;

For example: Mongod-logpath= '/data/db/log/server.log '-logappend.



2. Journal Log

The JOURANL log adds additional reliability assurance to MongoDB by pre-writing the redo log. When this feature is turned on, data updates are written to the journal Log, regularly committed (currently every 100ms), and then the changes are made in the official data. The journal function of starting the database is very simple, just specify the journal parameter after Mongod;

Open mode: mongod-journal



3. Oplog Master-Slave log

MongoDB's highly available replication strategy has one called replica Sets.replicaset the replication process has one server acting as the primary server, and one or more acting from the server, the master service writes the update to a local collection, which records the update operations that occur on the primary server. and distribute these operations to the slave server. This log is capped Collection. Use the following command to configure

mongod-oplogsize=1024 Unit is M

4. Slow query log

The slow query records the operation statement that the execution time exceeds the set time threshold. The slow query log is useful for discovering statements that have a performance problem, and it is recommended that you turn on this feature and often analyze the contents of the log.

To configure this feature, you only need to set the profile parameter at Mongod boot time. For example, if you want to record more than 5s of operations, you can use the following statement:

Mongod--profile=1--slowms=5








Log system for "Monogdb" MongoDB

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.