In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to solve the problem of inodes resource exhaustion in Linux system. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
1.inodes introduction
Under the Linux system, the file data is stored in the "block", and the meta-information of the file, such as the creator of the file, the creation date of the file, the size of the file, and so on. The area where the meta-information of the file is stored is called inode, which is translated into Chinese as "index node".
Inode also takes up space on the hard disk. When the hard disk is formatted, the operating system automatically divides the hard disk into two areas. One is the data area, which stores file data, and the other is the inode area (inode table), which stores the information contained in inode.
The size of each inode node is typically 128byte or 256byte. The total number of inode nodes, which is given when formatted, usually sets one inode per 1KB or per 2KB. Suppose that in a 1GB hard disk, the size of each inode node is 128bytes, and one inode is set for each 1KB, then the size of the inode table will reach 128MB, accounting for 12.8% of the whole hard disk.
2.inodes resource exhaustion
The use of inodes is similar to the use of storage space, but it cannot create files or execute some commands properly. When the inodes is used up, there may be still storage space. In this case, a large number of small files are generated, filling up the inode table.
In general, when the storage space is used up, inodes is often used only a few percent, so it is easy to ignore the monitoring of inodes usage.
Borrow a network chart to illustrate the situation where inodes is used up and disk space is not used up: check disk space usage and use the df command
To view inodess usage, use the df-I command
The above two commands can use the-h parameter, the commands are df-h and df-hi. You can see from the figure that 71% of disk space is used, but inodes uses 100%.
3.inodes exhaustion resolution
The size of the inodes is determined when the disk formats the partition, depending on the size of the partition. The larger the partition, the larger the inodes, and vice versa.
The root directory of the linux operating system generally has a small partition, so if there are small files generated on a fixed time and not cleaned up in time, it is easy to cause inodes to fill up.
Inodes fulfillment resolution steps:
(1) View the directory with the most files
For i in / *; do echo $I; find $I | wc-1; done
If you determine the scope of the directory, write / * specifically
In the end, it is found that there are too many small files in the / var/spool/postfix/maildrop directory for the following reasons: when linux executes cron, the output and warning information in the cron execution script will be emailed to the cron owner. Due to the failure of sendmail and postfix in the customer environment, and the unsuccessful sending of mail, all small files are accumulated in the maildrop directory, and due to the lack of automatic cleaning mechanism, a large number of files are accumulated in this directory.
After troubleshooting root users, it is found that there is a timing task that synchronizes the clock every minute, and the timing task produces a small file every minute.
(2) Delete a large number of files
Ls | xargs-n 1000 rm-rf needs to use the xargs command, otherwise deletion will fail.
4. Summary
(1) add MAILTO= "" to the first line of crontab-e and no files will be generated.
(2) Redirect sets the output file for scheduled tasks. Scheduled tasks that do not require log output can redirect logs to / dev/null, as shown below:
* / 10 * / tmp/test.sh > / dev/null 2 > & 1
(3) clean up documents regularly.
Find directory-type f-mtime + 30 | xargs-n 1000 rm-fags *
(4) Monitoring the use of inodes
Remarks: attention should be paid to the writing of crontab and the regular cleaning of the generated documents.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
After reading the above, do you have any further understanding of how to solve the problem of inodes resource exhaustion in Linux system? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.