11.7. フェンシングレベルを使用した高可用性クラスターの設定
(RHEL 9.4 以降) 次の手順では、ha_cluster
システムロールを使用して、フェンシングレベルを定義する高可用性クラスターを作成します。
前提条件
Playbook を実行するノードに
ansible-core
がインストールされている。注記ansible-core
をクラスターメンバーノードにインストールする必要はありません。-
Playbook を実行するシステムに
rhel-system-roles
パッケージがインストールされている。 - クラスターメンバーとして使用するシステムには、RHEL および RHEL High Availability Add-On のアクティブなサブスクリプションがある。
警告
ha_cluster
システムロールは、指定されたノードの既存のクラスター設定を置き換えます。ロールで指定されていない設定は失われます。
手順
- ha_cluster システムロールのインベントリーの指定 で説明されているように、クラスター内のノードを指定するインベントリーファイルを作成します。
Playbook ファイルを作成します (例:
new-cluster.yml
)。注記実稼働用の Playbook ファイルを作成するときは、Encrypting content with Ansible Vault で説明されているように、パスワードを 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: apc1 agent: 'stonith:fence_apc_snmp' instance_attrs: - attrs: - name: ip value: apc1.example.com - name: username value: user - name: password value: secret - name: pcmk_host_map value: node1:1;node2:2 - id: apc2 agent: 'stonith:fence_apc_snmp' instance_attrs: - attrs: - name: ip value: apc2.example.com - name: username value: user - name: password value: secret - name: pcmk_host_map value: node1:1;node2:2 # Nodes have redundant power supplies, apc1 and apc2. Cluster must # ensure that when attempting to reboot a node, both power supplies # are turned off before either power supply is turned back on. ha_cluster_stonith_levels: - level: 1 target: node1 resource_ids: - apc1 - apc2 - level: 1 target: node2 resource_ids: - apc1 - apc2 roles: - linux-system-roles.ha_cluster
- ファイルを保存します。
手順 1 で作成したインベントリーファイル inventory へのパスを指定して、Playbook を実行します。
# ansible-playbook -i inventory new-cluster.yml