标签:logs access lex 磁盘分区 tab 删除一个文件 exe 扩展 cannot
第1章 磁盘空间不足实例1-1 no space left on device 原因 如何排查与解决
1.inode df -i ; 找出系统中目录大小大于1M 确认之后 删除大量小文件
2.block df -h ; du -sh 一层一层查找 确认之后 删除文件
.conf 配置文件
.sh 脚本
.tar.gz 压缩包
.py python脚本
1.二进制文件(命令)
2.文本文件(text)
3.数据文件(data)需要单独命令查看
f file 文件
d dir 目录
l softlink 软连接
b block 块设备
c character 字符设备
p pipe 管道
s socket 套接字
[root@oldboyedu50-lnb /tmp]# file /bin/ls /etc/hosts /tmp/etc-pai.tar.gz
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
/etc/hosts: ASCII text
/tmp/etc-pai.tar.gz: gzip compressed data, from Unix, last modified: Fri Jul 20 02:39:55 2018
[root@oldboyedu50-lnb /tmp]# ll etc.tar.gz
-rw-r--r-- 1 root root 9734648 Jul 20 01:41 etc.tar.gz
[root@oldboyedu50-lnb /tmp]# mv etc.tar.gz etc.txt
[root@oldboyedu50-lnb /tmp]# ll etc.txt
-rw-r--r-- 1 root root 9734648 Jul 20 01:41 etc.txt
r----read 可读 4
w----write 可写 2
x----execute 可执行 1
- 0
-rw- r-- r-- 2 root root 186 Jul 26 11:19 /etc/hosts
420 400 400
6 4 4
1.字符转换数字
-rw-r----- 640
-r--r--r-- 444
-rw-r--r-- 644
-rw------- 600
2.数字转换字符
644 -rw-r--r--
755 -rwxr-xr-x
400 -r--------
640 -rw-r-----
软连接(softlink 或 符号链接 symlink) 硬链接 (hard link)
在同一个磁盘分区中,文件的inode号码相同,互为硬链接
1.特点 同一个分区中 inode相同的文件,互为硬链接
2.防止误删除
3.彻底删除一个文件条件:
文件硬链接数为0(rm)
创建硬链接 ln命令创建
[root@oldboyedu50-lnb /oldboy]# echo oldboyedu.com > oldboy.txt
[root@oldboyedu50-lnb /oldboy]# ll oldboy.txt
-rw-r--r-- 1 root root 14 Jul 27 21:49 oldboy.txt
[root@oldboyedu50-lnb /oldboy]# ln oldboy.txt oldboy.txt-hard
[root@oldboyedu50-lnb /oldboy]# ll oldboy.txt
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt
[root@oldboyedu50-lnb /oldboy]# ll -i oldboy.txt oldboy.txt-hard
1046996 -rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt
1046996 -rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt-hard
相当于windows快捷方式 存放的源文件的位置
创建软连接
[root@oldboyedu50-lnb /oldboy]# ln -s oldboy.txt oldboy.txt-soft
[root@oldboyedu50-lnb /oldboy]# ls -l oldboy.txt*
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt-hard
lrwxrwxrwx 1 root root 10 Jul 27 22:09 oldboy.txt-soft -> oldboy.txt
[root@oldboyedu50-lnb /oldboy]# ls -l oldboy.txt*
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt-hard
lrwxrwxrwx 1 root root 10 Jul 27 22:09 oldboy.txt-soft -> oldboy.txt
lrwxrwxrwx 1 root root 18 Jul 27 22:16 oldboy.txt-soft2 -> /oldboy/oldboy.txt
[root@oldboyedu50-lnb /oldboy]# mv alex.txt oldboy.txt
[root@oldboyedu50-lnb /oldboy]# ls -l oldboy.txt*
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt
-rw-r--r-- 2 root root 14 Jul 27 21:49 oldboy.txt-hard
lrwxrwxrwx 1 root root 10 Jul 27 22:09 oldboy.txt-soft -> oldboy.txt
lrwxrwxrwx 1 root root 18 Jul 27 22:16 oldboy.txt-soft2 -> /oldboy/oldboy.txt
1.硬连接数为0 rm
2.进程调用数为0 是否有人使用
lsof |grep oldboy.txt tail -f /oldboy/oldboy.txt
list open files
[root@oldboyedu50-lnb /oldboy]# lsof |grep oldboy.txt
tail 3755 root 3r REG 8,3 14 1046996 /oldboy/oldboy.txt
命令或服务名称 文件大小 inode号码 文件名
实例2-1 模拟 文件没有被彻底删除(i_link)为0 进程调用数(i_count)不为0
seq 500000000 >>/var/log/messages
1.查看磁盘使用
[root@oldboyedu50-lnb /oldboy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 17G 1.1G 95% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 40M 141M 22% /boot
/dev/sdc 73K 14K 55K 21% /app/logs
[root@oldboyedu50-lnb /oldboy]# du -sh /*|sort -h |tail -1
16G /var
[root@oldboyedu50-lnb /oldboy]# du -sh /var/*|sort -h|tail -1
16G /var/log
[root@oldboyedu50-lnb /oldboy]# du -sh /var/log/*|sort -h|tail -1
16G /var/log/messages
2.删除这个文件
[root@oldboyedu50-lnb /oldboy]# ll /var/log/messages
-rw------- 1 root root 16197811985 Jul 27 23:00 /var/log/messages
[root@oldboyedu50-lnb /oldboy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 17G 1.1G 95% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 40M 141M 22% /boot
/dev/sdc 73K 14K 55K 21% /app/logs
[root@oldboyedu50-lnb /oldboy]# \rm -f /var/log/messages
3.磁盘空间不足 继续通过du -sh 排查
[root@oldboyedu50-lnb /oldboy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 17G 1.1G 95% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 40M 141M 22% /boot
/dev/sdc 73K 14K 55K 21% /app/logs
[root@oldboyedu50-lnb /oldboy]# du -sh /* |sort -h |tail
du: cannot access `/proc/3800/task/3800/fd/4': No such file or directory
du: cannot access `/proc/3800/task/3800/fdinfo/4': No such file or directory
du: cannot access `/proc/3800/fd/4': No such file or directory
du: cannot access `/proc/3800/fdinfo/4': No such file or directory
376K /root
7.6M /bin
16M /sbin
27M /lib64
30M /etc
38M /boot
80M /var
114M /tmp
214M /lib
1.1G /usr
4. 原因:文件没有被彻底删除
找出这个被占用文件
[root@oldboyedu50-lnb /oldboy]# lsof |grep messages
rsyslogd 1412 root 4w REG 8,3 16197811985 392705 /var/log/messages (deleted)
5.解决
#deleted lsof标记 表示文件硬链接数为0 进程调用数不为0
#进程调用数为0 ==== 重启服务/软件
[root@oldboyedu50-lnb /oldboy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 17G 1.1G 95% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 40M 141M 22% /boot
/dev/sdc 73K 14K 55K 21% /app/logs
[root@oldboyedu50-lnb /oldboy]# /etc/init.d/rsyslog restart
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
[root@oldboyedu50-lnb /oldboy]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.6G 17G 9% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 40M 141M 22% /boot
/dev/sdc 73K 14K 55K 21% /app/logs
[root@oldboyedu50-lnb /oldboy]# lsof |grep messages
rsyslogd 3828 root 1w REG 8,3 229 392660 /var/log/messages
标签:logs access lex 磁盘分区 tab 删除一个文件 exe 扩展 cannot
原文地址:http://blog.51cto.com/13858927/2152190