Linux servers appear: No space left on device solutions _ _DRACOYU operation and maintenance of the blog -CSDN blog
https://blog.csdn.net/chanbo8205/article/details/85229453
Linux servers appear: No space left on device solutions
Error message:
2016-06-02 23:56:26 [com.thinkive.server.logger.TradeLogger]-[ERROR]
java.io.IOException: No space left on device
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:282)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
at com.thinkive.server.logger.TradeLogger$LoggerThread.flushLogFile(TradeLogger.java:404)
at com.thinkive.server.logger.TradeLogger$LoggerThread.run(TradeLogger.java:322)
Inadequate server disk, df -h look, var Normally, there is a surplus, the problem is not found, and later displayed a lot of No space left on device:
/ Var obviously there is a lot of space, why prompt "not enough space" of it to use the results of the node df -i command to view disk found in the following figure?:
100% of the nodes.
This time the user can look at whether the log file too if log files take up a lot of inodes expired at cleaning up the log can be temporarily released.
The following are checking inodes full one situation, for reference only:
View the original sentence crontab inside the regular implementation There is no added> / dev / null 2> & 1, program the system cron execution of the output contents, output contents will be sent cron users by mail, and sendmail does not start so we had a a lot of fragmented files:
cd / var / spool / clientmqueue / into this directory, delete these useless files, use ls to see what the result is no response, too many files, so he uses this command: ls | xargs rm -rf in batches the process of deleting files
Operation to this step, according to the occupancy of large directory files, temporary files to take up part of the transfer disk smaller directory.
The last two days for a server, the findings suggest "No space left on device" when using wget to download files, and even use the error will prompt completion when the tab key.
Once I encountered this problem before, because of disk space was already occupied, making it impossible to create a new file. Under normal circumstances, delete some files to free up space, you can solve the problem.
When I use the df command to view the partition, the results are as follows:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 29G 29G 0 100% /
udev 10M 0 10M 0% /dev
tmpfs 101M 232K 100M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 405M 0 405M 0% /run/shm
See here, I really think that the disk is 100% occupied, so he viewed the occupation of each directory:
# You -sh / *
8.8M / bin
30M /boot
0 /dev
5.3M /etc
24K /home
0 /initrd.img
205M /lib
4.0K /lib64
16K /lost+found
8.0K / media
4.0K / mnt
4.0K /opt
0 /proc
2.5G /root
232K /run
5.2M /sbin
8.0K /srv
0 /sys
4.0K /tmp
2.6G / usr
1.8G / was
0 /vmlinuz
Obviously, the total disk usage is less than completely 10G, disk theory has not been filled.
In this case, it is likely to be too small files, leading to a sharp increase inode, inode area of space consumed .
If so, even if the remaining disk space, but can not create new inode to store the meta-information file, it can not create new files.
So, I verify with df command:
# Df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/ Dev / vda1 1.9M 299K 1.6M 17% /
udev 123K 299 123K 1% /dev
tmpfs 126K 249 125K 1% /run
tmpfs 126K 4 126K 1% /run/lock
tmpfs 126K 2 126K 1% /run/shm
You can see, inode area occupied only a small part, there are a lot of unused space, so the inode is not a problem area was already occupied.
To here, my heart is very depressed. This problem led directly to the Apache, MySql and some other services are not started, the server has basically can not use, but the reason was confusing.
Finally, the server provider told me that another possible case, delete some files Shihai is being used by another process, then the file is not actually deleted, just marked as deleted, and only after the end of the process will actually file from disk Clear.
So I see the files being used in the process by lsop command:
# lsof | grep deleted
mysqld 1952 2982 mysql 5u REG 254,1 0 127 /tmp/ibzMEe4z (deleted)
mysqld 1952 2982 mysql 6u REG 254,1 0 146 /tmp/ibq6ZFge (deleted)
mysqld 1952 2982 mysql 10u REG 254,1 0 150 /tmp/ibyNHH8y (deleted)
apache2 2869 root 9u REG 254,1 0 168 /tmp/.ZendSem.2w14iv (deleted)
apache2 2869 root 10w REG 0,16 0 11077 /run/lock/apache2/rewrite-map.2869 (deleted)
...
python 3102 root 1w REG 254,1 22412342132 264070 /var/log/nohup.out (deleted)
Finally found the culprit turned out to be a Python script running in the background of a steady flow of /var/log/nohup.out save the output to a file, the file size actually reached 20G +!
After running in the background before the stage script, no longer control over it. My estimate is deleted nothup.out Python files during operation, because the file is occupied, it can only be marked as deleted, but not actually deleted, leading to disk full.
The lesson to remind me, the task can not be simply put back on the laissez-faire attitude, especially when using the nohup command, all output will be continuously added to the same file, if the process does not terminate, you might as causes the output file occupies the entire disk.
=============================================================================
=============================================================================
=============================================================================
A simple understanding of Linux inode and block - hard to force the operation and maintenance - blog Park
https://www.cnblogs.com/diantong/p/10504513.html
A simple understanding of Linux inode and block
Linux common file system type: ext3 (CentOS5), ext4 (CentOS6), xfs (CentOS7)
Windows common file system types: FAT32, NTFS
(1) .inode content
1) inode file that contains meta information, specifically, have the following:
Number of bytes in the file
User ID file owner
Group ID documents
Read files, write, and execute permissions
Timestamp file, there are three: ctime inode refers to the time of the last change file attributes, for example: chmod + x a.sh; mtime refers to the last time the file content changes, such as: echo aa >> a.sh or vim a.sh; atime value of the file's last open time, for example: cat a.sh.
The number of links that point to the number of file names inode
The location of the file data block
2) We can use the stat command to view a file's inode information:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
3) test ctime, mtime and atime
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
由此可见,黑客是可以通过修改时间,再植入木马,防止被find找到。
4)inode的大小
Inode也会消耗硬盘空间,所以硬盘格式化时,操作系统自动将文件分成两个区域。一个是数据区,用于存放文件数据;另一个是inode区,用于存放inode所包含的信息。
每个inode节点的大小一般是128字节或256字节。Inode节点的总数在格式化时就给定,一般是1KB或2KB或4KB就设置一个inode。如果一块1GB的硬盘,每个inode节点的大小为128字节,每1KB就设置一个inode,那么inode区的大小就会达到128MB,占整个硬盘的12.8%。(所以block可以设置的大一点)
5)inode号
每个inode都有一个号码,操作系统用inode号来识别不同的文件。
Unix/Linux系统内部不是用文件名,而使用inode号来识别文件。对于系统来说,文件名只是iode号便于识别的别名。表面上用户是通过文件名打开文件,实际上系统内部分成三个步骤:首先,系统找到这个文件名对应的inode号;其次通过inode号获取inode信息;最后根据inode信息找到文件数据所在的block,读出数据。
可以使用’ls -i [filename]’快速查看文件的inode号:
1 2 |
|
在Unix/Liunx系统中,目录也是一种文件。目录文件的结构非常简单,即使一系列目录项的列表。每个目录项由所包含文件的文件名以及该文件名对应的inode号组成。
可以使用’ls -id [directory]’快速查看目录的inode号:
1 2 |
|
另外可以使用’df -i’查看每个磁盘分区的inode总数和已经使用的数量
1 2 3 4 5 6 7 8 9 10 11 12 |
|
注意:由于每个文件都必须有一个inode号,因此有可能发生inode已用光,但硬盘未存满的情况。这时就无法在硬盘上创建新的文件。
6)inode的特殊作用
有时文件名有特殊字符或乱码,无法正常修改或删除,可以通过inode号来进行操作。实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
移动或重命名文件,只改变文件名,inode没影响。
使用vim修改文件内容后,inode会发生改变。实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
我一开始还怀疑会不会是我字节没有写满一个block,但我用cat写了20416个字节,结果inode号还是没变。我估计echo追加和cat重写都不改变inode号。
(2).block的内容
block是真正存储数据的地方。block是文件系统中的最小存储单位,扇区是磁盘中的最小存储单位。
注意:Linux下叫block,Windows下叫簇。
1) Windows如何修改簇的大小
可以右键一个分区,点击格式化会出现如下窗口:
这里的分配单元大小就是设置簇的大小。
2) Block或簇的大小对系统的影响
簇或block调大时,节约了寻址时间,速度变快,但浪费空间;簇和block调小时,节约空间,但寻址时间变长,速度变慢。
说明:为什么簇或block调大会浪费空间?这是因为一个文件会占用多个簇或block来存放。当前一个簇或block放不下时,就会占用下一个簇或block,到最后如果产生不足以占用一个完整的簇或block时,仍然会占用一个完整的簇或block,就会浪费这个簇或block剩下的空间。
如果有一个2T的硬盘,可以前1.5T使用4K的簇或block,后0.5G使用64K的簇或block,这样可以改善机械硬盘越到最后速度越慢的问题。
3) Linux下查看block的大小以及修改方式
查看block的大小
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
注意:xfs_info只能用于xfs的文件系统,如果是ext4或ext3请使用tune2fs
修改block的大小,就需要用到mkfs.xfs格式化命令,需要格式化分区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
注意:mkfs.xfs就是mkfs –t xfs的简写。