网上查询的Heartbeat最简单的安装方式就是使用yum安装,就是直接先下载一个epel源,然后yum install -y heartbeat
但是我在Centos 7.6 上这个方法却行不通,说找不到heartbeat这个包。尽管我换了很多个epel源,结果还是一样的,十分无奈。
后来我打算直接手动安装rpm包得了,可是heartbeat的rpm十分难找,不过还是找到了。但是它的安装可以说是异常艰难,因为依赖超多。有兴趣的人可以试试,下载地址如下:
wget ftp://ftp.ntua.gr/pub/linux/fedora-epel/6/x86_64/Packages/h/heartbeat-3.0.4-2.el6.x86_64.rpm
wget ftp://ftp.ntua.gr/pub/linux/fedora-epel/6/x86_64/Packages/h/heartbeat-libs-3.0.4-2.el6.x86_64.rpm
所以后来我直接选择了源码安装,虽然也有一点点麻烦,但是在没有yum源的情况已经是最快的方式了。
为了节省时间,方便操作,我直接将安装方式写成了脚本,直接运行即可。
适用系统 Centos7.6
不过在这里我也将需要用到的源码下载地址告诉大家,
源码包下载地址:
wget https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/Heartbeat-3.0.6.tar.gz #heartbeat 下载
wget https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/Cluster-Glue-1.0.12.tar.gz #依赖下载
wget https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/resource-agents-3.9.6.tar.gz #依赖下载
#!/usr/bin/bash
set -u
dir=/tmp/heartbeat
function prepare {
dir=/tmp/heartbeat
[ -d $dir ]|| mkdir $dir
url=https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/Cluster-Glue-1.0.12.tar.gz
wget -O $dir/Cluster-Glue-1.0.12.tar.gz $url
url=https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/Heartbeat-3.0.6.tar.gz
wget -O $dir/Heartbeat-3.0.6.tar.gz $url
url=https://gitee.com/hcak-wu/Heartbeat_source_install/raw/master/resource-agents-3.9.6.tar.gz
wget -O $dir/resource-agents-3.9.6.tar.gz $url
cd $dir
tar xf Cluster-Glue-1.0.12.tar.gz
tar xf Heartbeat-3.0.6.tar.gz
tar xf resource-agents-3.9.6.tar.gz
yum install -y gcc gcc-c++ autoconf automake libtool glib2-devel libxml2-develbzip2-devel \
e2fsprogs-devel libxslt-devel libtool-ltdl-devel make wget docbook-dtds docbook-style-xsl bzip2-devel asciidoc libuuid-devel
groupadd haclient
useradd -g haclient hacluster -M -s /sbin/nologin
}
prepare
cd $dir/Cluster-Glue-1.0.12
./autogen.sh
./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64
make -j4 && make install
[ "$?" -ne 0 ]&& echo "Cluster-Glue 安装出错!!"&& exit 1
cd $dir/resource-agents-3.9.6
./autogen.sh
./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64 CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64
ln -s /usr/local/heartbeat/lib64/* /lib64/
make -j4 && make install
[ "$?" -ne 0 ]&& echo "resource-agents-3.9.6 安装出错!!"&& exit 1
cd $dir/Heartbeat-3.0.6
./bootstrap
./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64
sed -i "$ d" /usr/local/heartbeat/include/heartbeat/glue_config.h
make -j4 && make install
[ "$?" -ne 0 ]&& echo "Heartbeat-3.0.6 安装出错 出错!!"&& exit 1
cp doc/ha.cf doc/authkeys doc/haresources /etc/heartbeat/ha.d/
chmod 600 /etc/heartbeat/ha.d/authkeys
echo "----------------------------------"
echo "安装完成"
ls -l /etc/heartbeat/ha.d/
ls -l /etc/init.d/heartbeat
/tmp/heartbeat/