# Pacemaker + CoroSync + PCS --- ## 比較 ### keepalived * based on VRRP * 透過 vrrp_script 來檢測 node 的狀態 * 透過 config 檔直接設定 * 基本上是 Active + Hot Standby 的模型 ### Pacemaker + CoroSync + PCS * 從 OpenAIS 分離出來的子專案 * Pacemaker: Cluster Resource Manager - 負責掌控 resource 的生命週期 * CoroSync: Group Communication System - 負責節點間通訊、 heartbeat * 透過 resource script * 透過 pcs 界面控制 * 可以實作出 Active / Standby 的模型 --- ## haproxy with pcs ### 安裝 ``` $ sudo yum install corosync pacemaker pcs fence-agents resource-agents ``` ### 防火牆設定 ``` $ sudo firewall-cmd --add-port="2224/tcp" --permanent # pcs $ sudo firewall-cmd --add-port="5405/udp" --permanent # corosync $ sudo firewall-cmd --add-port="3121/tcp" --permanent # pacemaker $ sudo firewall-cmd --reload ``` ### 設定 hacluster 密碼 ``` $ sudo passwd hacluster ``` ### 建立 cluster ``` $ sudo pcs cluster auth hpc02 hpc03 -u hacluster -p 123456 --force $ sudo pcs cluster setup --force --name hpc hpc0{1..3} $ sudo pcs cluster start --all ``` ### 設定 ``` $ sudo pcs property set stonith-enabled=false # 關閉 STONITH $ sudo pcs property set no-quorum-policy=ignore # 雙節點時需設定 ``` ### 建立資源 ``` $ sudo pcs resource create haproxy systemd:haproxy op monitor interval=2s ``` ### 建立 VIP 資源 ``` $ sudo pcs resource create HAProxy_VIP_VL3 ocf:heartbeat:IPaddr2 ip=10.8.8.20 cidr_netmask=22 op monitor interval=1s $ sudo pcs constraint colocation add haproxy with HAProxy_VIP_VL3 $ sudo pcs constraint order HAProxy_VIP_VL3 then haproxy ``` ``` $ sudo pcs status Cluster name: hpc Stack: corosync Current DC: haproxy07 (version 1.1.15-11.el7_3.4-e174ec8) - partition with quorum Last updated: Mon May 11 08:42:06 2020 Last change: Fri Mar 13 10:32:11 2020 by hacluster via crmd on haproxy08 2 nodes and 2 resources configured Online: [ haproxy07 haproxy08 ] Full list of resources: haproxy (systemd:haproxy): Started haproxy08 HAProxy_VIP_VL3 (ocf::heartbeat:IPaddr2): Started haproxy08 Daemon Status: corosync: active/enabled pacemaker: active/enabled pcsd: active/enabled ``` ## Playbook * [lw-cloud.ansible.M2/haproxy-pcs](https://gitlab.tw1.ltzwk.com/cloud/lw-cloud.ansible.M2/-/tree/feature/haproxy-pcs) * [haproxy-pcs.ansible.role](https://gitlab.tw1.ltzwk.com/cloud/haproxy-pcs.ansible.role) ``` $ ansible-playbook -i inventories/dev.tw1.ltzwk.com/hosts haproxy-pcs.yml ```
{"metaMigratedAt":"2023-06-15T02:01:39.624Z","metaMigratedFrom":"Content","title":"Pacemaker + CoroSync + PCS","breaks":true,"contributors":"[{\"id\":\"c5624c76-c2a7-46fd-bccf-427935c2f33d\",\"add\":3152,\"del\":760}]"}
    374 views