Lvm 缓存“VG 名称不匹配”

Lvm 缓存“VG 名称不匹配”

我正在使用虚拟机来模拟。

md1 很慢,而 md2 很快。

我知道我正在跨 VG 执行此操作,并且如果 LV_Data 和 Lv_Cache 在同一个 VG 中,它就可以工作,但这没有任何意义,缓存在同一个磁盘(raid)中?不。

我发现了这个: https://bugzilla.redhat.com/show_bug.cgi?id=1503693#c0 我不确定是不是同样的原因

问题是:会发生什么?或者有其他方法可以解决这个问题?

详细信息如下:

    [root@localhost ~]# pvdisplay 
      --- Physical volume ---
      PV Name               /dev/md1
      VG Name               vg_1
      PV Size               <12.00 TiB / not usable 5.00 MiB
      Allocatable           yes 
      PE Size               4.00 MiB
      Total PE              3145531
      Free PE               3145531
      Allocated PE          0
      PV UUID               G1KYfG-oCfA-B2Oz-ckJH-Ozxa-Hvhq-gNzQKV

      --- Physical volume ---
      PV Name               /dev/md2
      VG Name               vg_2
      PV Size               255.87 GiB / not usable <2.94 MiB
      Allocatable           yes 
      PE Size               4.00 MiB
      Total PE              65503
      Free PE               65503
      Allocated PE          0
      PV UUID               CmBVAe-EgPh-IzGC-8ew0-x5al-4r0H-htd2Ex

    [root@localhost ~]# vgdisplay 
      --- Volume group ---
      VG Name               vg_1
      System ID             
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  12
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                0
      Open LV               0
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               <12.00 TiB
      PE Size               4.00 MiB
      Total PE              3145531
      Alloc PE / Size       0 / 0   
      Free  PE / Size       3145531 / <12.00 TiB
      VG UUID               I5eDgM-xNtS-eaCE-81l5-4tRL-YSb9-yNkbXm

      --- Volume group ---
      VG Name               vg_2
      System ID             
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  17
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                0
      Open LV               0
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               255.87 GiB
      PE Size               4.00 MiB
      Total PE              65503
      Alloc PE / Size       0 / 0   
      Free  PE / Size       65503 / 255.87 GiB
      VG UUID               l9vIDi-5yVp-0QCx-Rc9K-w7c4-WYOP-IfemFY

    [root@localhost ~]# lvcreate -L 1T -n slow /dev/vg_1
      Logical volume "slow" created.
    [root@localhost ~]# lvcreate -L 250G -n fast /dev/vg_2
      Logical volume "fast" created.
    [root@localhost ~]# lvcreate -L 250M -n meta /dev/vg_2
      Rounding up size to full physical extent 252.00 MiB
      Logical volume "meta" created.
    [root@localhost ~]# lvs
      LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      slow vg_1 -wi-a-----   1.00t                                                    
      fast vg_2 -wi-a----- 250.00g                                                    
      meta vg_2 -wi-a----- 252.00m 

    [root@localhost ~]# lvconvert --type cache-pool --poolmetadata vg_2/meta vg_2/fast
      Using 288.00 KiB chunk size instead of default 64.00 KiB, so cache pool has less then 1000000 chunks.
      WARNING: Converting logical volume vg_2/fast and vg_2/meta to cache pool's data and metadata volumes with metadata wiping.
      THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
    Do you really want to convert vg_2/fast and vg_2/meta? [y/n]: y
      Converted vg_2/fast_cdata to cache pool.

    [root@localhost ~]# lvs -a
      LV              VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      slow            vg_1 -wi-a-----   1.00t                                                    
      fast            vg_2 Cwi---C--- 250.00g                                                    
      [fast_cdata]    vg_2 Cwi------- 250.00g                                                    
      [fast_cmeta]    vg_2 ewi------- 252.00m                                                    
      [lvol0_pmspare] vg_2 ewi------- 252.00m        <=========== ? ( this didn't appear in the guide )

    [root@localhost ~]# lvconvert --type cache --cachepool vg_2/fast vg_1/slow
      VG name mismatch from position arg (vg_1) and option arg (vg_2).  <=========== ? ( the error )

答案1

在同一 VG 中并不意味着在同一磁盘上。只能组合卷组内的 LV。

任何 lvcreate 都允许指定用于分配空间的物理卷。

所以你要:

  1. 在较大但较慢的 PV (/dev/md1) 上创建数据 LV

    lvcreate -n data -L 2T vg /dev/md1
    
  2. 在较小且较快的 PV(/dev/md2)上创建缓存池

    lvcreate --type cache-pool -n cache -L 80G vg /dev/md2
    
  3. 将数据 LV 转换为缓存

    lvconvert --type cache --cachepool cache vg/data
    

或者分两步:跳过步骤 1,并使用以下方法代替步骤 3:

    lvcreate --type cache -L 2T --cachepool cache vg /dev/md1

更多内容请参见man lvmcache

相关内容