Ubuntu Pacemakerをインストールする方法

環境
Ubuntu 24.04

概要
Linux の High Availability システム Pacemaker のインストールと設定です。
当例では以下のような環境でクラスターの基本設定を実施します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
|
+----------------------+ | +----------------------+
| [ Cluster Node#1 ] |10.0.0.51 | 10.0.0.52| [ Cluster Node#2 ] |
| node01.arkgame.com +----------+----------+ node02.arkgame.com |
| | | |
+----------------------+ +----------------------+
| +----------------------+ | +----------------------+ | [ Cluster Node#1 ] |10.0.0.51 | 10.0.0.52| [ Cluster Node#2 ] | | node01.arkgame.com +----------+----------+ node02.arkgame.com | | | | | +----------------------+ +----------------------+
                                 |
+----------------------+          |          +----------------------+
| [  Cluster Node#1  ] |10.0.0.51 | 10.0.0.52| [  Cluster Node#2  ] |
|   node01.arkgame.com   +----------+----------+   node02.arkgame.com   |
|                      |                     |                      |
+----------------------+                     +----------------------+

1.全ノードで、以下のように Pacemaker のインストールと必要な設定を実施しておきます。
# apt -y install pacemaker pcs
# systemctl enable pcsd
# クラスター管理ユーザーのパスワード設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# passwd hacluster
Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# passwd hacluster Changing password for user hacluster. New password: Retype new password: passwd: all authentication tokens updated successfully.
# passwd hacluster
Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

# クラスター初期化
# pcs cluster destroy

2.いずれか一方のノードで以下のようにクラスターの基本設定を実施します。
# 各ノード間で認証を確立

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs host auth node01.arkgame.com node02.arkgame.com
Username: hacluster
Password:
node01.arkgame.com: Authorized
node02.arkgame.com: Authorized
# pcs host auth node01.arkgame.com node02.arkgame.com Username: hacluster Password: node01.arkgame.com: Authorized node02.arkgame.com: Authorized
# pcs host auth node01.arkgame.com node02.arkgame.com
Username: hacluster
Password:
node01.arkgame.com: Authorized
node02.arkgame.com: Authorized

クラスターを構成

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster setup ha_cluster node01.arkgame.com node02.arkgame.com
# pcs cluster setup ha_cluster node01.arkgame.com node02.arkgame.com
# pcs cluster setup ha_cluster node01.arkgame.com node02.arkgame.com

各ノードでクラスターに必要なサービスを起動する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster start --all
node01.arkgame.com: Starting Cluster...
node02.arkgame.com: Starting Cluster...
# pcs cluster start --all node01.arkgame.com: Starting Cluster... node02.arkgame.com: Starting Cluster...
# pcs cluster start --all
node01.arkgame.com: Starting Cluster...
node02.arkgame.com: Starting Cluster...

自動起動を設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster enable --all
node01.arkgame.com: Cluster Enabled
node02.arkgame.com: Cluster Enabled
# pcs cluster enable --all node01.arkgame.com: Cluster Enabled node02.arkgame.com: Cluster Enabled
# pcs cluster enable --all
node01.arkgame.com: Cluster Enabled
node02.arkgame.com: Cluster Enabled

ステータスを確認する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster status
Cluster Status:
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: node01.arkgame.com (version 2.1.6-6fdc9deea29) - partition with quorum
* Last updated: Mon Jul 22 23:59:21 2024 on node01.arkgame.com
* Last change: Mon Jul 22 23:59:08 2024 by hacluster via crmd on node01.arkgame.com
* 2 nodes configured
* 0 resource instances configured
Node List:
* Online: [ node01.arkgame.com node02.arkgame.com ]
PCSD Status:
node02.arkgame.com: Online
node01.arkgame.com: Online
# pcs cluster status Cluster Status: Cluster Summary: * Stack: corosync (Pacemaker is running) * Current DC: node01.arkgame.com (version 2.1.6-6fdc9deea29) - partition with quorum * Last updated: Mon Jul 22 23:59:21 2024 on node01.arkgame.com * Last change: Mon Jul 22 23:59:08 2024 by hacluster via crmd on node01.arkgame.com * 2 nodes configured * 0 resource instances configured Node List: * Online: [ node01.arkgame.com node02.arkgame.com ] PCSD Status: node02.arkgame.com: Online node01.arkgame.com: Online
# pcs cluster status
Cluster Status:
 Cluster Summary:
   * Stack: corosync (Pacemaker is running)
   * Current DC: node01.arkgame.com (version 2.1.6-6fdc9deea29) - partition with quorum
   * Last updated: Mon Jul 22 23:59:21 2024 on node01.arkgame.com
   * Last change:  Mon Jul 22 23:59:08 2024 by hacluster via crmd on node01.arkgame.com
   * 2 nodes configured
   * 0 resource instances configured
 Node List:
   * Online: [ node01.arkgame.com node02.arkgame.com ]

PCSD Status:
  node02.arkgame.com: Online
  node01.arkgame.com: Online

# pcs status corosync

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Membership information
----------------------
Nodeid Votes Name
1 1 node01.arkgame.com (local)
2 1 node02.arkgame.com
Membership information ---------------------- Nodeid Votes Name 1 1 node01.arkgame.com (local) 2 1 node02.arkgame.com
Membership information
----------------------
    Nodeid      Votes Name
         1          1 node01.arkgame.com (local)
         2          1 node02.arkgame.com

3.構成したクラスターの設定を全て消去して、完全に初期化する場合は以下のように実行します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster stop --all
node01.arkgame.com: Stopping Cluster (pacemaker)...
node02.arkgame.com: Stopping Cluster (pacemaker)...
node01.arkgame.com: Stopping Cluster (corosync)...
node02.arkgame.com: Stopping Cluster (corosync)...
# pcs cluster stop --all node01.arkgame.com: Stopping Cluster (pacemaker)... node02.arkgame.com: Stopping Cluster (pacemaker)... node01.arkgame.com: Stopping Cluster (corosync)... node02.arkgame.com: Stopping Cluster (corosync)...
# pcs cluster stop --all
node01.arkgame.com: Stopping Cluster (pacemaker)...
node02.arkgame.com: Stopping Cluster (pacemaker)...
node01.arkgame.com: Stopping Cluster (corosync)...
node02.arkgame.com: Stopping Cluster (corosync)...

構成したクラスターの設定を全て消去する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# pcs cluster destroy --all
Warning: Unable to load CIB to get guest and remote nodes from it, those nodes will not be deconfigured.
node02.arkgame.com: Stopping Cluster (pacemaker)...
node01.arkgame.com: Stopping Cluster (pacemaker)...
node02.arkgame.com: Successfully destroyed cluster
node01.arkgame.com: Successfully destroyed cluster
# pcs cluster destroy --all Warning: Unable to load CIB to get guest and remote nodes from it, those nodes will not be deconfigured. node02.arkgame.com: Stopping Cluster (pacemaker)... node01.arkgame.com: Stopping Cluster (pacemaker)... node02.arkgame.com: Successfully destroyed cluster node01.arkgame.com: Successfully destroyed cluster
# pcs cluster destroy --all
Warning: Unable to load CIB to get guest and remote nodes from it, those nodes will not be deconfigured.
node02.arkgame.com: Stopping Cluster (pacemaker)...
node01.arkgame.com: Stopping Cluster (pacemaker)...
node02.arkgame.com: Successfully destroyed cluster
node01.arkgame.com: Successfully destroyed cluster

 

IT

Posted by arkgame