1.corosync概述
html
Corosync是OpenAIS發展到Wilson版本後衍生出來的開放性集羣引擎工程。能夠說Corosync是OpenAIS工程的一部分。 OpenAIS從openais0.90開始獨立成兩部分,一個是Corosync;另外一個是AIS標準接口Wilson。Corosync包含 OpenAIS的核心框架用來對Wilson的標準接口的使用、管理。它爲商用的或開源性的集羣提供集羣執行框架。node
2.安裝配置corosync+pacemakerlinux
1).準備工做centos
配置各節點SSH互信:bash
# node1 ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' ssh-copy-id -i .ssh/id_rsa.pub root@192.168.220.133 # node2 ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' ssh-copy-id -i .ssh/id_rsa.pub root@192.168.220.132
配置主機名稱與uname -n一致,並經過/etc/hosts解析:網絡
# node1 hostname node1.wyb.com sed -i 's@\(HOSTNAME=\).*@\1node1.wyb.com@g' /etc/sysconfig/network echo '192.168.220.132 node1.wyb.com node1' >> /etc/hosts echo '192.168.220.133 node2.wyb.com node2' >> /etc/hosts # node2 hostname node2.wyb.com sed -i 's@\(HOSTNAME=\).*@\1node2.wyb.com@g' /etc/sysconfig/network echo '192.168.220.132 node1.wyb.com node1' >> /etc/hosts echo '192.168.220.133 node2.wyb.com node2' >> /etc/hosts
時間同步:框架
# node1 node2 ntpdate asia.pool.ntp.org echo '*/3 * * * * /usr/sbin/ntpdate asia.pool.ntp.org &> /dev/null' >> /var/spool/cron/root
2).安裝
dom
[root@node1 coorosync]# ls cluster-glue-1.0.11-3.1.x86_64.rpm corosynclib-1.4.7-1.el6.x86_64.rpm pacemaker-1.1.9-2.1.x86_64.rpm pacemaker-libs-1.1.9-2.1.x86_64.rpm cluster-glue-libs-1.0.11-3.1.x86_64.rpm crmsh-2.1-1.6.x86_64.rpm pacemaker-cli-1.1.9-2.1.x86_64.rpm pssh-2.3.1-5.el6.noarch.rpm corosync-1.4.7-1.el6.x86_64.rpm libqb0-0.14.4-1.1.x86_64.rpm pacemaker-cluster-libs-1.1.9-2.1.x86_64.rpm resource-agents-3.9.5-3.1.x86_64.rpm [root@node1 coorosync]# yum --nogpgcheck localinstall *.rpm
3).配置ssh
主配置文件:
ide
[root@node1 coorosync]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf [root@node1 coorosync]# grep -vE "^([[:space:]]*#)|^$" /etc/corosync/corosync.conf compatibility: whitetank #表示是否支持0.8以前的版本 totem { #圖騰,這是用來定義集羣中各節點中是怎麼通訊的 version: 2 #各節點互相通訊的協議的版本 secauth: on #各節點間通訊是否須要認證 threads: 0 #使用多少線程進行加密和發送多播信息 interface { ringnumber: 0 #環號碼,避免消息環路產生 bindnetaddr: 192.168.220.0 #綁定的網絡地址 mcastaddr: 239.255.1.1 #多播地址 mcastport: 5405 #多播端口 ttl: 1 } } logging { #日誌相關 fileline: off to_stderr: no to_logfile: yes logfile: /var/log/cluster/corosync.log to_syslog: no debug: off timestamp: on logger_subsys { subsys: AMF debug: off } } service { #定義啓動corosync時啓動pacemaker ver: 0 name: pacemaker } aisexec { #定義以哪一個用戶和組啓動corosync user: root group: root }
生成認證文件並複製配置文件到node2上:
[root@node1 coorosync]# mv /dev/random{,.bak} #若是不替換random,可能會由 [root@node1 coorosync]# ln -sv /dev/urandom /dev/random 於熵池不足而致使生成認證文件慢 [root@node1 coorosync]# corosync-keygen [root@node1 coorosync]#cd /etc/corosync [root@node1 coorosync]# scp authkey corosync.conf node2:/etc/corosync/
4).啓動corosync
#node1 [root@node1 ~]# service corosync start #查看corosync引擎是否正常啓動: [root@node1 ~]# grep -e "Corosync Cluster Engine" -e "configuration file" /var/log/cluster/corosync.log Sep 16 21:46:30 corosync [MAIN ] Corosync Cluster Engine ('1.4.7'): started and ready to provide service. Sep 16 21:46:30 corosync [MAIN ] Successfully read main configuration file '/etc/corosync/corosync.conf'. #查看初始化成員節點通知是否正常發出: [root@node1 ~]# grep TOTEM /var/log/cluster/corosync.log Sep 16 21:46:30 corosync [TOTEM ] Initializing transport (UDP/IP Multicast). Sep 16 21:46:30 corosync [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0). Sep 16 21:46:30 corosync [TOTEM ] The network interface [192.168.202.132] is now up. Sep 16 21:46:30 corosync [TOTEM ] A processor joined or left the membership and a new membership was formed. #檢查啓動過程當中是否有錯誤產生: [root@node1 ~]# grep ERROR: /var/log/cluster/corosync.log | grep -v unpack_resources #查看pacemaker是否正常啓動: [root@node1 ~]# grep pcmk_startup /var/log/cluster/corosync.log Sep 16 21:46:30 corosync [pcmk ] info: pcmk_startup: CRM: Initialized Sep 16 21:46:30 corosync [pcmk ] Logging: Initialized pcmk_startup Sep 16 21:46:30 corosync [pcmk ] info: pcmk_startup: Maximum core file size is: 4294967295 Sep 16 21:46:30 corosync [pcmk ] info: pcmk_startup: Service: 9 Sep 16 21:46:30 corosync [pcmk ] info: pcmk_startup: Local hostname: node1.wyb.com #若是上面命令執行均沒有問題,接着能夠執行以下命令啓動node2上的corosync #注意:啓動node2須要在node1上使用以下命令進行,不要在node2節點上直接啓動 [root@node1 ~]# ssh node2 'service corosync start' #使用以下命令查看集羣節點的啓動狀態: [root@node1 ~]# crm status Last updated: Wed Sep 30 22:16:09 2015 Last change: Thu Sep 17 16:58:00 2015 via crm_attribute on node1.wyb.com Stack: classic openais (with plugin) Current DC: node1.wyb.com - partition with quorum Version: 1.1.9-2.1-2db99f1 2 Nodes configured, 2 expected votes 0 Resources configured. Online: [ node1.wyb.com node2.wyb.com ]
安裝問題:在安裝corosync+pacemaker時,經過yum安裝CentOS6.5自帶的pacemaker-1.1.12+corosync-1.4.7,啓動corosync後,pacemaker的cib進程一直崩潰致使集羣不成功,換成redhat6.4系統配置centos源安裝出現一樣問題,換電腦以後同樣出現一樣問題,最後經過網絡(http://rpm.pbone.net)本身下載不一樣版本的rpm安裝包,安裝成功。
3.drbd安裝和配置
請參考上一篇博客:http://wangyongbin.blog.51cto.com/8964308/1696570
參考資料:
openais集羣分析:http://blog.sina.com.cn/s/blog_7695e9f40100pcnz.html
linux高可用集羣詳解:http://blog.csdn.net/flcandclf/article/details/14520501
CentOS 6.5 Corosync + pacemaker實現httpd服務的高可用:http://tanxw.blog.51cto.com/4309543/1401399/