内容简介:本文风哥教程参考Linux官方文档、Red Hat Enterprise Linux官方文档、Ansible Automation Platform官方文档、Docker官方文档、Kubernetes官方文档和Podman官方文档等内容,详细介绍了相关技术的配置和使用方法。
本文档详细介绍集群存
风哥提示:
储资源(LVM/NFS)的配置和管理方法。
Part01-LVM资源配置
1.from PG视频:www.itpux.com1 创建LVM资源
[root@ha-node1 ~]# pcs resource create shared_lvm ocf:heartbeat:LVM \
volgrpname=shared_vg \
exclusive=true \
op monitor interval=30s timeout=30s
Creating Resource (shared_lvm)…
* Check: shared_lvm-ocf:heartbeat:LVM
* Check: shared_lvm-volgrpname=shared_vg
* Check: shared_lvm-exclusive=true
Resource ‘shared_lvm’ created
# 验证LVM资源
[root@ha-node1 ~]# pcs resource show shared_lvm
Resource: shared_lvm (class=ocf provider=heartbeat type=LVM)
Attributes: exclusive=true volgrpname=shared_vg
Operations: monitor interval=30s timeout=30s (shared_lvm-monitor-interval-30s)
# 查看资源状态
[root@ha-node1 ~]# pcs status resources
* shared_lvm (ocf::heartbeat:LVM): Started ha-node1
# 验证LVM激活
[root@ha-node1 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
shared shared_vg -wi-a—– 100.00g
[root@ha-node1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
shared_vg 1 1 0 wz–n- 100.00g 0
1.2 创建文件系统资源
[root@ha-node1 ~]# pcs resource create shared_fs ocf:heartbeat:Filesystem \
device=”/dev/shared_vg/shared” \
directory=”/shared” \
fstype=”xfs” \
op monitor interval=20s timeout=40s \
op start timeout=60s \
op stop timeout=60s
Creating Resource (shared_fs)…
* Check: shared_fs-ocf:heartbeat:Filesystem
* Check: shared_fs-device=/dev/shared_vg/shared
* Check: shared_fs-directory=/shared
* Check: shared_fs-fstype=xfs
Resource ‘shared_fs’ created
# 验证文件系统资源
[root@ha-node1 ~]# pcs resource show shared_fs
Resource: shared_fs (class=ocf provider=heartbeat type=Filesystem)
Attributes: device=/dev/shared_vg/shared directory=/shared fstype=xfs
Operations: monitor interval=20s timeout=40s (shared_fs-monitor-interval-20s)
start interval=0s timeout=60s (shared_fs-start-interval-0s)
stop interval=0s timeout=60s (shared_fs-stop-interval-0s)
# 验证挂载
[root@ha-node1 ~]# df -h /shared
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/shared_vg-shared 100G 33M 100G 1% /shared
[root@ha-node1 ~]# mount | grep shared
/dev/mapper/shared_vg-shared on /shared type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
Part02-NFS资源配置
2.1 创建NFS服务器资源
[root@ha-node1 ~]# pcs resource create nfs_server ocf:heartbeat:nfsserver \
nfs_shared_infodir=/shared/nfsinfo \
nfs_no_notify=true \
op monitor interval=30s timeout=20s
Creating Resource (nfs_server)…
* Check: nfs_server-ocf:heartbeat:nfsserver
* Check: nfs_server-nfs_shared_infodir=/shared/nfsinfo
* Check: nfs_server-nfs_no_notify=true
Resource ‘nfs_server’ created
# 创建NFS导出资源
[root@ha-node1 ~]# pcs resource create nfs_export ocf:heartbeat:exportfs \
clientspec=”192.168.1.0/24″ \
directory=”/shared/data” \
fsid=1 \
options=”rw,sync,学习交流加群风哥QQ113257174no_root_squash” \
op monitor interval=30s timeout=20s
Creating Resource (nfs_export)…
* Check: nfs_export-ocf:heartbeat:exportfs
* Check: nfs_export-clientspec=192.168.1.0/24
* Check: nfs_export-directory=/shared/data
* Check: nfs_export-fsid=1
* Check: nfs_export-options=rw,sync,no_root_squash
Resource ‘nfs_export’ created
# 验证NFS资源
[root@ha-node1 ~]# pcs resource show nfs_server
Resource: nfs_server (class=ocf provider=heartbeat type=nfsserver)
Attributes: nfs_no_notify=true nfs_shared_infodir=/shared/nfsinfo
Operations: monitor interval=30s timeout=20s (nfs_server-monitor-interval-30s)
# 查看NFS导出
[root@ha-node1 ~]# exportfs -v
/shared/data 192.168.1.0/24(rw,wdelay,no_root_squash,no_subtre更多学习教程公众号风哥教程itpux_come_check,学习交流加群风哥微信: itpux-comsec=sys,rw,secure,no_root_squash,no_all_squash)
2.2 创建NFS客户端资源
[root@client ~]# pcs resource create nfs_mount ocf:heartbeat:Filesystem \
device=”192.168.1.100:/shared/data” \
directory=”/mnt/nfs” \
fstype=”nfs” \
options=”rw,hard,intr” \
op monitor interval=30s timeout=40s
Creating Resource (nfs_mount)…
* Check: nfs_mount-ocf:heartbeat:Filesystem
* Check: nfs_mount-device=192.168.1.100:/shared/data
* Check: nfs_mount-directory=/mnt/nfs
* Check: nfs_mount-fstype=nfs
* Check: nfs_mount-options=rw,hard,intr
Resource ‘nfs_mount’ created
# 验证挂载
[root@client ~]# df -h /mnt/nfs
Filesystem Size Used Avail Use% Mounted on
192.168.1.100:/shared/data 100G 50M 100G 1% /mnt/nfs
[root@client ~]# mount | grep nfs
192.168.1.100:/shared/data on /mnt/nfs type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.50,local_lock=none,addr=192.168.1.100)
Part03-存储资源组
3.1 创建存储资源组
[root@ha-node1 ~]# pcs resource group add storage_group shared_lvm shared_fs nfs_server nfs_export
# 查看资源组
[root@ha-node1 ~]# pcs resource show storage_group
Group: storage_group
Resource: shared_lvm (class=ocf provider=heartbeat type=LVM)
Attributes: exclusive=true volgrpname=shared_vg
Operations: monitor interval=30s timeout=30s (shared_lvm-monitor-interval-30s)
Resource: shared_fs (class=ocf provider=heartbeat type=Filesystem)
Attributes: device=/dev/shared_vg/shared directory=/shared fstype=xfs
Operations: monitor interval=20s timeout=40s (shared_fs-monitor-interval-20s)
Resource: nfs_server (class=ocf provider=heartbeat type=nfsserver)
Attributes: nfs_no_notify=true nfs_shared_infodir=/shared/nfsinfo
Operations: monitor interval=30s timeout=20s (nfs_server-monitor-interval-30s)
Resource: nfs_export (class=ocf provider=heartbeat type=exportfs)
Attributes: clientspec=192.168.1.0/24 directory=/shared/data fsid=1 options=rw,sync,no_root_squash
Operations: monitor interval=30s timeout=20s (nfs_export-monitor-interval-30s)
# 查看资源状态
[root@ha-node1 ~]# pcs status resources
* storage_group (ocf::heartbeat:LVM): Started ha-node1
3.2 设置资源约束
[root@ha-node1 ~]# pcs constraint colocation add storage_group with VirtualIP INFINITY
# 设置启动顺序
[root@ha-node1 ~]# pcs constraint order VirtualIP then storage_group
Adding VirtualIP storage_group (kind: Mandatory) (Options: first-action=start then-action=start)
# 查看约束
[root@ha-node1 ~]# pcs constraint
Location Constraints:
No location constraints found
Ordering Constraints:
start VirtualIP then start storage_group (Mandatory)
Colocation Constraints:
storage_group with VirtualIP (score:INFINITY)
Ticket Constraints:
# 验证资源配置
[root@ha-node1 ~]# pcs status resources
* VirtualIP (ocf::heartbeat:IPaddr2): Started ha-node1
* storage_group (ocf::heartbeat:LVM): Started ha-node1
Part04-存储资源测试
4.1 测试存储故障转移
[root@ha-node1 ~]# pcs cluster standby ha-node1
# 查看资源状态
[root@ha-node1 ~]# pcs status resources
* VirtualIP (ocf::heartbeat:IPaddr2): Started ha-node2
* storage_group (ocf::heartbeat:LVM): Started ha-node2
# 在node2验证存储
[root@ha-node2 ~]# df -h /shared
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/shared_vg-shared 100G 33M 100G 1% /shared
[root@ha-node2 ~]# exportfs -v
/shared/data 192.更多视频教程www.fgedu.net.cn168.1.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
# 恢复节点
[root@ha-node1 ~]# pcs cluster unstandby ha-node1
# 验证资源状态
[root@ha-node1 ~]# pcs status resources
* VirtualIP (ocf::heartbeat:IPaddr2): Started ha-node2
* storage_group (ocf::heartbeat:LVM): Started ha-node2
- 使用资源组管理相关资源
- 设置正确的启动顺序
- 配置共置约束确保资源在同一节点
- 设置合理的监控间隔
- 定期测试故障转移
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
