Home Database Mysql Tutorial MongoDB日志太大怎么办?

MongoDB日志太大怎么办?

Jun 07, 2016 pm 03:56 PM
mongodb what to do log

MongoDB的日志增长的很快,/var所在的空间马上就占满了,即便换到另一个磁盘分区保存日志,日志还是增长的很快,磁盘眼看要告磬。 有一个好办法,就是使用旋转日志。 MongoDB的旋转日志有点怪,Linux下mongd服务接受一个kill -SGIUSR1命令后就立刻将当前日志

MongoDB的日志增长的很快,/var所在的空间马上就占满了,即便换到另一个磁盘分区保存日志,日志还是增长的很快,磁盘眼看要告磬。

有一个好办法,就是使用旋转日志。

MongoDB的旋转日志有点怪,Linux下mongd服务接受一个kill -SGIUSR1命令后就立刻将当前日志文件重命名为带日期的文件,然后创建新的日志文件。

不想一般的旋转日志,可以配置旋转策略。不过没关系,经过测试,发送该命令时不会影响到MongoDB的服务。

下面是一个例子,先查找进程id, 然后发送命令。

root@jstc:/etc/init.d# ps -def | grep mongod
mongodb    723     1 48 May04 ?        6-22:23:53 /usr/bin/mongod --config /etc/mongodb.conf
root     22035 22012  0 20:22 pts/2    00:00:00 grep --color=auto mongod
root@jstc:/etc/init.d# kill -SIGUSR1 723
root@jstc:/etc/init.d# cd /home/mongodb/log/
root@jstc:/home/mongodb/log# ls
mongodb.log  mongodb.log.2014-05-18T12-23-51
root@jstc:/home/mongodb/log# ls -alh
total 20G
drwxrwxrwx 2 root    root    4.0K May 18 20:23 .
drwxrwxrwx 4 root    root    4.0K Apr 20 21:25 ..
-rw-r--r-- 1 mongodb nogroup  34K May 18 20:24 mongodb.log
-rwxrwxrwx 1 mongodb nogroup  20G May 18 20:23 mongodb.log.2014-05-18T12-23-51
Copy after login

现在可以将之前20G的日志文件挪走或者删除了。

也可以自己先个定时脚本,定期发送命令给mongod服务。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if I forget my Ouyi Wallet mnemonic phrase? Can it still be found? What should I do if I forget my Ouyi Wallet mnemonic phrase? Can it still be found? Jul 19, 2024 pm 12:13 PM

In the Web3 world, although it is free, it is full of dangers. Therefore, the first step in the security of Ouyi wallet is to protect the private key and mnemonic phrase. Everyone knows the importance of private keys, and today the emphasis is on mnemonics. The mnemonic phrase can be understood as another form of presentation of the private key. Having the mnemonic phrase is equivalent to owning the private key and controlling the wallet assets. It is also thought that its presence is lower than that of the private key, and users may forget the mnemonic phrase of Ouyi Wallet. So what should I do if I forget the mnemonic phrase of Ouyi Wallet? Can I still retrieve my Ouyi Wallet mnemonic if I forget it? Issues that users need to pay attention to. Generally speaking, if the mnemonic phrase is forgotten, it cannot be retrieved, but try to contact the relevant customer service personnel for help. The editor below will tell you in detail. What should I do if I forget my Ouyi Wallet mnemonic phrase? If you forget the mnemonic phrase of Ouyi Wallet, please try to recall it or contact us.

How to solve the rustling sound during TV playback (eliminate TV rustling sound) How to solve the rustling sound during TV playback (eliminate TV rustling sound) Jul 21, 2024 pm 03:29 PM

With the advancement of technology and people's increasing demand for high-definition picture quality, TV has become an indispensable part of home entertainment. However, sometimes you may hear an annoying rustling sound while watching TV, which not only affects the viewing experience, but may also cause the TV to malfunction. This article will introduce some methods to solve the rustling sound during TV playback, so that you can enjoy a higher quality movie viewing experience. 1: Check whether the audio cable connection is loose. If there is a rustling sound when the TV is playing, first check whether the audio cable connection is firm. Make sure both ends of the audio cable are plugged into the correct connectors and check for loose connections or poor connections. Two: Adjust the TV volume and audio device settings. Appropriately adjusting the TV volume and audio device settings will help eliminate rustling sounds. try

The computer does not have Bluetooth, how to solve it (how to quickly add Bluetooth function and precautions) The computer does not have Bluetooth, how to solve it (how to quickly add Bluetooth function and precautions) Jun 29, 2024 pm 06:57 PM

In modern society, Bluetooth has become an indispensable technology in our daily lives. However, for some older computers, they may not have built-in Bluetooth functionality. What if your computer does not have Bluetooth and you want to use a Bluetooth device? This article will introduce you to several methods and precautions for quickly adding Bluetooth functionality. 1. Use a Bluetooth adapter - A Bluetooth adapter is an external device that can be connected to a computer through a USB interface. -Purchase a compatible Bluetooth adapter and install the driver according to the instructions. -Plug the Bluetooth adapter into the USB port of your computer and wait for the system to automatically install the driver. 2. Check the driver 1. Check if there is a Bluetooth device on the computer. Open the device manager and check if there is a Bluetooth device. if not

Methods to solve the problem of insomnia (secrets to deep sleep) Methods to solve the problem of insomnia (secrets to deep sleep) Aug 22, 2024 pm 06:04 PM

Sleep is an important part of human health, and long-term insomnia not only affects the normal functions of the body, but also puts a certain amount of pressure on mental health. In order to help those friends who often stay up late and suffer from insomnia, this article will provide some scientific and effective solutions to help you enter deep sleep and say goodbye to the trouble of insomnia. How to solve the problem of insomnia Causes of insomnia Understand the various possible causes of insomnia, such as stress, anxiety, sleep environment, living habits, etc. Improve the sleeping environment. Adjust the sleeping environment to create a quiet, comfortable and warm environment, such as adjusting light, reducing noise, etc. Regular sleep habits Form regular sleep habits, establish the same bedtime and wake-up time every day, and develop good sleep habits. Relax your mind and body using relaxation techniques such as deep breathing, meditation, warm water soaking, etc.

There is no sound when headphones are plugged into the computer (There is no sound when headphones are plugged into the computer) There is no sound when headphones are plugged into the computer (There is no sound when headphones are plugged into the computer) Jun 26, 2024 pm 12:26 PM

When using a computer, we often encounter situations where we cannot hear the beautiful sound even though we plug in the headphones. This kind of problem may appear on computers of various brands and models. It is not only annoying, but also affects our normal use. This article will provide you with methods and techniques to solve the problem of no sound when headphones are plugged into the computer to help you quickly solve this problem. Check whether the headphone connection is reliable. If there is no sound after plugging headphones into the computer, first check whether the headphone connection is reliable. Make sure the headphone plug is firmly inserted into the computer's audio jack and is not loose or broken. Sometimes the plug is not inserted in place or is loose, causing the audio signal to fail to be transmitted, resulting in no sound. Confirm that the headphones are working properly. If the headphones are connected reliably but there is still no sound, you need to confirm

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

How to configure MongoDB automatic expansion on Debian How to configure MongoDB automatic expansion on Debian Apr 02, 2025 am 07:36 AM

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

How to solve the problem when the computer cannot connect to the mobile phone (quick troubleshooting) How to solve the problem when the computer cannot connect to the mobile phone (quick troubleshooting) Jun 25, 2024 pm 06:33 PM

In daily life, we often need to connect computers and mobile phones to realize functions such as file transfer, data backup, and network sharing. However, sometimes we encounter situations where the computer cannot connect to the mobile phone, which brings some trouble to our work and study. This article will introduce you to some solutions to help you quickly troubleshoot and achieve a stable connection between your computer and mobile phone. 1. Confirm whether the data cable is connected normally. 2. Check whether the USB debugging mode of the phone is turned on. 3. Try to replace the USB data cable. 4. Make sure the computer has the correct driver installed. 5. Check whether the computer’s USB interface is working normally. 6. Turn off the firewall and anti-virus. Software 7. Try to connect the phone to other computers 8. Check whether the USB driver on the computer needs to be updated 9. Restart the computer and

See all articles