High Availability(高可用性)
クラスターを組んで片方のノードが都合により停止になっても他のノードが引き継ぎサービスを提供し続ける機構
クラスターって言葉は扱いが難しい... HPCにも使うから

昔windowsServerにてwindowsServer/wsfcを組んでみた. こんな感じなもの.

参照先https://linux-ha.osdn.jp/wp/

リソース追加HighAvailability/resource
(HAクラスターのサービスにNFSを追加 HighAvailability/resource/NFS )

構成

CentOS7で pacemaker-1.1corosync-2 で行います.

VMware esxiで作ってます.

マシン名IPアドレスOSsystem diskshared disk
(fencing device)
仮想IP
ha01
(ha01-1-heartbeat)
192.168.0.100
(10.10.10.1)
CentOS7.78GB100GB
(1GB)
192.168.0.102
ha02
(ha02-1-heartbeat)
192.168.0.101
(10.10.10.2)
8GB

スプリットブレイン対策のため死活確認のインターコネクトネットワークを複数用意すべきかも
*余談: ホスト名へのアンダーバー(_)はRFC952で不許可であるが、OSによっては許容されている

*スプリットブレイン対策によってはインターコネクトネットワークは不要かも..

Shared disk

参照VMware/shared

下拵え

grouplist から「High Availability」をインストールします.
「High Availability」をインストールすると pacemaker とその関連のものらが同時にインストールされます.

[root@ha01 ~]# yum grouplist hidden | less           <--- grouplist を全て見る
 :
Available Environment Groups:
 :
Available Groups:
 :
   High Availability
 :
Done
[root@ha01 ~]#
 
[root@ha01 ~]# yum groupinfo  "High Availability"    <--- grouplist「High Availability」の中身を確認
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
 
Group: High Availability
 Group-Id: ha
 Description: Infrastructure for highly available services and/or shared storage.
 Mandatory Packages:
    pacemaker
 Default Packages:
   +fence-agents-aliyun
   +fence-agents-all
   +fence-agents-aws
   +fence-agents-azure-arm
   +fence-agents-gce
   +omping
   +pacemaker-doc
   +pcs
 Optional Packages:
   awscli
   booth-arbitrator
   booth-site
   resource-agents-aliyun
   sbd
[root@ha01 ~]# yum groupinstall "High Availability"

次に /etc/hosts を整備する

[root@ha01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain
 
192.168.0.100 ha01 ha01.sybyl.local
192.168.0.101 ha02 ha02.sybyl.local
 
#---- heartbeat ----#
10.10.0.1 ha01-1-heartbeat
10.10.0.2 ha02-1-heartbeat
 
[root@ha01 ~]#

そして既定で用意されているhigh-availability向けのfirewall設定を読み込ませる. 「/usr/lib/firewalld/services/」に定義可能なサービスがある

[root@ha01 ~]# firewall-cmd --add-service=high-availability --permanent
[root@ha01 ~]# firewall-cmd --reload

上記は全ノードに施します.

pcs(Pacemaker Configuration System)でクラスターを構築

rpmのDescriptionには

Description : pcs is a corosync and pacemaker configuration tool.  It permits
            : users to easily view, modify and create pacemaker based clusters.

とある.
初めに「yum groupinfo "High Availability"」の実行で作られたユーザ「hacluster」にパスワードを付与する

[root@ha01 ~]# id hacluster
uid=189(hacluster) gid=189(haclient) groups=189(haclient)
 
[root@ha01 ~]# echo hacluster123 | passwd --stdin hacluster   <-- ユーザ[hacluster]のパスワードを「hacluster123」とした

その後に pcsd.service を有効にして稼働させる.

[root@ha01 ~]# systemctl enable pcsd.service
[root@ha01 ~]# systemctl start pcsd.service

この操作をもう片方の ha02 にも施す

設定が終わったら片方でクラスターのノード間の認証を行う

[root@ha01 ~]# pcs cluster auth ha01-1-heartbeat   ha02-1-heartbeat -u hacluster -p hacluster123  --force
ha01-1-heartbeat: Authorized
ha02-1-heartbeat: Authorized
[root@ha01 ~]#

この時「/var/lib/pcsd/{tokens,pcs_users.conf}」が作られる.

クラスターを作成する. クラスター監視用アドレスを指定する

[root@ha01 ~]# pcs cluster setup --name ha ha01-1-heartbeat   ha02-1-heartbeat
 
*サービスLANのIPもクラスター監視用アドレスとして使用するなら
「pcs cluster setup --name ha   ha01,ha01-1-heartbeat   ha02,ha02-1-heartbeat」 と同一ノードのIP(名前)をカンマ(,)で繋げる
 
[root@ha01 ~]#
 
[root@ha01 ~]# pcs cluster status
Error: cluster is not currently running on this node
 
[root@ha01 ~]# pcs cluster start --all
ha01-1-heartbeat: Starting Cluster (corosync)...
ha02-1-heartbeat: Starting Cluster (corosync)...
ha01-1-heartbeat: Starting Cluster (pacemaker)...
ha02-1-heartbeat: Starting Cluster (pacemaker)...
 
[root@ha01 ~]# pcs cluster status
Cluster Status:
 Stack: unknown
 Current DC: NONE
 Last updated: Sat May 30 11:39:29 2020
 Last change: Sat May 30 11:39:19 2020 by hacluster via crmd on ha01-1-heartbeat
 2 nodes configured
 0 resources configured
 
PCSD Status:
  ha01-1-heartbeat: Online
  ha02-1-heartbeat: Online
 
[root@ha01 ~]#

この段階では何もHighAvailabilityなリソース、サービスは登録してません.
単にクラスターの枠組みを作っただけです.

各種確認

作成したクラスターの様子を確認

双方でcorosync(Corosync Cluster Engine)のノード間通信を確認.

[root@ha01 ~]# pcs status corosync                  [root@ha02 ~]# pcs status corosync
                                                    
Membership information                              Membership information
----------------------                              ----------------------
    Nodeid      Votes Name                              Nodeid      Votes Name
         1          1 ha01-1-heartbeat (local)               1          1 ha01-1-heartbeat
         2          1 ha02-1-heartbeat                       2          1 ha02-1-heartbeat (local)
[root@ha01 ~]#                                      [root@ha02 ~]#

corosyncのコマンド「corosync-cfgtool」では下記のように確認できる

[root@ha01 ~]# corosync-cfgtool -s                  [root@ha02 ~]# corosync-cfgtool -s
Printing ring status.                               Printing ring status.
Local node ID 1                                     Local node ID 2
RING ID 0                                           RING ID 0
        id      = 10.10.0.1                                 id      = 10.10.0.2
        status  = ring 0 active with no faults              status  = ring 0 active with no faults
[root@ha01 ~]#                                      [root@ha02 ~]#

そして作られたクラスターでは参加したノードに「/etc/corosync/corosync.conf」が作成されます.

[root@ha02 corosync]# cat corosync.conf
totem {
    version: 2
    cluster_name: ha
    secauth: off
    transport: udpu
}
 
nodelist {
    node {
        ring0_addr: ha01-1-heartbeat
        nodeid: 1
    }
 
    node {
        ring0_addr: ha02-1-heartbeat
        nodeid: 2
    }
}
 
quorum {
    provider: corosync_votequorum
    two_node: 1
}
 
logging {
    to_logfile: yes
    logfile: /var/log/cluster/corosync.log
    to_syslog: yes
}

pacemakerのコマンド「crm_verify」でも状態を確認すると下記エラーが報告されている.

スプリットブレイン

ノード間で死活確認がうまく動かずに双方とも「Active」になって仕事しちゃう現象.

その対策の1つとしてSTONITH(Shoot-The-Other-Node-In-The-Head:他ノードを即時強制終了)がある.
ipmiなポート経由で相手を眠らせるとか、
esxi の上で動くのでesxiのコマンド経由で相手を眠らせる方法がある.
「yum search fence-agents」で得られるのがその対策リストらしい.

既定で「STONITHを施す」となっているため下記のようなエラーが発生してしまう.

[root@ha01 ~]# crm_verify -L -V
   error: unpack_resources:     Resource start-up disabled since no STONITH resources have been defined
   error: unpack_resources:     Either configure some or disable STONITH with the stonith-enabled option
   error: unpack_resources:     NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
[root@ha01 ~]#

だが、今はこの要求されるSTONITHは無視/無効する.

[root@ha01 ~]# pcs property list --all | grep stonith
 stonith-action: reboot
 stonith-enabled: true
 stonith-max-attempts: 10
 stonith-timeout: 60s
 stonith-watchdog-timeout: (null)
 
[root@ha01 ~]# pcs property set stonith-enabled=false
 
(確認)
[root@ha01 ~]# pcs property list --all | grep stonith
 stonith-action: reboot
 stonith-enabled: false
 stonith-max-attempts: 10
 stonith-timeout: 60s
 stonith-watchdog-timeout: (null)
 
[root@ha01 ~]# crm_verify -L -V    <-- エラー項目が表示されない
[root@ha01 ~]#

*この部分の変更がどこに書かれているのかが分からない...

このSTONITH以外にも「Quorum」を使った方法もあるが、こちらは2ノードクラスターでは使えない.
Quorum: 定足数. 3ノードクラスターで2ノードから「こいつは寝てる」となれば他へリソースが移される感じかな.

[root@ha01 ~]# pcs property list --all | grep quorum
 no-quorum-policy: stop
 
[root@ha01 ~]# pcs property set no-quorum-policy=ignore
 
[root@ha01 ~]# pcs property list --all | grep quorum
 no-quorum-policy: ignore
 
[root@ha01 ~]#

再起動

両ノードを再起動してみた

[root@ha01 ~]# systemctl list-unit-files | grep pcsd
pcsd.service                                  enabled
 
[root@ha01 ~]# ps -ef |grep pcsd | grep -v grep
root      1115     1  0 22:11 ?        00:00:01 /usr/bin/ruby /usr/lib/pcsd/pcsd
 
[root@ha01 ~]#

とpcsdは再起動後も動いているのだが、

[root@ha01 ~]# pcs cluster status
Error: cluster is not currently running on this node
[root@ha01 ~]#

と動ていない.
っで

[root@ha01 ~]# pcs cluster start --all
ha01-1-heartbeat: Starting Cluster (corosync)...
ha02-1-heartbeat: Starting Cluster (corosync)...
ha01-1-heartbeat: Starting Cluster (pacemaker)...
ha02-1-heartbeat: Starting Cluster (pacemaker)...
[root@ha01 ~]#

っで動かす.

参考先

https://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/1.1/html/Clusters_from_Scratch/index.html
http://kan3aa.hatenablog.com/category/CentOS
https://gist.github.com/kogoto/92eef35b28ae632a11f7

最新の60件
2025-01-23 2025-01-22 2025-01-21 2025-01-20 2025-01-13 2025-01-12 2025-01-08 2024-12-30 2024-12-29 2024-12-22 2024-12-20 2024-12-17 2024-12-15 2024-12-14 2024-12-12 2024-12-11 2024-12-10 2024-12-09 2024-12-08 2024-12-04 2024-11-28 2024-11-22 2024-11-15 2024-11-14 2024-11-12 2024-11-06 2024-11-05 2024-11-04 2024-11-02 2024-11-01 2024-10-29 2024-10-28 2024-10-27 2024-10-23 2024-10-18 2024-10-17 2024-10-15 2024-10-14 2024-10-13 2024-10-11 2024-10-10 2024-10-09 2024-10-08 2024-10-05

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-06-17 (水) 19:10:33