Thursday, October 3, 2013

LVM and hosttag

hi all,

LVM is working well with host tag especially when working for a active/passive cluster nodes. There are just some simple lines needed at /etc/lvm/lvm.conf

1. volume_list = [ "vg00", "vg01", "vg02", "vg03", "vg04", "vg05" ]
2. tags  { hosttags = 1 }


At the same time, you have to create another conf file with this command

echo "activation { volume_list=["@`hostname -f`"] }" >  /etc/lvm/lvm_`hostname -f`.conf

So, the result with the something like this.

[root@node01c lvm]# cat /etc/lvm/lvm_node01c.hiu.com.conf
activation { volume_list=["@node01c.hiu.com"] }

Once you are done, pretty much you are done.

When you are importing the vg01, you will need to add a tag onto it: vgchange --addtag vg01 upon the activation. Otherwise, you have to deport it so another node within the cluster can import it. To deport it, you have to do vgchange --deltag vg01. 

if you are working well, you will notice that the tagging is working against the lvdisplay too. For example:

[root@node01c lvm]# lvdisplay @node01c.hiu.com
  --- Logical volume ---
  LV Path                /dev/vg02/lvol01
  LV Name                lvol01
  VG Name                vg02
  LV UUID                CXLHnj-FWUY-Puej-r2SN-S7d5-Bkse-Ufx9yH
  LV Write Access        read/write
  LV Creation host, time node01c.hiu.com, 2013-10-03 15:34:30 +0800
  LV Status              available
  # open                 1
  LV Size                71.98 GiB
  Current LE             18428
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:19

Whereas, in the passive node, you wont find any output is printed.

[root@node02c lvm]# lvdisplay @node02c.hiu.com
[root@node02c lvm]#


Another method to determine your tagging is working fine by using the command lvs.


[root@node01c lvm]# lvs
  LV     VG   Attr     LSize  Pool Origin Data%  Move Log Copy%  Convert
  crash  vg00 -wi-ao--  7.81g
  home   vg00 -wi-ao--  4.00g
  opt    vg00 -wi-ao--  4.00g
  tmp    vg00 -wi-ao--  4.00g
  usr    vg00 -wi-ao--  4.00g
  var    vg00 -wi-ao--  4.00g
  lvol01 vg01 -wi-ao--  3.98g
  lvol01 vg02 -wi-ao-- 71.98g
  lvol01 vg03 -wi-ao--  1.98g
  lvol01 vg04 -wi-ao-- 61.98g
  lvol01 vg05 -wi-ao--  4.98g

[root@node02c lvm]# lvs
  LV     VG   Attr     LSize  Pool Origin Data%  Move Log Copy%  Convert
  crash  vg00 -wi-ao--  7.81g
  home   vg00 -wi-ao--  4.00g
  opt    vg00 -wi-ao--  4.00g
  tmp    vg00 -wi-ao--  4.00g
  usr    vg00 -wi-ao--  4.00g
  var    vg00 -wi-ao--  4.00g
  lvol01 vg01 -wi-----  3.98g
  lvol01 vg02 -wi----- 71.98g
  lvol01 vg03 -wi-----  1.98g
  lvol01 vg04 -wi----- 61.98g
  lvol01 vg05 -wi-----  4.98g

with this output, you can clearly see that there is a string like "wi-ao" appended onto the activated volume at the active node. 

No comments: