手机版
你好,游客 登录 注册
背景:
阅读新闻

Heartbeat + http&LVS 高可用实例

[日期:2012-08-04] 来源:Linux社区  作者:peaceweb [字体:大 中 小]
Heartbeat + http 高可用
一,试验拓扑:
二,两节点基本配置:
(这里我先配置的node1,node2也是一样的)
1、修改主机名
# vim /etc/sysconfig/network
HOSTNAME=node1
2、修改hosts,这里没做DNS所以写hosts
# vim /etc/hosts
192.168.80.141  node1
192.168.80.138  node2
3、配置http服务相关信息
# yum -y install httpd
# echo "node1" > /var/www/html/index.html
# chkconfig httpd off (这里设置成不启动,因为要使用heartbeat启动)
4、配置ssh双机互信
# ssh-keygen -t rsa
# ssh-copy-id -i .ssh/id_rsa.pub  root@node1
注:需要注意2节点的时间不要相差太多

三,安装heartbeat
这里使用的rpm安装的:
  1. # yum -y --nogpgcheck localinstall heartbeat-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm  
  2.  
  3. # cd /usr/share/doc/heartbeat-2.1.4/   
  4. # cp ha.cf authkeys haresources /etc/ha.d/  
  5. # chmod 600 authkeys  
  6.  
  7. # vim authkeys (添加如下内容md5后面的是个加密的随机数通过dd if=/dev/urandom count=512 bs=1 | md5sum最后一行产生的)  
  8. auth 1  
  9. 1 md5 3c41810e230a997444836b164ddb7978  
  10.  
  11. # egrep -v "^#|^$" /etc/ha.d/ha.cf   
  12. logfacility local0  
  13. keepalive 2     心跳检查时间  
  14. deadtime 30     防止分裂  
  15. bcast eth1  # Linux   指定网卡  
  16. auto_failback on    是重新抢回资源  
  17. node node1     节点名称与hosts对称  
  18. node node2  
  19. ping 192.168.80.1   指定仲裁  
  20. compression bz2    指定压缩  
  21. compression_threshold 2   2K以上压缩  
  22.  
  23. # vim /etc/ha.d/haresources   最后添加  
  24. node1  192.168.80.100/24/eth1/192.168.80.255 httpd  
  25.  
  26. # scp -p  authkeys ha.cf haresources node2:/etc/ha.d  
  27. # service heartbeat start  
  28. # ssh node2 '/etc/rc.d/init.d/heartbeat start'  
  29.  
下面访问下: 【Linux公社 http://www.linuxidc.com 】
 
  
 

之后可以通过执行cd /usr/share/heartbeat/下的
# ./hb_standby
2012/08/03_00:41:33 Going standby [all].
进行手动切换,在访问下,而且也可以可能到80的进程
linux
相关资讯       heartbeat  LVS  高可用 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款