一、环境

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. Android近场通信---NFC基础(三)(转)

    转自 http://blog.csdn.net/think_soft/article/details/8180203 过滤NFC的Intent 要在你想要处理被扫描到的NFC标签时启动你的应用程序,可 ...

  2. 牛客寒假5-D.炫酷路途

    链接:https://ac.nowcoder.com/acm/contest/331/D 题意: 小希现在要从寝室赶到机房,路途可以按距离分为N段,第i个和i+1个是直接相连的,只需要一秒钟就可以相互 ...

  3. 牛客练习赛42B(异或的性质)

    传送门 b^ c >= b - c,这个结论应该记住,我还在这里证过…… 这个题就用到了这个结论,假如当前答案集合为S,和为a,异或和为b,当前答案为a+b了.这时又读入个c,该不该加进来?a ...

  4. 基于阿里云SLB/ESS/EIP/ECS/VPC的同城高可用方案演练

    今天基于阿里云SLB/ESS/EIP/ECS/VPC等产品进行了一次同城高可用方案演练: 基本步骤如下: 1. 在华东1创建VPC网络VPC1,在华东1可用区B和G各创建一个虚拟交换机vpc1_swi ...

  5. 转 PHP 正则表达式 以及案例

    2.Perl兼容的语法扩充 Perl兼容的正则表达式的模式类似于Perl中的语法,表达式必须包含在定界符中,除数字.字母.反斜线外的任何字符都可以作为定界符.例如,表达式’/^(?i)php[34]/ ...

  6. bootstrap警告框、进度条和列表组

    警告框   <div class="container">      <div class="alert alert-success" rol ...

  7. .NET Core 1.0 CentOS7 尝试(一、安装)

    昨天宣布 ASP.NET Core RC2,据说差不多稳定了,以后不会有大改了. 参考:https://blogs.msdn.microsoft.com/webdev/2016/05/16/annou ...

  8. CSS子元素设置margin-top作用于父容器?

    CSS子元素设置margin-top作用于父容器? 原因: In this specification, the expression collapsing margins means that ad ...

  9. CSS 布局说——可能是最全的

    前言 现在,我们被称为前端工程师.然而,早年给我们的称呼却是页面仔.或许是职责越来越大,整体的前端井喷式的发展,使我们只关注了js,而疏远了css和html. 其实,我们可能经常在聊组件化,咋地咋地. ...

  10. Java 图形界面开发--图文并茂建立学生管理系统

    (尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/50932501 冷血之心的博客) 图形用户界面(Graphics U ...