经典的 LVM 问题排查方法(保持更新)

作者: 王炳明 分类: Linux 教程 发布时间: 2021-07-06 10:32 热度:459

Input/output error

机器上原本有 ssd 和 hdd 两个 vg,然后执行 pvs 出现了如下错误

$ pvs
  /dev/ssd-volumes/d1b59825-a9cf-4c9a-ac62-e6956ac95c58_disk.eph1: read failed after 0 of 4096 at 0: Input/output error
  /dev/ssd-volumes/d1b59825-a9cf-4c9a-ac62-e6956ac95c58_disk.eph1: read failed after 0 of 4096 at 214748299264: Input/output error
  /dev/ssd-volumes/d1b59825-a9cf-4c9a-ac62-e6956ac95c58_disk.eph1: read failed after 0 of 4096 at 214748356608: Input/output error
  /dev/ssd-volumes/d1b59825-a9cf-4c9a-ac62-e6956ac95c58_disk.eph1: read failed after 0 of 4096 at 4096: Input/output error
  /dev/ssd-volumes/92cddf6c-aec6-4307-8ce1-c84104e21844_disk.eph1: read failed after 0 of 4096 at 0: Input/output error
  /dev/ssd-volumes/92cddf6c-aec6-4307-8ce1-c84104e21844_disk.eph1: read failed after 0 of 4096 at 257697972224: Input/output error
  /dev/ssd-volumes/92cddf6c-aec6-4307-8ce1-c84104e21844_disk.eph1: read failed after 0 of 4096 at 257698029568: Input/output error
  /dev/ssd-volumes/92cddf6c-aec6-4307-8ce1-c84104e21844_disk.eph1: read failed after 0 of 4096 at 4096: Input/output error
  PV         VG          Fmt  Attr PSize  PFree  
  /dev/sdb   hdd-volumes LVM2 a--  <1.82t  93.13g
  /dev/sdc   hdd-volumes lvm2 a--  <1.82t      0 

解决方法

先执行 dmsetup ls 查看有哪些ssd的

$ dmsetup ls
ssd--volumes-92cddf6c--aec6--4307--8ce1--c84104e21844_disk.eph1 (253:13)
ssd--volumes-d1b59825--a9cf--4c9a--ac62--e6956ac95c58_disk.eph1 (253:12)

再执行 ssd 的删除掉

$ dmsetup remove ssd--volumes-92cddf6c--aec6--4307--8ce1--c84104e21844_disk.eph1
$ dmsetup remove ssd--volumes-d1b59825--a9cf--4c9a--ac62--e6956ac95c58_disk.eph1

如果是掉盘

$ echo 1 > /sys/block/sdb/device/delete

vg 丢失

使用 vgcfgrestore 可以从备份文件中恢复配置

# 列出所有可用备份
vgcfgrestore -l hdd-volumes

# 从最新的备份文件中恢复 vgcfgrestore hdd-volumes

# 从指定备份文件中恢复
vgcfgrestore -f /etc/lvm/archive/hdd-volumes_00043-2108766453.vg hdd-volumes

# 恢复备份后,需要用如下命令激活 vgchange -a y hdd-volumes

掉盘处理

如何有物理磁盘掉了,那么你在执行 vgs pvs lvs都会有错误提示信息,比如

$ lvs
  WARNING: Device for PV oFnuN1-zvQX-MjEM-NPne-c4Z1-Boce-e0zwjz not found or rejected by a filter.
  WARNING: Device for PV L3twus-E6cD-eFs1-Ij6e-cvSe-kMga-jzTojt not found or rejected by a filter.
  Couldn't find device with uuid L3twus-E6cD-eFs1-Ij6e-cvSe-kMga-jzTojt.
  WARNING: Device for PV oFnuN1-zvQX-MjEM-NPne-c4Z1-Boce-e0zwjz not found or rejected by a filter.
  Couldn't find device with uuid oFnuN1-zvQX-MjEM-NPne-c4Z1-Boce-e0zwjz.
  LV      VG          Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv-test hdd-volumes -wi-a---p- 10.00g     

此时你想创建 lv ?抱歉,无法创建

$ lvcreate -n lv-test-02 -L 10G hdd-volumes
  WARNING: Device for PV oFnuN1-zvQX-MjEM-NPne-c4Z1-Boce-e0zwjz not found or rejected by a filter.
  Couldn't find device with uuid oFnuN1-zvQX-MjEM-NPne-c4Z1-Boce-e0zwjz.
  Cannot change VG hdd-volumes while PVs are missing.
  ConsIDEr vgreduce --removemissing.
  Cannot process volume group hdd-volumes

解决方法是把这些个掉了的 pv 从 vg 中移除

$ vgreduce --removemissing hdd-volumes --force
明哥公众号

文章有帮助,请作者喝杯咖啡?

发表评论