Heartbeat
Heartbeat
心跳信息傳遞:
UDP Unicast
UDP Multicast
UDP broadcast
Serial Cable
組播地址用于標(biāo)識(shí)一個(gè)IP組播域。IANA(internet assigned number authority)把D類地址空間分配給IP組播;其范圍是從224.0.0.0至239.255.255.255。
永久組播地址:224.0.0.0——224.0.0.255;
臨時(shí)組播地址:224.0.1.0——238.255.255.255;
本地組播地址:239.0.0.0——239.255.255.255,僅在特定的本地范圍內(nèi)有效;
配置HA集群前提:
1、時(shí)間必須同步;
建議使用ntp協(xié)議進(jìn)行;
2、節(jié)點(diǎn)之間必須要通過(guò)主機(jī)名互相通信;
建議使用hosts文件;
通信中使用的名字必須與其節(jié)點(diǎn)為上“uname -n”命令展示出的名字保持一致;
3、需要仲裁設(shè)備;
4、彼此root用戶能基于ssh密鑰方式進(jìn)行通信;
注意:定義為集群服務(wù)中的任意資源都不能開(kāi)機(jī)自動(dòng)啟動(dòng),因?yàn)樗鼈儗⒂蒀RM啟動(dòng);
資源準(zhǔn)備:
1、選定vip;
2、httpd:
安裝好程序;
配置好httpd,本地測(cè)試完成;
關(guān)閉服務(wù),并確保開(kāi)機(jī)不會(huì)自動(dòng)啟動(dòng);
3、shared storage:NFS
安裝方法:
1、# yum install ?net-snmp-libs ?libnet ?PyXML ?perl-Time-Date
2、# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm?
配置文件:
ha.cf: heartbeat的主配置文件;
authkeys:集群信息加密算法及密鑰;
haresources: heartbeat v1的CRM配置接口;
如何配置:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
首先需要說(shuō)明的配置:
172.16.27.1 ?node1.stu27.com node1
172.16.27.2 ?node2.stu27.com node2
在配置集群時(shí),vip地址為:172.16.27.27
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
[node1 ]#yum install net-snmp-libs libnet PyXML -y
? #這里需要把heartbeat相關(guān)RPM包下載下來(lái),一般下載到家目錄中 ??
[node1 ]#rpm -ivh ?heartbeat-2.1.4-12.el6.x86_64.rpm ? heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-gui-2.1.4-12.el6.x86_64.rpm ?heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
? #①heartbeat ②heartbeat-pils ③heartbeat-stonith ?④heartbeat-gui ? ? ?
[node1 ]#ntpdate 172.16.0.1
[node1 ]#crontab -e
*/3 * * * * /usr/sbin/ntpdate 172.16.0.1 &> /dev/null
[node1 ]#ssh-keygen -P '' -t rsa
[node1 ]#ssh-copy-id root@node2
[node1 ]#vim /etc/hosts
172.16.27.1 ?node1.stu27.com node1
172.16.27.2 ?node2.stu27.com node2
[node1 ]#scp /etc/hosts ?node2:/etc/
? ? ? ? ? ? ? ? ?
[node2 ]#ntpdate 172.16.0.1
[node2 ]#crontab -e
*/3 * * * * /usr/sbin/ntpdate 172.16.0.1 &> /dev/null
[node2 ]#yum install net-snmp-libs libnet PyXML -y
[node2 ]#rpm -ivh ?heartbeat-2.1.4-12.el6.x86_64.rpm ? heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-gui-2.1.4-12.el6.x86_64.rpm ?heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
? ? ? ? ? ? ? ? ??
[node1 ]#cd /usr/share/doc/heartbeat-2.1.4/
[node1 ]#cp ha.cf haresources authkeys ?/etc/ha.d/
[node1 ]#cd /etc/ha.d
[node1 ]#vim ha.cf
mcast eth0 229.71.30.27 694 1 0 ?//組播地址
ping ? ?172.16.0.1 ? ? ? //ping node為網(wǎng)關(guān)
node ? ?node1.stu27.com ?//HA集群節(jié)點(diǎn)
node ? ?node2.stu27.com ?//HA集群節(jié)點(diǎn)
compression ? ? bz2 ? //啟用心跳信息傳遞時(shí)信息壓縮
compression_threshold 2
[node1 ]#vim /etc/rsyslog.conf
localo.* ? ? ? ? ? ?/var/log/halog.log
[node1 ]#service rsyslog restart
[node1 ]scp /etc/rsyslog.conf node2:/etc/
[node2 ]#service rsyslog restart
[node1 ]#vim authkeys
auth 1
1 sha1 ?dwecrhtvhthbbh
[node1 ]#chmod 400 authkeys
[node1 ]#cd /usr/lib64/heartbeat
[node1 ]#./ha_propagate ? ? ?會(huì)把/etc/ha.d/下面的ha.cf、authkeys文件傳遞給node2 ?
[node1 ]#/etc/init.d/heartbeat start; ssh node2 ?'/etc/init.d/heartbeat start'
[node1 ]#cd /etc/ha.d/
[node1 ]#scp haresources ?node2:/etc/ha.d/
[node1 ]#/etc/init.d/heartbeat start; ssh node2 '/etc/init.d/heartbeat start'
[node1 ]#vim haresources
node2.magedu.com IPaddr2::172.16.100.27(vip)/16/eth0/172.16.255.255(廣播地址) ? httpd
? ?172.16.100.27(vip)/16(掩碼)/eth0(vip所在網(wǎng)卡)/172.16.255.255(廣播地址) ?httpd(啟動(dòng)的服務(wù)) ? ??
[node1 ]#scp haresources node2:/etc/ha.d/
[node1 ]#/etc/init.d/heartbeat restart; ssh node2 ?'/etc/init.d/heartbeat restart'
[node1 ]#vim /var/www/html/index.html
<h1>node1</h1>
[node2 ]#vim /var/www/html/index.html
<h1>node2</h1>
? ? ? ? ? ? ? ?
在瀏覽器輸入:http://172.16.27.27
然后會(huì)看到: node2
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ??
[node2 ]#cd /usr/lib64/heartbeat
[node2 ]#./hb_standby ? ??
? 把vip讓給node1,此時(shí)刷新瀏覽器發(fā)現(xiàn):node1
[node1 ]#/etc/init.d/heartbeat stop; ssh node2 '/etc/init.d/heartbeat stop'
[node1 ]#cd /etc/ha.d/
[node1 ]#vim ha.cf
crm on ??
?#底部添加,啟用 內(nèi)置的v2版的crm的管理功能,此時(shí)/etc/ha.d/haresources文件已經(jīng)沒(méi)用處了
? ? ??
[node2 ]#cd /etc/ha.d/
[node2 ]#vim ha.cf
crm on
? ? ??
[node1 ]#ss -tnl
5560 端口顯示mgmtd ?heartbeat內(nèi)部的資源管理器所監(jiān)聽(tīng)的進(jìn)程
? ? ?
[node2 ]#crm_mon
顯示集群狀態(tài)
DC:指派的協(xié)調(diào)員(從集群中選取)做決策 dc把配置同步到素有集群主機(jī)上?
? ? ??
[node2 ]#crm_sh
config配置資源
list
exit ?退出
? ? ??
[node1 ]#tail /etc/passwd
hacluster
在哪個(gè)節(jié)點(diǎn)上登陸圖形化界面使用hacluster 添加密碼
[node1 ]#echo 111111 |passwd --stdin hacluster
? ? ? ?
[node1 ]#hb_gui &
此時(shí)使用xshell可能打不開(kāi)圖形化設(shè)置界面,進(jìn)入虛擬機(jī)?
? ? ? ??
[node1 ]#startx ?
進(jìn)入linux圖形界面
打開(kāi)終端
如果,在別的節(jié)點(diǎn)打開(kāi)的話
>ssh -X ?root@172.16.27.1 ? 然后輸入密碼即可
? ? ? ??
[node1 ]#hb_gui &
進(jìn)入圖形設(shè)置界面
轉(zhuǎn)載于:https://blog.51cto.com/9910189/1611237
總結(jié)
- 上一篇: 命令模式--command模式
- 下一篇: QuartusII联合modelsim仿