主机名 IP  所需软件 
master 192.168.30.130  heartbeat、httpd
node-1 192.168.30.131  nfs 
node-2 192.168.30.132  heartbeat、httpd 

配置hosts文件

[root@master ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.30.130 master
192.168.30.131 node-
192.168.30.132 node-
192.168.30.133 node-
[root@master ~]# scp /etc/hosts node-:/etc/
[root@master ~]# scp /etc/hosts node-:/etc/
[root@master ~]# scp /etc/hosts node-:/etc/

配置共享存储

[root@node- ~]# yum install -y nfs-utils
[root@node- ~]# mkdir /nfsdata
[root@node- ~]# echo "<h1>This is the HeartBeat HTTP Server Test</h1>" > /var/www/html/index.html
[root@node- ~]# vim /etc/exports
/nfsdata 192.168.30.0/(rw)
[root@node- ~]# chown -R /nfsdata/
[root@node- ~]# chkconfig nfs on
[root@node- ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[root@node- ~]# showmount -e
Export list for node-:
/nfsdata 192.168.30.0/

配置WEB服务器

主web服务器

[root@master ~]# yum install -y httpd
[root@master ~]# showmount -e node-
Export list for node-:
/nfsdata 192.168.30.0/
[root@master ~]# mount -t nfs node-:/nfsdata /var/www/html/
[root@master ~]# df -h /var/www/html/
Filesystem Size Used Avail Use% Mounted on
node-:/nfsdata 18G .1G 13G % /var/www/html
[root@master ~]# service httpd start
Starting httpd: [ OK ]
[root@master ~]# curl 127.1
<h1>This is the HeartBeat HTTP Server Test</h1>
[root@master ~]# umount /var/www/html/
[root@master ~]# chkconfig httpd on

从web服务器

[root@node- ~]# yum install -y httpd
[root@node- ~]# showmount -e node-
Export list for node-:
/nfsdata 192.168.30.0/
[root@node- ~]# mount -t nfs node-:/nfsdata /var/www/html/
[root@node- ~]# df -h /var/www/html/
Filesystem Size Used Avail Use% Mounted on
node-:/nfsdata 18G .1G 13G % /var/www/html
[root@node- ~]# service httpd start
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
测试访问页面
[root@node- ~]# curl 127.1
<h1>This is the HeartBeat HTTP Server Test</h1>
[root@node- ~]# umount /var/www/html/ #卸载测试资源,heartbeat安装完后,这些通过heartbeat加载
[root@node- ~]# chkconfig httpd on

安装heartbeat软件包

配置YUM源
[root@master ~]# ls /media/cdrom/
EFI Packages RELEASE-NOTES-pa-IN.html
EULA README RELEASE-NOTES-pt-BR.html
EULA_de RELEASE-NOTES-as-IN.html RELEASE-NOTES-ru-RU.html
EULA_en RELEASE-NOTES-bn-IN.html RELEASE-NOTES-si-LK.html
EULA_es RELEASE-NOTES-de-DE.html RELEASE-NOTES-ta-IN.html
EULA_fr RELEASE-NOTES-en-US.html RELEASE-NOTES-te-IN.html
EULA_it RELEASE-NOTES-es-ES.html RELEASE-NOTES-zh-CN.html
EULA_ja RELEASE-NOTES-fr-FR.html RELEASE-NOTES-zh-TW.html
EULA_ko RELEASE-NOTES-gu-IN.html repodata
EULA_pt RELEASE-NOTES-hi-IN.html ResilientStorage
EULA_zh RELEASE-NOTES-it-IT.html RPM-GPG-KEY-redhat-beta
GPL RELEASE-NOTES-ja-JP.html RPM-GPG-KEY-redhat-release
HighAvailability RELEASE-NOTES-kn-IN.html ScalableFileSystem
images RELEASE-NOTES-ko-KR.html Server
isolinux RELEASE-NOTES-ml-IN.html TRANS.TBL
LoadBalancer RELEASE-NOTES-mr-IN.html
media.repo RELEASE-NOTES-or-IN.html
[root@master ~]# cd /media/cdrom/HighAvailability/
[root@master HighAvailability]# pwd
/media/cdrom/HighAvailability
[root@master ~]# vim /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media/cdrom
enabled=
gpgcheck=
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [rhel-HA-source]
name=Red Hat Enterprise Linux $releasever - $basearch -HA-Source
baseurl=file:///media/cdrom/HighAvailability
enabled=
gpgcheck=
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

开始创建heartbeat软件包

[root@master ~]# tar -xf Heartbeat---958e11be8686.tar.bz2 -C /usr/local/src/
[root@master ~]# cd /usr/local/src/Heartbeat---958e11be8686/
[root@master Heartbeat---958e11be8686]# rpmbuild -ba heartbeat-fedora.spec
[root@master ~]# tar -xf Heartbeat---958e11be8686.tar.bz2 -C /usr/local/src/
[root@master ~]# cd /usr/local/src/Heartbeat---958e11be8686/
[root@master Heartbeat---958e11be8686]# rpmbuild -ba heartbeat-fedora.spec
error: File /root/rpmbuild/SOURCES/heartbeat.tar.bz2: No such file or directory
[root@master Heartbeat---958e11be8686]# cd
[root@master ~]# ls /root/rpmbuild/SOURCES/
[root@master ~]# ll -d /root/rpmbuild/SOURCES/
drwxr-xr-x root root Jun : /root/rpmbuild/SOURCES/
[root@master ~]# tar -xf Heartbeat---958e11be8686.tar.bz2 -C /root/rpmbuild/SOURCES/
[root@master ~]# cd /root/rpmbuild/SOURCES/
[root@master SOURCES]# mv Heartbeat---958e11be8686/ heartbeat
[root@master SOURCES]# ls
heartbeat
[root@master SOURCES]# tar -cjvf heartbeat.tar.bz2 heartbeat
开始创建软件包
[root@master heartbeat]# rpmbuild -ba heartbeat-fedora.spec
error: Failed build dependencies:
libtool-ltdl-devel is needed by heartbeat-3.0.-.el6.x86_64
cluster-glue-libs-devel is needed by heartbeat-3.0.-.el6.x86_64
解决依赖
[root@master heartbeat]# yum install -y ncurses-devel openssl-devel gettext bison flex mailx cluster-glue-libs-devel docbool-dtds docbook-style-xsl libtook-ltdl-devel libuuid-devel
[root@master heartbeat]# rpmbuild -ba heartbeat-fedora.spec
...........
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.VvZNu1
+ umask
+ cd /root/rpmbuild/BUILD
+ cd heartbeat
+ rm -rf /root/rpmbuild/BUILDROOT/heartbeat-3.0.-.el6.x86_64
+ exit

在WEB主服务器上

[root@master heartbeat]# cd /root/rpmbuild/RPMS/x86_64/
[root@master x86_64]# ls
heartbeat-3.0.-.el6.x86_64.rpm heartbeat-devel-3.0.-.el6.x86_64.rpm
heartbeat-debuginfo-3.0.-.el6.x86_64.rpm heartbeat-libs-3.0.-.el6.x86_64.rpm
[root@master x86_64]# yum install -y cluster-glue resource-agents
[root@master x86_64]# rpm -ivh heartbeat-libs-3.0.-.el6.x86_64.rpm
Preparing... ########################################### [%]
:heartbeat-libs ########################################### [%]
[root@master x86_64]# rpm -ivh heartbeat-3.0.-.el6.x86_64.rpm
Preparing... ########################################### [%]
:heartbeat ########################################### [%]
[root@master x86_64]# scp heartbeat-libs-3.0.-.el6.x86_64.rpm heartbeat-3.0.-.el6.x86_64.rpm node-:/root/
root@node-'s password:
heartbeat-libs-3.0.-.el6.x86_64.rpm % 76KB .6KB/s :
heartbeat-3.0.-.el6.x86_64.rpm % 234KB .5KB/s :

从WEB服务器

[root@node- ~]# yum install -y ncurses-devel openssl-devel gettext bison mailx cluster-glue-libs-devel docbook-dtds docbook-style-xsl cluster-glue resource-agents  #前提是/etc/yum.repo文件需要修改与master一样
[root@node- ~]# rpm -ivh heartbeat-libs-3.0.-.el6.x86_64.rpm
Preparing... ########################################### [%]
:heartbeat-libs ########################################### [%]
[root@node- ~]# rpm -ivh heartbeat-3.0.-.el6.x86_64.rpm
Preparing... ########################################### [%]
:heartbeat ########################################### [%]
[root@node- ~]# grep haclient /etc/group
haclient:x::
[root@node- ~]# id hacluster
uid=(hacluster) gid=(haclient) groups=(haclient)

配置heartbea,在master上

定义验证文件

[root@master ~]# cp /usr/share/doc/heartbeat-3.0./ha.cf /etc/ha.d/
[root@master ~]# cp /usr/share/doc/heartbeat-3.0./authkeys /etc/ha.d/
[root@master ~]# cp /usr/share/doc/heartbeat-3.0./haresources /etc/ha.d/
[root@master ~]# vim /etc/ha.d/authkeys #设置主备节点之间通信使用的验证文件
auth 3 #去掉原有的注释,auth后面的数字对应下面的序号,使用crc认证的话,auth后面就写1,使用md5认证的话,auth后面就写3
# crc
# sha1 HI!
md5 sishenkey #去掉原有注释并修改
[root@master ~]# chmod /etc/ha.d/authkeys #不改权限的话不能启动

定义浮动资源

[root@master ~]# vim /etc/ha.d/haresources
#node-name resource1 resource2 ... resourceN #此行下面添加
master IPaddr::192.168.30.130//eth0 Filesystem::192.168.30.131:/nfsdata::/var/www
/html/::nfs httpd
#node-name 主服务器主机名,从服务器上不要修改这里
#IPaddr::192.168.30.130//eth0 #定义VIP及绑定到哪张网卡上
#Filesystem::192.168.30.131:/nfsdata::/var/www/html/ 定义要挂载的存储
#httpd 指定要启动的服务,这个服务必须是/etc/init.d/下面的,可以通过service启动或关闭的

手动测试浮动IP是否可用

[root@master ha.d]# /etc/ha.d/resource.d/IPaddr 192.168.30.100//eth0 start
INFO: Adding inet address 192.168.30.100/ with broadcast address 192.168.30.255 to device eth0
INFO: Bringing device eth0 up
INFO: /usr/libexec/heartbeat/send_arp -i -r -p /var/run/resource-agents/send_arp-192.168.30.100 eth0 192.168.30.100 auto not_used not_used
INFO: Success
INFO: Success
ARPING 192.168.30.100 from 192.168.30.100 eth0
[root@master ha.d]# Sent probes ( broadcast(s))
Received response(s) 使用ip addr查看,ifconfig看不到
[root@master ha.d]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c::4d:: brd ff:ff:ff:ff:ff:ff
inet 192.168.30.130/ brd 192.168.30.255 scope global eth0
inet 192.168.30.100/ brd 192.168.30.255 scope global secondary eth0
inet6 fe80::20c:29ff:fe4d:/ scope link
valid_lft forever preferred_lft forever

测试文件系统是否正常

[root@master ha.d]# /etc/ha.d/resource.d/Filesystem 192.168.30.131:/nfsdata /var/www/html/ nfs start
INFO: Running start for 192.168.30.131:/nfsdata on /var/www/html
INFO: Filesystem /var/www/html is already mounted.
INFO: Success
INFO: Success
[root@master ha.d]# ll /var/www/html/
total
-rw-r--r-- root root Jun : index.html
#结果表明是成功的

查看主配置文件

[root@master ~]# grep "^[^#]" /etc/ha.d/ha.cf  #查看配置文件的有效行有哪些
logfacility local0
auto_failback on
#auto_failback 为on时,主节点恢复正常,资源自动转给主节点,建议设为off,等主节点恢复正常后且业务不繁忙后再切回来,防止主节点恢复正常时,因为回切导致的异常。

修改主配置文件

[root@master ~]# vim /etc/ha.d/ha.cf #以下行去掉原有注释,启用
debugfile /var/log/ha-debug
logfile /var/log/ha-log
keepalive #指定heartbeat之间的时间间隔2秒
deadtime #在30秒后判断节点死亡
warntime #在日志中发出“late heartbeat”警告之前等待的时间,单位:秒
initdead #在一些系统上,系统启动或重启之后需要经过一段时间网络才能正常工作,该选项用于解决这种情况产生的时间间隔,取值至少为deadtime的两倍
udpport #使用端口694惊醒bcast和ucast通信(默认值:,IANA官方注册的端口号)
ucast eth0 192.168.30.132 #表示从本机的eth0接口发出的心跳消息给对方节点,写对方IP,这是单播地址。node-2上要写192.168.30.,心跳网卡:加入有两张网卡,可以写成eth1。注意,配置文件中91行#bcast eth0 表示在eth0接口上使用广播heartbeat(将eth1替换为eth0,eth2,或者用户使用的任何接口)
auto_failback on #默认启用
node master #必须配置,集群中机器的主机名
node node-
ping 192.168.30.2 #通过ping命令实现仲裁,这里需要注意每个人的网关不同,依据自己的实际网关而定
respawn hacluster /usr/libexec/heartbeat/ipfail #注意这里需要手动去看ipfail是在lib下面,还是在libexec下
apiauth ipfail gid=haclient uid=hacluster

从WEB服务器上(node-2)

[root@master ~]# cd /etc/ha.d/
[root@master ha.d]# scp authkeys ha.cf haresources node-:/etc/ha.d/
root@node-'s password:
authkeys % .6KB/s :
ha.cf % 10KB .3KB/s :
haresources % .9KB/s :
[root@node- ~]# chmod /etc/ha.d/authkeys
[root@node- ~]# vim /etc/ha.d/ha.cf
ucast eth0 192.168.30.130 #只需修改这里

启动heartbeat(在WEB主和从上)

[root@master ~]# /etc/init.d/heartbeat restart
Stopping High-Availability services: [ OK ]
Waiting to allow resource takeover to complete: [ OK ]
Starting High-Availability services: INFO: Running OK
CRITICAL: Resource IPaddr::192.168.30.100//eth0 is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Resource IPaddr::192.168.30.100//eth0 is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or the source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Non-idle resources will affect resource takeback!
CRITICAL: Non-idle resources may affect data integrity!
[ OK ]
[root@node- ~]# /etc/init.d/heartbeat restart
Stopping High-Availability services: [ OK ]
Waiting to allow resource takeover to complete: [ OK ]
Starting High-Availability services: INFO: Resource is stopped
[ OK ]
#注意这里在启动的时候等待大概2分钟左右master提示在接管所有浮动资源.等下启动成功后,会释放浮动资源,最后再次加载

验证端口是否监听成功

[root@master ~]# netstat -antup | grep
udp 0.0.0.0: 0.0.0.0:* /heartbeat: wri
[root@node- ~]# netstat -antup | grep
udp 0.0.0.0: 0.0.0.0:* /heartbeat: wri

Ok,端口正常!

查看浮动IP是否存在

[root@master ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c::4d:: brd ff:ff:ff:ff:ff:ff
inet 192.168.30.130/ brd 192.168.30.255 scope global eth0
inet 192.168.30.100/ brd 192.168.30.255 scope global secondary eth0
inet6 fe80::20c:29ff:fe4d:/ scope link
valid_lft forever preferred_lft forever [root@node- ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :::2f::4d brd ff:ff:ff:ff:ff:ff
inet 192.168.30.132/ brd 192.168.30.255 scope global eth0
inet6 fe80:::56ff:fe2f:844d/ scope link
valid_lft forever preferred_lft forever

查看浮动资源是否挂载

[root@master ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_master-LogVol00 18G .1G 13G % /
tmpfs .0G 72K .0G % /dev/shm
/dev/sda1 194M 35M 150M % /boot
/dev/sr0 .6G .6G % /media/cdrom
192.168.30.131:/nfsdata 18G .1G 13G % /var/www/html

浏览器测试浮动IP

手动停掉master上的eth0,再次测试浮动IP

[root@master ~]# ifdown eth0
然后去node-2上查看
[root@node- ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :::2f::4d brd ff:ff:ff:ff:ff:ff
inet 192.168.30.132/ brd 192.168.30.255 scope global eth0
inet 192.168.30.100/ brd 192.168.30.255 scope global secondary eth0
inet6 fe80:::56ff:fe2f:844d/ scope link
valid_lft forever preferred_lft forever
#node-2已经接管浮动IP

还是可以的!OK~到此结束

RHEL 6.5----heartbeat的更多相关文章

  1. heartbeat在yum系发行版本的处理资料

    centos 安装包[rpm]和光盘iso文件 http://mirror.centos.org/centos/ 对应如上包的代码 http://vault.centos.org/ git.cento ...

  2. Configure Red Hat Enterprise Linux shared disk cluster for SQL Server——RHEL上的“类”SQL Server Cluster功能

    下面一步一步介绍一下如何在Red Hat Enterprise Linux系统上为SQL Server配置共享磁盘集群(Shared Disk Cluster)及其相关使用(仅供测试学习之用,基础篇) ...

  3. Configure Always On Availability Group for SQL Server on RHEL——Red Hat Enterprise Linux上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Red Hat Enterprise Linux上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的 ...

  4. CentOS7数据库架构之NFS+heartbeat+DRBD(亲测,详解)

    目录 参考文档 理论概述 DRBD 架构 NFS 架构部署 部署DRBD 部署heartbeat 部署NFS及配合heartbeat nfs切记要挂载到别的机器上不要为了省事,省机器 参考文档 htt ...

  5. Linux:将rhel yum 切换到centos yum

    Red Hat Enterprise Linux Server(RHEL) yum安装软件时This system is not registered with RHN. RHN support wi ...

  6. Configure a bridged network interface for KVM using RHEL 5.4 or later?

    environment Red Hat Enterprise Linux 5.4 or later Red Hat Enterprise Linux 6.0 or later KVM virtual ...

  7. 在CentOS或RHEL上安装Nux Dextop仓库

    介绍 Nux Dextop是类似CentOS.RHEL.ScientificLinux的第三方RPM仓库(比如:Ardour,Shutter等等).目前,Nux Dextop对CentOS/RHEL ...

  8. 1-linux系统管理(一)之安装RHEL 6.4

    linux系统管理之安装RHEL 6.4 进入安装界面 这里选择跳过 点击下一步 选择安装语言 选择键盘 选择系统储存方式 选择是否格式化储存设备 给安装的系统一个计算机名 选择时区 给root一个密 ...

  9. Heartbeat使用梳理

    在日常的集群系统架构中,一般用到Heartbeat的主要就2种:1)高可用(High Availability)HA集群, 使用Heartbeat实现,也称为"双机热备", &qu ...

  10. CentOS 7 (RHEL 7)服务管理命令的变化

    CentOS 7 (RHEL 7)带来了新的服务管理命令,为了保持兼容原有的命令仍可以使用,以下是新旧命令的对照. 启动.停止.重启.重载.检查服务:6: service httpd start|st ...

随机推荐

  1. hadoop yarn namenode datanoe 启动异常问题解决 分析日志

    cat logs/hadoop-root-datanode-hadoop1.log ********************************************************** ...

  2. JasperReport 中文问题解决

    1 运行环境    1.1 JasperReport 3.5    JasperReports 是iReport的核心内容.它是一个强有力的开源报表产生工具,可以将内容输出到屏幕上.打印机或生成PDF ...

  3. JS中prototype,js原型扩展

    作者:轩脉刃(yjf512)出处:(http://www.cnblogs.com/yjf512/)版权声明:本文的版权归作者与博客园共有.欢迎转载阅读,转载时须注明本文的详细链接. 原文 http:/ ...

  4. Bug不能重现的原因分析及其对策

    摘 要:本文简要分析了无法重现的Bug的可能产生原因,包括环境不一致.缺少最准确的描述和浏览器的不当设置.针对这些原因,本文给出了相应的对策.通过这些措施,可以重现许多以前认为不可重现的Bug.    ...

  5. 【NOI 2015】软件包管理器

    [题目链接] 点击打开链接 [算法] 树链剖分,子树的DFS序也是连续的一段 要注意细节! [代码] #include<bits/stdc++.h> using namespace std ...

  6. python-day9-进程、线程、协程篇

    python threading模块 线程有两种调用方式: 直接调用 import threading import time def sayhi(num): #定义每个线程要运行的函数 print( ...

  7. 【旧文章搬运】Windows句柄表分配算法分析(一)

    原文发表于百度空间,2009-03-30========================================================================== 阅读提示: ...

  8. 【旧文章搬运】Windows内核常见数据结构(基本类型)

    原文发表于百度空间,2008-7-23 ========================================================================== 学内核从基 ...

  9. CS231n 2016 通关 第二章-KNN 作业分析

    KNN作业要求: 1.掌握KNN算法原理 2.实现具体K值的KNN算法 3.实现对K值的交叉验证 1.KNN原理见上一小节 2.实现KNN 过程分两步: 1.计算测试集与训练集的距离 2.通过比较la ...

  10. 出现ImportError: No module named win32api异常

    ImportError: No module named win32api出现异常 实际是需要安装和自己python兼容的win32all 在http://starship.python.net/cr ...