RedHat LVM Tagging
id : 5k86d144bc
category : computer
blog : unixlinux
created : 05/28/10 - 12:58:16

lvm.conf
  • First of all edit your /etc/lvm/lvm.conf
    • Server 1 :
....
volume_list [ "vg00", "@tag_server1" ]

    • Server 2 :
volume_list [ "vg00", "@tag_server2" ]
  • We suppose your root VG is called vg00.

Set a tag on a VG
  • If you want to set a tag, use vgchange command :
# vgchange --addtag tag_server1 <vg_name>


Del a tag on a VG
  • If you want to delete a tag use vgchange command :
# vgchange --deltag tag_server2 <vg_name>"


Discover tagged vg
  • If you want to discover a tagged VG (set in /etc/lvm/lvm.conf)
# vgchange -an <vg_name>
# vgchange -ay <vg_name>


Display tagged VG
  • If you want to display tagged VG use vgs command
# vgs @<tag>


Practice
  • We suppose we have two host :
    • host1
    • host2

  • host1
host1# grep volume_list /etc/lvm/lvm.conf
volume_list = [ "vg00", "@host1" ]
host1# vgs @host1
host1# lvs | grep vgtest
  lvclvmdtest  vgtest -wi---  52.00M
  lvclvmdtest2 vgtest -wi---  52.00M
  tinaclulv    vgtest -wi---   2.00G

  • There are no VG tagged with host1, all lv in vgtest are inactive

  • host2
host2# grep volume_list /etc/lvm/lvm.conf
volume_list = [ "vg00", "@host2" ]
host2# vgs @host2
  VG     #PV #LV #SN Attr   VSize  VFree
  vgtest   1   3   0 wz--n- 31.61G 29.51G
host2# lvs | grep vgtest
  lvclvmdtest  vgtest -wi-a-  52.00M
  lvclvmdtest2 vgtest -wi-a-  52.00M
  tinaclulv    vgtest -wi-a-   2.00G

  • vgtest is tagged with host2, all lv in vgtest are active

  • Delete tag on host2, and set it to host one
host2# vgchange --deltag host2 vgtest
host2# vgchange --addtag host1 vgtest
host2# vgchange -an vgtest
 0 logical volume(s) in volume group "vgtest" now active
host2# vgchange -ay vgtest 
 0 logical volume(s) in volume group "vgtest" now active
host2# lvs | grep vgtest
  lvclvmdtest  vgtest -wi---  52.00M
  lvclvmdtest2 vgtest -wi---  52.00M
  tinaclulv    vgtest -wi---   2.00G

  • All lv in vgtest are now inactive

  • Rediscover vg on host1
host1# vgchange -an vgtest
host1# vgchange -ay vgtest
  3 logical volume(s) in volume group "vgtest" now active
host1# lvs | grep vgtest
  lvclvmdtest  vgtest -wi-a-  52.00M
  lvclvmdtest2 vgtest -wi-a-  52.00M
  tinaclulv    vgtest -wi-a-   2.00G

  • All lv in vgtest are now active, and you can mount it.

Bonus
  • Tags can be set on LV, PV, or VG :
    • VG : vgchange --addtag.
    • LV : lvchange --addtag.
    • PV : pvchange --addtag.
  • Use lvs/pvs/vgs @ to display lv,pv,vg tagged with a specified tag.
  • Use these commands to view which tag is set on an element :
    • VG :
# vgs -o vg_tags <vg_name>

    • LV :
# lvs -o lv_tags </dev/vg_name/lv_name>

    • PV :
# pvs -o pv_tags <pv_name>