13.1 cLVM 配置

要设置群集感知卷组,必须成功完成以下几项任务:

  1. 将 LVM2 的锁定类型更改为群集感知的。

    编辑文件 /etc/lvm/lvm.conf 并找到以下行:

    locking_type = 1

    将锁定类型更改为 3,并将配置写入磁盘。将此配置复制到所有节点。

  2. 将 clvmd 资源作为克隆品包含在 Pacemaker 配置中,并让它依赖于 DLM 克隆资源。Crm 配置壳层中的典型片段将按如下显示:

    primitive dlm ocf:pacemaker:controld
    primitive clvm ocf:lvm2:clvmd \
            params daemon_timeout="30"
    clone dlm-clone dlm \
            meta target-role="Started" interleave="true" ordered="true"
    clone clvm-clone clvm \
            meta target-role="Started" interleave="true" ordered="true"
    colocation colo-clvm inf: clvm-clone dlm-clone
    order order-clvm inf: dlm-clone clvm-clone
    ...    
        

    在开始之前,确认这些资源已在您的群集中成功启动。您可以使用 crm_mon 或 GUI 来检查正在运行的服务。

  3. 使用以下命令准备 LVM 的物理卷:

    pvcreate <physical volume path>
  4. 创建群集感知卷组:

    vgcreate --clustered y <volume group name> <physical volume path>
  5. 根据需要创建逻辑卷,例如:

    lvcreate --name testlv -L 4G <volume group name>
  6. 要确保在群集范围内激活卷组,请按如下方式配置 LVM 资源:

    primitive vg1 ocf:heartbeat:LVM \
            params volgrpname="<volume group name>"
    clone vg1-clone vg1 \
            meta interleave="true" ordered="true"
    colocation colo-vg1 inf: vg1-clone clvm-clone
    order order-vg1 inf: clvm-clone vg1-clone
        
  7. 如果希望只在一个节点上激活卷组,可使用以下示例;在这种情况下,cLVM 将防止在多个节点上激活 VG 内的所有逻辑卷,作为非群集应用程序的附加保护措施:

    primitive vg1 ocf:heartbeat:LVM \
            params volgrpname="<volume group name>" exclusive="yes"
    colocation colo-vg1 inf: vg1 clvm-clone
    order order-vg1 inf: clvm-clone vg1
        
  8. 现在 VG 内的逻辑卷可作为文件系统装入或原始用法提供。确保使用逻辑卷的服务必须具备适当的依赖性,以便在激活 VG 后对它们进行排列和排序。

完成这些配置步骤后,即可像在任何独立工作站中一样进行 LVM2 配置。