Heartbeat
Heartbeat
心跳信息傳遞:
UDP Unicast
UDP Multicast
UDP broadcast
Serial Cable
組播地址用于標識一個IP組播域。IANA(internet assigned number authority)把D類地址空間分配給IP組播;其范圍是從224.0.0.0至239.255.255.255。
永久組播地址:224.0.0.0——224.0.0.255;
臨時組播地址:224.0.1.0——238.255.255.255;
本地組播地址:239.0.0.0——239.255.255.255,僅在特定的本地范圍內有效;
配置HA集群前提:
1、時間必須同步;
建議使用ntp協議進行;
2、節點之間必須要通過主機名互相通信;
建議使用hosts文件;
通信中使用的名字必須與其節點為上“uname -n”命令展示出的名字保持一致;
3、需要仲裁設備;
4、彼此root用戶能基于ssh密鑰方式進行通信;
注意:定義為集群服務中的任意資源都不能開機自動啟動,因為它們將由CRM啟動;
資源準備:
1、選定vip;
2、httpd:
安裝好程序;
配置好httpd,本地測試完成;
關閉服務,并確保開機不會自動啟動;
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配置接口;
如何配置:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
首先需要說明的配置:
172.16.27.1 ?node1.stu27.com node1
172.16.27.2 ?node2.stu27.com node2
在配置集群時,vip地址為:172.16.27.27
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
[node1 ]#yum install net-snmp-libs libnet PyXML -y
? #這里需要把heartbeat相關RPM包下載下來,一般下載到家目錄中 ??
[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為網關
node ? ?node1.stu27.com ?//HA集群節點
node ? ?node2.stu27.com ?//HA集群節點
compression ? ? bz2 ? //啟用心跳信息傳遞時信息壓縮
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 ? ? ?會把/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所在網卡)/172.16.255.255(廣播地址) ?httpd(啟動的服務) ? ??
[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
然后會看到: node2
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ??
[node2 ]#cd /usr/lib64/heartbeat
[node2 ]#./hb_standby ? ??
? 把vip讓給node1,此時刷新瀏覽器發現: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 ??
?#底部添加,啟用 內置的v2版的crm的管理功能,此時/etc/ha.d/haresources文件已經沒用處了
? ? ??
[node2 ]#cd /etc/ha.d/
[node2 ]#vim ha.cf
crm on
? ? ??
[node1 ]#ss -tnl
5560 端口顯示mgmtd ?heartbeat內部的資源管理器所監聽的進程
? ? ?
[node2 ]#crm_mon
顯示集群狀態
DC:指派的協調員(從集群中選取)做決策 dc把配置同步到素有集群主機上?
? ? ??
[node2 ]#crm_sh
config配置資源
list
exit ?退出
? ? ??
[node1 ]#tail /etc/passwd
hacluster
在哪個節點上登陸圖形化界面使用hacluster 添加密碼
[node1 ]#echo 111111 |passwd --stdin hacluster
? ? ? ?
[node1 ]#hb_gui &
此時使用xshell可能打不開圖形化設置界面,進入虛擬機?
? ? ? ??
[node1 ]#startx ?
進入linux圖形界面
打開終端
如果,在別的節點打開的話
>ssh -X ?root@172.16.27.1 ? 然后輸入密碼即可
? ? ? ??
[node1 ]#hb_gui &
進入圖形設置界面
轉載于:https://blog.51cto.com/9910189/1611237
總結
- 上一篇: 命令模式--command模式
- 下一篇: QuartusII联合modelsim仿