一、环境

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. bzoj3196:Tyvj1730二逼平衡树

    传送门 暴力啊,直接树套树上啊 线段树套splay,卡卡常就直接A了 代码: #include<cstdio> #include<iostream> #include<a ...

  2. D - Fliptile

    #include <stdio.h> #include <iostream> #include <math.h> #include <algorithm> ...

  3. slice方法可以将“类似数组的对象”变成真正的数组 (遇到时候再研究一次)

    典型的“类似数组的对象”是函数的arguments对象,以及大多数 DOM 元素集,还有字符串. // arguments对象 function args() { return arguments } ...

  4. [題解]luogu P1156 垃圾陷阱

    前言:[數據刪除] 來源:題解 不發題面了 首先我们来分析题目,“每个垃圾都可以用来吃或堆放”,浓浓的透露出一个背包气息.我们可以类比背包问题的放或不放.于是dp[i][j]dp[i][j]dp[i] ...

  5. CI模板中如何引入模板

    <?php $this->load->view('index/head.html') ?>

  6. 运行nodejs项目报Process finished with exit code 1 错误

    在项目中,明明在别人的机子上项目可以运行,但是复制到自己的电脑就无法就无法启动.报Process finished with exit code 1错误,也没提示错误地方.自己倒腾了很久总结了几个解决 ...

  7. find搜索文件系统,实时搜索

    find搜索文件系统.实时搜索 find[目录][条件][动作] [目录] 不输入目录代表当前目录 find find /etc ----------------------------------- ...

  8. mysql命令行执行时不输出列名(字段名)

    -N 即可 如:mysql -N -e "select * from test" 摘自:http://blog.csdn.net/eroswang/article/details/ ...

  9. linux各文件夹的作用(转)

    转自:http://www.cnblogs.com/amboyna/archive/2008/02/16/1070474.html linux下的文件结构,看看每个文件夹都是干吗用的/bin 二进制可 ...

  10. Hibernate:Disjunction&Conjunction构造复杂的查询条件.

    Hibernate:Disjunction&Conjunction构造复杂的查询条件 Disjunction和Conjunction是逻辑或和逻辑与,如下: 用来组合一组逻辑或[or]条件的方 ...