一、环境

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. lucene原理及java实现

    https://blog.csdn.net/liuhaiabc/article/details/52346493 https://blog.csdn.net/yang307511977/article ...

  2. [题解](堆)luogu_P1631序列合并

    思路来自题解 作者: Red_w1nE 更新时间: 2016-11-13 20:46 在Ta的博客查看  72 最近有点忙 没时间贴代码了== [分析] 首先,把A和B两个序列分别从小到大排序,变成两 ...

  3. [题解](背包)luogu_P4095 eden的新背包问题

    有一点乱搞吧......对人对背包的理解有些考验,要想知道去掉某个点的值,可以选择对前缀求一次背包,后缀求一次背包,而且不省掉价钱那一维, 这样每个点就可以由前后组合成了,枚举一下价钱取max即可 直 ...

  4. UWP 基本控件

    -------持续更新 updated 2017.11.8---------------------- 一:TextBlock 文本显示框 1. IsTextSelectionEnabled属性  值 ...

  5. Win10系统特别卡的一个原因

    我遇到的Win10特别卡的原因是它自带的一个杀毒软件 迈克菲(McAfee)导致的,在卸载之前电脑真的特别卡,打开一个窗口都卡,,卸载了之后瞬间感觉电脑飞起来了.... 当然还有很多原因会导致电脑卡, ...

  6. freertos之内存管理

    任务.信号量.邮箱才调度器开始调度之前就应该创建,所以它不可能像裸奔程序那样的函数调用能确定需要多少内存资源,RTOS提供了3种内存管理的方法: 1 方法一:确定性好适合于任务.信号量.队列都不被删除 ...

  7. msyql 死锁

    1.使用 show processlist; 查询当前进程; 找到Command 状态是query 并且Time 时间很长的id kill掉即可 2.select * from information ...

  8. jquery select取option的value值发生变化事件

    html代码如下所示: <div id = "schedule"> <label>是否设置:</label> <select name=& ...

  9. ios has denied the launch request.

    ios has denied the launch request. You can choose either of the two ways. Solution 1: Open System Pr ...

  10. Selenium私房菜系列9 -- 我遇到的问题及解决问题的方法

    Selenium私房菜系列10 -- 我遇到的问题及解决问题的方法