HA 高可用之V1版
????HA(High Available), 高可用性群集,是保證業務連續性的有效解決方案,一般有兩個或兩個以上的節點,且分為活動節點及備用節點。通常把正在執行業務的稱為活動節點,而作為活動節點的一個備份的則稱為備用節點。當活動節點出現問題,導致正在運行的業務(任務)不能正常運行時,備用節點此時就會偵測到,并立即接續活動節點來執行業務。從而實現業務的不中斷或短暫中斷。
RA:resource agent 能夠接收CRM調度用于對某一個資源進行調度的工具
????{start|stop|restart|status}?
在高可用集群中,任何服務都不一個自啟動,而是有CRM管理啟動與否
RHEL OR CentOS高可用集群解決方案:
RHEL 5版本:
自帶: RHCS(cman+rgmanager)
????選用第三方:corosync+pacemaker, heartbeat(v1或v2), keepalived
RHEL 6版本:
自帶:RHCS(cman+rgmanager)
????corosync+rgmanager
????cman+pacemaker 6.5之后默認就是cman+pacemaker?
????heartbeat v3 + pacemaker 6.4之后?
????keepalived
Messaging Layer類型: 底層的心跳消息會話,定義信息通信HMC消息認證碼、心跳信息間隔傳遞時長、剛啟動系統緩沖、事物信息傳遞方式(壓縮),TCP/UDP傳遞協議?
hearbeat端口:694/udp端口:694/udp
支持單播、組播等方式傳遞消息
????heartbeat v1, v2, v3
????(OpenAIS)corosync
????cman
CRM類型: Cluster Resources Manager,為那些非ha-ware的應用程序提供調用的基礎平臺
一般情況下,一個高可用服務包括多個資源,從屬于同一個服務的多個資源必須運行于一個節點上
????heartbeat v1: haresources (配置接口:配置文件,文件名也叫haresources)
????heartbeat v2: crm (各節點均運行進程crmd,配置接口:客戶端crmsh(shell),heartbeat-GUI)
????heartbeat v3 = heartbeat + pacemaker + cluster-glue:?
????pacemaker:?
????配置接口:
????CLI: crm(SuSE), pcs
????GUI: hawk, LCMC, pacemaker-mgmt
????cman + rgmanager:
????resource group manager: Failover Domain
????配置接口:
????RHCS: RedHat Cluster Suite
????配置接口:Conga (完全生命令周期的配置接口)
RA類型:resource agent,能夠接收CRM調度用于對某一個資源進行調度的工具
????heartbeat legacy: heartbeat的傳統類型
????LSB:/etc/rc.d/init.d/*
????OCF: Open Cluster Framework
????provider: pacemaker
????linbit
????STONITH:?
????
配置HA高可用集群:
大概過程:
1、配置ssh不需要密碼即可訪問、同步時間
2、上傳hearbeat包
3、安裝hearbeat:
解決依賴關系:
[root@node1 heartbeat2]# yum install perl-TimeDate net-snmp-libs libnet PyXML
[root@node1 heartbeat2]# rpm -ivh /tmp/libnet-1.1.6-7.el6.x86_64.rpm
[root@node1 heartbeat2]# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
2、編輯主配置文件:
logfile /var/log/ha-log ?#日志存放目錄
keepalive 1000ms ?#or 1 #每間隔多久發送一次心跳信息
deadtime 8 #多長時間認為對方掛掉
warntime 4 #多長時間沒有收到對方的心跳會發出警報,必須小于deadtime
initdead 120 ?#系統剛啟動后等待會話時間
udpport 694 ?#端口號
#baud ? 19200 ?#限制串行口速率,非串行口不用啟動
#bcast ?eth0 ?#廣播
mcast eth0 225.0.0.1 694 1 0 #組播等方式傳遞消息,比較合適
#ucast eth0 192.168.1.2 #單播
auto_failback on #服務自動轉回
#stonith baytech /etc/ha.d/conf/stonith.baytech #設備,不需要配合
node ? ?node1.a.com #HA集群內所有主機的全名,且不能寫IP地址
node ? ?node2.a.com?
ping ? ?192.168.10.1 ?#ping的地址,完成仲裁
compression ? ? bz2 數據壓縮格式
compression_threshold 2 #低于多大的數據不壓縮,單位為KB
各主機編輯/var/www/html/index.html,測試http訪問可用正常被訪問,但是不能設置為開機啟動
[root@node2 htdocs]# service httpd stop
[root@node2 htdocs]# chkconfig ?httpd off
3、定義集群資源:
[root@node2 ha.d]# vim haresources #定義集群資源
node1.a.com ? ? ? ? ? 192.168.10.19/24/eth0 ? ? ? ? ? ? ? httpd
優先使用的主機 ? ?資源VIP(虛擬IP)/掩碼/指定網卡 ? ? ? ?定義的服務
4、啟動服務:
node1:
[root@node1 ha.d]# /etc/init.d/heartbeat start
????Starting High-Availability services:
????2015/01/08_17:19:02 INFO: ?Resource is stopped
????Done.
????node2:
[root@node2 ~]# /etc/init.d/heartbeat ?restart
????Stopping High-Availability services:?
????Done.
????Waiting to allow resource takeover to complete:
????Done.
????Starting High-Availability services:?
????2015/01/08_17:30:20 INFO: ?Resource is stopped
????Done.
查看日志:
[root@node2 ~]# tail /var/log/ha-log?
heartbeat[2875]: 2015/01/08_17:30:22 info: remote resource transition completed.
heartbeat[2875]: 2015/01/08_17:30:22 info: remote resource transition completed.
heartbeat[2875]: 2015/01/08_17:30:22 info: Local Resource acquisition completed. (none)
heartbeat[2875]: 2015/01/08_17:30:23 info: node1.a.com wants to go standby [foreign]
heartbeat[2875]: 2015/01/08_17:30:23 info: standby: acquire [foreign] resources from node1.a.com
heartbeat[2901]: 2015/01/08_17:30:23 info: acquire local HA resources (standby).
heartbeat[2901]: 2015/01/08_17:30:23 info: local HA resource acquisition completed (standby).
heartbeat[2875]: 2015/01/08_17:30:23 info: Standby resource acquisition done [foreign].
heartbeat[2875]: 2015/01/08_17:30:23 info: Initial resource acquisition complete (auto_failback)
heartbeat[2875]: 2015/01/08_17:30:24 info: remote resource transition completed.
5、在客戶機訪問192.168.10.19測試:
測試結果一定是可以訪問192.168.10.19并且優先顯示node1的網頁內容
將node1的heartbeat服務關閉測試能否遷移至node2:
測試結果可以
再將node1打開,測試能否遷移至node1:
結果可以
6、在另外一個節點啟動NFS服務共享給集群使用,并創建一個index.html文件:
node3:
[root@node3 ~]mkdir ?-pv /www/htdocs?
[root@node3 ~]vim /etc/export?
????/www/htdocs ?*(rw)
[root@node3 ~]setfacl -m u:apache:rwx /www/htdocs
[root@node3 ~]vim /www/htdocs/index.html
? ?<h1> Page in NFS</h1>
[root@node3 ~service nfs restart
配置客戶端使用NFS:
停止node1和node2的heartbeat服務:
[root@node1 ha.d]service heartbeat stop
[root@node1 ha.d]ssh node2 'service heartbeat stop'
[root@node1 ha.d]vim /etc/ha.c/haresources
node1.a.com 192.168.10.19/24/eth0 ?Filesystem:192.168.10.135::/www/htdocs::/var/www/html::nfs httpd
優先運行的主機 ?VIP ? 文件系統::共享NFS的服務器IP::共享目錄::掛載至本地目錄::文件系統格式 ?http服務
[root@node1 ha.d]# scp haresources ?node2:/etc/ha.d/?
7、重新在客戶端訪問能否讀取NFS的Page頁:
手動將主節點切換為備用節點,服務是會自動切換至另外一個節點之上繼續運行:
轉載于:https://blog.51cto.com/zhangshijie/1600979
總結
以上是生活随笔為你收集整理的HA 高可用之V1版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: H5前端框架推荐合集 (转)
- 下一篇: Cacti 每日导出图形及流量报表 [未