,硬件环境

    

 eth0: 对外IP           

        

 eth1: 对内IP(HA专用)           

        

 两台主机的eth1使用双机对联线直接连接。           

        

 node1: 主机名:0_52 ( gc01 )           

        

 eth0: 192.168.0.52 //对外IP地址           

        

 eth1: 10.0.0.72 //HA心跳使用地址           

        

 node2: 主机名:0_54 ( gc02 )           

        

 eth0: 192.168.0.54 //对外IP地址           

        

 eth1: 10.0.0.74 //HA心跳使用地址

 

,检查主机的几个配置文件

 

/etc/hosts            

       

/etc/host.conf           

       

/etc/resolv.conf           

       

/etc/sysconfig/network           

       

/etc/sysconfig/network-scripts/ifcfg-eth0           

       

/etc/sysconfig/network-scripts/ifcfg-eth1           

       

/etc/nsswitch.conf 

 
  
  1. #vi /etc/hosts 

node1hosts内容如下:

 

 

 
  
  1. 127.0.0.1 localhost.localdomain localhost 

  2. 192.168.0.52 0_52 gc01 

  3. 10.0.0.72 gc01 

  4. 10.0.0.74 gc02 

  5. 192.168.0.54 0_54 

node2hosts内容如下:

 

  1. 127.0.0.1 localhost.localdomain localhost  

  2. 192.168.0.54 0_54 gc02 

  3. 10.0.0.74 gc02  

  4. 10.0.0.72 gc01  

  5. 192.168.0.52 0_52 

 

 

 
  
  1. #cat /etc/host.conf 

  2. order hosts,bind 

 

 

 

,安装 Heartbeat(主从都需安装)

 
  
  1. #yum install -y libnet  

  2. # yum install -y heartbeat-devel  

  3. #yum install -y heartbeat-ldirectord   

  4. #yum install -y heartbeat  

  5.   

  6. #cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/           

  7. #cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/           

  8. #cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/ 

 

 

,配置心跳的加密方式:authkeys (主从相同)

 
  
  1. #vi /etc/ha.d/authkeys 

  2. auth 1 

  3. 1 crc 

 

 

 

,配置心跳的监控(主从相同)

 
  
  1. #vi /etc/ha.d/haresources             

  2.          

  3. 0_52  192.168.10.200 httpd  

 

 

,配置心跳的配置文件:ha.cf (主从相同)

 

 
  
  1. #vi /etc/ha.d/ha.cf             

  2.  

  3. logfile /var/log/ha_log/ha-log.log  

  4.          

  5. bcast eth1  

  6. keepalive 2  

  7.  

  8. warntime 10  

  9.  

  10. deadtime 30  

  11.  

  12. initdead 120  

  13.  

  14. hopfudge 1  

  15.  

  16. udpport 694  

  17.  

  18. auto_failback on   

  19.  

  20. node 0_52 

  21.  

  22. node 0_54 ##节点2

 

 

 

 

,防火墙设置七,防火墙设置

 
  
  1. #vi /etc/sysconfig/iptables 

 
 
  
  1. #加入以下内容             

  2.          

  3. -A RH-Firewall-1-INPUT -p udp -m udp --dport 694 -d 10.0.0.72 -j ACCEPT 

 
  
  1. #/etc/init.d/iptables restart 

 

 

八、

 
  
  1. #chkconfig heartheat on 

  2. #chkconfig httpd off