IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> Linux结构需要清理 -> 正文阅读

[系统运维]Linux结构需要清理

前言

我再做磁盘配额的时候为了实验我的磁盘配额是否生效,我在限制目录下用被限制的用户生成大量的无效文件出现了结构需要清理的报错。我尝试解绑之后发现用户被进程占用无法解绑。我尝试杀死进程之后发现并没有实际效果,最后它进程卡顿结束以后实现卸载,再尝试挂载被告知结构需要清理。我尝试移除这个目录发现可以,我再次创建一个同名目录并刷新挂载,但是之后发现事情和挂载无关。我使用xfs_repair /dev/ghr/lvghr去修复我的系统文件,恢复正常

故障

[root@192 ghr-class]# lsof | grep "ghr-class"        #查看进程里有关问题目录的进程
lsof: WARNING: can't stat() xfs file system /ghr-class
      Output information may be incomplete.
bash      22152                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23807                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)grep      23808                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23809                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)[root@192 ghr-class]# kill 22152 23807 23808 23809
-bash: kill: (23807) - 没有那个进程                    #尝试杀死进程
-bash: kill: (23808) - 没有那个进程
-bash: kill: (23809) - 没有那个进程
[root@192 ghr-class]# lsof | grep "ghr-class"
lsof: WARNING: can't stat() xfs file system /ghr-class
      Output information may be incomplete.
bash      22152                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23843                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)grep      23844                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23845                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)[root@192 ghr-class]# kill 22152
[root@192 ghr-class]# kill 23843
-bash: kill: (23843) - 没有那个进程              #又做了一次尝试,发现没有效果后放弃杀死进程 
[root@192 ghr-class]# kill 22152
[root@192 ghr-class]# lsof | grep "ghr-class"
lsof: WARNING: can't stat() xfs file system /ghr-class
      Output information may be incomplete.
bash      22152                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23854                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)grep      23855                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)lsof      23856                 root  cwd   unknown                                     
    /ghr-class (stat: Input/output error)
[root@192 ghr-class]# df -h            #查看磁盘使用情况
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G  4.8G   31G   14% /
devtmpfs                 897M     0  897M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  9.1M  903M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                497M  172M  326M   35% /boot
tmpfs                    183M   28K  183M    1% /run/user/0
/dev/sr0                 4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
/dev/mapper/ghr-lvghr     15G   33M   15G    1% /ghr-class
/dev/mapper/ghr1-lvghr1   15G   33M   15G    1% /ghr-class1
[root@192 ghr-class]# cd /ghr-class1/
[root@192 ghr-class1]# cd /ghr-class
[root@192 ghr-class]# ll                #想看下结构需要清理可能是什么导致的
ls: 无法打开目录.: 输入/输出错误
[root@192 ghr-class]# cd /
[root@192 /]# rm -rf ghr-class           #尝试移除目录
rm: 无法删除"ghr-class": 是一个目录
[root@192 /]# ll               
ls: 无法访问ghr-class: 输入/输出错误
总用量 28
drwxrwxrwt.  16 root root 4096 8月  11 21:46 tmp
drwxr-xr-x. 138 root root 8192 8月  11 20:08 etc
dr-xr-x---.  16 root root 4096 8月  11 20:04 root
drwxr-xr-x   42 root root 1240 8月  11 19:43 run
drwxrwxrwx    2 root root    6 8月  11 16:58 ghr-class1
drwxr-xr-x.   4 root root   34 8月  11 12:06 home
drwxr-xr-x    2 root root    6 8月  11 11:31 kgc-class
drwxr-xr-x   22 root root 3640 8月  11 11:30 dev
drwxr-xr-x    2 root root    6 8月  11 08:52 kgc
dr-xr-xr-x.   5 root root 4096 8月  11 08:24 boot
dr-xr-xr-x   13 root root    0 8月  11 08:24 sys
dr-xr-xr-x  270 root root    0 8月  11 08:24 proc
drwxr-xr-x.   2 root root    6 8月  10 09:22 2
drwxr-xr-x.   2 root root    6 8月  10 09:22 1
drwxr-xr-x.   4 root root   25 7月  29 10:24 opt
drwxr-xr-x.   2 root root    6 7月  28 09:57 help
drwxr-xr-x.  21 root root 4096 7月  26 22:18 var
drwxr-xr-x.  13 root root  155 7月  26 22:12 usr
lrwxrwxrwx.   1 root root    8 7月  26 22:12 sbin -> usr/sbin
lrwxrwxrwx.   1 root root    7 7月  26 22:12 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 7月  26 22:12 lib64 -> usr/lib64
lrwxrwxrwx.   1 root root    7 7月  26 22:12 bin -> usr/bin
drwxr-xr-x.   2 root root    6 11月  5 2016 media
drwxr-xr-x.   2 root root    6 11月  5 2016 mnt
drwxr-xr-x.   2 root root    6 11月  5 2016 srv
d??????????   ? ?    ?       ?            ? ghr-class
[root@192 /]# rm -rf /1          /移除一个无用目录确认系统正常工作
[root@192 /]# mount -a           /重启挂载关系,尝试解决问题
[root@192 /]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G  4.8G   31G   14% /
devtmpfs                 897M     0  897M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  9.1M  903M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                497M  172M  326M   35% /boot
tmpfs                    183M   28K  183M    1% /run/user/0
/dev/sr0                 4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
/dev/mapper/ghr-lvghr     15G   33M   15G    1% /ghr-class
/dev/mapper/ghr1-lvghr1   15G   33M   15G    1% /ghr-class1
[root@192 /]# umount /ghr-class        #成功卸载
[root@192 /]# mount -a                 #因为做了自动挂载直接刷新挂载关系,尝试重新挂载无效
mount: 将 /dev/mapper/ghr-lvghr 挂载到 /ghr-class 失败: 结构需要清理
[root@192 /]# df -h                     #查看挂载情况发现问题目录被卸载
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G  4.8G   31G   14% /
devtmpfs                 897M     0  897M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  9.1M  903M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                497M  172M  326M   35% /boot
tmpfs                    183M   28K  183M    1% /run/user/0
/dev/sr0                 4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
[root@192 /]# rm -rf /ghr-class          #移除问题目录
[root@192 /]# mkdir /ghr-class            #新建同名目录
[root@192 /]# mount -a                    #重启挂载关系
[root@192 /]# df -h                       #确认挂载完成,因为本身就是个空的目录我才敢这么做
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G  4.8G   31G   14% /
devtmpfs                 897M     0  897M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  9.1M  903M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                497M  172M  326M   35% /boot
tmpfs                    183M   28K  183M    1% /run/user/0
/dev/sr0                 4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
/dev/mapper/ghr1-lvghr1   15G   33M   15G    1% /ghr-class1
/dev/mapper/ghr-lvghr     15G  165M   15G    2% /ghr-class

#现在就重做一下磁盘配额并再做测试就行了
[root@192 /]# xfs_quota -xc 'limit -u bsoft=80M bhard=100M isoft=40 ihard=50 ghr5' /ghr-
class[root@192 /]# xfs_quota -xc 'report abiuh'
[root@192 /]# xfs_quota -xc 'report -abuih'
User quota on /ghr-class1 (/dev/mapper/ghr1-lvghr1)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]

User quota on /ghr-class (/dev/mapper/ghr-lvghr)
                        Blocks                            Inodes              
User ID      Used   Soft   Hard Warn/Grace     Used   Soft   Hard Warn/Grace  
---------- --------------------------------- --------------------------------- 
root            0      0      0  00 [------]      3      0      0  00 [------]
ghr5            0    80M   100M  00 [------]     23     40     50  00 [------]

[root@192 /]# chown ghr5 /ghr-class  #重做了之前的整个步骤

[ghr5@192 ghr-class]$ touch {1..51}.txt   #发现问题没有解决,越发的觉得自己是个笨蛋。这个结构应该不是目录,而是文件系统,当时没想到。我们重新格式化可能会解决。
touch: 无法创建"24.txt": 结构需要清理
touch: 无法创建"25.txt": 输入/输出错误

[root@192 /]# xfs_repair /dev/mapper/ghr-lvghr 
xfs_repair: cannot open /dev/mapper/ghr-lvghr: 设备或资源忙
[root@192 /]# xfs_repair -f /dev/mapper/ghr-lvghr 
xfs_repair: cannot open /dev/mapper/ghr-lvghr: 设备或资源忙
[root@192 /]# umount /ghr-class
[root@192 /]# xfs_repair -f /dev/mapper/ghr-lvghr 
Phase 1 - find and verify superblock...
Cannot get host filesystem geometry.
Repair may fail if there is a sector size mismatch between
the image and the host filesystem.
Phase 2 - using internal log
        - zero log...
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_repair.  If you are unable to mount the filesystem, then use
the -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.
[root@192 /]# xfs_repair -L /dev/mapper/ghr-lvghr 
#日志很长我省略掉了
[root@192 /]# mount -a       #刷新挂载
[root@192 /]# df -h          #查看挂载
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   36G  4.8G   31G   14% /
devtmpfs                 897M     0  897M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  9.1M  903M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                497M  172M  326M   35% /boot
tmpfs                    183M   28K  183M    1% /run/user/0
/dev/sr0                 4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
/dev/mapper/ghr1-lvghr1   15G   33M   15G    1% /ghr-class1
/dev/mapper/ghr-lvghr     15G   33M   15G    1% /ghr-class
[root@192 /]# touch /ghr-class/{1..51}.txt       #创建成功
[root@192 /]# rm -rf /ghr-class/{1..51}.txt      #问题解决
   

总结

我觉得可能是我重启挂载关系,让问题目录变得可以被卸载了,之后我以为搞好了之后发现问题并不是进程或者目录的原因,结构需要清理是文件系统出现了问题,我修复了挂载映射的文件系统分区。解决了这个结构需要清理的问题。

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2021-08-12 17:05:23  更:2021-08-12 17:07:20 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/20 15:50:03-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码