redhat linux下认不到盘阵的解决步骤(转自cu)
2009-04-24 08:33
周六时服务器关机,今天早上服务器开机时,发现日立盘阵找不到了,上面做了逻辑卷,生成了/dev/mapper/vgams-lvams设备文件的,但是今早上发现这个文件没有了,用pvdisplay命令查看发现原来生成的一个pv的pv name认不到了。请问现在这种情况应该怎么处理,有什么办法在不损伤盘阵上数据的情况下重新生成mapper目录下的那个设备文件?或者如何才能备份出里面的数据呢?谢谢各位大侠救急了!!!!

[root@io01 etc]# pvdisplay
   Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.     ====> 就是丢失的/dev/sdb1这个pv的uuid
   ......
   Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
   Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
   --- Physical volume ---
   PV Name             /dev/sdc1
   VG Name             vgams
   PV Size             975.11 GB / not usable 0
   Allocatable           yes (but full)
   PE Size (KByte)    4096
   Total PE              249629
   Free PE             0
   Allocated PE       249629
   PV UUID             y8Uxl5-pk5g-fed8-fpKG-mHde-nCyF-luYddV

   ......

   --- Physical volume ---
   PV Name             /dev/sdi1
   VG Name             vgams
   PV Size             975.11 GB / not usable 0
   Allocatable           yes (but full)
   PE Size (KByte)    4096
   Total PE              249629
   Free PE             0
   Allocated PE       249629
   PV UUID             BjDowe-lqey-Uc1J-15BY-fPsC-yLfT-upSLgt

   --- Physical volume ---
   PV Name             unknown device                            ====> 这里pv 名字找不到了,原本应该是/dev/sdb1
   VG Name             vgams
   PV Size             899.99 GB / not usable 0
   Allocatable           yes (but full)
   PE Size (KByte)    4096
   Total PE              230398
   Free PE             0
   Allocated PE       230398
   PV UUID             nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY      

[root@io01 etc]#
终于解决了,就是分区表的问题,恢复一下分区表就可以了。在这里感谢各位兄弟姐妹的支持和帮助,尤其感谢jerrywjl 大侠耐心的指导!再次感谢!!

下面是我最终的解决过程:

1、首先导出正常pv的分区表,并做相应修改,然后恢复不正常pv的分区表:

[root@io01 home]# fdisk -l /dev/sdb    ==> 分区表乱七八糟!
Disk /dev/sdb: 966.3 GB, 966367641600 bytes
255 heads, 63 sectors/track, 117487 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot    Start       End    Blocks Id   System
/dev/sdb1 ?    264386    257082   2088818490 1   FAT12
Partition 1 does not end on cylinder boundary.
/dev/sdb2 ?    66852    51358   2023024920+   42   SFS
Partition 2 does not end on cylinder boundary.
/dev/sdb3 ?    105920    105961    329394 6f   Unknown
Partition 3 does not end on cylinder boundary.
/dev/sdb4           87045    154994 545800106+   49   Unknown
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
[root@io01 home]# sfdisk -d /dev/sdd > sdd-table                ===> 导出正常pv的分区表
[root@io01 home]# sed 's/sdd/sdb/g' sdd-table > sdb-table ===> 修改分区表中的sdd为sdb
[root@io01 home]# sfdisk /dev/sdb < sdb-table                       ===> 恢复丢失pv的分布表
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 117487 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End #cyls #blocks Id   System
/dev/sdb1 ? 264385+ 524430- 260046- 2088818490 1   FAT12
            start: (c,h,s) expected (1023,254,63) found (124,38,11)
            end: (c,h,s) expected (1023,254,63) found (344,195,26)
/dev/sdb2 ?   66851+ 318706- 251855- 2023024920+   42   SFS
            start: (c,h,s) expected (1023,254,63) found (453,241,50)
            end: (c,h,s) expected (1023,254,63) found (26,59,22)
/dev/sdb3 ? 105919+ 105960-     42- 329394 6f   Unknown
            start: (c,h,s) expected (1023,254,63) found (367,183,2)
            end: (c,h,s) expected (1023,254,63) found (102,116,32)
/dev/sdb4    87044+ 154993-   67949- 545800106+   49   Unknown
            start: (c,h,s) expected (1023,254,63) found (332,76,4)
            end: (c,h,s) expected (1023,254,63) found (344,78,21)
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start    End #sectors   Id   System
/dev/sdb1          63 1887428654 1887428592   8e   Linux LVM
/dev/sdb2          0       -       0 0   Empty
/dev/sdb3          0       -       0 0   Empty
/dev/sdb4          0       -       0 0   Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:   dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk( icon_cool.gif.)
[root@io01 home]#

2、接下来一步是很重要的一步,恢复pv,首先要查看丢失pv的uuid:

[root@io01 home]# lvs -a -o +devices       ===> 查看丢失卷的uuid   
Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
Couldn't find all physical volumes for volume group vgams.
Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
Couldn't find all physical volumes for volume group vgams.
......
[root@io01 home]# pvcreate --uuid "nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY" --restorefile /etc/lvm/archive/vgams_00000.vg /dev/sdb1    ===> 重写lvm元数据区,注意一定要用正确的uuid,该项操作不会影响到lvm的数据区,即不会损害数据
   Couldn't find device with uuid 'nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
   Physical volume "/dev/sdb1" successfully created

3、恢复卷组、逻辑卷,并挂载到相应目录:

[root@io01 home]# vgcfgrestore vgams    ===> 恢复卷组
Restored volume group vgams

[root@io01 home]# lvs -a -o +devices
   LV VG Attr LSize Origin Snap%   Move Log Copy%   Devices
   lvams vgams -wi--- 7.32T                            /dev/sdc1(0)
   lvams vgams -wi--- 7.32T                            /dev/sde1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdg1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdi1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdd1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdf1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdh1(0)
   lvams vgams -wi--- 7.32T                            /dev/sdb1(0)
[root@io01 home]# ls /dev/vgams
ls: /dev/vgams: No such file or directory
[root@io01 home]# lvchange -ay /dev/vgams/lvams       ===> 启用卷,注意在这步之前/dev/vgams/lvams是没有的
[root@io01 home]# lvs -a -o +devices
   LV VG Attr LSize Origin Snap%   Move Log Copy%   Devices
   lvams vgams -wi-a- 7.32T                            /dev/sdc1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sde1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdg1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdi1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdd1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdf1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdh1(0)
   lvams vgams -wi-a- 7.32T                            /dev/sdb1(0)
[root@io01 home]# ls /dev/vgams/lvams
/dev/vgams/lvams
[root@io01 home]# mount /dev/vgams/lvams /vol    ===> 挂载卷
[root@io01 home]# df -h
Filesystem          Size   Used Avail Use% Mounted on
/dev/sda1              20G 13G   5.8G   69% /
none                3.9G     0   3.9G 0% /dev/shm
/dev/sda5          130G 16G   108G   13% /home
/dev/sda2              20G   454M 19G 3% /var
/dev/sda3              99G   6.6G 87G 8% /soft
/dev/mapper/vgams-lvams
                  7.3T   3.1T   4.2T   43% /vol