0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘】RHEL9.4にPacemaker + Corosync + pcs でクラスタを構築する

Last updated at Posted at 2025-04-24

概要

VMware上にRHELサーバを2台構築し、Pacemaker + Corosync によるActive/Standby構成のHAクラスタを構築・検証した内容を備忘として書き留めておく。

本来は物理環境で検証したかったが、環境を用意できなかったため、仮想環境での検証となる。
VMwareなら仮想環境上でNICが冗長化されているためOS側でNICの冗長化を考慮する必要性は薄いが、物理環境想定のためBondingを組む。

環境

  • 仮想環境: VMware ESXi 6.5 (だが、物理環境のつもりで構築)
  • OS: RHEL 9.4 (最小インストール)
  • CPU: 4core
  • メモリ: 8GB
  • ネットワーク構成:
    • サービスLAN(bond0:2NICによる冗長構成、クラスタ通信・VIP用)
    • 管理LAN(STONITHでESXiから仮想マシンを停止するのに使用)
  • Disk: 50GB HDD(共有ディスクなし)
  • 構成: 2ノード構成

目的

  • 仮想環境上でPacemakerクラスタを構築し、基本的な動作を確認する
  • VIPのフェイルオーバー、STONITHの動作確認
  • クォーラムの挙動確認

クラスタ構成図

クラスタ構成図

手順

ホスト名設定とかproxy設定とか環境によるものや細かい設定は記載しない
作業hrootユーザで実施

RHELインストール

  • RHEL9.4のメディアを使い最小インストールする

プロキシ設定

今回使った検証環境ではプロキシ設定が必要だったため、設定した
クラスタのノード間通信がプロキシ経由で通信しようとしたため、no_proxyが必要だった

vi /etc/environment
http_proxy="http://<proxy>:<port>"
https_proxy="http://<proxy>:<port>"
no_proxy="localhost,127.0.0.1,RHEL-Cluster01,RHEL-Cluster02"

ファイアウォール停止と無効化

本番環境では非推奨だが、NW側で通信制限されているものとして無効化する

vi /etc/environment
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld

hosts設定

名前解決が必要になってくるので設定しておく

vi /etc/hosts
192.168.0.1   rhel-cluster01 RHEL-Cluster01
192.168.0.2   rhel-cluster02 RHEL-Cluster02

サブスクリプション登録

subscription-manager register --username ユーザ名 --password パスワード 
subscription-manager attach --auto

レポジトリの有効化

subscription-manager repos --enable=rhel-9-for-x86_64-baseos-rpms \
                             --enable=rhel-9-for-x86_64-appstream-rpms \
                             --enable=rhel-9-for-x86_64-highavailability-rpms

Pacemaker / Corosync / pcs パッケージインストール

パッケージをインストールし、自動起動の有効化と起動しておく

dnf install -y pacemaker corosync pcs
systemctl enable --now pacemaker
systemctl enable --now corosync
systemctl enable --now pcsd

hacluster ユーザのパスワード設定

passwd hacluster

ノード間認証とクラスタ作成

ノード間認証後にクラスタ作成・起動をする

pcs host auth RHEL-Cluster01 RHEL-Cluster02 -u hacluster -p パスワード
pcs cluster setup Cluster RHEL-Cluster01 RHEL-Cluster02
pcs cluster start --all

VIPリソース作成

サービスLANで実行させるVIPを作成する

pcs resource create RHEL-ClusterVIP ocf:heartbeat:IPaddr2 \
  ip=192.168.0.3 cidr_netmask=24 nic=bond0 \
  op monitor interval=30s

フェンシング設定(vmware_soap)

vmware_soapを使い、ESXiに仮想マシンを停止するようSTONITHリソースを作成し、クラスタ異常時はESXi経由で対向の仮想マシンを停止させる

vmware_soapを使うために以下のパッケージをインストール

dnf install -y fence-agents-vmware-rest

RHEL-Cluster01にフェンシングする設定

pcs stonith create Fencing-RHEL01 fence_vmware_soap \
  ip=192.168.1.101 username=root password=パスワード \
  ssl=1 pcmk_host_map="RHEL-Cluster01:RHEL-Cluster01の仮想マシン名" \
  op start timeout=60s op stop timeout=60s op monitor interval=60s

RHEL-Cluster02にフェンシングする設定

pcs stonith create Fencing-RHEL02 fence_vmware_soap \
  ip=192.168.1.101 username=root password=パスワード \
  ssl=1 pcmk_host_map="RHEL-Cluster02:RHEL-Cluster02の仮想マシン名" \
  op start timeout=60s op stop timeout=60s op monitor interval=60s

STONITHリソースは停止するサーバの対抗で起動するよう指定する

pcs constraint location Fencing-RHEL01 prefers RHEL-Cluster02=INFINITY
pcs constraint location Fencing-RHEL02 prefers RHEL-Cluster01=INFINITY

クラスタステータスを確認してみる

pcs status

Cluster name: Cluster
Cluster Summary:
  * Stack: corosync (Pacemaker is running)
  * Current DC: RHEL-Cluster01 (version 2.1.8-3.el9-3980678f0) - partition with quorum
  * Last updated: Thu Apr 24 21:49:28 2025 on RHEL-Cluster01
  * Last change:  Wed Apr 23 17:27:59 2025 by root via root on RHEL-Cluster01
  * 2 nodes configured
  * 3 resource instances configured

Node List:
  * Online: [ RHEL-Cluster01 RHEL-Cluster02 ]

Full List of Resources:
  * RHEL-ClusterVIP     (ocf:heartbeat:IPaddr2):         Started RHEL-Cluster01
  * Fencing-RHEL01      (stonith:fence_vmware_soap):     Started RHEL-Cluster02
  * Fencing-RHEL02      (stonith:fence_vmware_soap):     Started RHEL-Cluster01

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

2台ともクラスタに参加して、VIPは1号機に、フェンシング設定は適切な側で起動していることがわかる

まとめ

今回のような2ノード構成のクラスタでは、スプリットブレインのリスクを回避するために通常はクォーラムサーバを導入するのが一般的です。しかし、今回はあえてクォーラムサーバを構築せず、自己フェンシングなどの機能を使って動作検証を行った。

まだ検討しきれていない部分もあるため、クォーラムの扱いや自己フェンシングの有効な設定方法については、今後の課題として残っている。

また、今回は VIP のクラスタ化のみを行ったが、今後はデータベースやアプリケーションもクラスタリソースとして構成し、より実用的な構成を検証したい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?