Skip to content

antony@notes:~/suse$ cat "SUSE-Linux-Enterprise-HAE.md"

SUSE Linux Enterprise HAE

2024-03-13· suse ·SLE HAE

SUSE Linux Enterprise HAE

Preface

本篇文章會主要會介紹,什麼是 SUSE Linux Enterprise HAE,並且介紹它的架構

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

:::warning

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

[TOC]

:::

Introduction to SUSE Linux Enterprise HA

SLE HA Product Overview

  • SUSE Linux Enterprise High Availability 可作為 SLE15 的 Extension ( 擴充 ) 來提供
  • 它由多項 open source clustering technologies 組合而成,包括主要的兩個技術:
    • Pacemaker
      • 資源管理器,用來管理在叢集中的資源,例如: VIP、檔案系統、Apache、資料庫…等,都可以透過它來管理,來防止服物被中斷
    • Corosync
      • 確保在叢集中的 Node 之間的資訊進行同步,假設有一台 Node 故障,能夠快速發現,並且要恢復時,能夠把節點快速加回叢集中。
  • 藉由 SLE HAE 使您能夠在虛擬機、在雲端上的虛擬機和實體機實施的高可用性解決方案

SLE HAE 目標

  • 消除單點故障,以 HANA 為例,它本身就是一種克隆資源,第二台節點本身會去跟第一台主節點同步所有的資料,一但第一台節點當機,第二台節點能夠立即提供服務。
  • 確保服務的高可用性,一旦有服務在本機發生故障,它能夠幫你把服務檢測,一但在本機不可恢復就會遷移到其他節點上繼續提供服務。
  • 實現 critical network resources ( 關鍵網路資源 ) 的管理
    • 確保 Data ( 數據 ) 能夠一直被存取
    • 確保 Applications ( 應用 ) 能夠跑的長長久久、穩穩當當
    • Services ( 服務 )

建立 SLE HAE 的好處

  • 讓服務能夠變成高可用
    • 朝著零停機時間邁進
  • 降低故障恢復所需的時間
  • 減少計劃更新所需的停機時間
    • 將服務移轉至另一台節點上
    • 更新 Node 的系統
    • 再將服務移轉回來

Cluster Types

  • SUSE Linux Enterprise HA supports:
    • Local Clusters
    • Metro Clusters
    • Geo Clusters
  • Local Cluster
    • 單一個 Cluster 在一個地點
    • 例如,叢集的所有節點都在一個 Datacenter ( 資料中心 ) 內
  • Metro Cluster
    • 單一個 Cluster 分佈在多棟建築物中
  • Geo Cluster
    • 多個 local clusters ,在地理位置上相互遠離

Geo Clustering

  • A Geo Cluster consists of:
    • Multiple geographically dispersed sites ( 多個地理分散的地點 )
    • A local cluster on each site ( 每個不同的地點都會有一個 local cluster )
  • A subscription for SUSE Linux Enterprise HA Extension includes Geo Clustering for SLE HA
  • Geo Clustering 提供跨不同地點的故障切換

  • 以 SUSE Linux Enterprise High Availability Extension 為基礎建立的 Geo clusters 可以被視為 “overlay” clusters ,每一個 cluster 在傳統的 cluster 中對應的是一個 node,overlay cluster 由 booth cluster ticket manager 管理
  • Geo Cluster 中的每一個 Local Cluster 都執行一個 booth 背景程序。 它連接到其他不同地點的 Cluster 中運行的 booth 背景程序,並交換連線詳情。
  • booth 背景程序依賴 ticket (在 Cluster 中的一個物件) 來實現叢集資源跨地點的高可用性。 ticket 會決定要在哪一個地點的 Cluster 上要執行哪些 Application。 booth 保證每張 ticket 一次只能授予一個地點的 Cluster。

如果兩個 booth 程序之間的通訊中斷,Application 的轉移會由誰決策?

可能是因為兩個 Cluster 所在的地點之間的網路故障,也可能是因為某個 Cluster 所在的地點網路被中斷,在這種情況下,你需要一個額外的實例 ( 第三個不同地點的 Cluster 或是一個 arbitrator [仲裁器]) 來就跨地點的資源故障轉移等決策達成共識。

:::info

Arbitrator ( 仲裁器 )

是叢集之外的單一台 Node,以特殊模式執行 booth 服務。 每個 Geo Cluster 可以有一個或多個 arbitrator。

:::

最常見的情況可能是一個 Geo Cluster 有兩個地點,在第三個地點上有一個 arbitrator。 這就需要三個 booth 服務。

也可以運行一個在 兩個地點 的 Geo Cluster 但是沒有 arbitrator。 在這種情況下,Geo Cluster 的管理員需要手動管理 ticket。 如果要同時向多個地點的 Cluster 授予 ticket, booth 會顯示警告。

Primary Components of SLE HA

HA Base Components

  • Corosync (負責管理叢集的心跳)
  • Pacemaker (資源管理器和策略控制器)
  • crm shell ( crm 命令來管理叢集)
  • Hawk (Web 介面來管理叢集)

Storage Components (可選的)

  • 以下是能做為 HAE Storage 的技術
    • Clustered NFS
    • cLVM
    • OCFS2 (可以給 Active/Active 的服務使用)
    • GFS2 (可以給 Active/Active 的服務使用)
    • Cluster Managed MDRAID
    • DRBD (只能給 Active/Standby 的服務使用,Active 那台主機可以 rw,Standby 的那台主機只能 read)
    • Samba
    • Ceph (SES)

Network Load Balancing

  • Linux IP Virtual Server (LVS)
    • Operates at OSI layer 4 (Transport)
  • HAProxy
    • Operates at OSI layer 7 (Application)
  • Conntracked
    • User state tools for stateful packet inspection for iptables
  • Rear
    • Disaster Recovery, Relax and Recover (Rear)

SLE HA Licensing

  • Required subscriptions
    • SLE 15
    • SLE 15 HA
      • Includes geo clustering

Questions and Answers

Q. A SUSE Linux Enterprise HA subscription is included with a SLE15 subscription, True or false?

A. False, a SLE HA scbscription is required

Q. What are the two open source clustering technologies used by SLE HA?

A. Pacemaker and Corosync

Q. SUSE Linux Enterprise HA supports which types of cluster?

A. Local Clusters, Metro Clusters and Geo Clusters

Q. A subscription for Geo Clustering for SLE HA is included with the SLE HA Extension subscription, true or false?

A. True

Terms

  • RTO - Rcovery Time Objective
    • 故障後恢復正常運行的目標時間
  • RPO - Recovery Point Objective
    • 可能遺失的資料量

Cluster Terminology

High Availability Cluster

高可用性叢集的設計主要是為了確保服務的最高可用性。

Node

任何電腦,無論是真實電腦還是虛擬電腦,都是 Cluster 的成員。

CCM

Consensus Cluster Membership ( 共識叢集成員資格 )。

這是決定哪些 Node 組成叢集,並把這個資訊分享給叢集中的所有 Node 。每個叢集的 Node 都運行一個 CCM module。

Quorum

如果一個 cluster partition 擁有多數節點 (或投票權),就被定義為具有仲裁的能力 (quorate)

A cluster partition is defined to have quorum (is “quorate”) if it has the majority of nodes (or votes)

Epoch

cluster configuration/status 的版本號

Split Brain

cluster nodes 被分為兩個或多個群組,而這些群組彼此不知道對方的存在。

發生 Split Brain 的原因有可能只是因為機器跟機器之間網路斷線,在只有 2 個節點的情況下,HA 本身不具備要殺死 A 節點還是 B 節點的能力,理論上雙方都會認為自己是存活的一方,此時為了保證共享資源的完整性,雙方都會調用 Fencing 的機制,這時候就會啟動 SDB,就有可能出現一種狀況,那就是 Double Fencing,雙方同時要 Fencing 對方,為了避免這種情況發生,HA 之中可以設定一種參數,來防止雙方同時發出 Fencing。

Fencing

防止在 Cluster 中被隔離或 failing 的 Node 存取 shared resource ( 共享資源 ) 。

何時會觸發這種機制? 答: 在叢集發生 Split Brain 和 啟動/停止服務的動作超過預設的時間時會觸發 Fencing。

Active/Passive

active node 上運行一個或多個服務,而 Passive node 則等待 active node 發生故障後再接管服務。

Active/Active

每個 node 同時都是 active 和 passive 的。 例如,一個 node 上有一些服務在運行,但它也可以接手另一個 node 上的其他服務。

SLE 15 HA Architecture

Membership and messaging layer (Corosync)

此元件負責在叢集內傳遞訊息、確保叢集成員資格的一致性,以及計算足夠節點的數量。這些資訊由群組通訊系統 Corosync cluster engine 處理。

  • Sends out messages
    • Example: “I am alive”
  • Can use unicast (單播) or multicast (多播)
    • Unicast
      • More secure if multiple cluster share the same network infrastructure
      • 當叢集中新增或刪除節點時,需要重新配置 corosync
      • cloud hosted HA clusters 需要
    • Multicast
      • Easy to add nodes with reconfiguring all the existing nodes
  • Corosync is a seperate systemd service - Cloud hosted HA clusters 不能使用 multicast

Resource Allocation Layer

The Resource Allocation Layer is provided by Pacemaker

Components

  • Cluster Resource Manager - CRM
  • Cluster Information DataBase - CIB
  • Designated Coordinator - DC
  • Policy Engine - PE
  • Local Resource Manager - LRM
  • STONITH

Cluster Resouce Manager (Pacemaker)

Pacemaker 作為叢集資源管理器,是叢集中所有事件的「大腦」。它以 pacemaker-controld 的形式實現,它是叢集控制器,負責協調所有動作。

事件可以是節點加入或退出叢集、資源故障,或者計劃的活動,例如維護等。

  • 在 Resouce Allocation layer 和更高層的通訊都是透過 CRM 去溝通
  • 維運和管理 Cluster Information Base - CIB
  • 在 Cluster 中的其中一個 CRM 會晉升為 Designated Coordinator – DC
  • Local CRM 會在叢集中的每一個 Node 上跑

Cluster Information Database (CIB)

  • Pacemaker 會在每一台 node 上維護 cluster information database。
  • 它是一個 XML 的叢集設定檔,包含 :
    • All cluster options
    • nodes
    • resources
    • constraints
    • the relationship to each other
  • 它不僅是叢集的設定檔,也會反映叢集目前的狀態
  • 每個叢集節點都會儲存一個 CIB 的副本,並且會在叢集中同步
  • pacemaker-based 背景程序,負責讀取和寫入 Cluster 的設定和狀態。
  • 設定檔的版本儲存在每個 Node 的硬碟上

Designated Coordinator (DC)

  • 在 Cluster 的所有 Node 上,其中一個 CRM 會透過選舉晉升為 Designated Coordinator
    • 當 Cluster 中沒有 DC 存在時,會進行選舉
    • 如果當前 DC 因任何原因離開 Cluster 時,也會進行選舉
  • 決定是否必須在整個叢集範圍內進行變更
    • 範例
      • 移動資源
      • 封鎖一個節點
  • Maintains the master copy of the CIB

Policy Engine (PE)

  • Policy Engine 在每個 Node 上運行,但 DC 上的引擎是 active 的。
  • pacemaker-schedulerd 背景程序的形式實現。
  • 當需要進行 cluster transition 時,pacemaker-schedulerd 會根據目前狀態和設定計算叢集的下一個狀態。
  • 它決定需要安排哪些操作來實現下一狀態。

描述

根據 CIB 的信息,Policy Engine 會計算出 Cluster 的理想狀態以及實現該狀態的方法。 PE 向 DC 發送指令清單。 DC 透過 Corosync 發送指令,其他節點上的 crmd 對等節點會接收到這些指令。 每個 crmd 使用其 LRM 執行資源修改。 lrmd 不具備叢集感知能力,可直接與資源代理程式互動。

Local resource manager (LRM)

  • 負責接收 CRM 的請求
  • 呼叫 local Resource Agents
    • CRM → LRM → RA
  • Task performed on Resource Agents:
    • Start
    • Stop
    • Monitor
  • Is authoritative ( 有權威性的 ) about the state of resouces on the local node

STONITH

STONITH 是一種隔離技術,用來隔離故障的節點,防止它繼續造成影響。 STONITH 的英文全名是 Shoot-The-Other-Node-In-The-Head。

STONITH 通常使用遠端電源開關來實現。 當 Pacemaker 偵測到某個節點故障時,會發出命令給 STONITHd,要求它隔離故障節點。STONITHd 會根據 CIB 中的設定,選擇合適的 STONITH 裝置,並對它發出指令,將故障節點關機或斷電。

在 Pacemaker 中,STONITH 裝置被當作資源來管理,以便於對其故障進行監控,而STONITHd 則負責了解 STONITH 拓撲 (裝置的類型、名稱、位置等資訊),因此其客戶端只需請求對節點進行圍欄,剩下的就交給 STONITHd 了。

image

Summary

CIB 使用 XML 格式記錄叢集的設定和所有資源的狀況,所有叢集的節點都會自動同步 CIB 的內容,讓 PEngine 可以根據這些資料來計算出叢集的理想狀態,並想出達成理想狀態的方法。

PEngine 會把一連串指示交給 DC,DC 可以想像成是指揮官,負責指揮整個叢集的運作。 Pacemaker 會選出一個 CRMd 當成 DC,由它來統一做決策。如果選出來的 CRMd 失效了,就會趕快選出另一個來接手。

DC 會按照 PEngine 的指示,指揮其他節點上的 LRMd 或 CRMd 工作。 它會透過叢集的通訊系統發送指令,叫這些節點照著做。

所有節點都會把自己的工作結果回報給 DC。 DC 會比對預期結果和實際結果,如果有問題,就會請 PEngine 重新計算理想狀態,想出解決辦法。

有時候,為了保護資料或讓資源復原,可能需要強制關閉某些節點。 這時 Pacemaker 就會用 STONITHd 來處理。

Resource Layer

  • 包含一個或多個 Resource Agents
  • Examples of resources include:
    • IPaddr2
      • An ip address resource
    • STONITH
      • A fencing resource

Resource Agent

  • Resouce Agents 就是程式
    • 通常是 shell scripts
  • Resource Agents can:
    • Start
    • Stop
    • Monitor
  • 致力於特定類型的服務
    • Example: IPaddr2
  • 會被 Local Resouce Manager 呼叫
    • 回傳值會傳回 CRM

Resource Agent Providers

  • 以下是多個 Resource Agent providers
    • OCF
      • Open Cluster Framework
      • Recommended to use OCF providers if available
    • LSB
      • Linux Standards Base
      • Provided by the operating system and found in /etc/init.dge
    • systemd
      • Directly manage systemd services
    • service
      • Sopports systemd, init and upstart
        • Useful if the cluster has a mix of service types
    • STONITH
      • Used exclusivly for fencing related resources

Third Party Resource Agents

  • Third parties can include custom Resouce Agents
    • These provide out of the box cluster integration for third party applications

STONITH

  • 全名 : “Shoot The Other Node In The Head”
  • Pacemaker provides STONITH
  • Provides a node level fencing mechanism
  • Fencing is required if a problem occurs and a node must be denied access to a cluster resource
    • Example: A node is denied access to a filesystem so it can be loaded on another node

Distributed Lock Manager

  • Provides generic cluster wide locking facilities
    • Allow the use of active/active storage
  • Utilizes Pacemaker cluster membership services that run in user space
    • Therefore runs as a reources on each node

Cluster Logical Volume Manager

  • Uses the daemon lvmlockd
    • Replaces clvmd
    • lvmlockd introduced with SLE15 HA
  • Used with LVM2 in a cluster enviroment
  • Protects the LVM metadata on shared storage

Questions and Answers

Q. Name three components of the Resource Allocation Layer

A. Cluster Resource Manager, Cluster Information Base, Designated Coordinator, Policy Engine, Local Resource Manager

Q. What does SLE HA use as its Cluster Resource Manager?

A. Pacemaker

Q. What does SLE HA use as its Messaging component?

A. Corosync

Q. What type of tasks does a Resource Agent perform, give three examples?

A. Start, Stop and Monitor resouces