http://8858975.blog.51cto.com/8848975/1786935

hamaster 192.168.8.106

haslave 192.168.8.119

vip 192.168.8.120

gateway 192.168.8.1

cat /etc/hosts
127.0.0.1 localhost
192.168.8.106 hamaster
192.168.8.119 haslave


  1. 依赖包安装

yum -y install autoconf automake gcc-c++ asciidoc libxslt-devel libtool libtool-ltdl-devel libxml2 libxml2-devel bzip2-devel glib2-devel mercurial *openssl* net-snmp OpenIPMI flex bison e2fsprogs-devel

2.源码编译安装

下载地址:http://linux-ha.org/wiki/Download

#--Heartbeat 3.0.6:
wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
#Cluster Glue 1.0.12:
wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
#--Resource Agents 3.9.6: 
wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz

3.用户及用户组配置

groupadd haclient
useradd -g haclient hacluster

4.编译Cluster Glue

tar -jxvf cluster-clue-1.0.12.tar.bz2 
cd Reusable-Cluster-Components-glue--0a7add1d9996/
./autogen.sh
# 注:32位系统 LIBS='/lib/libuuid.so.1'
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
make && make install

卸载

make uninstall && make clean

5.编译Heartbeat

tar -zxvf resource-agents-3.9.6.tar.gz
cd resource-agents-3.9.6
./autogen.sh
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
make && make install

卸载

make uninstall && make clean

6.编译Heartbeat

tar -jxvf heartbeat-3.0.6.tar.bz2
cd Heartbeat-3-0-958e11be8686/
./bootstrap
export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib"
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
make && make install

卸载

make uninstall && make clean

heartbeat路径检查

whereis heartbeat

7.heartbeat配置

cp doc/{ha.cf,haresources,authkeys} /etc/ha.d/

cat /etc/ha.d/authkeys | grep -v ^# | grep -v ^$
auth 3
3 md5 Hello! 

cat /etc/ha.d/ha.cf | grep -v ^# | grep -v ^$
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 90
udpport 694
#hamaster配置
ucast eth0 192.168.8.119
#haslave配置
ucast eth0 192.168.8.106
auto_failback on
node hamaster
node haslave
ping 192.168.8.1
respawn hacluster /usr/libexec/heartbeat/ipfail
apiauth ipfail gid=hacluster uid=hacluster

cat /etc/ha.d/haresources | grep -v ^# | grep -v ^$
hamaster 192.168.8.120/24/eno16777984:0 nginx

8.启动heartbeat并验证高可用