LVM目录文件丢失修复

LVM 修复 /dev/mapper/下的文件

今天排查系统问题时,发现LVM没有正常挂载成功。缺少文件系统了。分别用df 、lsblk查看挂载的系统和磁盘情况,发现磁盘在,是没有挂载上。
[ora11g@vm-kvm50078-ora ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root
2.0G 489M 1.4G 26% /
tmpfs 16G 72K 16G 1% /dev/shm
/dev/vdb1 504M 94M 385M 20% /boot
/dev/mapper/vg_root-lv_home
2.5G 66M 2.3G 3% /home
/dev/mapper/vg_root-lv_opt
2.0G 956M 959M 50% /opt
/dev/mapper/vg_root-lv_tmp
32G 71M 30G 1% /tmp
/dev/mapper/vg_root-lv_usr
5.0G 1.9G 2.9G 39% /usr
/dev/mapper/vg_root-lv_var
5.0G 2.1G 2.6G 45% /var

[ora11g@vm-kvm50078-ora app]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 30G 0 disk
└─vg_root-lv_tmp (dm-4) 253:4 0 32G 0 lvm /tmp
vdb 252:16 0 23G 0 disk
├─vdb1 252:17 0 512M 0 part /boot
└─vdb2 252:18 0 22.5G 0 part
├─vg_root-lv_swap (dm-0) 253:0 0 4G 0 lvm [SWAP]
├─vg_root-lv_root (dm-1) 253:1 0 2G 0 lvm /
├─vg_root-lv_usr (dm-2) 253:2 0 5G 0 lvm /usr
├─vg_root-lv_var (dm-3) 253:3 0 5G 0 lvm /var
├─vg_root-lv_tmp (dm-4) 253:4 0 32G 0 lvm /tmp
├─vg_root-lv_opt (dm-5) 253:5 0 2G 0 lvm /opt
└─vg_root-lv_home (dm-6) 253:6 0 2.5G 0 lvm /home
vdc 252:32 0 50G 0 disk #以下的就是相关的卷
vdd 252:48 0 30G 0 disk
vde 252:64 0 100G 0 disk
vdf 252:80 0 400G 0 disk
vdg 252:96 0 300G 0 disk
vdh 252:112 0 200G 0 disk


排查fstab配置,配置也在
[ora11g@vm-kvm50078-ora app]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Jun 22 09:26:05 2016

/dev/mapper/vg_app-lv_app /opt/app ext3 defaults 0 0
/dev/mapper/vg_app-lv_redo_ora1xxb /oracle/redo_ora179b ext3 defaults 0 0
/dev/mapper/vg_app-lv_archive_ora1xxb /oracle/archive_ora1xxb ext3 defaults 0 0
/dev/mapper/vg_app-lv_oradata_ora1xxb /oracle/oradata_ora1xxb ext3 defaults 0 0

切root尝试自动挂载
[root@vm-kvm50078-ora ~]# mount -a
mount: special device /dev/mapper/vg_app-lv_app does not exist
mount: special device /dev/mapper/vg_app-lv_redo_ora1xxb does not exist
mount: special device /dev/mapper/vg_app-lv_archive_ora1xxb does not exist
mount: special device /dev/mapper/vg_app-lv_oradata_ora1xxb does not exist

提示挂载点的文件不存在,进行查看,果然没了lv的相关软连接了!
[root@vm-kvm50078-ora ~]# cd /dev/mapper/
[root@vm-kvm50078-ora mapper]# ll
total 0
crw-rw---- 1 root root 10, 58 Aug 6 05:14 control
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_home -> ../dm-6
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_opt -> ../dm-5
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_root -> ../dm-1
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_swap -> ../dm-0
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_tmp -> ../dm-4
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_usr -> ../dm-2
lrwxrwxrwx 1 root root 7 Aug 6 05:14 vg_root-lv_var -> ../dm-3

# /dev/mapper/vg_app-lv_archive_ora1xxb   本该有一系列这个链接的,莫有了!

查看vg及lv都正常

[root@vm-kvm50078-ora ~]# vgs
WARNING: Inconsistent metadata found for VG vg_app - updating to use version 37
VG #PV #LV #SN Attr VSize VFree
vg_app 6 4 0 wz--n- 1.05t 4.00m
vg_root 2 7 0 wz--n- 52.49g 0
[root@vm-kvm50078-ora ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_app vg_app -wi------- 50.00g
lv_archive_ora1xxb vg_app -wi------- 100.00g
lv_oradata_ora1xxb vg_app -wi------- 899.98g
lv_redo_ora179b vg_app -wi------- 30.00g
lv_home vg_root -wi-ao---- 2.50g
lv_opt vg_root -wi-ao---- 2.00g
lv_root vg_root -wi-ao---- 2.00g
lv_swap vg_root -wi-ao---- 4.00g
lv_tmp vg_root -wi-ao---- 32.00g
lv_usr vg_root -wi-ao---- 5.00g
lv_var vg_root -wi-ao---- 5.00g

几个相关的lv是非激活状态。

【激活可以使用】lvchange -ay /dev/vg_app/lv_oracle 试试(以本地环境测试的!。路径实际是读取的lv的信息,非实际路径,如下)
(base) [root@localhost /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_app/lv_oracle
LV Name lv_oracle
VG Name vg_app
LV UUID euTXlb-fd5u-TdOB-cdGX-WimE-7bfe-a9xcvj
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2021-08-12 10:50:46 +0800
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2

以上有2个重点的地方,一个是LV Path 一个是BLOCK device 配置,这个是配置2,那么对应于 /dev/dm-2 这个block设备,后续想的lv的连接,都是自行这个块设备
(base) [root@localhost rhel]# ll
总用量 0
lrwxrwxrwx. 1 root root 7 8月 12 10:47 root -> ../dm-0
lrwxrwxrwx. 1 root root 7 8月 12 10:47 swap -> ../dm-1

(base) [root@localhost rhel]# ll /dev/mapper/
总用量 0
crw-------. 1 root root 10, 236 8月 12 10:47 control
lrwxrwxrwx. 1 root root 7 8月 12 10:47 rhel-root -> ../dm-0
lrwxrwxrwx. 1 root root 7 8月 12 10:47 rhel-swap -> ../dm-1

综上,如果块设备在,就可以进行重建相关的链接,以下是我测试记录,新建挂载没问题!
mkdir vg_app
ll -d vg_app/
ll -d rhel/
cd vg_app/
ln -s /dev/dm-2 lv_oracle
ll
mount /dev/vg_app/lv_oracle /tmp
cd /tmp/


上述进行相关的文件创建,然后mount -a 挂载即可!

原文地址:https://www.cnblogs.com/if-then/p/15136058.html