一、环境

node01  192.168.127.101  心跳:192.168.42.101

node02  192.168.127.102  心跳:192.168.42.102

虚拟ip:192.168.127.100

二、原理

  http://www.mamicode.com/info-detail-1494631.html  

  

三、安装

node01[root@node01 ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.127.101 node01
192.168.127.102 node02[root@node01 ~]# ssh-keygen[root@node01 ~]# ssh-copy-id node02[root@node01 ~]# yum groupinstall "Development tools"    ####安装开发工具[root@node01 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo    ####安装epel源[root@node01 ~]# yum -y install glib2-devel libtool-ltdl-devel net-snmp-devel bzip2-devel ncurses-devel openssl-devel libtool libxml2-devel \gettext bison flex zlib-devel mailx which libxslt docbook-dtds docbook-style-xsl PyXML shadow-utils opensp autoconf automake bzip2[root@node01 ~]# yum install -y glib2-devel libxml2 libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel \make wget docbook-dtds docbook-style-xsl bzip2-devel asciidoc libuuid-devel    ####安装heartbeat依赖

[root@node01 ~]# groupadd haclient[root@node01 ~]# useradd -g haclient hacluster -M -s /sbin/nologin   ###添加heartbeat默认用户合租[root@node01 ~]# cd /server/tools/[root@node01 tools]# rz

[root@node01 tools]# tar -jxf 0a7add1d9996.tar.bz2 [root@node01 tools]# ls0a7add1d9996.tar.bz2  Reusable-Cluster-Components-glue--0a7add1d9996[root@node01 tools]# cd Reusable-Cluster-Components-glue--0a7add1d9996/[root@node01 Reusable-Cluster-Components-glue--0a7add1d9996]#[root@node01 Reusable-Cluster-Components-glue--0a7add1d9996]# ./autogen.sh autoconf:    autoconf (GNU Autoconf) 2.69automake:    automake (GNU automake) 1.13.4...Now run ./configure

[root@node01 Reusable-Cluster-Components-glue--0a7add1d9996]# ./configure --prefix=/application/heartbeat 

  Prefix                   = /application/heartbeat  Executables              = /application/heartbeat/sbin  Man pages                = /application/heartbeat/share/man  Libraries                = /application/heartbeat/lib  Header files             = /application/heartbeat/include  Arch-independent files   = /application/heartbeat/share  Documentation            = /application/heartbeat/share/doc/cluster-glue  State information        = /application/heartbeat/var  System configuration     = /application/heartbeat/etc

  Use system LTDL          = no

  HA group name            = haclient  HA user name             = hacluster
[root@node01 Reusable-Cluster-Components-glue--0a7add1d9996]#make &&make install
[root@node01 tools]# tar xf resource-agents-3.9.6.tar.gz [root@node01 tools]# cd resource-agents-3.9.6[root@node01 resource-agents-3.9.6]# ./autogen.sh[root@node01 resource-agents-3.9.6]# export CFLAGS="$CFLAGS -I/application/heartbeat/include -L/application/heartbeat/lib"[root@node01 resource-agents-3.9.6]# ./configure --prefix=/application/heartbeat/[root@node01 resource-agents-3.9.6]# ln -s /application/heartbeat/lib/* /lib/[root@node01 resource-agents-3.9.6]# ln -s /application/heartbeat/lib/* /lib64/[root@node01 resource-agents-3.9.6]# make &&make install 

[root@node01 tools]# tar -jxf 958e11be8686.tar.bz2 [root@node01 tools]# ls0a7add1d9996.tar.bz2  Heartbeat-3-0-958e11be8686  resource-agents-3.9.6.tar.gz958e11be8686.tar.bz2  resource-agents-3.9.6       Reusable-Cluster-Components-glue--0a7add1d9996[root@node01 tools]# cd Heartbeat-3-0-958e11be8686/[root@node01 Heartbeat-3-0-958e11be8686]# ./bootstrap[root@node01 Heartbeat-3-0-958e11be8686]# ./configure --prefix=/application/heartbeat/[root@node01 Heartbeat-3-0-958e11be8686]# make      #######报错如下.../application/heartbeat/include/heartbeat/glue_config.h:105:0: error: "HA_HBCONF_DIR" redefined [-Werror] #define HA_HBCONF_DIR "/application/heartbeat/etc/ha.d/" ^In file included from ../include/lha_internal.h:38:0,                 from strlcpy.c:1:../include/config.h:390:0: note: this is the location of the previous definition #define HA_HBCONF_DIR "/application/heartbeat/etc/ha.d" ^cc1: all warnings being treated as errorsgmake[1]: *** [strlcpy.lo] 错误 1gmake[1]: 离开目录“/server/tools/Heartbeat-3-0-958e11be8686/replace”make: *** [all-recursive] 错误 1[root@node01 Heartbeat-3-0-958e11be8686]# vim /application/heartbeat/include/heartbeat/glue_config.h#define HA_HBCONF_DIR "/application/heartbeat/etc/ha.d/"    ######删除该行

[root@node01 Heartbeat-3-0-958e11be8686]# cd /application/heartbeat/share/doc/heartbeat/[root@node01 heartbeat]# cp -a ha.cf authkeys haresources /application/heartbeat/etc/ha.d/[root@node01 ha.d]# chmod 600 authkeys [root@node01 ha.d]# ln -svf /application/heartbeat/lib64/heartbeat/plugins/RAExec/* /application/heartbeat/lib/heartbeat/plugins/RAExec/[root@node01 ha.d]# ln -svf /application/heartbeat/lib64/heartbeat/plugins/* /application/heartbeat/lib/heartbeat/plugins/

[root@node01 ha.d]# vim ha.cf

debugfile       /var/log/ha-debuglogfile         /var/log/ha-logkeepalive       2deadtime        30warntime        10initdead        120udpport         694bcast   ens37ucast   ens37   192.168.42.102auto_failback   onnode    node01node    node02ping 192.168.127.102respawn hacluster /application/heartbeat/libexec/heartbeat/ipfailapiauth ipfail gid=haclient uid=hacluster

#############################################################

debugfile /var/log/ha-debug         # 保存调试信息文件

logfile /var/log/ha-log                    # 日志文件

logfacility     local0                 # 表示使用系统日志

keepalive 2                                      # 心跳的时间间隔,单位s

deadtime 30                           # 超出该时间间隔未收到对方节点的心跳,则判定对方死亡

warntime 10                           # 超出该时间间隔未收到对方节点的心跳,则发出警告记录到日志中

initdead 120      # 在某系统上,系统启动或重启之后需要经过一段时间网络才能正常工作,该选项用于解决这种情况产生的时间间隔,取值至少为deadtime的2倍

udpport 694           # 设置广播通信使用的端口,694为默认使用的端口号

bcast ens37          # 传播心跳的广播播网卡信息

ucast ens37 192.168.42.102      # node02 配置 192.168.42.101            # 设置对方机器心跳检测的网卡和IP

auto_failback on              # heartbeat的两台主机分别为主节点和从节点。主节点在正常情况下占用资源并运行所有的服务,遇到故障时把资源交给从节点由从节点运行服务。在该选项设为on的情况下,一旦主节点恢复运行,则 自动获取资源并取代从节点,否则不取代从节点

node    node01     # 配置主从的节点信息

node    node02

ping 192.168.127.102       # ping模式用于测试 如果ping不通 某个主机 就认为当前断网 需要转移vip

respawn hacluster /usr/local/heartbeat/libexec/heartbeat/ipfail  # 指定与heartbeat一同启动和关闭的进程,该进程被自动监视,遇到故障则重新启动。最常用的进程是ipfail,该进程用于检测和处理网络故障,需要配合ping语句指定的ping node来检测网络连接。如果你的系统是64bit,请注意该文件的路径

apiauth ipfail gid=haclient uid=hacluster   # 指定用户&组

##########################################################################

[root@node01 ha.d]# vim authkeys

auth 2
2 sha1 hello!

[root@node01 ha.d]# vim haresources     #########此文件主备相同

node01  192.168.127.100/24/ens33:0

node02安装同上


四、测试

关闭node01.

C:\Users\suffergtf>ping 192.168.127.100

正在 Ping  字节的数据:
来自  时间<1ms TTL=
来自  时间<1ms TTL=
来自  时间<1ms TTL=
来自  时间<1ms TTL=

heartbeat安装配置的更多相关文章

  1. heartbeat集群安装配置

    安装配置高可用集群需要注意:1.节点名称:集群每个节点的名称都得能互相解析 /etc/hosts hosts主机名的正反解析结果必须跟"uname -n"的结果保持一致2.时间必须 ...

  2. Linux-HA实战(1)— Heartbeat安装

    接触Heartbeat主要是因为之前项目中使用了TFS,最近想给nameserver做HA,因为TFS官方用的Heartbeat,所以刚好了解下,参考了网络上很多内容,这里简单记录下. 内容 环境和软 ...

  3. lvs keepalived 安装配置详解

    前段时间看了一篇文章,lvs做负载均衡根F5差不多,说实话不怎么相信,因为F5没玩过,也无法比较.F5相当的贵,真不是一般企业能负担的起的.负载均衡软件也用过不少,nginx,apache,hapro ...

  4. lvs keepalived 安装配置详解【转】

    lvs keepalived 安装配置详解 张映 发表于 2012-06-20 分类目录: 服务器相关 前段时间看了一篇文章,lvs做负载均衡根F5差不多,说实话不怎么相信,因为F5没玩过,也无法比较 ...

  5. elk安装配置

    ELK介绍   官网https://www.elastic.co/cn/ 中文指南https://www.gitbook.com/book/chenryn/elk-stack-guide-cn/det ...

  6. ELK 架构之 Logstash 和 Filebeat 安装配置

    上一篇:ELK 架构之 Elasticsearch 和 Kibana 安装配置 阅读目录: 1. 环境准备 2. 安装 Logstash 3. 配置 Logstash 4. Logstash 采集的日 ...

  7. (转)Linux-HA开源软件Heartbeat(配置篇)

    原文:http://ixdba.blog.51cto.com/2895551/548625 http://gzsamlee.blog.51cto.com/9976612/1828870 Linux-H ...

  8. (转)Linux-HA实战(1)— Heartbeat安装

    原文:http://blog.csdn.net/liaomin416100569/article/details/76087448-------centos7源代码编译安装heartbeat 原文:h ...

  9. CentOS6.6下DRBD+HeartBeat+NFS配置

    一.DRBD配置 Distributed Replicated Block Device(DRBD)是一个用软件实现的.无共享的.服务器之间镜像块设备内容的存储复制解决方案. 我们可以理解为它其实就是 ...

随机推荐

  1. Access restriction: The type 'JPEGCodec' is not API

    问题 今天导入项目时Eclipse报错如下: Access restriction: The type 'JPEGCodec' is not API (restriction on required ...

  2. Redis - Windows平台下怎么切换db并且清理数据

    Redis 本身支持16个数据库(0~15),通过 数据库id 设置,默认为0.在Windows平台下可以通过启动redis-cli.exe来进入客户端,客户端默认连接数据库0,在客户端里可以输入各种 ...

  3. StretchDIBits速度测试(COLORONCOLOR)

    下面是一个测试程序,源码下载

  4. 086 Partition List 分隔链表

    给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前.你应当保留两个分区中每个节点的初始相对位置.例如,给定1->4->3->2-&g ...

  5. javascript要点(上)

    立即执行函数 即Immediately Invoked Function Expression (IIFE),正如它的名字,就是创建函数的同时立即执行.它没有绑定任何事件,也无需等待任何异步操作: ( ...

  6. WORDPRESS下载按钮调整

  7. jmeter压力测试中遇到的问题汇总

    1.线程数大于1的时候,计数器配置没有勾选reset counter选项,导致测试结果出错 正常结果: 实际结果:index大于count数量时出错,病区及床号直接显示在count的基础上开始加1了 ...

  8. Kettle-Spoon入门示例

    Spoon 是Kettle的设计调试工具 [Demo文档下载] https://files.cnblogs.com/files/shexunyu/Kettle-Spoon-Demo%E5%B8%AE% ...

  9. SpringBoot 2.x (9):整合Mybatis注解实战

    SSM框架再熟悉不过了,不过以前通常是使用XML写SQL语句 这里用SpringBoot整合Mybatis并且使用注解进行开发 依赖: <!-- Mybatis --> <depen ...

  10. Tame Your Software Dependencies for More Flexible Apps

    http://msdn.microsoft.com/en-us/magazine/cc337885.aspx