申明:
centos7的pacemaker與6使用的方法不一致,即使用centos6.x的方法在centos7.x上面配置pacemaker不能成功。
因此openstack 上面的centos7.1如果使用官方文檔直接配置高可用HA也是無法成功的。(吐槽:openstack的liberty出的HA方案官方文檔不適用於centos7.x)
關於openstack liberty版本的高可用HA方案請參考下述實驗!!!
|
PS:與pacemaker高可用方案相對應的keepalived原理(主從配置+haproxy)及配置文件詳解請參考博文:
http://blog.csdn.net/tantexian/article/details/50056229
centos7配置pacemaker官方文檔地址:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/High_Availability_Add-On_Administration/ch-startup-HAAA.html

Pacemaker’s key features include:
監測並恢復節點和服務級別的故障
存儲無關,並不需要共享存儲
資源無關,任何能用腳本控制的資源都可以作為服務
Supports fencing (also referred to as the STONITH acronym,
deciphered later on) for ensuring data integrity
支持大型或者小型的集群
Supports both quorate and resource-driven clusters
Supports practically any redundancy configuration
自動同步各個節點的配置文件
可以設定集群范圍內的ordering, colocation and anti-colocation
Support for advanced service types
Clones:為那些要在多個節點運行的服務所准備的
Multi-state: for services with multiple modes (e.g. master/slave, primary/secondary)
Unified, scriptable cluster management tools
|
本次實驗環境:
centos7.1
node31:172.31.2.31
node32 : 172.31.2.32
node31、node32兩台機器上面都安裝pacemaker,因此下述操作都需要在兩天機器上面執行。
1、配置防火牆端口及關閉selinux
systemctl disable firewalld
systemctl stop firewalld
iptables -F
2、配置hostname:
hostnamectl --static --transient set-hostname node31
hostnamectl --static --transient set-hostname node32
vim /etc/hosts

3、時間同步:
yum install ntp -y
ntpdate cn.pool.ntp.org
4、雙機互信(本次實驗發現,不配置雙機互信似乎也不會出現問題):
ssh-keygen -t rsa

復制id_rsa.pub文件:
scp /root/.ssh/id_rsa.pub
root@172.31.2.32:/root/.ssh/authorized_keys

注:在node32執行同樣的互信操作。
5、安裝pacemaker集群相關組件:
yum install pcs pacemaker corosync fence-agents-all -y
6、啟動pcsd服務(開機自啟動)
systemctl start pcsd.service
systemctl enable pcsd.service
7、創建集群用戶:
passwd hacluster(此用戶在安裝pcs時候會自動創建)

上述所有操作都需要在兩個節點上面執行。
8、集群各節點之間進行認證:
pcs cluster auth node31 node32(此處需要輸入的用戶名必須為pcs自動創建的hacluster,其他用戶不能添加成功)

9,創建並啟動名為my_cluster的集群,其中node31 node32為集群成員:
pcs cluster setup --start --name my_cluster node31 node32

10、設置集群自啟動:
pcs cluster enable --all

11、查看並設置集群屬性:
查看當前集群狀態:
pcs cluster status
![]()
檢查pacemaker服務:
ps aux | grep pacemaker
![]()
檢驗Corosync的安裝及當前corosync狀態:
corosync-cfgtool -s
corosync-cmapctl | grep members
pcs status corosync
檢查配置是否正確(假若沒有輸出任何則配置正確):
crm_verify -L -V
禁用STONITH:
pcs property set stonith-enabled=false
無法仲裁時候,選擇忽略:
pcs property set no-quorum-policy=ignore
![]() |
12、pcs resource資源屬性配置:
Pacemaker / Corosync 是 Linux 下一組常用的高可用集群系統。Pacemaker 本身已經自帶了很多常用應用的管理功能。但是如果要使用 Pacemaker 來管理自己實現的服務或是一些別的沒現成的東西可用的服務時,就需要自己實現一個資源了。
其中Pacemaker 自帶的資源管理程序都在 /usr/lib/ocf/resource.d 下。其中的 heartbeat 目錄中就包含了那些自帶的常用服務。那些服務的腳本可以作為我們自己實現時候的參考。
更多關於自定義資源請參考博文:
http://blog.csdn.net/tantexian/article/details/50160159
接下來針對一些常用的pcs命令進行簡要講解。
查看pcs resource針對資源操作用法:
pcs resource help
![]()
查看pcs支持的資源代理標准:
pcs resource providers
![]()
注:Pacemaker 的資源主要有ocf、lsb、service、systemd、stonith幾大類。LSB是為了促進 Linux 不同發行版間的兼容性,LSB(Linux Standards Base)開發了一系列標准,使各種軟件可以很好地在兼容 LSB 標准的系統上運行, LSB 即 Linux 標准服務,通常就是 /etc/init.d 目錄下那些腳本。Pacemaker 可以用這些腳本來啟停服務,可以通過pcs resource list lsb查看。另一類 OCF 實際上是對 LSB 服務的擴展,增加了一些高可用集群管理的功能如故障監控等和更多的元信息。可以通過 pcs resource list ocf 看到當前支持的資源。要讓 pacemaker 可以很好的對服務進行高可用保障就得實現一個 OCF 資源。CentOS7 使用systemd替換了SysV。Systemd目的是要取代Unix時代以來一直在使用的init系統,兼容SysV和LSB的啟動腳本,而且夠在進程啟動過程中更有效地引導加載服務。
查看pacemaker支持資源高可用的列表:
pcs resource list
![]()
假若想查看httpd(apache)可使用:pcs resource list | grep apache
![]()
具體apache用法:
pcs resource describe ocf:heartbeat:apache
![]()
|