heartbeat安装配置

一、环境

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 ::1 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]# ls
0a7add1d9996.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.69
automake:    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]# ls
0a7add1d9996.tar.bz2  Heartbeat-3-0-958e11be8686  resource-agents-3.9.6.tar.gz
958e11be8686.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 errors
gmake[1]: *** [strlcpy.lo] 错误 1
gmake[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-debug
logfile         /var/log/ha-log
keepalive       2
deadtime        30
warntime        10
initdead        120
udpport         694
bcast   ens37
ucast   ens37   192.168.42.102
auto_failback   on
node    node01
node    node02
ping 192.168.127.102
respawn hacluster /application/heartbeat/libexec/heartbeat/ipfail
apiauth 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      # 在某系统上,系统启动或重启之后需要经过一段时间网络才能正常工作,该选项用于解决这种情况产生的时间间隔,取值至少为deadtime2

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 192.168.127.100 具有 32 字节的数据:
来自 192.168.127.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.127.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.127.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.127.100 的回复: 字节=32 时间<1ms TTL=64

 

转载于:https://www.cnblogs.com/suffergtf/p/9525416.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值