centos7上源码编译安装Heartbeat
最近有遇到改造一款第三方软件安装包,安装路径统一到/opt/路径下。原来是直接使用yum安装的,本文则介绍如何采用源码编译方式在centos7上安装Heartbeat。
一、认识什么是Heartbeat
Heartbeat 项目是 Linux-HA 工程的一个组成部分,它实现了一个高可用集群系统。心跳服务和集群通信是高可用集群的两个关键组件,在 Heartbeat 项目里,由 heartbeat 模块实现了这两个功能。
原理: heartbeat最核心的包括两个部分,心跳监测部分和资源接管部分,心跳监测可以通过网络链路和串口进行,而且支持冗 余链路,它们之间相互发送报文来告诉对方自己当前的状态,如果在指定的时间内未收到对方发送的报文,那么就认为对方失效,这时需启动资源接管模块来接管运 行在对方主机上的资源或者服务。
Heartbeat的官方地址:http://www.linux-ha.org/wiki/Download
二、编译安装Hearttbeat
1、准备编译环境
服务器:centos7安装依赖包:yum install -y gcc gcc-c++ autoconf automake libnet libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel docbook-dtds docboot-style-xsl asciidoc创建用户和用户组:
groupadd haclient #创建组haclient
useradd -g haclient hacluster -M -s /sbin/nologin #创建用户hacluster
2、下载相关安装包
源码编译安装Heartbeat需要下载的安装包文件有(需要注意依次按照顺序安装):
- Cluster Glue 1.0.12: http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
- Resource Agents 3.9.6: https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz
- Heartbeat 3.0.6: http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
3、编译cluster-glue
#解压安装包
tar -xf 0a7add1d9996.tar.bz2
#进入解压后的目录
cd Reusable-Cluster-Components-glue--0a7add1d9996/
#执行脚本
./autogen.sh
#执行configure
./configure --prefix=/opt/heartbeat/ --sysconfdir=/opt/heartbeat/etc libdir=/opt/heartbeat/lib64 LIBS='/lib64/libuuid.so.1'
#编译并安装
make && make install
4、编译resource agents
resource agents就是各种资源的ocf脚本,这些脚本被LRM调用从而实现各种资源的启动,停止,监控等
#解压安装包
tar xf resource-agents-3.9.6.tar.gz
#进入解压后的目录
cd resource-agents-3.9.6/
#执行脚本
./autogen.sh
#执行configure
./configure --prefix=/opt/heartbeat/ --sysconfdir=/opt/heartbeat/etc libdir=/opt/heartbeat/lib64 CFLAGS=-I/opt/heartbeat/include LDFLAGS=-I/opt/heartbeat/lib64 LIBS='/lib64/libuuid.so.1'
#编译并安装
make && make install
5、编译安装heartbeat
#解压安装包
tar -jxvf 958e11be8686.tar.bz2
#进入解压目录
cd Heartbeat-3-0-958e11be8686
#执行脚本
./bootstrap
#执行configure
./configure --prefix=/opt/heartbeat --sysconfdir=/opt/heartbeat/etc CFLAGS=-I/opt/heartbeat/include LDFLAGS=-L/opt/heartbeat/lib64 LIBS='/lib64/libuuid.so.1'
#创建库文件链接
ln -s /opt/heartbeat/lib64/\* /lib64
#修改源码文件,否则会make报错
vim /opt/heartbeat/include/heartbeat/glue_config.h/*define HA_HBCONF_DIR “/usr/local/heartbeat/etc/ha.d/”*/ #把这一行用/**/注释掉或者删除掉
#编译并安装
make && make install
6、相关文件复制
#复制配置源码中的配置文件到配置目录
cp -rf doc/{ha.cf,haresources,authkeys} /opt/heartbeat/etc/ha.d/
mkdir -p /opt/heartbeat/usr/lib
cp -rf /usr/lib/ocf /opt/heartbeat/usr/lib/
#修改认证文件及属性
chmod 600 authkeys
#修改配置文件中软件启动路径
sed -i 's#/usr/lib/ocf#/opt/heartbeat/usr/lib/ocf#g' /opt/heartbeat/etc/ha.d/shellfuncs
sed -i 's#/usr/lib/ocf#/opt/heartbeat/usr/lib/ocf#g' /opt/heartbeat/etc/ha.d/resource.d/hto-mapfuncs
sed -i 's#/usr/lib/ocf#/opt/heartbeat/usr/lib/ocf#g' /opt/heartbeat/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs
7、修改配置文件,开启Heartbeat服务
编辑配置文件ha.cf(/opt/heartbeat/etc/ha.d/ha.cf)
#调试日志
debugfile /var/log/ha-debug
#日志文件
logfile /var/log/ha-log
#表示使用系统日志
logfacility local0
#心跳的时间间隔,默认单位为秒
keepalive 1
#超出该时间间隔未收到对方节点的心跳,则判定对方死亡
deadtime 30
#超出该时间间隔未收到对方节点的心跳,则发出警告记录到日志中
warntime 10
#在某系统上,系统启动或重启之后需要经过一段时间网络才能正常工作,该选项用于解决这种情况产生的时间间隔,取值至少为deadtime的2倍
initdead 120
#设置广播通信使用的端口,694为默认使用的端口号
udpport 694
#传播心跳的广播网卡信息
bcast eth0
#设置对方机器心跳检测的IP
ucast eth0 192.168.17.10
#在该选项设为on的情况下,一旦主节点恢复运行,则自动获取资源并取代从节点
auto_failback off
#配置主从的节点信息(主机名)
node localhost
#如果ping不通该地址,就认为当前断网,需要转移vip
ping 127.0.0.1
#指定与heartbeat一同启动和关闭的进程,该进程被自动监视,遇到故障则重新启动。最常用的进程是ipfail,该进程用于检测和处理网络故障,需要配合ping语句指定的ping、node来检测网络连接。如果你的系统是64bit,请注意该文件的路径
respawn hacluster /opt/heartbeat/libexec/heartbeat/ipfail
#指定用户和组
apiauth ipfail gid=haclient uid=hacluster
编辑验证密钥authkeys(/opt/heartbeat/etc/ha.d/authkeys)
#
# Authentication file. Must be mode 600
#
#
# Must have exactly one auth directive at the front.
# auth send authentication using this method-id
#
# Then, list the method and key that go with that method-id
#
# Available methods: crc sha1, md5. Crc doesn't need/want a key.
#
# You normally only have one authentication method-id listed in this file
#
# Put more than one to make a smooth transition when changing auth
# methods and/or keys.
#
#
# sha1 is believed to be the "best", md5 next best. --->sha1是被认为是最好的 咱们用这个就是最好
#
# crc adds no security, except from packet corruption.
# Use only on physically secure networks.
#
auth 1
1 crc
2 sha1 HI!
3 md5 Hello!
编辑资源文件haresources(/opt/heartbeat/etc/ha.d/haresources)
该文件表示资源的管理 如果是主机 当主机启动后 自动加载该文件中配置的所有启动资源 资源脚本默认在 haresources同级目录下的resource.d目录下
#机器名 虚拟服务器IP 系统服务
localhost 192.168.17.10 mysqld
8、关闭防火墙并启动heartbeat服务
找到可执行文件heartbeat,输入:heartbeat start
三、常见问题及解决方法
1、/usr/bin/ld: cannot find -lplumb
解决方法:find / -name libplumb* ,找到对应的依赖库文件,拷贝到/usr/lib64下即可。
2、gmake[2]: a2x:命令未找到
解决方法:yum install asciidoc
3、安装resource-agents-3.9.6,报错 ln: 无法创建符号链接"/usr/lib/ocf/resource.d/heartbeat/.ocf-binaries": 文件已存在
解决方法:make uninstall,然后重新安装即可。
4、ERROR: Illegal directive [xxx] in /opt/heartbeat/etc/ha.d//ha.cf
解决方法:这种情况一般是配置文件ha.cf中配置有误,检查配置文件。
centos7上源码编译安装Heartbeat相关推荐
- CentOS7下源码编译安装MySQL5.6.4
CentOS7下源码编译安装MySQL5.6.4 写这篇博客的主要原因是:请看上一篇博客:CentOS7下更改MySQL5.6.4默认的数据存储位置.对,当初通过rpm安装的mysql5.6.4,一切 ...
- CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境
什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/Perl/Python组合成的动态Web应用程序和服务器,它是一组Web应用程序的基础 ...
- Centos7.5源码编译安装nodejs
官方文档:https://nodejs.org/zh-cn/download/releases/ 我安装的是 #1.把安装包上传到/usr/local/node #2.创建一个node文件夹 #3.解 ...
- centos6.8安装php7.3,CentOS7.6源码编译安装PHP 7.3.8
安装步骤 1. 使用wget命令下载源码安装包 wget https://www.php.net/distributions/php-7.3.8.tar.gz --no-check-certifica ...
- openvswitch2.8.1 centos7.4 源码编译安装
安装依赖 yum install gcc pkgconfig autoconf automake libtool git make python-devel openssl-devel kernel ...
- centos7 访问php页面显示源码_运维干货分享:centos7下源码编译安装php-7.1.5(脚本)...
PHP简介: PHP是一种创建动态交互性站点的强有力的服务器端脚本语言.PHP是目前动态网页开发中使用最为广泛的语言之一.PHP能运行在包括Windows.Linux等在内的绝大多数操作系统环境中. ...
- 7.1 pdo 宝塔面板php_运维干货分享:centos7下源码编译安装php-7.1.5(脚本)
PHP简介: PHP是一种创建动态交互性站点的强有力的服务器端脚本语言.PHP是目前动态网页开发中使用最为广泛的语言之一.PHP能运行在包括Windows.Linux等在内的绝大多数操作系统环境中. ...
- linux上源码编译安装mysql-5.6.28
在 linux 上编译安装 mysql-5.6.28.tar.gz http://www.mysql.com/ mysql下载地址: http://www.mysql.com/downloads/my ...
- centos7.8源码编译安装nginx1.17.10
http://nginx.org/download/ nginx安装包下载地址. 集成安装 yum -y install gcc gcc-c++ autoconf automake yum -y in ...
最新文章
- 编写spring应用
- C++中最好不要在构造函数和析构函数中调用虚函数!!!
- 验证url 地址是否是图片
- Go 语言编程 — go-swagger OpenAPI 工具
- LeetCode ZigZag Conversion
- python 数据结构包_Python Redistr包_程序模块 - PyPI - Python中文网
- html或原生js是单一对应绑定的,原生js数据绑定
- vxworks任务通信机制
- c++如何打印一维数组首地址_4.1 数组的定义
- Linux Ubuntu编译内核错误,安装ubuntu以后,编译kernel出错
- 解决 Command “python setup.py egg_info“ failed with error code 1 问题
- 通信线路工程验收规范 gb51171-2016_一级建造师市政涉及到的相关规范汇总
- Deep Convolutional Network Cascade for Facial Point Detection论文算法解析
- 基于Debian的Linux发行版安装深度音乐及其插件,支持ubunut16
- 【微信小程序项目】——十分钟开发网络API·天气查询小程序、天气查询,美观简约,简单易上手
- 攻破 JAVA NIO 技术壁垒( 下 ) 2017-09-02 ImportNew (点击上方公众号,可快速关注) 来源:朱小厮, blog.csdn.net/u013256816/articl
- OPC服务器软件介绍
- 下载安装webpack
- 自定义组件 QQ对话框
- c语言解密pdf,C语言设计-英文加密解密系统资料.pdf