1.概述

1.1 关于Heartbeat

Heartbeat是Linux-HA工程的组成部分,它实现了一个高可用集群系统。通过Heartbeat可以实现双机热备,以实现服务的持续性。

Heartbeat工作原理:Heartbeat最核心的包括两个部分,心跳监测部分和资源接管部分。心跳监测可以通过网络链路和串口进行,而且支持冗余链路,它们之间相互发送报文来告诉自己当前状态,如果在指定的时间未收到对方发送的报文,那么就认为对方死亡,这时启动资源接管模块来接管运行对方主机上的资源或者服务。

Heartbeat3和Heartbeat2的最大差别在于:3按照模块把原来2拆分成多个子项目,并且提供了一个cluster-glue组件,专门用于ResoureManger的管理。

即:Heartbeat+cluster-glue+resource-agent

1.2 本篇博客实践环境

本篇博客主要在共享存储上安装Heartbeat的主体软件部分,配置部分分别放置在各个需要配置Heartbeat的节点上。由于这种做法,会需要几个特殊的细节处理。

即:将Heartbeat的三类源码包安装在/opt上,然后在node11.node12上进行/etc/heartbeat配置

注:本篇博客参考:http://www.cnblogs.com/knitmesh/p/5439665.html

2. 部署基础环境

2.1 通过YUM安装依赖环境

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 

2.2 创建Heartbeat用户和组

注:这里采用了LDAP认证方式,在LDAP服务器上执行一下创建用户和组的操作,在其他节点上都能够认证该用户

groupadd haclient #创建组haclient
useradd -g haclient hacluster -M -s /sbin/nologin #创建用户hacluster

3. 编译安装

3.1下载源码包

Heartbeat的官方地址:http://www.linux-ha.org/wiki/Download

下载Cluster-Glue wget http://hg.linux-ha.org/glue/archive/glue-1.0.9.tar.bz2

下载Resource Agents wget https://github.com/ClusterLabs/resource-agents/tarball/v3.9.2

下载Heartbeat wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2

3.2 编译安装

3.2.1 编译cluster-glue

#解压
tar -jxvf glue-1.0.9.tar.bz2
#进入解压后的目录
cd Reusable-Cluster-Components-glue--glue-1.0.9
#执行脚本
./autogen.sh
#执行configure
./configure --prefix=/opt/heartbeat/ --sysconfdir=/etc/heartbeat libdir=/opt/heartbeat/lib64 LIBS='/lib64/libuuid.so.1'
#编译
make
#安装
make install

3.2.2 编译resource agents

resource agents就是各种资源的ocf脚本,这些脚本被LRM调用从而实现各种资源的启动,停止,监控等

#解压
tar -zxvf v3.9.2
#进入解压后的目录
cd ClusterLabs-resource-agents-b735277
#执行脚本
./autogen.sh
#执行configure
./configure --prefix=/opt/heartbeat/ --sysconfdir=/etc/heartbeat libdir=/opt/heartbeat/lib64 CFLAGS=-I/opt/heartbeat/include LDFLAGS=-I/opt/heartbeat/lib64 LIBS='/lib64/libuuid.so.1'
#编译
make
#安装
make install

3.2.3 编译安装heartbeat

#解压
tar -jxvf 958e11be8686.tar.bz2
#进入解压目录
cd Heartbeat-3-0-958e11be8686
#执行脚本
./bootstarp
#执行configure
./configure --prefix=/opt/heartbeat --sysconfdir=/etc/heartbeat 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,注释或者删除最后一行内容
vim lib/hbclient/Makefile,删掉-Werror字段
#编译
make
#安装
make install

4.相关文件复制

#复制配置源码中的配置文件到配置目录
cp doc/{ha.cf,haresource,authkeys} /etc/heartbeat/ha.d/
#拷贝heartbeat到/etc/init.d目录
#添加服务启动项
chkconfig --add heartbeat
chkconfig heartbeat on
#修改认证文件及属性
chmod 600 authkeys
#修改配置文件中软件启动路径
sed -i 's#/usr/lib/ocf#/opt/heartbeat/usr/lib/ocf#g' /etc/heartbeat/ha.d/shellfuncs
sed -i 's#/usr/lib/ocf#/opt/heartbeat/usr/lib/ocf#g' /etc/heartbeat/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
#创建脚本链接
ln -s /opt/heartbeat/usr/lib/ocf /usr/lib/ocf
#测试
service heartbeat status

5.配置和测试

5.1 node11配置

#进入配置目录
cd /etc/heartbeat/ha.d
#修改authkeys,内如如下:
auth 1
1 crc
#编辑ha.cf文件,内容如下:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
ucast eth1 192.168.10.12
auto_failback off
watchdog /dev/watchdog
node node11
node node12
ping 192.168.10.12
respawn hacluster /opt/heartbeat/libexec/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
#编辑haresources文件,最后一行添加:
node11 192.168.10.100 mysqld

5.2 node12配置

#进入配置目录
cd /etc/heartbeat/ha.d
#修改authkeys,内如如下:
auth 1
1 crc
#编辑ha.cf文件,内容如下:
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
ucast eth1 192.168.10.11
auto_failback off
watchdog /dev/watchdog
node node11
node node12
ping 192.168.10.11
respawn hacluster /opt/heartbeat/libexec/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
#编辑haresources文件,最后一行添加:
node11 192.168.10.100 mysqld

5.3 启动

node11上执行:service heartbeat start

node12上执行:service heartbeat start

任何节点上执行:ping 192.168.10.100

【源码安装】Heartbeat3.0.9的更多相关文章

  1. CentOS7源码安装Redis5.0.4非关系型数据库

    源码安装redis-5.0.4 一. 下载redis 1. 需要连接网络 二. 案例(另一种安装方法) [root@localhost ~]# wget http://download.redis.i ...

  2. 源码安装 qemu-2.0.0 及其依赖 glib-2.12.12

    源码安装qemu-2.0.0 下载源代码并解压 http://wiki.qemu-project.org/download/qemu-2.0.0.tar.bz2 .tar.gz 编译及安装: cd q ...

  3. CentOS下源码安装vsftpd-3.0.0,并设置指定用户访问指定目录(附带完整配置文件)

    1.卸载系统已经存在的ftp服务器 因为是源码安装,所以不能通过rpm -qa的方式查看是否已经安装ftp服务器,可以通过find / | grep vsftp*方式查看系统中存在哪些与vsftpd相 ...

  4. ubuntu16.04下源码安装onos1.0.2

    由于工作需要,下载安装onos1.0.2的版本,大家看需求可以下载安装更高级的版本 参考链接:http://www.sdnlab.com/14650.html 1.系统环境 Ubuntu16.04 L ...

  5. Linux 6.8 源码安装MySQL8.0

    搭建环境说明: 系统版本:Red Hat Enterprise Linux Server release 6.8 (Santiago) 内核版本:Linux 2.6.32-642.el6.x86_64 ...

  6. CentOS7.4 源码安装MySQL8.0

    MySQL 8 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 MySQL 5.7 快 2 倍,还带来了大量的改进和更快的性能! 以下为本人2018.4.23日安装过程的记录.整个过程大 ...

  7. 源码安装zabbix_agent4.0.3

    1.源码包下载地址:https://www.zabbix.com/download_sources 2.下载完后上传在任意目录用root用户创建以下脚本server_ip为服务端ip然后执行. gro ...

  8. 简单说说Ubuntu利用bzr源码安装OpenERP7.0的操作步骤

    1.修改Ubuntu国内更新源,具体方法自己baidu.google. 修改更新源后,更新系统 sudo apt-get update sudo apt-get upgrade 复制代码 2.安装Po ...

  9. centos7源码安装vim8.0

    centos 6和7通过yum安装的vim版本仍为7.4,若想尝鲜,可获取源码包编译安装. 准备工作 1.检查vim旧版本,若已存在,将其卸载. $ vim$ yum remove vim* -y 2 ...

  10. Debian系Linux源码安装Redis5.0.6

    一,先在官网下载源码包:https://redis.io/download 二,解压源码包,并cd到解压后的目录: 三,执行make MALLOC=libc: 接着cd src[解压的目录里有这个子目 ...

随机推荐

  1. day09_request&response学习笔记

    ============================================================ 一.HttpServletResponse接口 p.MsoNormal { m ...

  2. valid palindrome(回文)

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  3. Linux的chkconfig命令详解

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法: chkconfig [--a ...

  4. springboot中使用分页,文件上传,jquery的具体步骤(持续更新)

    分页: pom.xml     加依赖 <dependency> <groupId>com.github.pagehelper</groupId> <arti ...

  5. invalid bound statement (not found)

    invalid bound statement (not found) mybatis 错误: 一般是Mapepr.xml文件中文nameapce没有和mapper接口发生映射,导致mybatis绑定 ...

  6. linux基础-系统安装教程篇(centos6.5)

    一.linux系统简介: Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统.它能运行主要的UNIX工具软件.应用程 ...

  7. angular5学习笔记(deep in 路由)

    最近接手了一个angular5的项目.项目本身是由不同的人开发的,所有代码结构风格本身就有很大不同,加上本身接触angular5也不久,之前都是使用1,所有自身压力还是很大的. 接手前几天当然是熟悉代 ...

  8. Nginx安装及配置

    Nginx是一款速度快,功能强大的http以及反向代理服务器,经过简单的配置之后即可以用来托管页面. 不幸的是,和很多其他系统管理工具一样,相关的原理教程和配置说明文档都很少.虽然官方提供了一个wik ...

  9. JAVA Set 交集,差集,并集

    /** * Created by yuhui on 2017/7/11 0011. */ import java.util.HashSet; import java.util.Set; public ...

  10. EasyUI集成Kindeditor使用

    在实际的项目中,我们需要在项目中集成富文本编辑器,而kindeditor作为一款优良的编辑器,在项目中或多或少都会用到! 实际效果图     使用方法: 1.首先下载Kindeditor编辑器,我这里 ...