一,硬件環境
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
#vi /etc/hosts
node1的hosts內容如下:
127.0.0.1 localhost.localdomain localhost
192.168.0.52 0_52 gc01
10.0.0.72 gc01
10.0.0.74 gc02
192.168.0.54 0_54
node2的hosts內容如下:
-
127.0.0.1 localhost.localdomain localhost
-
192.168.0.54 0_54 gc02
-
10.0.0.74 gc02
-
10.0.0.72 gc01
-
192.168.0.52 0_52
#cat /etc/host.conf
order hosts,bind
三,安裝 Heartbeat(主從都需安裝)
#yum install -y libnet
# yum install -y heartbeat-devel
#yum install -y heartbeat-ldirectord
#yum install -y heartbeat
#cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
四,配置心跳的加密方式:authkeys (主從相同)
#vi /etc/ha.d/authkeys
auth 1
1 crc
五,配置心跳的監控(主從相同)
#vi /etc/ha.d/haresources
0_52 192.168.10.200 httpd
六,配置心跳的配置文件:ha.cf (主從相同)
#vi /etc/ha.d/ha.cf
logfile /var/log/ha_log/ha-log.log
bcast eth1
keepalive 2
warntime 10
deadtime 30
initdead 120
hopfudge 1
udpport 694
auto_failback on
node 0_52
node 0_54 ##節點2
七,防火牆設置七,防火牆設置
#vi /etc/sysconfig/iptables
#加入以下內容
-A RH-Firewall-1-INPUT -p udp -m udp --dport 694 -d 10.0.0.72 -j ACCEPT
#/etc/init.d/iptables restart
八、
#chkconfig heartheat on
#chkconfig httpd off