25.5. 配置带有隔离和资源的高可用性集群
以下流程使用 ha_cluster 系统角色创建包括隔离设备、集群资源、资源组和克隆资源的高可用性集群。
先决条件
您已在要运行 playbook 的节点上安装了
ansible-core。注意您不需要在集群成员节点上安装
ansible-core。-
您已在要运行 playbook 的系统上安装了
rhel-system-roles软件包。 - 作为集群成员运行的系统必须拥有对 RHEL 和 RHEL 高可用性附加组件的有效订阅。
警告
ha_cluster 系统角色替换指定节点上的任何现有集群配置。没有在角色中指定的任何设置都将丢失。
流程
- 创建一个指定集群中节点的清单文件,如在 为 ha_cluster 系统角色指定一个清单 中所述。
创建一个 playbook 文件,如
new-cluster.yml。注意为生产环境创建 playbook 文件时,vault 会加密密码,如在 使用 Ansible Vault 加密内容 中所述。
以下示例 playbook 文件配置一个运行
firewalld和selinux服务的集群。集群包括隔离、多个资源和资源组。它还包含资源组的资源克隆。- hosts: node1 node2 vars: ha_cluster_cluster_name: my-new-cluster ha_cluster_hacluster_password: password ha_cluster_manage_firewall: true ha_cluster_manage_selinux: true ha_cluster_resource_primitives: - id: xvm-fencing agent: 'stonith:fence_xvm' instance_attrs: - attrs: - name: pcmk_host_list value: node1 node2 - id: simple-resource agent: 'ocf:pacemaker:Dummy' - id: resource-with-options agent: 'ocf:pacemaker:Dummy' instance_attrs: - attrs: - name: fake value: fake-value - name: passwd value: passwd-value meta_attrs: - attrs: - name: target-role value: Started - name: is-managed value: 'true' operations: - action: start attrs: - name: timeout value: '30s' - action: monitor attrs: - name: timeout value: '5' - name: interval value: '1min' - id: dummy-1 agent: 'ocf:pacemaker:Dummy' - id: dummy-2 agent: 'ocf:pacemaker:Dummy' - id: dummy-3 agent: 'ocf:pacemaker:Dummy' - id: simple-clone agent: 'ocf:pacemaker:Dummy' - id: clone-with-options agent: 'ocf:pacemaker:Dummy' ha_cluster_resource_groups: - id: simple-group resource_ids: - dummy-1 - dummy-2 meta_attrs: - attrs: - name: target-role value: Started - name: is-managed value: 'true' - id: cloned-group resource_ids: - dummy-3 ha_cluster_resource_clones: - resource_id: simple-clone - resource_id: clone-with-options promotable: yes id: custom-clone-id meta_attrs: - attrs: - name: clone-max value: '2' - name: clone-node-max value: '1' - resource_id: cloned-group promotable: yes roles: - rhel-system-roles.ha_cluster- 保存该文件。
运行 playbook,指定在第 1 步中创建的清单文件清单的路径。
# ansible-playbook -i inventory new-cluster.yml