RH436 Managing High Availability LVM
1. 环境准备
foundation0上先启动所有虚拟机,再跳转到workstation上初始化ha lvm实验环境
rht-vmctl start all
ssh student@workstation
lab start lvm-ha
2. 创建逻辑卷
- 在nodea,nodeb和nodec上分别执行,将LVM系统类型改为uname类型
sed -i 's#\(system_id_source = "\)none"#\1uname"#g' /etc/lvm/lvm.conf
2. 在nodea上创建lvm并格式化
pvcreate /dev/mapper/mpatha
vgcreate clustervg /dev/mapper/mpatha
lvcreate -L 1G -n clusterlv clustervg
mkfs.xfs /dev/clustervg/clusterlv
分区
格式化
3. 创建集群资源
- 在nodea上将vg添加到集群资源
pcs resource create halvm LVM-activate vgname=clustervg \
vg_access_mode=system_id --group=halvmfs
- nodea,nodeb和nodec上分别执行创建挂载点
mkdir /data
- 在nodea上将lvm添加到集群资源
pcs resource create xfsfs Filesystem device=/dev/clustervg/clusterlv \
directory=/data fstype=xfs --group=halvmfs
pcs status
4. 在nodea上确认lv的状态
lvs
df -Th
lvdisplay
4. 集群资源切换测试
- 在nodea上进行资源切换
pcs status
pcs resource move halvmfs
pcs status
2. 在nodeb上检查资源
确认下来卷已经被挂载到nodeb上了
df -Th
lvdisplay
3. 再切换一次
pcs resource move halvmfs
切换后在nodec上再次确认
pcs status
df -Th
至此这个实验完成了.
4. 到workstation环境关闭实验
lab finish lvm-ha
5. 实验碰到的错误
实验时nodec忘记修改lvm的模式了,当在nodeb资源确认之后再次切换时发生了错误.
错误也非常明确就是没有配置nodec.private.example.com (nodec.private.example.com ‘not configured’)
[root@nodeb ~]# pcs resource move halvmfs
Warning: Creating location constraint 'cli-ban-halvmfs-on-nodeb.private.example.com' with a score of -INFINITY for resource halvmfs on nodeb.private.example.com.
This will prevent halvmfs from running on nodeb.private.example.com until the constraint is removed
This will be the case even if nodeb.private.example.com is the last node in the cluster
[root@nodeb ~]# pcs status
Cluster name: cluster1
Cluster Summary:
* Stack: corosync
* Current DC: nodec.private.example.com (version 2.0.4-6.el8-2deceaa3ae) - partition with quorum
* Last updated: Tue Jul 23 05:57:50 2024
* Last change: Tue Jul 23 05:57:48 2024 by root via crm_resource on nodeb.private.example.com
* 3 nodes configured
* 5 resource instances configured
Node List:
* Online: [ nodea.private.example.com nodeb.private.example.com nodec.private.example.com ]
Full List of Resources:
* fence_nodea (stonith:fence_ipmilan): Started nodea.private.example.com
* fence_nodeb (stonith:fence_ipmilan): Started nodeb.private.example.com
* fence_nodec (stonith:fence_ipmilan): Started nodec.private.example.com
* Resource Group: halvmfs:
* halvm (ocf::heartbeat:LVM-activate): Stopped
* xfsfs (ocf::heartbeat:Filesystem): Stopped
Failed Resource Actions:
* halvm_start_0 on nodec.private.example.com 'not configured' (6): call=24, status='complete', exitreason='local/system_id is not set!', last-rc-change='2024-07-23 05:57:48 -04:00', queued=0ms, exec=168ms
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
解决起来也非常方便
sed -i 's#\(system_id_source = "\)none"#\1uname"#g' /etc/lvm/lvm.conf
修改完后重启集群就好了