zoukankan      html  css  js  c++  java
  • LVM 镜像硬盘更换、数据恢复(centos7.4 redhat7.5)

     
    案例说明
    Centos7 
    VG:vg  LV:vg-lv
    Redhat 7.5
    VG:vgtest LV:lvtest 目的:模拟硬盘 /dev/sdb损坏、在线添加新硬盘/dev/sdc,lv镜像数据同步
    Last login: Thu Nov 15 07:10:20 2018 from 192.168.31.220
    [root@web02 ~]# df -h                                       ###查看文件系统
    Filesystem         Size  Used Avail Use% Mounted on
    /dev/sda2           47G  1.6G   43G   4% /
    tmpfs              246M     0  246M   0% /dev/shm
    /dev/sda1          976M   39M  886M   5% /boot
    /dev/mapper/vg-lv  5.8G   12M  5.5G   1% /dd_data
    [root@web02 ~]# lsblk                                       ###查看硬盘分区信息
    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sr0                        11:0    1 1024M  0 rom  
    sda                         8:0    0   50G  0 disk 
    ├─sda1                      8:1    0    1G  0 part /boot
    ├─sda2                      8:2    0 47.5G  0 part /
    └─sda3                      8:3    0  1.5G  0 part [SWAP]
    sdb                         8:16   0   10G  0 disk 
    └─sdb1                      8:17   0   10G  0 part 
      └─vg-lv_mimage_0 (dm-1) 253:1    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdd                         8:48   0   10G  0 disk 
    └─sdd1                      8:49   0   10G  0 part 
      ├─vg-lv_mlog (dm-0)     253:0    0    4M  0 lvm  
      │ └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
      └─vg-lv_mimage_1 (dm-2) 253:2    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    
    [root@web02 ~]# lvdisplay         ###查看lv信息
    --- Logical volume ---
    LV Path /dev/vg/lv
    LV Name lv
    VG Name vg
    LV UUID bm5k1e-hD8k-cZhf-EfD9-NP2g-Scr0-Meh8Yr
    LV Write Access read/write
    LV Creation host, time web02.riyimei.cn, 2018-11-15 07:53:10 +0000
    LV Status available
    # open 1
    LV Size 6.00 GiB
    Current LE 1536
    Mirrored volumes 2   ###镜像数量
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:3
    
    [root@web02 dd_data]# pvs                          ###查看pv信息
    PV VG Fmt Attr PSize PFree
    /dev/sdb1 vg lvm2 a--u 10.00g 4.00g
    /dev/sdd1 vg lvm2 a--u 9.99g 3.99g
    [root@web02 ~]# dd if=/dev/zero of=/dev/sdb1 count=10    ###损坏/dev/sdb的数据信息
    10+0 records in
    10+0 records out
    5120 bytes (5.1 kB) copied, 0.00133574 s, 3.8 MB/s
    [root@web02 ~]# lsblk 
    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sr0                        11:0    1 1024M  0 rom  
    sda                         8:0    0   50G  0 disk 
    ├─sda1                      8:1    0    1G  0 part /boot
    ├─sda2                      8:2    0 47.5G  0 part /
    └─sda3                      8:3    0  1.5G  0 part [SWAP]
    sdb                         8:16   0   10G  0 disk 
    └─sdb1                      8:17   0   10G  0 part 
      └─vg-lv_mimage_0 (dm-1) 253:1    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdd                         8:48   0   10G  0 disk 
    └─sdd1                      8:49   0   10G  0 part 
      ├─vg-lv_mlog (dm-0)     253:0    0    4M  0 lvm  
      │ └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
      └─vg-lv_mimage_1 (dm-2) 253:2    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    [root@web02 ~]# lvs                                    ###查看lv出现报错
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      LV   VG   Attr       LSize Pool Origin Data%  Meta%  Move Log       Cpy%Sync Convert
      lv   vg   mwi-aom-p- 6.00g                                [lv_mlog] 100.00
    [root@web02 ~]# vgs                                     ###vg也出现报错
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      VG   #PV #LV #SN Attr   VSize  VFree
      vg     2   1   0 wz-pn- 19.99g 7.98g
    [root@web02 ~]# pvs                                      ###查看pv信息提示有一块硬盘无法识别
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      PV             VG   Fmt  Attr PSize  PFree
      /dev/sdd1      vg   lvm2 a--u  9.99g 3.99g
      unknown device vg   lvm2 a-mu 10.00g 4.00g

    在线添加新硬盘

    [root@web02 ~]# fdisk /dev/sd
    sda   sda1  sda2  sda3  sdb   sdb1  sdd   sdd1  
    [root@web02 ~]# fdisk /dev/sd^C
    [root@web02 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan      ###刷新硬盘
    [root@web02 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
    [root@web02 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
    [root@web02 ~]# lsblk 
    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sr0                        11:0    1 1024M  0 rom  
    sda                         8:0    0   50G  0 disk 
    ├─sda1                      8:1    0    1G  0 part /boot
    ├─sda2                      8:2    0 47.5G  0 part /
    └─sda3                      8:3    0  1.5G  0 part [SWAP]
    sdb                         8:16   0   10G  0 disk 
    └─sdb1                      8:17   0   10G  0 part 
      └─vg-lv_mimage_0 (dm-1) 253:1    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdd                         8:48   0   10G  0 disk 
    └─sdd1                      8:49   0   10G  0 part 
      ├─vg-lv_mlog (dm-0)     253:0    0    4M  0 lvm  
      │ └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
      └─vg-lv_mimage_1 (dm-2) 253:2    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdc                         8:32   0   10G  0 disk    ###新添加的硬盘
    [root@web02 ~]# fdisk -l  /dev/sdc     ###查看核实新硬盘信息
    
    Disk /dev/sdc: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
    [root@web02 ~]# fdisk  /dev/sdc    ###对新硬盘分区,做成lvm格式
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0xc9fa05fb.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
    
    Command (m for help): n      ###新建分区
    Command action
       e   extended
       p   primary partition (1-4)
    p  ### 主分区
    Partition number (1-4): 1  ###设置为1分区
    First cylinder (1-1305, default 1): 
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 
    Using default value 1305
    
    Command (m for help): t   ###分区类型
    Selected partition 1
    Hex code (type L to list codes): 8e   lvm格式分区
    Changed system type of partition 1 to 8e (Linux LVM)
    
    Command (m for help): p   ###打印分区信息
    
    Disk /dev/sdc: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xc9fa05fb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1               1        1305    10482381   8e  Linux LVM
    
    Command (m for help): w   ###写入分区信息
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@web02 ~]# lsblk   ###查看新硬盘分区
    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sr0                        11:0    1 1024M  0 rom  
    sda                         8:0    0   50G  0 disk 
    ├─sda1                      8:1    0    1G  0 part /boot
    ├─sda2                      8:2    0 47.5G  0 part /
    └─sda3                      8:3    0  1.5G  0 part [SWAP]
    sdb                         8:16   0   10G  0 disk 
    └─sdb1                      8:17   0   10G  0 part 
      └─vg-lv_mimage_0 (dm-1) 253:1    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdd                         8:48   0   10G  0 disk 
    └─sdd1                      8:49   0   10G  0 part 
      ├─vg-lv_mlog (dm-0)     253:0    0    4M  0 lvm  
      │ └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
      └─vg-lv_mimage_1 (dm-2) 253:2    0    6G  0 lvm  
        └─vg-lv (dm-3)        253:3    0    6G  0 lvm  /dd_data
    sdc                         8:32   0   10G  0 disk 
    └─sdc1                      8:33   0   10G  0 part 
    [root@web02 ~]# lvs -a -o +devices    ###查看lv的激活信息状态
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      LV            VG   Attr       LSize Pool Origin Data%  Meta%  Move Log       Cpy%Sync Convert Devices                      
      lv            vg   mwi-aom-p- 6.00g                                [lv_mlog] 100.00           lv_mimage_0(0),lv_mimage_1(0)
      [lv_mimage_0] vg   iwi-aom-p- 6.00g                                                           unknown device(0)            
      [lv_mimage_1] vg   iwi-aom--- 6.00g                                                           /dev/sdd1(0)                 
      [lv_mlog]     vg   lwi-aom--- 4.00m                                                           /dev/sdd1(1536)    
    
    [root@web02 ~]# pvcreate /dev/sdc1     ###把 /dev/sdc1 创建成pv
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      Physical volume "/dev/sdc1" successfully created
    [root@web02 ~]# pvs     ###查看pv /dev/sdc1 
      Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
      Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
      PV             VG   Fmt  Attr PSize  PFree 
      /dev/sdc1           lvm2 ---- 10.00g 10.00g
      /dev/sdd1      vg   lvm2 a--u  9.99g  3.99g
      unknown device vg   lvm2 a-mu 10.00g  4.00g
    

      

    ####将坏掉的设备删除lv镜像自动删除
    ***重要一定要先将坏的硬盘解除vg

    [root@web02 dd_data]# vgreduce --removemissing --force vg     ###坏盘自动解除:--force后面添加有坏盘的vg名称
    Couldn't find device with uuid XvYP09-jmxl-A6Pl-ViMz-t0k8-AwWd-5IUbWv.
    Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
    Couldn't find device for segment belonging to vg/lv_mimage_0 while checking used and assumed devices.
    Wrote out consistent volume group vg
    
    [root@web02 dd_data]# pvs
    PV VG Fmt Attr PSize PFree 
    /dev/sdc1 lvm2 ---- 10.00g 10.00g
    /dev/sdd1 vg lvm2 a--u 9.99g 3.99g
    
    
    [root@web02 dd_data]# vgextend vg /dev/sdc1   ###把新硬盘添加的vg
    Volume group "vg" successfully extended
    [root@web02 dd_data]# pvs
    PV VG Fmt Attr PSize PFree
    /dev/sdc1 vg lvm2 a--u 9.99g 9.99g
    /dev/sdd1 vg lvm2 a--u 9.99g 3.99g
    [root@web02 dd_data]# vgs
    VG #PV #LV #SN Attr VSize VFree 
    vg 2 1 0 wz--n- 19.98g 13.98g
     
    [root@web02 dd_data]# lvs
    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    lv vg -wi-ao---- 6.00g 

    将新硬盘添加到lv镜像数据同步(可以不添加/dev/sdd1:lvconvert -m1 /dev/vg/lv /dev/sdc1 )

    [root@web02 dd_data]# lvconvert -m1 /dev/vg/lv /dev/sdd1 /dev/sdc1  
    vg/lv: Converted: 0.0%
    vg/lv: Converted: 4.7%
    vg/lv: Converted: 9.4%
    vg/lv: Converted: 14.1%
    vg/lv: Converted: 18.9%
    vg/lv: Converted: 23.7%
    vg/lv: Converted: 28.4%
    vg/lv: Converted: 33.0%
    vg/lv: Converted: 37.9%
    vg/lv: Converted: 42.8%
    vg/lv: Converted: 47.6%
    vg/lv: Converted: 52.3%
    vg/lv: Converted: 57.0%
    vg/lv: Converted: 61.8%
    vg/lv: Converted: 66.7%
    vg/lv: Converted: 71.5%
    vg/lv: Converted: 76.4%
    vg/lv: Converted: 81.3%
    vg/lv: Converted: 86.1%
    vg/lv: Converted: 90.8%
    vg/lv: Converted: 95.4%
    vg/lv: Converted: 100.0%
    
    [root@web02 dd_data]# lvs -a -o +devices
      LV            VG   Attr       LSize Pool Origin Data%  Meta%  Move Log       Cpy%Sync Convert Devices                      
      lv            vg   mwi-aom--- 6.00g                                [lv_mlog] 100.00           lv_mimage_0(0),lv_mimage_1(0)
      [lv_mimage_0] vg   iwi-aom--- 6.00g                                                           /dev/sdd1(0)                 
      [lv_mimage_1] vg   iwi-aom--- 6.00g                                                           /dev/sdc1(0)                 
      [lv_mlog]     vg   lwi-aom--- 4.00m                                                           /dev/sdc1(1536)              
    [root@web02 dd_data]# lvdisplay 
      --- Logical volume ---
      LV Path                /dev/vg/lv
      LV Name                lv
      VG Name                vg
      LV UUID                bm5k1e-hD8k-cZhf-EfD9-NP2g-Scr0-Meh8Yr
      LV Write Access        read/write
      LV Creation host, time web02.riyimei.cn, 2018-11-15 07:53:10 +0000
      LV Status              available
      # open                 1
      LV Size                6.00 GiB
      Current LE             1536
      Mirrored volumes       2
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:3
       
    [root@web02 dd_data]# lvs
      LV   VG   Attr       LSize Pool Origin Data%  Meta%  Move Log       Cpy%Sync Convert
      lv   vg   mwi-aom--- 6.00g                                [lv_mlog] 100.00          
    [root@web02 dd_data]# vgs
      VG   #PV #LV #SN Attr   VSize  VFree
      vg     2   1   0 wz--n- 19.98g 7.98g
    [root@web02 dd_data]# pvs
      PV         VG   Fmt  Attr PSize PFree
      /dev/sdc1  vg   lvm2 a--u 9.99g 3.99g
      /dev/sdd1  vg   lvm2 a--u 9.99g 3.99g
    
    [root@web02 dd_data]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 47G 1.6G 43G 4% /
    tmpfs 246M 0 246M 0% /dev/shm
    /dev/sda1 976M 39M 886M 5% /boot
    /dev/mapper/vg-lv 5.8G 12M 5.5G 1% /dd_data
    
    [root@web02 dd_data]# ls
    liweiming  lost+found  test
    [root@web02 dd_data]# lvdisplay -m
      --- Logical volume ---
      LV Path                /dev/vg/lv
      LV Name                lv
      VG Name                vg
      LV UUID                bm5k1e-hD8k-cZhf-EfD9-NP2g-Scr0-Meh8Yr
      LV Write Access        read/write
      LV Creation host, time web02.riyimei.cn, 2018-11-15 07:53:10 +0000
      LV Status              available
      # open                 1
      LV Size                6.00 GiB
      Current LE             1536
      Mirrored volumes       2
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:3
       
      --- Segments ---
      Logical extents 0 to 1535:
        Type        mirror
        Monitoring        monitored
        Mirrors        2
        Mirror size        1536
        Mirror log volume    lv_mlog
        Mirror region size    512.00 KiB
        Mirror original:
          Logical volume    lv_mimage_0
          Logical extents    0 to 1535
        Mirror destinations:
          Logical volume    lv_mimage_1
          Logical extents    0 to 1535
    [root@web02 dd_data]# lvs -a -o name,copy_percent,devices vg
      LV            Cpy%Sync Devices                      
      lv            100.00   lv_mimage_0(0),lv_mimage_1(0)
      [lv_mimage_0]          /dev/sdd1(0)                 
      [lv_mimage_1]          /dev/sdc1(0)                 
      [lv_mlog]              /dev/sdc1(1536)              
    [root@web02 dd_data]# lvs --all --segments -o +devices
      LV            VG   Attr       #Str Type   SSize Devices                      
      lv            vg   mwi-aom---    2 mirror 6.00g lv_mimage_0(0),lv_mimage_1(0)
      [lv_mimage_0] vg   iwi-aom---    1 linear 6.00g /dev/sdd1(0)                 
      [lv_mimage_1] vg   iwi-aom---    1 linear 6.00g /dev/sdc1(0)                 
      [lv_mlog]     vg   lwi-aom---    1 linear 4.00m /dev/sdc1(1536)              
    [root@web02 dd_data]#

    Redhat7.5

    ##解除镜像、转回线性逻辑卷
    [root@lvm ~]# lvconvert -m0 /dev/mapper/vgtest-lvtest
    Are you sure you want to convert raid1 LV vgtest/lvtest to type linear losing all resilience? [y/n]: y Logical volume vgtest/lvtest successfully converted. [root@lvm ~]# lvdisplay -m --- Logical volume --- LV Path /dev/vgtest/lvtest LV Name lvtest VG Name vgtest LV UUID SYCcLe-3RgP-aUj0-Fnef-eODz-cLoK-YtF4iM LV Write Access read/write LV Creation host, time lvm, 2018-11-27 15:20:19 +0800 LV Status available # open 1 LV Size 5.00 GiB Current LE 1280 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:9 --- Segments --- Logical extents 0 to 1279: Type linear Physical volume /dev/sdd1 Physical extents 1 to 1280 --- Logical volume --- LV Path /dev/vg_root/lv_opt LV Name lv_opt VG Name vg_root LV UUID 24eBV3-UY8L-Yuel-2jKm-VlDC-sQMV-zQODY7 LV Write Access read/write LV Creation host, time localhost, 2018-11-15 14:32:30 +0800 LV Status available # open 1 LV Size <15.50 GiB Current LE 3967 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Segments --- Logical extents 0 to 3966: Type linear Physical volume /dev/sda3 Physical extents 0 to 3966 --- Logical volume --- LV Path /dev/vg_root/lv_tmp LV Name lv_tmp VG Name vg_root LV UUID 73xbdz-RV5j-ifd0-npSE-g2Ut-6P52-dHyhaZ LV Write Access read/write LV Creation host, time localhost, 2018-11-15 14:32:32 +0800 LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Segments --- Logical extents 0 to 1023: Type linear Physical volume /dev/sda3 Physical extents 3967 to 4990 --- Logical volume --- LV Path /dev/vg_root/lv_home LV Name lv_home VG Name vg_root LV UUID 7TzF7z-l4eL-LcZl-Dv6h-nfCC-3Ysd-HnhNqb LV Write Access read/write LV Creation host, time localhost, 2018-11-15 14:32:34 +0800 LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 --- Segments --- Logical extents 0 to 1023: Type linear Physical volume /dev/sda3 Physical extents 4991 to 6014 --- Logical volume --- LV Path /dev/vg_root/lv_var LV Name lv_var VG Name vg_root LV UUID fnck2V-dYdH-3h0R-qXai-Y1pz-YoDn-Xd1t0c LV Write Access read/write LV Creation host, time localhost, 2018-11-15 14:32:35 +0800 LV Status available # open 1 LV Size 10.00 GiB Current LE 2560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:4 --- Segments --- Logical extents 0 to 2559: Type linear Physical volume /dev/sda3 Physical extents 6015 to 8574 --- Logical volume --- LV Path /dev/vg_root/lv_root LV Name lv_root VG Name vg_root LV UUID leRKJl-a7xF-k5pH-uCcl-3fHa-m6Os-gVDW07 LV Write Access read/write LV Creation host, time localhost, 2018-11-15 14:32:37 +0800 LV Status available # open 1 LV Size 15.00 GiB Current LE 3840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Segments --- Logical extents 0 to 3839: Type linear Physical volume /dev/sda3 Physical extents 8575 to 12414 ##扫出需要做镜像的硬盘 [root@lvm ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda3 vg_root lvm2 a-- <48.50g 0 /dev/sdd1 vgtest lvm2 a-- <10.00g <5.00g /dev/sde1 vgtest lvm2 a-- <10.00g <10.00g

    ## 把线性逻辑卷做出镜像逻辑 镜像备份1份
    [root@lvm
    ~]# lvconvert -m 1 /dev/mapper/vgtest-lvtest /dev/sdd1 /dev/sde1 Are you sure you want to convert linear LV vgtest/lvtest to raid1 with 2 images enhancing resilience? [y/n]: y Logical volume vgtest/lvtest successfully converted. [root@lvm ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv_home vg_root -wi-ao---- 4.00g lv_opt vg_root -wi-ao---- <15.50g lv_root vg_root -wi-ao---- 15.00g lv_tmp vg_root -wi-ao---- 4.00g lv_var vg_root -wi-ao---- 10.00g lvtest vgtest rwi-aor--- 5.00g 0.62 [root@lvm ~]# lvs -a -o +devices LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices lv_home vg_root -wi-ao---- 4.00g /dev/sda3(4991) lv_opt vg_root -wi-ao---- <15.50g /dev/sda3(0) lv_root vg_root -wi-ao---- 15.00g /dev/sda3(8575) lv_tmp vg_root -wi-ao---- 4.00g /dev/sda3(3967) lv_var vg_root -wi-ao---- 10.00g /dev/sda3(6015) lvtest vgtest rwi-aor--- 5.00g 6.20 lvtest_rimage_0(0),lvtest_rimage_1(0) [lvtest_rimage_0] vgtest iwi-aor--- 5.00g /dev/sdd1(1) [lvtest_rimage_1] vgtest Iwi-aor--- 5.00g /dev/sde1(1) [lvtest_rmeta_0] vgtest ewi-aor--- 4.00m /dev/sdd1(0) [lvtest_rmeta_1] vgtest ewi-aor--- 4.00m /dev/sde1(0) [root@lvm ~]# lvs -a -o name,copy_percent,devices vgtest LV Cpy%Sync Devices lvtest 14.68 lvtest_rimage_0(0),lvtest_rimage_1(0) [lvtest_rimage_0] /dev/sdd1(1) [lvtest_rimage_1] /dev/sde1(1) [lvtest_rmeta_0] /dev/sdd1(0) [lvtest_rmeta_1] /dev/sde1(0)
    [BEGIN] 2018/11/27 22:23:20
    Connection established.
    To escape to local shell, press Ctrl+Alt+].
    Last login: Tue Nov 27 16:02:26 2018 from 172-5-0-243.lightspeed.oshkwi.sbcglobal.net
    [root@lvm ~]# 
    [root@lvm ~]# lvs -a -o name,copy_percent,devices vgtest
      LV                Cpy%Sync Devices                              
      lvtest            100.00   lvtest_rimage_0(0),lvtest_rimage_1(0)
      [lvtest_rimage_0]                                               
      [lvtest_rimage_1]          /dev/sdd1(1)                         
      [lvtest_rmeta_0]                                                
      [lvtest_rmeta_1]           /dev/sdd1(0)                         
     
    [root@lvm ~]# lvs -a -o +devices
      LV                VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                              
      lv_home           vg_root -wi-ao----   4.00g                                                     /dev/sda3(4991)                      
      lv_opt            vg_root -wi-ao---- <15.50g                                                     /dev/sda3(0)                         
      lv_root           vg_root -wi-ao----  15.00g                                                     /dev/sda3(8575)                      
      lv_tmp            vg_root -wi-ao----   4.00g                                                     /dev/sda3(3967)                      
      lv_var            vg_root -wi-ao----  10.00g                                                     /dev/sda3(6015)                      
      lvtest            vgtest  rwi-aor-r-   5.00g                                    100.00           lvtest_rimage_0(0),lvtest_rimage_1(0)
      [lvtest_rimage_0] vgtest  vwi-aor-r-   5.00g                                                                                          
      [lvtest_rimage_1] vgtest  iwi-aor---   5.00g                                                     /dev/sdd1(1)                         
      [lvtest_rmeta_0]  vgtest  ewi-aor-r-   4.00m                                                                                          
      [lvtest_rmeta_1]  vgtest  ewi-aor---   4.00m                                                     /dev/sdd1(0)                         
    [root@lvm ~]# pvs
      PV         VG      Fmt  Attr PSize   PFree  
      /dev/sda3  vg_root lvm2 a--  <48.50g      0 
      /dev/sdd1  vgtest  lvm2 a--  <10.00g   4.99g
      /dev/sde1  vgtest  lvm2 a--  <10.00g <10.00g
    [root@lvm ~]# vgs
      VG      #PV #LV #SN Attr   VSize   VFree  
      vg_root   1   5   0 wz--n- <48.50g      0 
      vgtest    2   1   0 wz--n-  19.99g <14.99g
    [root@lvm ~]# lvs
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor-r-   5.00g                                    100.00          
    [root@lvm ~]# lvconvert -m1 /dev/vgtest/lvtest /dev/sdd1 /dev/sde1
    Are you sure you want to convert raid1 LV vgtest/lvtest to 2 images enhancing resilience? [y/n]: y
      WARNING: vgtest/lvtest already has image count of 2.
      Logical volume vgtest/lvtest successfully converted.
    [root@lvm ~]# lvs -a -o +devices
      LV                VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                              
      lv_home           vg_root -wi-ao----   4.00g                                                     /dev/sda3(4991)                      
      lv_opt            vg_root -wi-ao---- <15.50g                                                     /dev/sda3(0)                         
      lv_root           vg_root -wi-ao----  15.00g                                                     /dev/sda3(8575)                      
      lv_tmp            vg_root -wi-ao----   4.00g                                                     /dev/sda3(3967)                      
      lv_var            vg_root -wi-ao----  10.00g                                                     /dev/sda3(6015)                      
      lvtest            vgtest  rwi-aor-r-   5.00g                                    100.00           lvtest_rimage_0(0),lvtest_rimage_1(0)
      [lvtest_rimage_0] vgtest  vwi-aor-r-   5.00g                                                                                          
      [lvtest_rimage_1] vgtest  iwi-aor---   5.00g                                                     /dev/sdd1(1)                         
      [lvtest_rmeta_0]  vgtest  ewi-aor-r-   4.00m                                                                                          
      [lvtest_rmeta_1]  vgtest  ewi-aor---   4.00m                                                     /dev/sdd1(0)                         
    [root@lvm ~]# lvconvert --repair  /dev/mapper/vgtest-lvtest
      WARNING: Disabling lvmetad cache for repair command.
      WARNING: Not using lvmetad because of repair.
    Attempt to replace failed RAID images (requires full device resync)? [y/n]: y
      Faulty devices in vgtest/lvtest successfully replaced.
    [root@lvm ~]# lvs -a -o +devices
      WARNING: Not using lvmetad because a repair command was run.
      LV                VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                              
      lv_home           vg_root -wi-ao----   4.00g                                                     /dev/sda3(4991)                      
      lv_opt            vg_root -wi-ao---- <15.50g                                                     /dev/sda3(0)                         
      lv_root           vg_root -wi-ao----  15.00g                                                     /dev/sda3(8575)                      
      lv_tmp            vg_root -wi-ao----   4.00g                                                     /dev/sda3(3967)                      
      lv_var            vg_root -wi-ao----  10.00g                                                     /dev/sda3(6015)                      
      lvtest            vgtest  rwi-aor---   5.00g                                    1.17             lvtest_rimage_0(0),lvtest_rimage_1(0)
      [lvtest_rimage_0] vgtest  Iwi-aor---   5.00g                                                     /dev/sde1(1)                         
      [lvtest_rimage_1] vgtest  iwi-aor---   5.00g                                                     /dev/sdd1(1)                         
      [lvtest_rmeta_0]  vgtest  ewi-aor---   4.00m                                                     /dev/sde1(0)                         
      [lvtest_rmeta_1]  vgtest  ewi-aor---   4.00m                                                     /dev/sdd1(0)                         
    [root@lvm ~]# lvs
      WARNING: Not using lvmetad because a repair command was run.
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    16.20           
    [root@lvm ~]# df -h
    Filesystem                   Size  Used Avail Use% Mounted on
    /dev/mapper/vg_root-lv_root   15G  1.4G   14G   9% /
    devtmpfs                     908M     0  908M   0% /dev
    tmpfs                        920M     0  920M   0% /dev/shm
    tmpfs                        920M  9.0M  911M   1% /run
    tmpfs                        920M     0  920M   0% /sys/fs/cgroup
    /dev/mapper/vg_root-lv_opt    16G   33M   16G   1% /opt
    /dev/mapper/vg_root-lv_home  4.0G   33M  4.0G   1% /home
    /dev/mapper/vg_root-lv_var    10G  125M  9.9G   2% /var
    /dev/mapper/vg_root-lv_tmp   4.0G   33M  4.0G   1% /tmp
    /dev/sda1                    509M  139M  371M  28% /boot
    tmpfs                        184M     0  184M   0% /run/user/0
    /dev/mapper/vgtest-lvtest    5.0G   33M  5.0G   1% /lvdata
    
    [root@lvm ~]# lvs
      WARNING: Not using lvmetad because a repair command was run.
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    55.62           
    [root@lvm ~]# lvdisplay /dev/vgtest/mirror
      Failed to find logical volume "vgtest/mirror"
    [root@lvm ~]# lvdisplay /dev/vgtest/lvtest 
      --- Logical volume ---
      LV Path                /dev/vgtest/lvtest
      LV Name                lvtest
      VG Name                vgtest
      LV UUID                SYCcLe-3RgP-aUj0-Fnef-eODz-cLoK-YtF4iM
      LV Write Access        read/write
      LV Creation host, time lvm, 2018-11-27 15:20:19 +0800
      LV Status              available
      # open                 1
      LV Size                5.00 GiB
      Current LE             1280
      Mirrored volumes       2
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     8192
      Block device           253:9
       
    [root@lvm ~]# 
    [root@lvm ~]# lvs
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    85.16           
    [root@lvm ~]# pvs
      PV         VG      Fmt  Attr PSize   PFree
      /dev/sda3  vg_root lvm2 a--  <48.50g    0 
      /dev/sdd1  vgtest  lvm2 a--  <10.00g 4.99g
      /dev/sde1  vgtest  lvm2 a--  <10.00g 4.99g
    [root@lvm ~]# lvs
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    90.04           
          
    [root@lvm ~]# lvs
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    100.00          
    
    [root@lvm ~]# systemctl status  lvm2-lvmetad.service 
    ● lvm2-lvmetad.service - LVM2 metadata daemon
       Loaded: loaded (/usr/lib/systemd/system/lvm2-lvmetad.service; static; vendor preset: enabled)
       Active: active (running) since Wed 2018-11-28 06:36:51 CST; 4ms ago
         Docs: man:lvmetad(8)
     Main PID: 5124 (systemd)
       CGroup: /system.slice/lvm2-lvmetad.service
               └─5124 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
    
    Nov 28 06:36:51 lvm systemd[1]: lvm2-lvmetad.service: main process exited, code=killed, status=9/KILL
    Nov 28 06:36:51 lvm systemd[1]: Unit lvm2-lvmetad.service entered failed state.
    Nov 28 06:36:51 lvm systemd[1]: lvm2-lvmetad.service failed.
    Nov 28 06:36:51 lvm systemd[1]: Started LVM2 metadata daemon.
    Nov 28 06:36:51 lvm systemd[1]: Starting LVM2 metadata daemon...
    [root@lvm ~]# systemctl stop  lvm2-lvmetad.service 
    Warning: Stopping lvm2-lvmetad.service, but it can still be activated by:
      lvm2-lvmetad.socket
    
    [root@lvm ~]# systemctl restart  lvm2-lvmetad.service 
    [root@lvm ~]# systemctl status  lvm2-lvmetad.service 
    ● lvm2-lvmetad.service - LVM2 metadata daemon
       Loaded: loaded (/usr/lib/systemd/system/lvm2-lvmetad.service; static; vendor preset: enabled)
       Active: active (running) since Wed 2018-11-28 06:37:17 CST; 5s ago
         Docs: man:lvmetad(8)
     Main PID: 5161 (lvmetad)
       CGroup: /system.slice/lvm2-lvmetad.service
               └─5161 /usr/sbin/lvmetad -f
    
    Nov 28 06:37:17 lvm systemd[1]: Started LVM2 metadata daemon.
    Nov 28 06:37:17 lvm systemd[1]: Starting LVM2 metadata daemon...
    [root@lvm ~]# lvs
      LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      lv_home vg_root -wi-ao----   4.00g                                                    
      lv_opt  vg_root -wi-ao---- <15.50g                                                    
      lv_root vg_root -wi-ao----  15.00g                                                    
      lv_tmp  vg_root -wi-ao----   4.00g                                                    
      lv_var  vg_root -wi-ao----  10.00g                                                    
      lvtest  vgtest  rwi-aor---   5.00g                                    100.00          
    

      

  • 相关阅读:
    【转】STL中map用法详解
    【转】容器 C++ set和map
    .NET简谈面向接口编程 狼人:
    详解.NET程序集的加载规则 狼人:
    ASP.NET MVC 入门介绍 (上) 狼人:
    页面片段缓存(二) 狼人:
    改善代码设计 —— 优化物件之间的特性(Moving Features Between Objects) 狼人:
    改善代码设计 —— 组织好你的数据(Composing Data) 狼人:
    C# 中奇妙的函数联接序列的五种简单方法 狼人:
    Log4Net 全方位跟踪程序运行 狼人:
  • 原文地址:https://www.cnblogs.com/liweiming/p/9964881.html
Copyright © 2011-2022 走看看