7.2. 在 Red Hat Openstack Platform 上的 HA 集群中配置虚拟 IP 地址
此流程为 RHOSP 平台上的 HA 集群创建 RHOSP 虚拟 IP 地址资源,使用 clouds.yaml
文件进行 RHOSP 身份验证。
RHOSP 虚拟 IP 资源与 IPaddr2
集群资源一起使用。当您配置 RHOSP 虚拟 IP 地址资源时,资源代理可确保 RHOSP 基础架构将虚拟 IP 地址与网络中的集群节点关联。这允许 IPaddr2
资源在该节点上正常工作。
先决条件
- 在 RHOSP 上运行配置的 HA 集群
- 用作虚拟 IP 地址的分配的 IP 地址
- 使用您要用于集群配置的 RHOSP 验证方法访问 RHOSP API,如 为 RHOSP 建立一个身份验证方法 中所述
流程
从集群中的任何节点完成以下步骤。
要查看
openstack-virtual-ip
资源代理的选项,请运行以下命令:pcs resource describe openstack-virtual-ip
Copy to clipboardCopied# pcs resource describe openstack-virtual-ip
运行以下命令,以确定您使用的虚拟 IP 地址的子网 ID。在本例中,虚拟 IP 地址为 172.16.0.119。
openstack --os-cloud=ha-example subnet list
Copy to clipboardCopied# openstack --os-cloud=ha-example subnet list +--------------------------------------+ ... +----------------+ | ID | ... | Subnet | +--------------------------------------+ ... +----------------+ | 723c5a77-156d-4c3b-b53c-ee73a4f75185 | ... | 172.16.0.0/24 | +--------------------------------------+ ... +----------------+
创建 RHOSP 虚拟 IP 地址资源。
以下命令为 IP 地址 172.16.0.119 创建 RHOSP 虚拟 IP 地址资源,指定您在上一步中确定的子网 ID。
pcs resource create ClusterIP-osp ocf:heartbeat:openstack-virtual-ip cloud=ha-example ip=172.16.0.119 subnet_id=723c5a77-156d-4c3b-b53c-ee73a4f75185
Copy to clipboardCopied# pcs resource create ClusterIP-osp ocf:heartbeat:openstack-virtual-ip cloud=ha-example ip=172.16.0.119 subnet_id=723c5a77-156d-4c3b-b53c-ee73a4f75185
配置排序和位置约束:
-
确保
openstack-info
资源在虚拟 IP 地址资源之前启动。 确保虚拟 IP 地址资源运行在与
openstack-info
资源相同的节点上。pcs constraint order start openstack-info-clone then ClusterIP-osp pcs constraint colocation add ClusterIP-osp with openstack-info-clone score=INFINITY
Copy to clipboardCopied# pcs constraint order start openstack-info-clone then ClusterIP-osp Adding openstack-info-clone ClusterIP-osp (kind: Mandatory) (Options: first-action=start then-action=start) # pcs constraint colocation add ClusterIP-osp with openstack-info-clone score=INFINITY
-
确保
为虚拟 IP 地址创建
IPaddr2
资源。pcs resource create ClusterIP ocf:heartbeat:IPaddr2 ip=172.16.0.119
Copy to clipboardCopied# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 ip=172.16.0.119
配置排序和位置限制,以确保
openstack-virtual-ip
资源在IPaddr2
资源之前启动,IPaddr2
资源在与openstack-virtual-ip
资源在同一节点上运行。pcs constraint order start ClusterIP-osp then ClusterIP pcs constraint colocation add ClusterIP with ClusterIP-osp
Copy to clipboardCopied# pcs constraint order start ClusterIP-osp then ClusterIP Adding ClusterIP-osp ClusterIP (kind: Mandatory) (Options: first-action=start then-action=start) # pcs constraint colocation add ClusterIP with ClusterIP-osp
验证
验证资源限制配置。
pcs constraint config
Copy to clipboardCopied# pcs constraint config Location Constraints: Ordering Constraints: start ClusterIP-osp then start ClusterIP (kind:Mandatory) start openstack-info-clone then start ClusterIP-osp (kind:Mandatory) Colocation Constraints: ClusterIP with ClusterIP-osp (score:INFINITY) ClusterIP-osp with openstack-info-clone (score:INFINITY)
检查集群状态,以验证资源是否正在运行。
pcs status
Copy to clipboardCopied# pcs status . . . Full List of Resources: * fenceopenstack (stonith:fence_openstack): Started node01 * Clone Set: openstack-info-clone [openstack-info]: * Started: [ node01 node02 node03 ] * ClusterIP-osp (ocf::heartbeat:openstack-virtual-ip): Started node03 * ClusterIP (ocf::heartbeat:IPaddr2): Started node03