Skip to content

antony@notes:~/suse$ cat "Install-and-Setup-SLE-HAE-15-SP5-Cluster.md"

Install and Setup SLE HAE 15 SP5 Cluster

2024-06-17· suse ·SLE HAE

Install and Setup SLE HAE 15 SP5 Cluster

Preface

本篇文章會主要會採取 Step by Step 和 ScreenShot 的方式介紹,如何搭建與設定 SUSE Linux Enterprise High Availability Extension 15 SP5 Cluster

可以透過點擊以下目錄,選擇想看的內容,跳轉至特定章節

:::warning

:::spoiler {state=“open”} 目錄

[TOC]

:::

1. 系統要求

1.1. 硬體要求

Server

伺服器可以是裸機或虛擬機器,它們不需要完全相同的硬體(記憶體、磁碟空間等),但必須具有相同的架構,不支援跨平台集群。

Network

  • 每個群集節點至少有兩張網卡
  • 網路設備必須支援要用於群集通訊的通訊方式: multicast or unicast。
  • 網卡應支援 100 Mbit/s 或更高的資料傳輸速率。
  • 對於支援的群集設置,需要兩個或更多的 communication paths ( 通訊路徑 ),可以透過以下方式實現 :
    • Network Device Bonding(首選)。
    • A second communication channel in Corosync.

Node fencing/STONITH

為避免出現 “大腦分裂 “的情況,集群需要一種 node fencing mechanism ( 節點隔離機制 )。

在 “split-brain ( 分腦 )“情況下,叢集節點會被分成兩個或多個互不相識(由於硬體或軟體故障或網路連線被切斷)的群組,隔離機制可隔離相關節點(通常是透過重設或關閉節點電源),這也被稱為 STONITH(“向其他節點頭部開槍”)。

節點隔離機制既可以是實體設備(電源開關),也可以是一種類似於 SBD(磁碟 STONITH)的機制,與看門狗相結合。使用 SBD 需要共享儲存空間。

除非使用 SBD,否則高可用性群集中的每個節點必須至少有一個 STONITH 設備。 我們強烈建議每個節點配備多個 STONITH 設備。

:::info

Important: No Support Without STONITH

  • You must have a node fencing mechanism for your cluster.
  • The global cluster options stonith-enabled and startup-fencing must be set to true. When you change them, you lose support.

:::

1.2. 軟體要求

在叢集中的所有 Node 至少需要以下 modules ( 模組 ) 和 extensions ( 擴充 ):

  • Basesystem Module 15 SP5
  • Server Applications Module 15 SP5
  • SUSE Linux Enterprise High Availability Extension 15 SP5

根據在安裝過程中選擇的 system role ( 系統角色 ),預設安裝以下 software patterns:

HA Node system role

High Availability (sles_ha) Enhanced Base System (enhanced_base)

HA GEO Node system role

Geo Clustering for High Availability (ha_geo) Enhanced Base System (enhanced_base)

1.3. 存儲要求

  • 某些服務需要共享儲存。 如果使用外部 NFS 共享,則所有群集節點必須透過網路能夠存取。
  • 為使資料具有高可用性,建議叢集使用 shared disk system ( 共用磁碟系統 [儲存區域網路或 SAN] )。
  • 如果使用 shared disk subsystem ( 共享磁碟子系統 ),請確保以下幾點:
    • 按照製造商的說明正確設定共享磁碟系統並使其正常運作。
    • 共用磁碟系統中包含的磁碟應配置為使用映像或 RAID,以增加共用磁碟系統的容錯性。
    • 如果使用 iSCSI 存取共用磁碟系統,請確保已正確設定 iSCSI 啟動程式和目標。
    • 使用 DRBD* 實作 mirroring RAID 系統(將資料分散到兩台機器)時,請確保只存取 DRBD 提供的設備,而不是 backing ( 後備 ) 設備。 要充分達到高可用性,可以使用與群集其他部分相同的 NICs ( 網卡 )。

1.4. 其他要求和建議

若要實現受支援且有用的高可用性設置,請考慮以下建議:

cluster nodes 數量

  • 對於有兩個以上節點的群集,強烈建議使用奇數個群集節點來達到法定人數。
  • 普通群集最多可包含 32 個節點。
  • 使用 pacemaker_remote 服務,高可用性群集可擴展至包含超出此限制的其他節點。

時間同步

  • 群集節點必須同步到叢集外的 NTP Server。
  • 自 SUSE Linux Enterprise High Availability Extension 15 以來,NTP 的預設實作是 chrony

Network Interface Card (NIC) names

  • 所有節點上必須相同。

Host name and IP address

  • 使用靜態 IP 位址。
  • 只支援私有 IP 位址。
  • /etc/hosts 檔案中列出所有叢集節點,並註明其完全合格的主機名稱和簡短主機名稱
    • 群集成員必須能透過名稱找到彼此,如果名稱不可用,群集內部通訊就會失敗。

SSH

  • 所有叢集節點必須能夠透過 SSH 互相存取。
  • crm report(用於故障排除)和 Hawk2 的歷史記錄資源管理器等工具要求節點之間免密碼 SSH 訪問,否則它們只能從當前節點收集資料。
  • 如果使用引導腳本設定群集,將自動建立和複製 SSH 金鑰。

2. 安裝前環境設定

2.1. 軟體設定

  1. 安裝的 ISO 檔
SLE-15-SP5-Full-x86_64-GM-Media1.iso

這片 ISO 檔,可以不用註冊碼就能安裝 SLE HAE,如果要訂閱的話,必須在註冊的時候,同時輸入 SLES 15 SP5 和 SLE HAE 的註冊碼,才能訂閱成功。

  1. 將加入叢集的所有節點上都至少需安裝以下模組和擴充:

    • Basesystem Module 15 SP5
    • Server Applications Module 15 SP5
    • SUSE Linux Enterprise High Availability Extension 15 SP5
  2. 確認模組和擴充

$ zypper lr

螢幕輸出 :

Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias                             | Name                           | Enabled | GPG Check | Refresh
--+-----------------------------------+--------------------------------+---------+-----------+--------
1 | Basesystem-Module_15.5-0          | sle-module-basesystem          | Yes     | (r ) Yes  | No
2 | SLEHA15-SP5_15.5-0                | sle-ha                         | Yes     | (r ) Yes  | No
3 | Server-Applications-Module_15.5-0 | sle-module-server-applications | Yes     | (r ) Yes  | No

2.1. 網路架構

主機名心跳網路App 網路儲存網路虛擬 IP 位址
sle-ha-110.13.0.31192.168.11.17110.12.2.11192.168.11.170
sle-ha-210.13.0.32192.168.11.17210.12.2.12
sle-ha-storage192.168.11.17310.12.2.13

2.1. 設定網路

$ sudo yast2 lan

sle-ha-1 網路設定資訊

## IP info
$ sudo yast2 lan list
id      name    bootproto
0       eth2    10.13.0.31/24
1       eth0    192.168.11.171/24
2       eth1    10.12.2.11/24

# Route info
$ ip r s
default via 192.168.xx.xx dev eth0

sle-ha-2 網路設定資訊

## IP info
$ sudo yast2 lan list
id      name    bootproto
0       eth2    10.13.0.32/24
1       eth0    192.168.11.172/24
2       eth1    10.12.2.12/24

# Route info
$ ip r s
default via 192.168.xx.xx dev eth0

sle-ha-storage 網路設定資訊

## IP info
$ sudo yast2 lan list
id      name    bootproto
0       eth0    192.168.11.173/24
1       eth1    10.12.2.13/24

# Route info
$ ip r s
default via 192.168.xx.xx dev eth0

2.2. 永久禁用 IPv6

在叢集中的每一台 Node 都要執行

$ echo $'net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1' | sudo tee -a /etc/sysctl.conf

2.3. 編輯 /etc/hosts 檔案

在叢集中的每一台 Node 都要執行

$ sudo nano /etc/hosts

新增的檔案內容如下 :

192.168.11.171   sle-ha-1
192.168.11.172   sle-ha-2
192.168.11.173   sle-ha-storage

2.4. 設定 SSH 免密碼

在叢集中的每一台 Node 都要執行

## 產生金鑰 (如果已經有了,可以跳過這個步驟)
$ ssh-keygen -t rsa -P ''

## 編輯 sshd 設定檔,設定允許透過公鑰認證
$ sudo sed -i 's|#PubkeyAuthentication yes|PubkeyAuthentication yes|g' /etc/ssh/sshd_config

## 重啟 SSHD Service
$ sudo systemctl restart sshd.service

## 在 sle-ha-2 主機 ,將 sle-ha-2 的公鑰複製到 sle-ha-1 主機
$ ssh-copy-id rancher@sle-ha-1

## 在 sle-ha-1 主機 ,將 sle-ha-1 的公鑰複製到 sle-ha-2 主機
$ ssh-copy-id rancher@sle-ha-2

2.5. 設定 NTP

在叢集中的每一台 Node 都要執行

$ sudo yast2 ntp-client

設定資訊如下 :

Start NTP Daemon:
(x) Now and on Boot

Configuration Source: 
Static

Synchronization Servers:
time.google.com

2.6. 安裝與設定 iSCSI LIO Target Server

連線至 sle-ha-storage 做以下設定

2.6.1. 安裝 iSCSI LIO Target Server

$ sudo zypper in -y yast2-iscsi-lio-server

2.6.2. 規劃儲存空間

$ lsblk /dev/{sdb,sdc,sdd,sde,sdf}

螢幕輸出 :

NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdb    8:16   0    1G  0 disk
sdc    8:32   0    1G  0 disk
sdd    8:48   0    1G  0 disk
sde    8:64   0  100G  0 disk
sdf    8:80   0  100G  0 disk
  • 3 顆 1 GB 的硬碟規劃給 SDB 使用
  • 2 顆 100 GB 的 Disk 規劃給 Application 使用

2.6.3. 設定 iSCSI LIO Target Server

  1. 啟動 YaST 設定 iSCSI LIO Target S
$ sudo yast2 iscsi-lio-server
  1. 切換到 Service 區塊

  2. 設定開機自動啟動 iSCSI Targets 服務

┌Service Configuration─────────────────────────────────────────┐
│Current status: Inactive                                      │
│After writing configuration:                                  │
│Start▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓                                  │
│After reboot:                                                 │
│Start on boot▒↓                                               │
└──────────────────────────────────────────────────────────────┘
                                                   [Finish]
  • After writing configuration: Start
  • After reboot: Start on boot
  1. 切換到 Targets 區塊

  2. 選擇 Add,然後定義給 SDB 用的 iSCSI LIO target group 和 devices:

    • Target: iqn.2023-11.com.example
    • Identifier: sbd-disk1
    • Portal Group: 1
    • IP Address: 10.12.2.13
    • Port Number: 3260
    • [x] Bind all IP addresses

image

  1. 新增 Disk

    • 在 Lun 區塊下點擊 add
    • LUN Path: /dev/sdb

image.png

  1. 重複以上兩個步驟,新增 sdb-disk2sdb-disk3 這兩個 iSCSI LIO target

  2. 選擇 Add,然後定義給 APP 用的 iSCSI LIO target group 和 devices:

    • Target: iqn.2023-11.com.example
    • Identifier: app-disk1
    • Portal Group: 1
    • IP Address: 10.12.2.13
    • Port Number: 3260
    • [x] Bind all IP addresses

image

  1. 新增 Disk

    • 在 Lun 區塊下點擊 add
    • LUN Path: /dev/sde

image

  1. 重複以上兩個步驟,新增 app-disk2 這兩個 iSCSI LIO target

  2. 點擊 Finish 儲存並應用設定

image

2.7. 安裝與設定 iSCSI initiator

  1. 在 sle-ha-1 和 sle-ha-2 做以下設定

  2. 安裝 iSCSI initiator 套件

$ sudo zypper in -y open-iscsi yast2-iscsi-client
  1. 啟動 YaST 設定 開機自動啟動服務
$ sudo yast2 iscsi-client
  • After writing configuration: start
  • After reboot: Start on boot

image

  1. 切換到 Discovered Targets 區塊,並點選 Discovery

image

  1. 輸入 IP 資訊

    • IP Address: 10.12.2.13
    • Port: 3260
    • 點選 Next

image

  1. 與 Targets 連線

image

  1. Startup and Authentication
  • Startup: automatic
  • Next

image

  1. 重複以上兩個步驟與剩餘的 4 個 Target 連線

  2. 確認 Connected Targets

確認都沒問題後點擊 OK

image

  1. 檢查是否成功將遠端的 Disk 映射過來
# lsscsi

螢幕輸出

[0:0:0:0]    disk    QEMU     QEMU HARDDISK    2.5+  /dev/sda
[2:0:0:0]    cd/dvd  QEMU     QEMU DVD-ROM     2.5+  /dev/sr0
[3:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdb
[4:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdc
[5:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdd
[6:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sde
[7:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdf

2.7. 安裝與啟動 multipathd Service

$ sudo zypper -n in multipath-tools
$ sudo modprobe dm-multipath path
$ sudo systemctl enable multipathd.service --now

2.8. 編輯多路徑設定檔

$ cat <<EOF | sudo tee /etc/multipath.conf
defaults {
        user_friendly_names yes
}

devices {
        device {
                vendor "(LIO-ORG|SUSE)"
                product "IBLOCK"
                path_grouping_policy "multibus"
        }
}
EOF

新增檔案內容如下 :

defaults {
        user_friendly_names yes
}

devices {
        device {
                vendor "(LIO-ORG|SUSE)"
                product "IBLOCK"
                path_grouping_policy "multibus"
        }
}

2.8.1. 重啟服務套用設定檔

$ sudo systemctl restart multipathd.service

2.9. 查看多路徑狀態,確認多條連結處於 running 狀態

$ sudo multipath -ll

螢幕輸出

mpathd (360014053be325d33ebb4e7e966df3a4f) dm-0 LIO-ORG,IBLOCK
size=100G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 3:0:0:0 sdb 8:16 active ready running
mpathe (36001405ee25a89d7a8a4df09f6a3a5f0) dm-1 LIO-ORG,IBLOCK
size=100G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 4:0:0:0 sdc 8:32 active ready running
mpathf (36001405c2d16cc2065f4004ac0a1c188) dm-2 LIO-ORG,IBLOCK
size=1.0G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 5:0:0:0 sdd 8:48 active ready running
mpathg (36001405e9b0b982a26f493e97b88ca61) dm-3 LIO-ORG,IBLOCK
size=1.0G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 6:0:0:0 sde 8:64 active ready running
mpathh (3600140552d947e312e24a4f8a9a0f9b1) dm-4 LIO-ORG,IBLOCK
size=1.0G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 7:0:0:0 sdf 8:80 active ready running

2.10. 查看 Disk

$ sudo lvmdiskscan

螢幕輸出 :

  /dev/mapper/mpathb [     100.00 GiB]
  /dev/sda1          [       8.00 MiB]
  /dev/mapper/mpathe [       1.00 GiB]
  /dev/sda2          [     199.99 GiB]
  /dev/mapper/mpathf [       1.00 GiB]
  /dev/mapper/mpathd [       1.00 GiB]
  /dev/mapper/mpathc [     100.00 GiB]
  5 disks
  2 partitions
  0 LVM physical volume whole disks
  0 LVM physical volumes

3. 部屬 SUSE Linux Enterprise HAE Cluster

3.1. 部屬概述

本章節將介紹使用 crm shell 提供的 bootstrap script ( 引導腳本 ) 設定一個非常基本的雙節點叢集,其中包括將 virtual IP 位址設定為叢集資源,以及在共用儲存上使用 SBD 作為節點隔離機制。

3.2. 部屬前環境確認

  • 設定好 NTP
  • 已分配好 3 塊 SBD 硬碟
  • 具有系統管理員權限的使用者帳號及密碼
  • 叢集 Init 之前必須啟動 Watchdog

3.3. 開始部屬第一台節點

  1. 安裝 High Availability 套件
$ sudo zypper install -t pattern ha_sles
  • 每一台 Node 都要安裝
  • 設定和管理群集的 packages 包含在 High Availability 的 pattern 中,此 pattern 僅在安裝 SUSE Linux Enterprise High Availability Extension 後可用。
  1. 為 SBD 啟用 softdog watchdog

2.1. 啟用 softdog watchdog:

## 啟用 softdog 檢查包
$ echo softdog | sudo tee /etc/modules-load.d/watchdog.conf

$ sudo systemctl restart systemd-modules-load

$ echo "modprobe softdog" | sudo tee -a /etc/init.d/boot.local

$ sudo modprobe softdog

2.2. 測試 softdog 模組是否正確載入:

$ lsmod | grep dog

螢幕輸出 :

softdog           16384  0

2.3. 確認 softdog Device 是否可用且工作:

$ sudo ls -l /dev/watchdog* && sudo sbd query-watchdog

螢幕輸出 :

crw------- 1 root root  10, 130 Nov 15 09:51 /dev/watchdog
crw------- 1 root root 247,   0 Nov 15 09:51 /dev/watchdog0

Discovered 2 watchdog devices:

[1] /dev/watchdog
Identity: Software Watchdog
Driver: softdog
CAUTION: Not recommended for use with sbd.

[2] /dev/watchdog0
Identity: Software Watchdog
Driver: softdog
CAUTION: Not recommended for use with sbd.

2.4. 確認 softdog device 是否運作 :

$ sudo sbd -w /dev/watchdog test-watchdog 

螢幕輸出 :

WARNING: This operation is expected to force-reboot this system
         without following any shutdown procedures.

Proceed? [NO/Proceed]
  • 輸入 : Proceed

螢幕輸出 :

Initializing /dev/watchdog with a reset countdown of 5 seconds ...

NOTICE: The watchdog device is expected to reset the system
        in 5 seconds.  If system remains active beyond that time,
        watchdog may not be functional.

Reset countdown ... 5 seconds
Reset countdown ... 4 seconds
Reset countdown ... 3 seconds
Reset countdown ... 2 seconds
System expected to reset any moment ...
  • 確認 5 秒倒數後,系統會直接被重新開機。
  1. 初始化一個新的 HA Cluaster
$ sudo crm cluster init --name topgun -u -i eth2 -M -S
  • --name,設定叢集名稱
  • -u,設定 corosync 使用單播 (udpu) 進行通信
  • -i,指定心跳網路使用的網卡
  • -M,使用第二條心跳線設定 corosync
  • 如果需要在 Cluster 通訊中使用 multicast 而不是 unicast(預設),請使用選項 --multicast (or -U)。
  • 腳本會檢查 NTP 設定和硬體看門狗服務。如果需要,它會產生用於 SSH 存取和 Csync2 同步的 SSH 公鑰和私鑰,並啟動相應服務。

螢幕輸出 :

INFO: Loading "default" profile from /etc/crm/profiles.yml
INFO: SSH key for root does not exist, hence generate it now
INFO: The user 'hacluster' will have the login shell configuration changed to /bin/bash
Continue (y/n)? y
INFO: SSH key for hacluster does not exist, hence generate it now
INFO: Configuring csync2
INFO: Starting csync2.socket service on sle-ha-1
INFO: BEGIN csync2 checking files
INFO: END csync2 checking files
INFO: Configure Corosync (unicast):
  This will configure the cluster messaging layer.  You will need
  to specify a network address over which to communicate (default
  is eth2's network, but you can use the network address of any
  active interface).

Address for ring0 [10.13.0.31]
Port for ring0 [5405]

Add another heartbeat line (y/n)? y
Address for ring1 [192.168.11.171]
Port for ring1 [5407]
WARNING: Diskless SBD requires cluster with three or more nodes. If you want to use diskless SBD for 2-node cluster, should be combined with QDevice.
INFO: Configuring diskless SBD
INFO: Hawk cluster interface is now running. To see cluster status, open:
INFO:   https://10.13.0.31:7630/
INFO: Log in with username 'hacluster', password 'linux'
WARNING: You should change the hacluster password to something more secure!
INFO: BEGIN Waiting for cluster
............
INFO: END Waiting for cluster
INFO: Loading initial cluster configuration
INFO: Configure Administration IP Address:
  Optionally configure an administration virtual IP
  address. The purpose of this IP address is to
  provide a single IP that can be used to interact
  with the cluster, rather than using the IP address
  of any specific cluster node.

Do you wish to configure a virtual IP address (y/n)? y
Virtual IP []192.168.11.170
INFO: BEGIN Configuring virtual IP (192.168.11.170)
.
INFO: END Configuring virtual IP (192.168.11.170)
INFO: Configure Qdevice/Qnetd:
  QDevice participates in quorum decisions. With the assistance of
  a third-party arbitrator Qnetd, it provides votes so that a cluster
  is able to sustain more node failures than standard quorum rules
  allow. It is recommended for clusters with an even number of nodes
  and highly recommended for 2 node clusters.

Do you want to configure QDevice (y/n)? n
  1. 檢查叢集狀態
$ sudo crm status

螢幕輸出 :

Status of pacemakerd: 'Pacemaker is running' (last updated 2023-11-17 09:41:03 +08:00)
Cluster Summary:
  * Stack: corosync
  * Current DC: sle-ha-1 (version 2.1.5+20221208.a3f44794f-150500.4.9-2.1.5+20221208.a3f44794f) - partition with quorum
  * Last updated: Fri Nov 17 09:41:04 2023
  * Last change:  Fri Nov 17 09:40:30 2023 by root via cibadmin on sle-ha-1
  * 1 node configured
  * 1 resource instance configured

Node List:
  * Online: [ sle-ha-1 ]

Full List of Resources:
  * admin-ip    (ocf::heartbeat:IPaddr2):        Started sle-ha-1
  1. 手動設定 SBD 前的要求
  • 儲存隔離機制最多可使用三個 SBD 設備。使用一至三個設備時,共用儲存必須可從所有節點存取。
  • 一個 SBD 設備可以在不同的集群之間共用,只要共用設備的節點不超過 255 個即可。
  • 對於有兩個以上節點的群集,也可以在無磁碟 ( diskless ) 模式下使用 SBD。
  • 在使用 bootstrap script 設定 SBD 之前,必須在每個叢集節點上啟用 watchdog。
  • SUSE Linux Enterprise Server 隨附的幾個核心模組提供了特定於硬體的 watchdog ( 看門狗 ) 驅動程式,High Availability Extension 核心模組使用 SBD 背景程序作為 " feeds ( 餵食 )” 看門狗的軟體元件。

:::info

重要:Softdog 限制

softdog 驅動程式假定至少有一個 CPU 仍在運作。 如果所有 CPU 都卡死,softdog 驅動程式中重新啟動系統的程式碼將永遠無法執行。相較之下,hardware watchdogs 即使在所有 CPU 都卡死的情況下也能繼續工作。

在 production 環境中使用叢集之前,我們強烈建議使用最適合您硬體的硬體模組來取代 softdog 模組。

不過,如果沒有與硬體相符的看門狗,也可以將 softdog 用作 kernel watchdog 模組。

:::

  1. 初始化 SBD DEVICES

6.1. 決定將以下 Block Devices 用於 SBD

  • /dev/mapper/mpathd
  • /dev/mapper/mpathe
  • /dev/mapper/mpathf

6.2. 使用以下命令初始化 SBD DEVICES

$ sudo sbd -d /dev/mapper/mpathd \
  -d /dev/mapper/mpathe \
  -d /dev/mapper/mpathf \
  -4 60 -1 30 create
  • -4 參數,用於指定 msgwait 逾時幾秒。
  • -1 參數,用於指定 watchdog 逾時幾秒,最小值是 15 秒。

6.3. 備份 sbd 設定檔

$ sudo cp /etc/sysconfig/sbd /etc/sysconfig/sbd.bak

6.4. 編輯 SBD 設定檔

$ sudo sed -i '9i SBD_DEVICE="/dev/mapper/mpathd;/dev/mapper/mpathe;/dev/mapper/mpathf"' /etc/sysconfig/sbd

6.5. ENABLING SBD 服務

$ sudo systemctl enable sbd

6.6. 重啟 Cluster

$ sudo crm cluster restart

6.7. 確認 SBD 程序已啟動

$ ps -eaf | grep sbd

螢幕輸出 :

root      7737     1  0 09:49 ?        00:00:00 sbd: inquisitor
root      7739  7737  0 09:49 ?        00:00:00 sbd: watcher: /dev/mapper/mpathd - slot: 0 - uuid: 8fe16007-8fcc-45d6-867f-2a1fd24d5e4b
root      7740  7737  0 09:49 ?        00:00:00 sbd: watcher: /dev/mapper/mpathe - slot: 0 - uuid: 32929898-fa8d-45b5-8030-b406002d5cf4
root      7741  7737  0 09:49 ?        00:00:00 sbd: watcher: /dev/mapper/mpathf - slot: 0 - uuid: 682f03ee-cf7d-4378-b0ca-f293b72efb20
root      7742  7737  0 09:49 ?        00:00:00 sbd: watcher: Pacemaker
root      7743  7737  0 09:49 ?        00:00:00 sbd: watcher: Cluster
rancher   7765  4523  0 09:50 pts/0    00:00:00 grep --color=auto sbd

3.4. 開始部屬第二台節點

  1. 安裝 High Availability 套件
$ sudo zypper install -t pattern ha_sles
  • 每一台 Node 都要安裝
  • 設定和管理群集的 packages 包含在 High Availability 的 pattern 中,此 pattern 僅在安裝 SUSE Linux Enterprise High Availability Extension 後可用。
  1. 為 SBD 啟用 softdog watchdog

2.1. 啟用 softdog watchdog:

## 啟用 softdog 檢查包
$ echo softdog | sudo tee /etc/modules-load.d/watchdog.conf

$ sudo systemctl restart systemd-modules-load

$ echo "modprobe softdog" | sudo tee -a /etc/init.d/boot.local

$ sudo modprobe softdog

2.2. 測試 softdog 模組是否正確載入:

$ lsmod | grep dog

螢幕輸出 :

softdog           16384  0

2.3. 確認 softdog Device 是否可用且工作:

$ sudo ls -l /dev/watchdog* && sudo sbd query-watchdog

螢幕輸出 :

crw------- 1 root root  10, 130 Nov 15 09:51 /dev/watchdog
crw------- 1 root root 247,   0 Nov 15 09:51 /dev/watchdog0

Discovered 2 watchdog devices:

[1] /dev/watchdog
Identity: Software Watchdog
Driver: softdog
CAUTION: Not recommended for use with sbd.

[2] /dev/watchdog0
Identity: Software Watchdog
Driver: softdog
CAUTION: Not recommended for use with sbd.

2.4. 確認 softdog device 是否運作 :

$ sudo sbd -w /dev/watchdog test-watchdog 

螢幕輸出 :

WARNING: This operation is expected to force-reboot this system
         without following any shutdown procedures.

Proceed? [NO/Proceed]
  • 輸入 : Proceed

螢幕輸出 :

Initializing /dev/watchdog with a reset countdown of 5 seconds ...

NOTICE: The watchdog device is expected to reset the system
        in 5 seconds.  If system remains active beyond that time,
        watchdog may not be functional.

Reset countdown ... 5 seconds
Reset countdown ... 4 seconds
Reset countdown ... 3 seconds
Reset countdown ... 2 seconds
System expected to reset any moment ...
  • 確認 5 秒倒數後,系統會直接被重新開機。
  1. 確認給 SDB 用的 Disk 資訊與第一台 Node 相同
$ sudo lvmdiskscan

螢幕輸出 :

  /dev/mapper/mpathb [     100.00 GiB]
  /dev/sda1          [       8.00 MiB]
  /dev/mapper/mpathe [       1.00 GiB]
  /dev/sda2          [     199.99 GiB]
  /dev/mapper/mpathf [       1.00 GiB]
  /dev/mapper/mpathd [       1.00 GiB]
  /dev/mapper/mpathc [     100.00 GiB]
  5 disks
  2 partitions
  0 LVM physical volume whole disks
  0 LVM physical volumes

:::info

重要 : 如果給 SDB 使用的這三顆硬碟,名稱與第一台節點不同,再將第二台節點加入叢集時會失敗。

:::

:::spoiler 如果不同則按照以下步驟調整為相同

3.1. 在第一台 Node 匯出 multipath 當前的設定檔

$ sudo multipath -T

螢幕輸出 :

...以上省略

multipaths {
        multipath {
                wwid "360014053be325d33ebb4e7e966df3a4f"
                # alias "mpathb"
        }
        multipath {
                wwid "36001405ee25a89d7a8a4df09f6a3a5f0"
                # alias "mpathc"
        }
        multipath {
                wwid "36001405c2d16cc2065f4004ac0a1c188"
                # alias "mpathd"
        }
        multipath {
                wwid "36001405e9b0b982a26f493e97b88ca61"
                # alias "mpathe"
        }
        multipath {
                wwid "3600140552d947e312e24a4f8a9a0f9b1"
                # alias "mpathf"
        }
}

3.2. 修改第二台節點 multipath 的設定檔

$ sudo nano /etc/multipath.conf

將上個步驟在設定檔中得到的 multipath 區塊複製到 第二台節點 multipath 的設定檔,並把 alias 前面的 # 刪除

...以上省略
multipaths {
        multipath {
                wwid "360014053be325d33ebb4e7e966df3a4f"
                alias "mpathb"
        }
        multipath {
                wwid "36001405ee25a89d7a8a4df09f6a3a5f0"
                alias "mpathc"
        }
        multipath {
                wwid "36001405c2d16cc2065f4004ac0a1c188"
                alias "mpathd"
        }
        multipath {
                wwid "36001405e9b0b982a26f493e97b88ca61"
                alias "mpathe"
        }
        multipath {
                wwid "3600140552d947e312e24a4f8a9a0f9b1"
                alias "mpathf"
        }
}    

3.3. 重啟 multipath 服務

$ sudo systemctl restart multipathd.service

3.4. 檢查是否符合預期

$ sudo lvmdiskscan

螢幕輸出 :

  /dev/mapper/mpathd [       1.00 GiB]
  /dev/sda1          [       8.00 MiB]
  /dev/mapper/mpathe [       1.00 GiB]
  /dev/sda2          [     199.99 GiB]
  /dev/mapper/mpathf [       1.00 GiB]
  /dev/mapper/mpathb [     100.00 GiB]
  /dev/mapper/mpathc [     100.00 GiB]
  5 disks
  2 partitions
  0 LVM physical volume whole disks
  0 LVM physical volumes

  1. 將第二台節點加入叢集
$ sudo crm cluster join -i eth2 -i eth0 -c rancher@sle-ha-1 -y
  • -i,指定網卡
  • -c,指定登入現有群集節點的使用者和主機
  • -y,自動回答 yes

螢幕輸出 :

INFO: Configuring csync2
INFO: Starting csync2.socket service
INFO: BEGIN csync2 syncing files in cluster
INFO: END csync2 syncing files in cluster
INFO: Merging known_hosts
INFO: BEGIN Probing for new partitions
INFO: END Probing for new partitions
WARNING: IP 192.168.11.172,10.13.0.32 was already configured
INFO: Got SBD configuration
INFO: Hawk cluster interface is now running. To see cluster status, open:
INFO:   https://10.13.0.32:7630/
INFO: Log in with username 'hacluster', password 'linux'
WARNING: You should change the hacluster password to something more secure!
INFO: BEGIN Waiting for cluster
..                                                                 
INFO: END Waiting for cluster
INFO: BEGIN Adjusting sbd related timeout values
WARNING: "stonith-timeout" in crm_config is set to 119, it was 60
INFO: END Adjusting sbd related timeout values
INFO: BEGIN Reloading cluster configuration
INFO: END Reloading cluster configuration
INFO: Done (log saved to /var/log/crmsh/crmsh.log)
  1. 檢查叢集狀態
$ sudo crm status

螢幕輸出 :

Status of pacemakerd: 'Pacemaker is running' (last updated 2023-11-17 11:45:37 +08:00)
Cluster Summary:
  * Stack: corosync
  * Current DC: sle-ha-1 (version 2.1.5+20221208.a3f44794f-150500.4.9-2.1.5+20221208.a3f44794f) - partition with quorum
  * Last updated: Fri Nov 17 11:45:38 2023
  * Last change:  Fri Nov 17 11:08:36 2023 by root via cibadmin on sle-ha-2
  * 2 nodes configured
  * 1 resource instance configured

Node List:
  * Online: [ sle-ha-1 sle-ha-2 ]

Full List of Resources:
  * admin-ip    (ocf::heartbeat:IPaddr2):        Started sle-ha-1
  1. 登入 HAWK2 網站
  • URL : https://10.13.0.31:7630/login
    • 兩台主機的 7630 Port 都能登入
  • 帳號 : hacluster
  • 密碼 : linux

image

3.5. HA 叢集基礎設定

  1. 檢查是否啟用 fencing
$ sudo crm configure show type:property
  • 允許 STONITH 設備 射擊 故障的節點和擁有無法停止的資源的節點。
  • STONITH is stands for “Shoot The Other Node in the Head”

螢幕輸出 :

property cib-bootstrap-options: \
        have-watchdog=true \
        dc-version="2.1.5+20221208.a3f44794f-150500.4.9-2.1.5+20221208.a3f44794f" \
        cluster-infrastructure=corosync \
        cluster-name=topgun \
        stonith-enabled=true \
        stonith-watchdog-timeout=-1 \
        stonith-timeout=119

如果發現 stonith-enabled 的值等於 false,那麼請執行以下命令 : $ sudo crm configure property stonith-enabled=true

STONITH 這個動作由 pacemaker-fenced 這個背景程序執行,這個程序會在叢集中的每一台 Node 的背景中運作,在 DC 節點的 pacemaker-fenced 負責接收來自 pacemaker-controld 的 fencing 請求,由 DC 節點的 pacemaker-fenced 和其他節點的 pacemaker-fenced 程式來執行所需的 fencing 操作。

  1. 將 SBD 設定為 Cluster Resource
$ sudo crm configure primitive sbd stonith:external/sbd params sbd_device="/dev/mapper/mpathe;/dev/mapper/mpathf;/dev/mapper/mpathd"  op start timeout=20 interval=0 op stop timeout=15 interval=0 op monitor timeout=20

/etc/sysconfig/sbd 中有設定 SBD_STARTMODE=always 的話,代表在叢集中的節點被 Fence 之後,會在主機重開機後,自動 Join 回叢集中; 如果把 SBD_STARTMODE 的值設為 clean 的話,主機重開機後,就"不會"自動 Join 回叢集中。

主機被 Fence 之後,手動 Join 回叢集的步驟如下 :

  1. sudo sbd -d /dev/sda list,檢查哪一台 Node 是 reset
  2. reset 的 node 改回 clear,sudo sbd -d /dev/sda message <node name> clear
  3. 啟動 pacemaker 服務,sudo systemctl start pacemaker.service
  4. 檢查叢集狀態 sudo crm status

4. 參考資料

SLES TroubleshootingPacemaker 解析