StorageCloud / Cluster

Implement and configuration Highly Available LVM (HA LVM)

Red Hat Enterprise Linux 4.5 and later include a new feature for implementing HA LVM without using CLVM (part of GFS).

In normal LVM use, only one node should access a volume group. If more than one node accesses data in the same VG, metadata corruption can occur. HA LVM simply allows another machine to use the existing VG when the machine currently using it goes down. rgmanager monitors the VG to ensure that only one instance is active.

One more point: when configuring HA LVM, each VG must contain only one LV used for HA LVM. Multiple LVs may compete to update metadata, causing corruption. Also, do not activate the same VG simultaneously on both machines even if each activates a different LV. If this seems complicated, consider CLVM instead, which avoids spending time on this configuration.

To deploy HA LVM, you need two computers and a SAN or NAS providing shared storage so that both computers can access the same disks. This follows the same concept as a typical HA cluster. Read more at Linux Cluster Concept [Fail-Over and Load-Balancing Cluster].

Set up LVM failover with the following steps.

  1. Create a logical volume and filesystem. Only one logical volume may be enabled in the volume group used for HA LVM, as in this example.
#pvcreate /dev/sd[cde]1
#vgcreate <ชื่อ volume group> /dev/sd[cde]1
#lvcreate -L <ขนาดของ logical volume> -n <ชื่อ logical volume> <ชื่อ volume group>
#mkfs.ext3 /dev/<ชื่อ volume group>/<ชื่อ logical volume>  
  1. Edit /etc/cluster/cluster.conf to add the logical volume to the resource manager section, as shown below. Alternatively, use system-config-cluster or the Conga GUI.

<rm>
  <failoverdomains>
    <failoverdomain name="FD" ordered="1" restricted="0">
      <failoverdomainnode name="cluster-lvm-01" priority="1"/>
      <failoverdomainnode name="cluster-lvm-02" priority="2"/>
    </failoverdomain>
  </failoverdomains>
  <resources>
    <lvm name="lvm" vg_name="<ชื่อ volume group>" lv_name="<ชื่อ logical volume>"!  />
    <fs name="FS" device="/dev/<ชื่อ volume group>/<ชื่อ logical volume>"
force_fsck="0" force_unmount="1" fsid="64050" fstype="ext3"
mountpoint="/mnt" options="" self_fence="0"/>
  </resources>
  <service autostart="1" domain="FD" name="serv" recovery="relocate">
    <lvm ref="lvm"/>
    <fs ref="FS"/>
  </service>
</rm>
  1. Edit volume_list in /etc/lvm/lvm.conf. Include the volume group name, set locking_type to 1, and
    include the machine name from /etc/cluster/cluster.conf with @ before it, as shown below:
volume_list = [ "VolGroup00", "@cluster-lvm-01" ]

Caution: Set volume_list only for VGs you intend to use; otherwise all listed VGs will be activated.

  1. Update initrd on every cluster machine with the following command:

#new-kernel-pkg —mkinitrd —initrdfile=/boot/initrd-uname -r.img —install uname -r —make-default

  1. Reboot the machines.

Finally, this HA LVM configuration does not solve every problem. If connectivity between the servers and the SAN or NAS fails, this configuration may be ineffective because HA LVM has no SAN/NAS connectivity management feature. Still, every problem has a solution, haha. Use multipath to help prevent this issue. Read more at Installing device mapper multipathing on SAN/NAS.

EOF.← Back to articles