ここでは Red Hat Enterprise Linux 7 における HA アドオンを使用したクラスタ構築について、ソフトウェアのインストールからクラスタ作成までに関する内容を記載します。
※フェンス機能の設定についてはこちらの記事、リソースの設定についてはこちらの記事に記載
High Availability アドオン概要

前提
以下の 2 ノードでクラスタを構成することとします。
- ノード1
- OS:Red Hat Enterprise Linux 7.3
- ホスト名:ha01
- IP アドレス:192.168.139.133
- ノード2
- OS:Red Hat Enterprise Linux 7.3
- ホスト名:ha02
- IP アドレス:192.168.139.134
クラスタソフトウェアのインストール
以下、各ノードの root ユーザで作業
HA リポジトリの有効化
■参考ページ

以下コマンドで HA リポジトリを有効化する。
subscription-manager repos --enable=rhel-ha-for-rhel-7-server-rpms
HA 用パッケージインストール
■参考ページ

フェンスエージェントについてはここでは全てをインストールすることとします。
yum install -y pcs pacemaker fence-agents-all
■ pcs のバージョンを表示
pcs --version
hacluster ユーザのパスワード設定
各ノードの root ユーザで作業
pcs パッケージをインストールすると自動で作成される hacluster ユーザのパスワードを設定。
passwd hacluster
※クラスタ内の全ノードで共通のパスワードにすることが推奨されている
firewalld 設定
■参考ページ

各ノードの root ユーザで作業
firewalld が有効になっている場合に設定。
firewall-cmd --permanent --add-service=high-availability
firewall-cmd --add-service=high-availability
クラスタの作成
■参考ページ

pcsd デーモンの起動および自動起動設定
各ノードの root ユーザで作業
systemctl start pcsd.service
systemctl enable pcsd.service
クラスタ内のノードの認証
クラスタ内のどれか 1 つのノードの root または hacluster ユーザで作業
例としてノード ha01 で以下作業を行う。
クラスタノードのホスト名が ha01 と ha02 の場合のコマンド。
※各ノードの hosts ファイルに各ノードのレコードが登録されている前提
pcs cluster auth ha01 ha02
ユーザ名とパスワードは hacluster ユーザのものを使用する。
# pcs cluster auth ha01 ha02
Username: hacluster
Password:
ha01: Authorized
ha02: Authorized
クラスタ作成
クラスタ内のどれか 1 つのノードの root または hacluster ユーザで作業
例としてノード ha01 で以下作業を行う。
pcs cluster setup --start --name my_cluster ha01 ha02
上のコマンドによって以下 3 点が実行される。
- ha01 と ha02 の 2 ノードで構成されるクラスタ my_cluster が作成される
- クラスター設定ファイルがクラスタ内の全ノードに伝搬される
--start
オプションを使用することでクラスタ内の全ノードでクラスタサービスが起動される
■実行例
# pcs cluster setup --start --name my_cluster ha01 ha02
Destroying cluster on nodes: ha01, ha02...
ha01: Stopping Cluster (pacemaker)...
ha02: Stopping Cluster (pacemaker)...
ha01: Successfully destroyed cluster
ha02: Successfully destroyed cluster
Sending 'pacemaker_remote authkey' to 'ha01', 'ha02'
ha02: successful distribution of the file 'pacemaker_remote authkey'
ha01: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
ha01: Succeeded
ha02: Succeeded
Starting cluster on nodes: ha01, ha02...
ha01: Starting Cluster (corosync)...
ha02: Starting Cluster (corosync)...
ha01: Starting Cluster (pacemaker)...
ha02: Starting Cluster (pacemaker)...
Synchronizing pcsd certificates on nodes ha01, ha02...
ha01: Success
ha02: Success
Restarting pcsd on the nodes in order to reload the certificates...
ha01: Success
ha02: Success
クラスタの起動
クラスタ内のどれか 1 つのノードの root または hacluster ユーザで作業
例としてノード ha01 で以下作業を行う。
以下コマンドで、クラスタ内のすべてのノードについてクラスタサービスが起動される。
pcs cluster start --all
■実行例
# pcs cluster start --all
ha01: Starting Cluster (corosync)...
ha02: Starting Cluster (corosync)...
ha01: Starting Cluster (pacemaker)...
ha02: Starting Cluster (pacemaker)...
クラスタサービスの有効化
■参考ページ

クラスタ内のどれか 1 つのノードの root または hacluster ユーザで作業
例としてノード ha01 で以下作業を行う。
以下コマンドで、クラスタ内のすべてのノードについて起動時に自動でクラスタサービスが実行されるようになる。
pcs cluster enable --all
■実行例
# pcs cluster enable --all
ha01: Cluster Enabled
ha02: Cluster Enabled
クラスタ関連コマンド
クラスタとクラスタリソースの状態を表示
pcs status
クラスタ状態のみ表示
pcs cluster status
クラスタリソース状態のみ表示
pcs status resources
クラスタの削除
pcs cluster destroy [--all] [node] [...]
クラスタノードの操作
pcs cluster start [--all] [node] [...] #クラスタサービスの起動
pcs cluster stop [--all] [node] [...] #クラスタサービスの停止
pcs cluster enable [--all] [node] [...] #クラスタサービスを自動起動させる
pcs cluster disable [--all] [node] [...] #クラスタサービスを自動起動させない
pcs cluster standby [--all] [node] [...] #スタンバイモードにする
pcs cluster unstandby [--all] [node] [...] #スタンバイモードから復旧させる
PCSD WEB UI の利用
■参考ページ

WEB UI でクラスタを管理することができます。
上で記載している手順の「クラスタ内のノードの認証」まで完了後に、ブラウザで以下 URL にアクセスします。
https://nodename:2224
nodename の部分はクラスタ内の任意のノードの IP アドレスとします。
例えば対象ノードの IP アドレスが 192.168.139.133 の場合は
- https://192.168.139.133:2224
にアクセスします。
以下の画面になるため hacluster ユーザのユーザ情報でログインします。
以下の管理画面になります。
注意点
- CLI 上で作成したクラスタを GUI 上に表示させるためには MANAGE CLUSETERS 画面で Add Existing を実行する必要がある
- GUI 上でクラスタを削除(Remove)しても GUI 上から表示が消えるだけで、システム上ではクラスタは存在し続ける
参考ページ


―――――――――――――