LVS基本远离、LVS类型、LVS调度算法、NAT模型的实现、DR模型的实现、VIP和RIP不在同一网段实现要点。

LVS持久连接:

  持久连接模版:

    -p 600

  PPC

  PCC

  PNFM

  ipvs:

    -t: TCP

    -u: UDP

    -f MARK

      # iptables -t mangle -A PREROUTING -d $VIP -p tcp --dport $ClusterPORT -i $INCARD -j MARK --set-mark 10

    port affinity: 端口姻亲

Health check

heartbeat 心跳

pacemaker 起搏器

Active/Passive

Primary/Standby

HA Resource 高可用资源

IP,Service,STONITH

FailOver: 故障转移

资源粘性:资源更倾向运行于哪个节点;

FailBack 转回

Messaging Layer 集群服务信息层,传递集群节点信息层次,仅是负责传递信息,并不负责信息计算和比较;

CRM:Cluster Resource Manager,资源管理器;

DC: Designated Coordinator 指定协调员

PE: Policy Engine 策略引擎

TE: Transaction Engine 事物引擎

LRM: Local Resource Manager 本地资源管理器

LSB:start|stop|restart|status

  符合Linux Standard Base标准库脚本

RA: Resource Agent 资源代理;

RG:Resource Group 资源组;

HA:

资源粘性:

资源约束:Contraint约束;

  排列约束:(colation)

    资源是否能够运行于同一节点

      score:

        正值: 可以在一起

        负值: 不能在一起

  位置约束: (location), score(分数)

    正值:倾向于此节点

    负值:倾向于逃离于此节点

  顺序约束: (order)

    定义资源启动或关闭时的次序

    vip, ipvs

      ipvs-->vip

-inf: 负无穷

inf: 正无穷

资源隔离:

  节点级别:STONITH

  资源级别:

    例如:FC SAN switch可以实现在存储资源级别控制某节点访问;

STONITH: 爆头

HA MySQL

vip: Float IP流IP

  vip: Float IP

  mysql service

  Filesystem

DAS

  split-brain: 脑列,集群节点无法有效获取其它节点的状态信息,产生脑列;

    后果之一:抢占共享存储

active/active: 高可用集群

HA HTTP

  vip2:

  http service

  File system

Cluster Filesystem: 集群文件系统

集群文件系统:

  GFS

  OCFS2

IDE:(ATA), 133M

SATA: 600M

  7200rpm

  IOPS: 100

SCSI: 320M

SAS:

  15000rpm

  IOPS: 200

USB 3.0: 400M

机械:

  随机读写

  顺序读写

固态:

IDE, SCSI: 并口

SATA, SAS, USB:串口

DAS:

  Direct Attached Storage

  直接附加存储,直接接到本机主板总线,BUS

    文件:块
NSA:
  Network Storage Attached

  网络附加存储

  文件服务器:文件级别

SAN: 将本地总线上的数据转换成能够通过网络发送,延长DAS设备传输距离的共享存储设备,而且支持多节点同时接入使用;

  Storage Area network

  存储区域网络

    FC SAN 光网络

    IP SAN: iSCSI

SCSI: Small Computer System Interface,内部有控制芯片,能够自动控制进行计算;

控制器: Controller

适配器: Adapter

DMA

宽带

  16:

  15: target

窄带

  8

  7: target

LUN: Logical Unit Number 逻辑单元号

FC 光钎

ISCSI Internet SCSI

Multipath

仲裁磁盘

HA Service

Director:

VIP

ipvs

watchdog 看门狗

高可用集群基本结构:

高可用集群指的是一个主机给他提供一个备节点,而且高可用集群让两个节点始终运行没有特别大的意义,因为高可用集群的主要目的是为了提供高可用服务的,一个高可用服务有可能会有很多集群资源组成,比如为了提供一个ipvs的Director高可用集群,一般需要VIP和ipvs规则,所以只要保证这两个资源同时运行在某个节点上就意味着,而且为这样一个节点提供一个备节点,万一当前这个节点发生故障的时候,能够将这两个资源运行在一个备用节点上的这种机制,我们就可以把她称为叫做高可用服务,或者我们就为这个高可用服务提供了高可用的能力,但现在问题是怎么能够让两个节点上的服务具备高可用能力,首先无论是节点故障,还是某个资源发生故障,我们都必须要能让我们的集群检测到,并且能够发现出现故障的时候采取相应的动作,于是集群当中每一个节点彼此之间必须要能够传递集群事物信息,所以需要在它们上面装一个层次叫做集群事物层,两个节点能够在事物层之间完成信息传递(Messaging Layer),集群事物信息所涉及的内容方方面面,真正信息传递完成以后,我们必须要提供资源管理的功能,Messaging Layer向上层提供了一个所谓的资源管理器层(CRM),CRM主要作用是提供资源管理的,它可以监控每个高可用服务资源,而且可以统计所有节点的状态信息,一旦发现某个节点故障可以发现实现资源转移,资源转移之前还可以根据资源的属性来判定下次转移的时候选择什么样的节点,万一原有的节点恢复以后,是否将原有的资源回转到原来的节点上,都由CRM配置的,所以CRM是一个能够利用Messaging Layer所传递集群事物信息,收集集群事物信息,并作出相应的高可用决策的工具,在CRM上层运行的是RA(资源代理),CRM通过本地内部的LRM来指挥RA针采取相应的动作,RA有很多个,RA就是一堆的脚本,这个脚本能够支持接受四种参数,start、stop、status、restart,这就是高可用集群的层次,资源代理的主要目的是能够接受CRM中LRM传递过来的指令在当前节点上对某个资源采取相应动作的,这个动作包括stop、start、restart、status,最起码是这四种其中之一,当一个资源代理start的时候无非就是将这个资源配置在当前节点上了,如果说没有CRM,没有RA的话,我们能否使用高可用服务,Messaging Layer可以实现集群基本的信息事物,包括心跳信息的传递,心跳信息传递的结果是我们可以判定一个节点是不是在线,CRM根据Messaging Layer才能判断那个节点在线,那个节点不在线,其次它能够代为管理每一个资源,每一个资源它有一个资源代理来实现对那个资源进行管理,由此CRM利用Messaging Layer功能将每一个RA的管理得以实现,如果没有CRM,高可用集群能不能工作起来,如果开发一款软件,这个软件自己它可以利用Messaging Layer功能,自己去收集每一个节点的相关信息,而后当它发现某一个节点出现故障的时候,它会自动的转移其它节点上去运行,为什么非得把CRM独立出来,难道不能开发一个直接利用Messaging Layer自我实现管理的所有功能吗,简单来讲我提供一个CRM,但是在这个CRM的基础上我们仅仅提供一种高可用服务,我们的RA只有有限的两个,比如VIP和ipvs,别的服务都不提供了,就是提供一个Director高可用集群的,那干脆开发一个软件本身就已经最有这三种能力行不行,它自己具有CRM功能,自己又能够管理RA,自己能够管理相应的资源,没有CRM可以实现集群服务,只不过前提是它自己要能够管理,而这种能够利用Messaginng Layer自我实现高可用集群服务的软件称为ha-aware application软件,这种软件直接调用Messaging Layer所提供的信息传递功能足以实现高可用服务,如果某一个软件,某一个服务自身不具备ha-aware的,那它就必须要借助CRM了,对非ha-aware的程序它们必须要借助于CRM实现,所以CRM的主要目的是就是将那些本身不具备ha功能的,没有ha能力的服务也能够工作在ha的场景当中,也能够提供ha的功能,所以CRM是个通用层,将那些所有期望应用,提供高可用服务,但本身不具备高可用能力的应用程序得以实现提供高可用的功能,这就是CRM的意义,RA本身都是一堆的脚本,只要能够遵循LSB格式,它们都能够实现用于代为管理某一个特定服务,我们怎么能够实现将某个特定地址,指定的地址配置在某个活动节点上,而一旦发生故障它还能够自动流转到其它节点上去,并且还能够实现自我监控,该怎么实现,一般说来很多高可用集群都自动提供有这种脚本,我们可以拿来直接调用,两个节点之间如果某个节点发生了故障,其中某个节点探测到另外一个节点发生了故障,它就应该取而代之,备节点探测到主节点发生故障应该取代那个节点,但问题是当主节点发生故障的时候,它怎么知道是不是自己故障而是对方故障,要借助额外的工具,比如网关,每一个节点当探测到对方的时候开始尝试自己能不能Ping通网关,只要是互联网上长期在线的网关,只要能Ping通都可以作出决策,所以单反能Ping通这个网关,我们都可以认为自己是活动的,于是就可以隔离对方,这是一种方式,第二种方式还可以利用另一种机制叫做仲裁磁盘的机制,我们不停往一个设备上写数据,我们的被节点就始终检测着我们主节点是否写数据,一旦检测不到,或者一旦我能访问这个磁盘,但却发现不了主节点往磁盘写数据,就可以认为主节点故障了,还会有第三种方式它利用linux内核中的功能叫做watchdog(看门狗),使用watchdog协调两个进程,但是一般说来watchdog只能用来协调同一个节点多个不同的进程,用在分布式结构的时候可能稍微麻烦一点,watchdog简单来讲它是一个设备,跟我们中间的仲裁磁盘一样,它一般在某个节点上用来协调两个进程的,每一个进程在启动以后要通过一个unix的套接字管道不停向watchdog中写数据,比如每隔5秒钟向它发一个数据,如果其它进程发现不了这个对应的进程在写数据,就认为这个进程挂掉了,会试图重启那个进程,所以它只不过用来协调同一个节点上的多个不同进程的,不是我们用来协调多个节点或者节点上的不同进程的,但是在有些场景下经过特殊改造watchdog也能发挥作用;

资源粘性:资源对某节点的依赖程序,通过score定义,服务倾向于那个节点上,或者对那个节点的依赖值;

资源约束:

  location: 位置约束,资源对节点倾向程度;

  coloation: 排列约束,资源间的互斥性,两个资源是不是倾向运行在一起,还是倾向于分开;

  order: 顺序约束,资源的采取动作的次序,资源的启动或关闭次序;

如果有三个集群,这三个集群也是通过Message Layer互相传递集群信息,传递心跳信息,如果只有两个节点只要向对方传递就可以了,如果有三个节点,我们可以把这三个节点定义同一个组播网络内,而后大家通过一个组播地址互相向其它任意节点传递自己的心跳信息,因此每一个节点将监控所有的其它节点,如果有三个节点当某节点跟其它节点无法通信的时候,比如a节点跟b节点能通信,但是联系不到c节点的时候,我们就能决策出来肯定是c的问题,因此可以定义这个集群有所谓的法定票数,c就不认为自己是集群了,如果它不认自己是集群,但它上面又运行有服务怎么办,a、b、c能够所谓的仲裁事物,为了能够决定集群事物,集群下一步的走向,我们必须有一个机制能够收集其中各节点的信息,并计算出来谁是合法的谁是不合法的,有这么个主导的主机DC,所以它们在CRM资源管理器当中推选出来一个所谓的DC(指派的事物协调员),它负责有通过PE策略引擎来计算策略,它随时观察当前集群中每一个状况,收集每个节点状况,并决定当前我们的集群节点是什么样子,万一它发现c节点联系不上了,当前集群事物要采取一定动作,而且要重新计算法定票数,重新计算下一个稳定状态,我们c在的时候处于稳定状态,当c走了,这时候发现c上面的资源怎么办,于是有这么个协调员把资源分配以后接下来又进入下一次稳定状态,由此像我们从一种状态转换到另外一种状态等等,这一切事物决策都由DC来完成,不巧的是如果DC刚好运行在c上面,怎么办,a和b发现自己是大于法定票数的,于是在CRM的主导下重新选择DC,于是这个DC再为当前集群做决策,做信息收集,做状态计算,做下一步集群事物的转换结果,将对应的该在c上运行的资源给它收回来转移到当前正处于活动状态的节点上去以实现正常提供服务的,如果有四个节点,a和b找不到c和d了,c和d找不到a和b怎么办,脑列,它们都认为自己合法的,但事实上都不合法,这个法定票数必须要大于半数,所以a、b能通信,c、d能通信,彼此间不能通信,那最后的结果集群挂了,因为a和b也认为自己不是集群,c和d认为自己也不是集群,所以它们各自都等待对方对自己作出判决,但是没人来判决,也没有人始终把我们资源收回去,如果我们直接把资源停掉,如果正在有人访问,我们现在没有集群的功能了该怎么办,我们的服务就挂了,所以当我们一旦不具备集群能力的时候,接下来该采取什么动作,也很关键,这个资源别人没有收回,我们当前也不在是一个合法的集群了,a和b在一块,c和d在一起,并且彼此都不是合法的集群,如果我们直接把自己的资源统统挂掉,意味着前端的用户访问都无法进来了,这也不一定合适,我们必须要定义当一个节点,或者一些节点它们认为自己不再是集群中的节点的时候,应该采取什么样的动作,这些动作包括,比如像freeze冻结,不再接收新的请求但是当前连接的请求将持续提供服务,一旦不具备法定票数应该怎么办,按道理来讲正常情况下应该,假如a、b、c都能够正常,d发现自己不正常了,我们还应该想外提供服务,d不需要服务,只不过a、b、c是正常的,但是我们避免出现一种独特的状况,我们可以定义集群工作在freeze模式下,一旦我们不具备集群功能了,服务不停止,只是冻结了,不再接收新的请求,那么新的请求都到a、b、c上去了,所以最理想的状况,应该是stop的,应该把集群停掉,这是最理想的状况,一旦我们为了避免这种理想状况,我们用户出现这种脑列的情况,各自都不具备法定票数的时候,整个集群都down掉,我们可以使用freeze,而在某些特殊场景下我们可以使用ignore,不管有没有法定票数,我的集群服务该运行还是运行,假如只有两个节点,无论任何一个节点跟对方通信不了了,都不具备法定票数,这个时候就俩节点,我们本来的目的被节点就是取代主节点,只要主节点故障了,一旦主节点故障了,被节点联系不上了,被节点发现自己不具备法定票数了,于是也不启动了,怎么办,那就没有意义了,所以两节点的时候必须要定义它们成为ignore模型,这个叫做集群全局资源策略,当全局资源不具备法定票数的时候,资源管理策略;

without_quorum_policy

  quorum: 法定票数,

  freeze: 冻结

  stop: 停止

  ignore: 忽略

一般说来一个高可用集群一定要使用隔离设备,就算VIP地址也会资源征用的,只不过没有特别大的危害而已,资源隔离设备通常是必须的,只不过在没有特别大危害场景下不提供也能说的过去;

failover domain: 故障转移域

N-m:N个节点,运行m个服务;

N-n: N个节点,运行n个服务;

CRM是集群资源管理器,它存在的主要目的是让那些非ha-aware的程序可以具备ha-aware的HA功能,事实上CRM本身也是个程序,只不过这个程序依赖于Messaging Layer,而且是个通用平台,它可以向其它的RA提供高可用能力,由此CRM有多少种实现方式,Messaging Layer有多少种实现方式,以及RA有多少种实现方式;

RHCS: RedHat Cluster Suite

Messaging Layer

  heartbeat (v1,v2,v3)

    heartbeat v3

      heartbeat, pacemaker(集群资源管理器),cluster-glue

  corosync

  cman

  keepalived

  ultramokey

CRM

  haresource, crm(heartbeat v1/v2)

  pacemaker(heartbeat v3/corosync)

  rgmanager(cman)

Heartbeat v1 自带资源管理器

  haresources: ha资源管理

Heartbeat v2 自带的资源管理器

  haresources 兼容v1版本ha资源管理

  crm

Heartbeat v3: 资源管理器crm发展为独立的项目,pacemaker(心脏起搏器)

Resource Type:

  Primitive: 主资源,主资源指的是在某一时刻只能运行于一个节点上的资源

  clone: 克隆资源,克隆资源指的是把主资源克隆N份,在我们集群中指定节点上每一个节点上都同时要运行的资源

  group: 组,是将资源归类,合并到一起当作一个单位同进同退的独特的资源,是个资源容器,而且组中只包含Primitive类型资源

  master/slave: 主从,是一种独特克隆类资源,它只能具有两份,只能运行在两个节点上,而且这两个节点有主从关系,

RA: Resource Agent 资源代理,RA在每个节点都由它是一堆脚本,平时它可能不执行,但一旦我们的集群资源管理器CRM发现需要在B节点上启动某一个资源了,调用资源代理上的start就启动起来了,启动起来以后还要随时监控它,让status去监控,所以资源代理是实现让CRM能够将某个定义成了高可用集群资源的资源能够被管理的,它接受LRM传递过来的控制指令完成对应的资源管理;

LRM: 本地资源管理器,

RA Classes:

  Legacy heartbeat v1 RA

  LSB(/etc/rc.d/init.d/都是遵循LSB脚本)

  OCF(Open Cluster Framework)

    pacemaker

    limbit (drbd)

  stonith

隔离级别:

  节点级别

    STONTIH

  资源级别

    FC SAN Switch

STONTH

Stonith设备

1、Power Distribution Units (PDU)(电源分布单元)

Power Distribution Units are an essential element in managing power capacity and functionality for critical network, server and data center equipment. They can provide remote load monitoring of connected equipment and individual outlet power control for remote power recycling.

2、Uninterruptible Power Supplies (UPS)(不间断电源)

A stable power supply provides emergency power to connected equipment by supplying power from a separate source in the event of utility power failure.

3、Blade Power Control Devices(刀片服务器电源控制设备)

If you are running a cluster on a set of blades, then the power control device in the blade enclosure is the only candidate for fencing. Of course, this device must be
capable of managing single blade computers.

4、Lights-out Devices(轻量级别)

Lights-out devices (IBM RSA, HP iLO, Dell DRAC) are becoming increasingly popular and may even become standard in off-the-shelf computers. However, they are inferior to UPS devices, because they share a power supply with their host (a cluster node). If a node stays without power, the device supposed to control it would be just as useless. In that case, the CRM would continue its attempts to fence the node indefinitely while all other resource operations would wait for the fencing/STONITH operation to complete.

5、Testing Devices(测试设备)

Testing devices are used exclusively for testing purposes. They are usually more gentle on the hardware. Once the cluster goes into production, they must be replaced
with real fencing devices.

ssh 172.16.100.1 'reboot'

meatware


STONITH的实现:

stonithd(是用来监控当前主机上所运行的STIONITH资源的,可以让各节点之间让多个STONITH进程互相通信的一种机制,STONITH的命令是作为STONITH插件在工作)

stonithd is a daemon which can be accessed by local processes or over the network. It accepts the commands which correspond to fencing operations: reset, power-off, and power-on. It can also check the status of the fencing device.

The stonithd daemon runs on every node in the CRM HA cluster. The stonithd instance running on the DC node receives a fencing request from the CRM. It is up to this and other stonithd programs to carry out the desired fencing operation.

STONITH Plug-ins(STONITH 插件)

For every supported fencing device there is a STONITH plug-in which is capable of controlling said device. A STONITH plug-in is the interface to the fencing device.

On each node, all STONITH plug-ins reside in /usr/lib/stonith/plugins (or in /usr/lib64/stonith/plugins for 64-bit architectures). All STONITH plug-ins look the same to stonithd, but are quite different on the other side reflecting the nature of the fencing device.

Some plug-ins support more than one device. A typical example is ipmilan (or external/ipmi) which implements the IPMI protocol and can control any device which supports this protocol.

 

epel

heartbeat - Heartbeat subsystem for High-Availability Linux

heartbeat-devel - Heartbeat development package

heartbeat-gui - Provides a gui interface to manage heartbeat clusters

heartbeat-ldirectord - Monitor daemon for maintaining high availability resources, 为ipvs高可用提供规则自动生成及后端realserver健康状态检查的组件;

heartbeat-pils - Provides a general plugin and interface loading library

heartbeat-stonith - Provides an interface to Shoot The Other Node In The Head


http://dl.fedoraproject.org/pub/epel/5/i386/repoview/letter_h.group.html

假如现在要做一个httpd的高可用集群,首先至少需要两个节点,上面安装一个Message Layer,双方节点要能够互相通信,还要定义它们的通信机制,所以可以让每一个节点集群Message Layer,它必须要能够开机自动启动,它本身也作为一个服务存在,而且通常会监听在UDP的某个端口上,让各个节点互相发送传递心跳信息和集群事物信息,对Heartbeat而言,这个端口通常是UDP的64号端口,

Heartbeat

  UDP:694

ha web

  vip

  httpd server

  File System

[root@localhost ~]# grep 694 /etc/services(查看services文件包含694字符串的段)
ha-cluster	694/tcp				# Heartbeat HA-cluster(heartbeat)
ha-cluster	694/udp				# Heartbeat HA-cluster(heartbeat)
rrimwm		1694/tcp			# rrimwm
rrimwm		1694/udp			# rrimwm
pwrsevent	2694/tcp			# pwrsevent
pwrsevent	2694/udp			# pwrsevent
vpntpp		3694/tcp			# VPN Token Propagation Protocol
vpntpp		3694/udp			# VPN Token Propagation Protocol
bioserver	6946/tcp			# Biometrics Server
bioserver	6946/udp			# Biometrics Server

rhel 5.8 32bit

  heartbeat v2

    ha web

    node1,node2

      节点名称,/etc/hosts

        节点名称必须跟uname -n命令的执行结果一致

      ssh互信通信

      时间同步

hartbeat官方站点:

http://linux-ha.org/wiki/Heartbeat

http://clusterlabs.org/

epel

heartbeat - Heartbeat subsystem for High-Availability Linux(heartbeat核心包)

heartbeat-devel - Heartbeat development package(开发包)

heartbeat-gui - Provides a gui interface to manage heartbeat clusters(图形接口,用于管理headbeat集群的)

heartbeat-ldirectord - Monitor daemon for maintaining high availability resources, (为ipvs高可用提供规则自动生成及后端realserver健康状态检查的组件)

heartbeat-pils - Provides a general plugin and interface loading library((装载库通用插件和接口)

heartbeat-stonith - Provides an interface to Shoot The Other Node In The Head(用于实现爆头接口)

http://dl.fedoraproject.org/pub/epel/5/i386/repoview/letter_h.group.html(heartbeat下载地址)

heartbeat三个配置文件:

1、密钥文件,(600权限, authkeys)

2、heartbeat服务的配置文件ha.cf

3、资源管理配置文件

haresources

环境:HA1的IP地址为172.16.100.6,HA2的IP地址为172.16.100.7,vip的IP为172.16.100.1;

HA1:

[root@localhost ~]# ifconfig eth0(查看eth0接口信息)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:215612 errors:0 dropped:0 overruns:0 frame:0
          TX packets:242146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:18006586 (17.1 MiB)  TX bytes:29369795 (28.0 MiB)
          Interrupt:67 Base address:0x2000 

HA2:

[root@localhost ~]# ifconfig eth0(查看eth0接口信息)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:8A:44:AB  
          inet addr:172.16.100.7  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8a:44ab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4937 (4.8 KiB)  TX bytes:21568 (21.0 KiB)
          Interrupt:67 Base address:0x2000 

[root@localhost ~]# ping 172.16.100.6(ping测试)
PING 172.16.100.6 (172.16.100.6) 56(84) bytes of data.
64 bytes from 172.16.100.6: icmp_seq=1 ttl=64 time=5.20 ms
64 bytes from 172.16.100.6: icmp_seq=2 ttl=64 time=0.200 ms
64 bytes from 172.16.100.6: icmp_seq=3 ttl=64 time=0.267 ms

--- 172.16.100.6 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.200/1.890/5.205/2.344 ms

提示:Ping测试到达HA1主机地址,可达;

HA1:

[root@localhost ~]# hostname node1.magedu.com(修改主机名为node1.magedu.com)
[root@localhost ~]# hostname(查看主机名)
node1.magedu.com
[root@localhost ~]# uname -n(查看主机名)
node1.magedu.com
[root@localhost ~]# vim /etc/sysconfig/network(修改network配置文件)

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=node1.magedu.com(修改主机名为node1.magedu.com)

HA2:

[root@localhost ~]# hostname node2.magedu.com(修改主机名为node2.magedu.com)
[root@localhost ~]# uname -n(查看主机名)
node2.magedu.com
[root@localhost ~]# vim /etc/sysconfig/network(修改network配置文件)

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=node2.magedu.com

HA1:

[root@node1 ~]# man ssh-keygen(查看ssh-keygen的man帮助文档)

     ssh-keygen - authentication key generation, management and conversion

     ssh-keygen [-q] [-b bits] -t(指定类型) type [-N new_passphrase] [-C comment] [-f output_keyfile](指定输出的文件)
     ssh-keygen -p(指定密码) [-P old_passphrase] [-N new_passphrase] [-f keyfile]
     ssh-keygen -i [-f input_keyfile]
     ssh-keygen -e [-f input_keyfile]
     ssh-keygen -y [-f input_keyfile]
     ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
     ssh-keygen -l [-f input_keyfile]
     ssh-keygen -B [-f input_keyfile]
     ssh-keygen -D reader
     ssh-keygen -F hostname [-f known_hosts_file]
     ssh-keygen -H [-f known_hosts_file]
     ssh-keygen -R hostname [-f known_hosts_file]
     ssh-keygen -U reader [-f input_keyfile]
     ssh-keygen -r hostname [-f input_keyfile] [-g]
     ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
     ssh-keygen -T output_file -f input_file [-v] [-a num_trials] [-W generator]

[root@node1 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''(生成一对密钥,-t指定加密算法类型rsa或dsa,-f指定私钥文件保存位置,-P指定密码)
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
83:91:07:dc:b4:c1:5d:da:2d:b9:5b:42:27:b3:ce:84 root@node1.magedu.com
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@172.16.100.7(通过ssh-copy-id将.ssh/id_rsa.pub公钥文件复制到远程主机172.16.100.7,以root
用户登录,-i指定公钥文件)  
15
The authenticity of host '172.16.100.7 (172.16.100.7)' can't be established.
RSA key fingerprint is ae:84:06:36:5b:88:0e:22:9f:16:04:cc:b3:ee:f3:ae.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.100.7' (RSA) to the list of known hosts.
root@172.16.100.7's password: 
Now try logging into the machine, with "ssh 'root@172.16.100.7'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
[root@node1 ~]# ssh 172.16.100.7 'ifconfig'(通过ssh远程执行172.16.100.7的ifconfig命令)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:8A:44:AB  
          inet addr:172.16.100.7  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8a:44ab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:501 errors:0 dropped:0 overruns:0 frame:0
          TX packets:531 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:52055 (50.8 KiB)  TX bytes:73406 (71.6 KiB)
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2616 (2.5 KiB)  TX bytes:2616 (2.5 KiB)

HA2:

[root@node2 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''(生成一对密钥,-t指定加密算法类型rsa或dsa,-f指定私钥文件保存位置,-P指定密码)
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
71:e9:dc:08:7c:7f:d5:4f:a9:f7:d8:20:01:cc:5a:8d root@node2.magedu.com
[root@node2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@172.16.100.6(通过ssh-copy-id将.shh/id_rsa.pub公钥文件复制到远程主机172.16.100.6,以root
用户登录,-i指定公钥文件) 
15
The authenticity of host '172.16.100.6 (172.16.100.6)' can't be established.
RSA key fingerprint is ea:32:fd:b5:e6:d2:75:e2:c2:c2:8c:63:d4:82:4c:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.100.6' (RSA) to the list of known hosts.
root@172.16.100.6's password: 
Now try logging into the machine, with "ssh 'root@172.16.100.6'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
[root@node2 ~]# ssh 172.16.100.6 'ifconfig'(通过ssh远程执行172.16.100.6主机的ifconfig命令)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:217065 errors:0 dropped:0 overruns:0 frame:0
          TX packets:243305 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:18151181 (17.3 MiB)  TX bytes:29525009 (28.1 MiB)
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:49468 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49468 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4221674 (4.0 MiB)  TX bytes:4221674 (4.0 MiB)

提示:双机互信已经完成;

HA1:

[root@node1 ~]# vim /etc/hosts(编辑hosts本机解析文件)

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
172.16.100.6    node1.magedu.com node1(添加node1主机地址解析)
172.16.100.7    node2.magedu.com node2(添加node2主机地址解析)

[root@node1 ~]# ping node2(ping测试node2主机)
PING node2.magedu.com (172.16.100.7) 56(84) bytes of data.
64 bytes from node2.magedu.com (172.16.100.7): icmp_seq=1 ttl=64 time=5.75 ms
64 bytes from node2.magedu.com (172.16.100.7): icmp_seq=2 ttl=64 time=0.339 ms

--- node2.magedu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.339/3.047/5.755/2.708 ms

提示:Ping测试到达node2主机可达,可以正常解析主机名和IP地址对应关系;
[root@node1 ~]# scp /etc/hosts node2:/etc/(复制本地文件hosts到node2主机/etc目录)
The authenticity of host 'node2 (172.16.100.7)' can't be established.
RSA key fingerprint is ae:84:06:36:5b:88:0e:22:9f:16:04:cc:b3:ee:f3:ae.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2' (RSA) to the list of known hosts.
hosts                                                                                                     100%  259     0.3KB/s   00:00 

HA2:

[root@node2 ~]# ping node1(ping测试到达node1主机)
PING node1.magedu.com (172.16.100.6) 56(84) bytes of data.
64 bytes from node1.magedu.com (172.16.100.6): icmp_seq=1 ttl=64 time=2.27 ms
64 bytes from node1.magedu.com (172.16.100.6): icmp_seq=2 ttl=64 time=0.238 ms
64 bytes from node1.magedu.com (172.16.100.6): icmp_seq=3 ttl=64 time=0.194 ms

--- node1.magedu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.194/0.902/2.275/0.971 ms

提示:Ping测试到达node1主机可达,可以正常解析主机名和IP地址对应关系;

HA1:

[root@node1 ~]# iptables -L(查看filter表中的规则)
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

提示:确保iptables没有相关的规则限定;

HA2:

[root@node2 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  

提示:确保iptables没有相关的规则限定;

HA1:

[root@node1 ~]# date(查看系统时间)
Mon Mar 14 23:59:10 CST 2016

HA2:

[root@node2 ~]# date(查看系统时间)
2016年 04月 06日 星期三 07:01:16 CST

HA1:

[root@node1 ~]# ntpdate 172.16.0.1(通过ntp服务器同步时间)
 5 Apr 23:16:19 ntpdate[29167]: no servers can be used, exiting
[root@node1 ~]# service ntpd stop(停止ntpd服务)
Shutting down ntpd:                                        [  OK  ]
[root@node1 ~]# chkconfig ntpd off(关闭ntpd服务在相应系统级别开机自动启动)

HA2:

[root@node2 ~]# service ntpd stop(停止ntpd服务)
关闭 ntpd:                                                [确定]
[root@node2 ~]# chkconfig ntpd off(关闭ntpd服务在相应系统级别开机自动启动)

提示:在将来使用建议使用ntpd服务同步时间,这种调整时间比较柔和;

HA1:

[root@node1 ~]# ntpdate 172.16.0.1(通过ntp服务器同步时间)
 5 Apr 23:15:40 ntpdate[6056]: step time server 172.16.100.6 offset -28710.971507 sec
[root@node1 ~]# date(查看系统时间)
Tue Apr  5 23:27:41 CST 2016

HA2:

[root@node2 ~]# ntpdate 172.16.0.1(通过ntp服务器同步时间)
 5 Apr 23:15:40 ntpdate[6056]: step time server 172.16.100.6 offset -28710.971507 sec
[root@node2 ~]# date(查看系统时间)
2016年 04月 05日 星期二 23:27:48 

HA1:

[root@node1 ~]# crontab -e(定义当前用户cron任务)

*/5 * * * * ntpdate 172.16.0.1(每5分钟到ntp服务器172.16.0.1同步一次时间)

no crontab for root - using an empty one
crontab: installing new crontab
提示:保证以后时间尽可能同步,可以写任务计划,crontab的配置信息比较独特,它的很多命令找的时候,它的PATH环境变量只保护/bin和/sbin两个目录,其它目录可能会找不到,
有时候可能也会保护/usr/bin和/usr/sbin,最好确保ntpdate在这些目录下,或者使用绝对路径;
[root@node1 ~]# which ntpdate(查看ntpdate二进制文件路径)
/sbin/ntpdate
[root@node1 ~]# crontab -e(定义当前用户cron任务)

*/5 * * * * /sbin/ntpdate 172.16.0.1 &> /dev/null(这样的任务计划,每执行一次都会给管理员发送邮件,不想收邮件将结果送给/dev/null)

[root@node1 ~]# scp /var/spool/cron/root node2:/var/spool/cron/(复制root文件到node2主机的/var/spool/cron目录)
root                                                                                            100%   50     0.1KB/s   00:00 
提示:每个用户的cron任务在/var/spool/cron目录和用户名同名;

HA2:

[root@node2 ~]# crontab -l(列出当前用户cron任务)
*/5 * * * * /sbin/ntpdate 172.16.0.1 &> /dev/null

提示:好不容易做好了两个节点,以后发现服务配置错了,想重新配置一次,完全还要重新开始,为了避免这种情况可以把它快照一下;

对HA1和HA2的主机做VMware快照;

HA1:

[root@node1 ~]# lftp 172.16.0.1/pub/Sources(连接ftp服务器)
cd ok, cwd/pub/Sources
lftp 172.16.0.1:/pub/Sources> cd Hearbeat2(切换到Hearbeat2目录)
lftp 172.16.0.1:/pub/Sources/Hearbeat2> cd i386/(切换到i386目录)
lftp 172.16.0.1:/pub/Sources/Hearbeat2/i386> cd ..(切换到上级目录)
lftp 172.16.0.1:/pub/Sources/Hearbeat2> mirror i386/(将i386目录文件镜像到本地)
Total: 1 directory, 7 files, 0 symlinks
New: 7 files, 0symlinks
2601305 bytes transferred
lftp 172.16.0.1:/pub/Sources/Hearbeat2> get perl-MailTools-1.77-1.el5.noarch.rpm(下载perl-MailTools软件)
92071 bytes transferred
lftp 172.16.0.1:/pub/Sources/Hearbeat2> bye(推出)

提示:在安装hearbeat-2.1.4相关版本的时候,需要先安装libnet以及perl-MailTools;
[root@node1 ~]# rpm -ivh perl-MailTools-1.77-1.el5.rf.noarch.rpm(安装perl-MailTools软件,-i安装,-v显示过程,-h显示进度条)
warning: perl-MailTools-1.77-1.el5.rf.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
error: Failed dependencies:
	perl(Date::Format) is needed by perl-MailTools-1.77-1.el5.rf.noarch
	perl(Date::Parse) is needed by perl-MailTools-1.77-1.el5.rf.noarch

提示:有依赖关系;
[root@node1 ~]# wget ftp://172.16.0.1/pub/gls/server.repo -O /etc/yum.repos.d/server.repo(通过互联网下载server.repo保存到/etc/yum.repos.d目
录叫server.repo,-O更改保存目录)
[root@node1 ~]# yum --nogpgcheck localinstall perl-MailTools-1.77-1.el5.rf.noarch.rpm(通过yum源安装本地rpm软件包,--nogpgcheck不进行gpg校验,
localinstall安装本地的rpm软件包) 
[root@node1 ~]# cd i386/(切换到i386目录)
[root@node1 i386]# ls(查看当前目录文件及子目录)
heartbeat-2.1.4-9.el5.i386.rpm        heartbeat-gui-2.1.4-9.el5.i386.rpm         heartbeat-pils-2.1.4-10.el5.i386.rpm     
libnet-1.1.4-3.el5.i386.rpm           heartbeat-devel-2.1.4-9.el5.i386.rpm       heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
heartbeat-stonith-2.1.4-10.el5.i386.rpm
[root@node1 i386]# ll(查看当前目录文件及子目录详细信息)
total 2608
-rw-r--r-- 1 root root 1637238 Apr  6 01:15 heartbeat-2.1.4-9.el5.i386.rpm
-rw-r--r-- 1 root root  293349 Apr  6 01:15 heartbeat-devel-2.1.4-9.el5.i386.rpm
-rw-r--r-- 1 root root  230890 Apr  6 01:15 heartbeat-gui-2.1.4-9.el5.i386.rpm
-rw-r--r-- 1 root root  111742 Apr  6 01:15 heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
-rw-r--r-- 1 root root   92070 Apr  6 01:15 heartbeat-pils-2.1.4-10.el5.i386.rpm
-rw-r--r-- 1 root root  179199 Apr  6 01:15 heartbeat-stonith-2.1.4-10.el5.i386.rpm
-rw-r--r-- 1 root root   56817 Apr  6 01:15 libnet-1.1.4-3.el5.i386.rpm
[root@node1 i386]# rpm -ivh heartbeat-2.1.4-9.el5.i386.rpm heartbeat-gui-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm 
heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm(安装heartbeat、heartbeat-gui、heartbeat-pils、hearbeat-stonith、libnet
的rpm包,-i安装,-v显示安装过程,-h显示进度条)
warning: heartbeat-2.1.4-9.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
error: Failed dependencies:
	libltdl.so.3 is needed by heartbeat-2.1.4-9.el5.i386
	libltdl.so.3 is needed by heartbeat-gui-2.1.4-9.el5.i386
	libltdl.so.3 is needed by heartbeat-pils-2.1.4-10.el5.i386
	libltdl.so.3 is needed by heartbeat-stonith-2.1.4-10.el5.i386
	libopenhpi.so.2 is needed by heartbeat-stonith-2.1.4-10.el5.i386

提示:依赖libltdl.so.3和libopenhpi.so.2等包;
[root@node1 i386]# yum --nogpgcheck localinstall  heartbeat-2.1.4-9.el5.i386.rpm heartbeat-gui-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4
-10.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm libnet-1.1.4-3.el5.i386.rpm(通过yum安装heartbeat、heartbeat-gui、heartbeat-pils、
hearbeat-stonith、libnet的rpm包,--nogpgcheck不进行gpg校验,localinstall安装本地rpm软件包)
[root@node1 ~]# scp perl-MailTools-1.77-1.el5.rf.noarch.rpm node2:/root/(复制本地软件包perl-MailTools到node2主机的/root目录)
perl-MailTools-1.77-1.el5.rf.noarch.rpm                                                            100%   85KB  85.1KB/s   00:00 
[root@node1 ~]# cd i386/(切换到i386目录)
[root@node1 i386]# scp heartbeat-2.1.4-9.el5.i386.rpm heartbeat-gui-2.1.4-9.el5.i386.rpm heartbeat-pils-2.1.4-10.el5.i386.rpm libnet-1.1.4
-3.el5.i386.rpm heartbeat-stonith-2.1.4-10.el5.i386.rpm node2:/root/(复制heartbeat、heartbeat-gui、heartbeat-pils、libnet、heartbeat-stoith
到node2主机/root目录)
heartbeat-2.1.4-9.el5.i386.rpm                                                                               100% 1599KB   1.6MB/s   00:00    
heartbeat-gui-2.1.4-9.el5.i386.rpm                                                                           100%  225KB 225.5KB/s   00:00    
heartbeat-pils-2.1.4-10.el5.i386.rpm                                                                         100%   90KB  89.9KB/s   00:00    
libnet-1.1.4-3.el5.i386.rpm                                                                                  100%   55KB  55.5KB/s   00:00    
heartbeat-stonith-2.1.4-10.el5.i386.rpm                                                                      100%  175KB 175.0KB/s   00:00
[root@node1 i386~]# scp /etc/yum.repos.d/server.repo node2:/etc/yum.repos.d/server.repo(复制server.repo到远程主机node2的/etc/yum.repos.d目录
叫server.repo)

HA2:

[root@node2 ~]# yum --nogpgcheck localinstall *.rpm(通过yum安装当前目录所有rpm软件包,--nogpgcheck不进行gpg校验,localinstall安装本地rpm软件包)

HA1:

[root@node1 i386]# cd(切换到用户家目录)
[root@node1 ~]# rpm -ql heartbeat(查看heartbeat安装生产那些文件)
/etc/ha.d(配置文件)
/etc/ha.d/README.config
/etc/ha.d/harc
/etc/ha.d/rc.d(资源相关脚本)
/etc/ha.d/rc.d/ask_resources
/etc/ha.d/rc.d/hb_takeover
/etc/ha.d/rc.d/ip-request
/etc/ha.d/rc.d/ip-request-resp
/etc/ha.d/rc.d/status
/etc/ha.d/resource.d(资源代理脚本)
/etc/ha.d/resource.d/AudibleAlarm
/etc/ha.d/resource.d/Delay
/etc/ha.d/resource.d/Filesystem
/etc/ha.d/resource.d/ICP
/etc/ha.d/resource.d/IPaddr(将VIP配置在某一个活动节点上的节点,而且还能监控IP地址是否生效)
/etc/ha.d/resource.d/IPaddr2
/etc/ha.d/resource.d/IPsrcaddr
/etc/ha.d/resource.d/IPv6addr
/etc/ha.d/resource.d/LVM
/etc/ha.d/resource.d/LVSSyncDaemonSwap
/etc/ha.d/resource.d/LinuxSCSI
/etc/ha.d/resource.d/MailTo
/etc/ha.d/resource.d/OCF
/etc/ha.d/resource.d/Raid1
/etc/ha.d/resource.d/SendArp
/etc/ha.d/resource.d/ServeRAID
/etc/ha.d/resource.d/WAS
/etc/ha.d/resource.d/WinPopup
/etc/ha.d/resource.d/Xinetd
/etc/ha.d/resource.d/apache
/etc/ha.d/resource.d/db2
/etc/ha.d/resource.d/hto-mapfuncs
/etc/ha.d/resource.d/ids
/etc/ha.d/resource.d/portblock
/etc/ha.d/shellfuncs
/etc/init.d/heartbeat
/etc/logrotate.d/heartbeat
/etc/pam.d/hbmgmtd
/usr/bin/cl_respawn
/usr/bin/cl_status
/usr/lib/heartbeat
/usr/lib/heartbeat/BasicSanityCheck
/usr/lib/heartbeat/ResourceManager
/usr/lib/heartbeat/TestHeartbeatComm
/usr/lib/heartbeat/api_test
/usr/lib/heartbeat/apphbd
/usr/lib/heartbeat/apphbtest
/usr/lib/heartbeat/atest
/usr/lib/heartbeat/attrd
/usr/lib/heartbeat/base64_md5_test
/usr/lib/heartbeat/ccm
/usr/lib/heartbeat/ccm_testclient
/usr/lib/heartbeat/cib
/usr/lib/heartbeat/cibmon
/usr/lib/heartbeat/clmtest
/usr/lib/heartbeat/crm.dtd
/usr/lib/heartbeat/crm_commands.py
/usr/lib/heartbeat/crm_commands.pyc
/usr/lib/heartbeat/crm_commands.pyo
/usr/lib/heartbeat/crm_primitive.py
/usr/lib/heartbeat/crm_primitive.pyc
/usr/lib/heartbeat/crm_primitive.pyo
/usr/lib/heartbeat/crm_utils.py
/usr/lib/heartbeat/crm_utils.pyc
/usr/lib/heartbeat/crm_utils.pyo
/usr/lib/heartbeat/crmd
/usr/lib/heartbeat/cts
/usr/lib/heartbeat/dopd
/usr/lib/heartbeat/drbd-peer-outdater
/usr/lib/heartbeat/findif
/usr/lib/heartbeat/ha_config
/usr/lib/heartbeat/ha_logd
/usr/lib/heartbeat/ha_logger
/usr/lib/heartbeat/ha_propagate
/usr/lib/heartbeat/haresources2cib.py
/usr/lib/heartbeat/haresources2cib.pyc
/usr/lib/heartbeat/haresources2cib.pyo
/usr/lib/heartbeat/hb_addnode
/usr/lib/heartbeat/hb_delnode
/usr/lib/heartbeat/hb_setsite
/usr/lib/heartbeat/hb_setweight
/usr/lib/heartbeat/hb_standby
/usr/lib/heartbeat/hb_takeover
/usr/lib/heartbeat/heartbeat
/usr/lib/heartbeat/ipctest
/usr/lib/heartbeat/ipctransientclient
/usr/lib/heartbeat/ipctransientserver
/usr/lib/heartbeat/ipfail
/usr/lib/heartbeat/logtest
/usr/lib/heartbeat/lrmadmin
/usr/lib/heartbeat/lrmd
/usr/lib/heartbeat/lrmtest
/usr/lib/heartbeat/mach_down
/usr/lib/heartbeat/mgmtd
/usr/lib/heartbeat/mgmtdtest
/usr/lib/heartbeat/mlock
/usr/lib/heartbeat/ocf-returncodes
/usr/lib/heartbeat/ocf-shellfuncs
/usr/lib/heartbeat/pengine
/usr/lib/heartbeat/pingd
/usr/lib/heartbeat/plugins
/usr/lib/heartbeat/plugins/AppHBNotification
/usr/lib/heartbeat/plugins/AppHBNotification/recmgr.so
/usr/lib/heartbeat/plugins/HBauth
/usr/lib/heartbeat/plugins/HBauth/crc.so
/usr/lib/heartbeat/plugins/HBauth/md5.so
/usr/lib/heartbeat/plugins/HBauth/sha1.so
/usr/lib/heartbeat/plugins/HBcomm
/usr/lib/heartbeat/plugins/HBcomm/bcast.so
/usr/lib/heartbeat/plugins/HBcomm/mcast.so
/usr/lib/heartbeat/plugins/HBcomm/ping.so
/usr/lib/heartbeat/plugins/HBcomm/ping_group.so
/usr/lib/heartbeat/plugins/HBcomm/serial.so
/usr/lib/heartbeat/plugins/HBcomm/ucast.so
/usr/lib/heartbeat/plugins/HBcompress
/usr/lib/heartbeat/plugins/HBcompress/bz2.so
/usr/lib/heartbeat/plugins/HBcompress/zlib.so
/usr/lib/heartbeat/plugins/RAExec
/usr/lib/heartbeat/plugins/RAExec/heartbeat.so
/usr/lib/heartbeat/plugins/RAExec/lsb.so
/usr/lib/heartbeat/plugins/RAExec/ocf.so
/usr/lib/heartbeat/plugins/RAExec/stonith.so
/usr/lib/heartbeat/plugins/quorum
/usr/lib/heartbeat/plugins/quorum/majority.so
/usr/lib/heartbeat/plugins/quorum/quorumd.so
/usr/lib/heartbeat/plugins/quorum/twonodes.so
/usr/lib/heartbeat/plugins/quorum/weight.so
/usr/lib/heartbeat/plugins/quorumd
/usr/lib/heartbeat/plugins/quorumd/2_0_8.so
/usr/lib/heartbeat/plugins/test
/usr/lib/heartbeat/plugins/test/test.so
/usr/lib/heartbeat/plugins/tiebreaker
/usr/lib/heartbeat/plugins/tiebreaker/twonodes.so
/usr/lib/heartbeat/quorumd
/usr/lib/heartbeat/quorumdtest
/usr/lib/heartbeat/ra-api-1.dtd
/usr/lib/heartbeat/recoverymgrd
/usr/lib/heartbeat/req_resource
/usr/lib/heartbeat/send_arp
/usr/lib/heartbeat/stonithd
/usr/lib/heartbeat/stonithdtest
/usr/lib/heartbeat/stonithdtest/apitest
/usr/lib/heartbeat/tengine
/usr/lib/heartbeat/transient-test.sh
/usr/lib/heartbeat/ttest
/usr/lib/heartbeat/utillib.sh
/usr/lib/libapphb.so.0
/usr/lib/libapphb.so.0.0.0
/usr/lib/libccmclient.so.1
/usr/lib/libccmclient.so.1.0.0
/usr/lib/libcib.so.1
/usr/lib/libcib.so.1.0.1
/usr/lib/libclm.so.1
/usr/lib/libclm.so.1.0.0
/usr/lib/libcrmcommon.so.1
/usr/lib/libcrmcommon.so.1.0.1
/usr/lib/libhbclient.so.1
/usr/lib/libhbclient.so.1.0.0
/usr/lib/libhbmgmt.so.0
/usr/lib/libhbmgmt.so.0.0.0
/usr/lib/libhbmgmtclient.so.0
/usr/lib/libhbmgmtclient.so.0.0.0
/usr/lib/libhbmgmtcommon.so.0
/usr/lib/libhbmgmtcommon.so.0.0.0
/usr/lib/libhbmgmttls.so.0
/usr/lib/libhbmgmttls.so.0.0.0
/usr/lib/liblrm.so.0
/usr/lib/liblrm.so.0.0.0
/usr/lib/libpe_rules.so.2
/usr/lib/libpe_rules.so.2.0.0
/usr/lib/libpe_status.so.2
/usr/lib/libpe_status.so.2.0.0
/usr/lib/libpengine.so.3
/usr/lib/libpengine.so.3.0.0
/usr/lib/libplumb.so.1
/usr/lib/libplumb.so.1.0.0
/usr/lib/libplumbgpl.so.1
/usr/lib/libplumbgpl.so.1.0.0
/usr/lib/librecoverymgr.so.1
/usr/lib/librecoverymgr.so.1.0.0
/usr/lib/libstonithd.so.0
/usr/lib/libstonithd.so.0.0.0
/usr/lib/libtransitioner.so.1
/usr/lib/libtransitioner.so.1.0.0
/usr/sbin/attrd_updater
/usr/sbin/ccm_tool
/usr/sbin/cibadmin
/usr/sbin/ciblint
/usr/sbin/crm_attribute
/usr/sbin/crm_diff
/usr/sbin/crm_failcount
/usr/sbin/crm_master
/usr/sbin/crm_mon
/usr/sbin/crm_resource
/usr/sbin/crm_sh
/usr/sbin/crm_standby
/usr/sbin/crm_uuid
/usr/sbin/crm_verify
/usr/sbin/crmadmin
/usr/sbin/ha_logger
/usr/sbin/hb_report
/usr/sbin/iso8601
/usr/sbin/ocf-tester
/usr/sbin/ptest
/usr/share/doc/heartbeat-2.1.4
/usr/share/doc/heartbeat-2.1.4/AUTHORS
/usr/share/doc/heartbeat-2.1.4/COPYING
/usr/share/doc/heartbeat-2.1.4/COPYING.LGPL
/usr/share/doc/heartbeat-2.1.4/ChangeLog
/usr/share/doc/heartbeat-2.1.4/DirectoryMap.txt
/usr/share/doc/heartbeat-2.1.4/GettingStarted.html
/usr/share/doc/heartbeat-2.1.4/GettingStarted.txt
/usr/share/doc/heartbeat-2.1.4/HardwareGuide.html
/usr/share/doc/heartbeat-2.1.4/HardwareGuide.txt
/usr/share/doc/heartbeat-2.1.4/README
/usr/share/doc/heartbeat-2.1.4/Requirements.html
/usr/share/doc/heartbeat-2.1.4/Requirements.txt
/usr/share/doc/heartbeat-2.1.4/apphbd.cf
/usr/share/doc/heartbeat-2.1.4/authkeys
/usr/share/doc/heartbeat-2.1.4/faqntips.html
/usr/share/doc/heartbeat-2.1.4/faqntips.txt
/usr/share/doc/heartbeat-2.1.4/ha.cf
/usr/share/doc/heartbeat-2.1.4/haresources
/usr/share/doc/heartbeat-2.1.4/hb_report.html
/usr/share/doc/heartbeat-2.1.4/hb_report.txt
/usr/share/doc/heartbeat-2.1.4/heartbeat_api.html
/usr/share/doc/heartbeat-2.1.4/heartbeat_api.txt
/usr/share/doc/heartbeat-2.1.4/logd.cf
/usr/share/doc/heartbeat-2.1.4/rsync.html
/usr/share/doc/heartbeat-2.1.4/rsync.txt
/usr/share/doc/heartbeat-2.1.4/startstop
/usr/share/heartbeat
/usr/share/heartbeat/BasicSanityCheck
/usr/share/heartbeat/ResourceManager
/usr/share/heartbeat/TestHeartbeatComm
/usr/share/heartbeat/crm.dtd
/usr/share/heartbeat/cts
/usr/share/heartbeat/cts/CIB.py
/usr/share/heartbeat/cts/CIB.pyc
/usr/share/heartbeat/cts/CIB.pyo
/usr/share/heartbeat/cts/CM_LinuxHAv2.py
/usr/share/heartbeat/cts/CM_LinuxHAv2.pyc
/usr/share/heartbeat/cts/CM_LinuxHAv2.pyo
/usr/share/heartbeat/cts/CM_fs.py
/usr/share/heartbeat/cts/CM_fs.pyc
/usr/share/heartbeat/cts/CM_fs.pyo
/usr/share/heartbeat/cts/CM_hb.py
/usr/share/heartbeat/cts/CM_hb.pyc
/usr/share/heartbeat/cts/CM_hb.pyo
/usr/share/heartbeat/cts/CTS.py
/usr/share/heartbeat/cts/CTS.pyc
/usr/share/heartbeat/cts/CTS.pyo
/usr/share/heartbeat/cts/CTSaudits.py
/usr/share/heartbeat/cts/CTSaudits.pyc
/usr/share/heartbeat/cts/CTSaudits.pyo
/usr/share/heartbeat/cts/CTSlab.py
/usr/share/heartbeat/cts/CTSlab.pyc
/usr/share/heartbeat/cts/CTSlab.pyo
/usr/share/heartbeat/cts/CTSproxy.py
/usr/share/heartbeat/cts/CTSproxy.pyc
/usr/share/heartbeat/cts/CTSproxy.pyo
/usr/share/heartbeat/cts/CTStests.py
/usr/share/heartbeat/cts/CTStests.pyc
/usr/share/heartbeat/cts/CTStests.pyo
/usr/share/heartbeat/cts/LSBDummy
/usr/share/heartbeat/cts/OCFIPraTest.py
/usr/share/heartbeat/cts/OCFIPraTest.pyc
/usr/share/heartbeat/cts/OCFIPraTest.pyo
/usr/share/heartbeat/cts/README
/usr/share/heartbeat/cts/extracttests.py
/usr/share/heartbeat/cts/extracttests.pyc
/usr/share/heartbeat/cts/extracttests.pyo
/usr/share/heartbeat/cts/getpeinputs.sh
/usr/share/heartbeat/ha_config
/usr/share/heartbeat/ha_propagate
/usr/share/heartbeat/hb_addnode
/usr/share/heartbeat/hb_delnode
/usr/share/heartbeat/hb_setsite
/usr/share/heartbeat/hb_setweight
/usr/share/heartbeat/hb_standby
/usr/share/heartbeat/hb_takeover
/usr/share/heartbeat/lrmtest
/usr/share/heartbeat/lrmtest/LRMBasicSanityCheck
/usr/share/heartbeat/lrmtest/README.regression
/usr/share/heartbeat/lrmtest/defaults
/usr/share/heartbeat/lrmtest/descriptions
/usr/share/heartbeat/lrmtest/evaltest.sh
/usr/share/heartbeat/lrmtest/language
/usr/share/heartbeat/lrmtest/lrmadmin-interface
/usr/share/heartbeat/lrmtest/lrmregtest
/usr/share/heartbeat/lrmtest/lrmregtest-heartbeat
/usr/share/heartbeat/lrmtest/lrmregtest-lsb
/usr/share/heartbeat/lrmtest/regression.sh
/usr/share/heartbeat/lrmtest/testcases
/usr/share/heartbeat/lrmtest/testcases/BSC
/usr/share/heartbeat/lrmtest/testcases/common.filter
/usr/share/heartbeat/lrmtest/testcases/metadata
/usr/share/heartbeat/lrmtest/testcases/metadata.exp
/usr/share/heartbeat/lrmtest/testcases/ra-list.sh
/usr/share/heartbeat/lrmtest/testcases/rscexec
/usr/share/heartbeat/lrmtest/testcases/rscexec.exp
/usr/share/heartbeat/lrmtest/testcases/rscmgmt
/usr/share/heartbeat/lrmtest/testcases/rscmgmt.exp
/usr/share/heartbeat/lrmtest/testcases/rscmgmt.log_filter
/usr/share/heartbeat/lrmtest/testcases/xmllint.sh
/usr/share/heartbeat/mach_down
/usr/share/heartbeat/ra-api-1.dtd
/usr/share/heartbeat/req_resource
/usr/share/heartbeat/stonithdtest
/usr/share/heartbeat/stonithdtest/STONITHDBasicSanityCheck
/usr/share/heartbeat/utillib.sh
/usr/share/locale/zh_CN/LC_MESSAGES/haclient.mo
/usr/share/man/man1/cl_status.1.gz
/usr/share/man/man1/ha_logger.1.gz
/usr/share/man/man1/hb_addnode.1.gz
/usr/share/man/man1/hb_delnode.1.gz
/usr/share/man/man1/hb_standby.1.gz
/usr/share/man/man1/hb_takeover.1.gz
/usr/share/man/man8/apphbd.8.gz
/usr/share/man/man8/cibadmin.8.gz
/usr/share/man/man8/crm_resource.8.gz
/usr/share/man/man8/ha_logd.8.gz
/usr/share/man/man8/heartbeat.8.gz
/usr/share/ocf
/usr/share/ocf/resource.d
/usr/share/ocf/resource.d/heartbeat
/usr/share/ocf/resource.d/heartbeat/.ocf-binaries
/usr/share/ocf/resource.d/heartbeat/.ocf-directories
/usr/share/ocf/resource.d/heartbeat/.ocf-returncodes
/usr/share/ocf/resource.d/heartbeat/.ocf-shellfuncs
/usr/share/ocf/resource.d/heartbeat/AudibleAlarm
/usr/share/ocf/resource.d/heartbeat/ClusterMon
/usr/share/ocf/resource.d/heartbeat/Delay
/usr/share/ocf/resource.d/heartbeat/Dummy
/usr/share/ocf/resource.d/heartbeat/EvmsSCC
/usr/share/ocf/resource.d/heartbeat/Evmsd
/usr/share/ocf/resource.d/heartbeat/Filesystem
/usr/share/ocf/resource.d/heartbeat/ICP
/usr/share/ocf/resource.d/heartbeat/IPaddr
/usr/share/ocf/resource.d/heartbeat/IPaddr2
/usr/share/ocf/resource.d/heartbeat/IPsrcaddr
/usr/share/ocf/resource.d/heartbeat/IPv6addr
/usr/share/ocf/resource.d/heartbeat/LVM
/usr/share/ocf/resource.d/heartbeat/LinuxSCSI
/usr/share/ocf/resource.d/heartbeat/MailTo
/usr/share/ocf/resource.d/heartbeat/ManageRAID
/usr/share/ocf/resource.d/heartbeat/ManageVE
/usr/share/ocf/resource.d/heartbeat/Pure-FTPd
/usr/share/ocf/resource.d/heartbeat/Raid1
/usr/share/ocf/resource.d/heartbeat/SAPDatabase
/usr/share/ocf/resource.d/heartbeat/SAPInstance
/usr/share/ocf/resource.d/heartbeat/SendArp
/usr/share/ocf/resource.d/heartbeat/ServeRAID
/usr/share/ocf/resource.d/heartbeat/SphinxSearchDaemon
/usr/share/ocf/resource.d/heartbeat/Stateful
/usr/share/ocf/resource.d/heartbeat/SysInfo
/usr/share/ocf/resource.d/heartbeat/VIPArip
/usr/share/ocf/resource.d/heartbeat/WAS
/usr/share/ocf/resource.d/heartbeat/WAS6
/usr/share/ocf/resource.d/heartbeat/WinPopup
/usr/share/ocf/resource.d/heartbeat/Xen
/usr/share/ocf/resource.d/heartbeat/Xinetd
/usr/share/ocf/resource.d/heartbeat/apache
/usr/share/ocf/resource.d/heartbeat/db2
/usr/share/ocf/resource.d/heartbeat/drbd
/usr/share/ocf/resource.d/heartbeat/eDir88
/usr/share/ocf/resource.d/heartbeat/ids
/usr/share/ocf/resource.d/heartbeat/iscsi
/usr/share/ocf/resource.d/heartbeat/ldirectord
/usr/share/ocf/resource.d/heartbeat/mysql
/usr/share/ocf/resource.d/heartbeat/o2cb
/usr/share/ocf/resource.d/heartbeat/oracle
/usr/share/ocf/resource.d/heartbeat/oralsnr
/usr/share/ocf/resource.d/heartbeat/pgsql
/usr/share/ocf/resource.d/heartbeat/pingd
/usr/share/ocf/resource.d/heartbeat/portblock
/usr/share/ocf/resource.d/heartbeat/rsyncd
/usr/share/ocf/resource.d/heartbeat/tomcat
/var/lib/heartbeat
/var/lib/heartbeat/cores
/var/lib/heartbeat/cores/hacluster
/var/lib/heartbeat/cores/nobody
/var/lib/heartbeat/cores/root
/var/lib/heartbeat/crm
/var/lib/heartbeat/pengine
/var/run/heartbeat
/var/run/heartbeat/ccm
/var/run/heartbeat/crm
现在可以启动heartbeat,要想启动heartbeat需要给它提供配置文件;
[root@node1 ~]# cd /etc/ha.d/(切换到/etc/ha.d目录)
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
harc  rc.d  README.config  resource.d  shellfuncs
提示:heartbeat的配置文件需要三个;
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
harc  rc.d  README.config  resource.d  shellfuncs
提示:当前目录没有一个配置文件,好在它给我们有样例配置文件在/usr/share/doc/heartbeat-2.1.4/目录;
[root@node1 ha.d]# ls /usr/share/doc/heartbeat-2.1.4/(查看/usr/share/doc/heartbeat-2.1.4目录文件及子目录)
apphbd.cf  ChangeLog     DirectoryMap.txt  GettingStarted.html  HardwareGuide.html  hb_report.html      heartbeat_api.txt  Requirements.html
rsync.txt  authkeys      COPYING           faqntips.html        GettingStarted.txt  HardwareGuide.txt   hb_report.txt      logd.cf
Requirements.txt         startstop         AUTHORS    COPYING.LGPL  faqntips.txt      ha.cf                haresources     heartbeat_api.html
README                   rsync.html
提示: ha.cf、authkeys、haresources直接复制到/etc/ha.d/目录就可以了;
[root@node1 ha.d]# cp /usr/share/doc/heartbeat-2.1.4/{authkeys,ha.cf,haresources} ./(复制ha.cf、authkeys、haresources文件到当前目录)
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@node1 ha.d]# ls -l(查看当前目录文件及子目录详细信息)
total 80
-rw-r--r-- 1 root root   645 Apr  6 01:51 authkeys
-rw-r--r-- 1 root root 10539 Apr  6 01:51 ha.cf
-rwxr-xr-x 1 root root   745 Jul 25  2009 harc
-rw-r--r-- 1 root root  5905 Apr  6 01:51 haresources
drwxr-xr-x 2 root root  4096 Apr  6 01:21 rc.d
-rw-r--r-- 1 root root   692 Jul 25  2009 README.config
drwxr-xr-x 2 root root  4096 Apr  6 01:21 resource.d
-rw-r--r-- 1 root root  7862 Jul 25  2009 shellfuncs
提示:注意authkeys配置文件权限,刚才复制的时候没有保留它原有的权限,复制的时候加-p选项就可以了,原来的权限是600的;
[root@node1 ha.d]# chmod 600 authkeys(更改authkeys权限为600)
[root@node1 ha.d]# vim authkeys(编辑authkeys密钥文件)

#
#       Authentication file.  Must be mode 600
#
#
#       Must have exactly one auth directive at the front.
#       auth    send authentication using this method-id
#
#       Then, list the method and key that go with that method-id
#
#       Available methods: crc sha1, md5.  Crc doesn't need/want a key.
#
#       You normally only have one authentication method-id listed in this file
#
#       Put more than one to make a smooth transition when changing auth
#       methods and/or keys.
#
#
#       sha1 is believed to be the "best", md5 next best.
#
#       crc adds no security, except from packet corruption.
#               Use only on physically secure networks.
#
#auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello!

[root@node1 ha.d]# dd if=/dev/random count=1 bs=512(复制从/dev/random读取随机数,count个数为1,bs大小为512的数据)
TqZ񿇐¶Y𝏚bȳ­n®xg\fꗲ§I£ðb+.ΉвFT«e`t+HSɬ´󹉷򕦞IΙmgp驦6­	·㺺²н$½Ҿޚq7񚵄ènR(钆ҼKTݰ+1 records in
0+1 records out
128 bytes (128 B) copied, 0.000429908 seconds, 298 kB/s
提示:/dev/random生成随机数;
[root@node1 ha.d]# dd if=/dev/random count=1 bs=512 | md5sum(复制从/dev/random读取随机数,count个数为1,bs大小为512的数据,将结果送给md5sum生成
md5校验码)
0+1 records in
0+1 records out
109 bytes (109 B) copied, 0.000114731 seconds, 950 kB/s
bf6e6054b8f62d6eff79f7e6994d23d2  -
[root@node1 ha.d]# vim authkeys(编辑authkeys密钥文件)

#
#       Authentication file.  Must be mode 600
#
#
#       Must have exactly one auth directive at the front.
#       auth    send authentication using this method-id
#
#       Then, list the method and key that go with that method-id
#
#       Available methods: crc sha1, md5.  Crc doesn't need/want a key.
#
#       You normally only have one authentication method-id listed in this file
#
#       Put more than one to make a smooth transition when changing auth
#       methods and/or keys.
#
#
#       sha1 is believed to be the "best", md5 next best.
#
#       crc adds no security, except from packet corruption.
#               Use only on physically secure networks.
#
#auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello!
auth 1(认证使用1的认证方法)
1 md5 bf6e6054b8f62d6eff79f7e6994d23d2(1是md5认证加随机数)
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@node1 ha.d]# vim ha.cf(编辑heartbeat核心配置文件)

#debugfile /var/log/ha-debug(调试日志文件)

#logfile /var/log/heartbeat.log(日志文件,不要和logfacility同时启用)

logfacility     local0(日志设施,local0表示通过syslog记录,不要和logfile同时启用)

keepalive 1(多长时间发一次心跳,默认2秒)

#deadtime 30(死亡时间,多长时间声明主机死亡)

#warntime 10(警告时长,如果heartbeat多长时间没有发过来keepailve信息,最多等10秒)

#initdead 120(启动第一个节点,另外一个节点还没启动,要等待另外一个节点加进来以后,两个节点就可以通信了,第一个节点启动起来等待第二个节点多长时间,如果第一个节点
启动了,第二个节点迟迟不来,自己不应该成为集群的,因为两个节点要见次面,见次面,某个节点再挂掉也无所谓,)

#udpport        694(heartbeat心跳信息传递所监听的端口)

#baud   19200(串行线缆发送速率,heartbeat支持两种心跳信息,以太网和串行线路)

#serial /dev/ttyS0      # Linux(串行设备是什么)
#serial /dev/cuaa0      # FreeBSD
#serial /dev/cuad0      # FreeBSD 6.x
#serial /dev/cua/a      # Solaris

#bcast  eth0            # Linux(基于以太网发送信息使用那种类型广播、组播)
bcast  eth0            # Linux
#bcast  eth1 eth2       # Linux
#bcast  le0             # Solaris
#bcast  le1 le2         # Solaris

#mcast eth0 225.0.0.1 694 1 0(组播)

#ucast eth0 192.168.1.2(单播,对方地址)

auto_failback on(原来的节点上线了,当前主机坏了就转移出去了,原来的主机出现又转移回去)

#stonith baytech /etc/ha.d/conf/stonith.baytech(定义stonith设备)

#stonith_host *     baytech 10.0.0.3 mylogin mysecretpassword(stonith方式)
#stonith_host ken3  rps10 /dev/ttyS1 kathy 0 
#stonith_host kathy rps10 /dev/ttyS1 ken3 0 

#watchdog /dev/watchdog(看门狗)

#node   ken3(当前集群有几个节点,每个节点使用一个node指令来进行定义)
#node   kathy
node    node1.magedu.com(告诉集群一共有那写节点)
node    node2.magedu.com

#ping 10.10.10.254(ping主机)
ping 172.16.100.254

#ping_group group1 10.10.10.254 10.10.10.253(限定一组内的主机只要有一个能ping通都可以)

#hbaping fc-card-name(光钎网卡)

#respawn userid /path/name/to/run
#respawn hacluster /usr/lib/heartbeat/ipfail(当一个heartbeat服务停了以后,是将这个节点down机,还是把heartbeat服务重启)

#deadping 30(ping节点多长时间认为连不上节点)

#apiauth ipfail uid=hacluster(api认证)
#apiauth ccm uid=hacluster(ccm集群配置管理器)
#apiauth cms uid=hacluster
#apiauth ping gid=haclient uid=alanr,root
#apiauth default gid=haclient

#msgfmt  classic/netstring(管理信息格式)

# use_logd yes/no

#conn_logd_time 60(日志记录其它主机)

#compression    bz2(集群事物信息在发送是否压缩,压缩算法)

#compression_threshold 2(大于2KB才压缩)

[root@node1 ha.d]# vim haresources(编辑heartbeat资源配置文件)

#               IPaddr::135.9.8.7/24/eth0/135.9.8.210(配置IP地址的时候,如果节点上有两个网卡,每个网卡都有地址,这个虚地址,配置成别名的地址应该配置在
那个网卡上)

#just.linux-ha.org      135.9.216.110(VIP) http(服务)

#just.linux-ha.org      135.9.216.110 135.9.215.111 135.9.216.112(VIP有多个) httpd(服务)

#node1(主节点名称,默认活动节点名称)  10.0.0.170(VIP) Filesystem(资源代理)::/dev/sda1(挂载设备)::/data1(挂载点)::ext2(文件系统类型)(文件系统
,自动挂载那个设备到那个目录下,文件系统类型是什么)

[root@node1 i386]# cd /etc/ha.d/(切换到/etc/ha.d目录)
[root@node1 ha.d]# ls resource.d/(查看resource.d目录文件及子目录)
apache        db2    Filesystem    ICP  IPaddr   IPsrcaddr  LinuxSCSI  LVSSyncDaemonSwap  OCF        Raid1    ServeRAID  WinPopup
AudibleAlarm  Delay  hto-mapfuncs  ids  IPaddr2  IPv6addr   LVM        MailTo             portblock  SendArp  WAS        Xinetd
提示:Filesystem资源代理,它可以自动配置资源的,而每个资源代理都可以接受参数的,如果后面需要参数使用::两个冒号隔开参数;

[root@node1 ha.d]# ifconfig(查看当前网卡接口信息)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:226839 errors:0 dropped:0 overruns:0 frame:0
          TX packets:251841 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21683964 (20.6 MiB)  TX bytes:32919949 (31.3 MiB)
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:49803 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49803 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4250575 (4.0 MiB)  TX bytes:4250575 (4.0 MiB)
提示:假如当前主机有两个网卡eth0和eth1,而指定VIP以后,这个VIP一定是配置在某个网卡的别名,它应该配置在那个网卡别名上,它就尽可能找跟VIP在同一网段的地址所配置网
卡的别名;
[root@node1 ha.d]# ls rc.d/(查看rc.d目录文件及子目录)
ask_resources  hb_takeover  ip-request  ip-request-resp  status
[root@node1 ha.d]# ls resource.d/(查看resource.d目录文件及子目录)
apache        db2    Filesystem    ICP  IPaddr   IPsrcaddr  LinuxSCSI  LVSSyncDaemonSwap  OCF        Raid1    ServeRAID  WinPopup
AudibleAlarm  Delay  hto-mapfuncs  ids  IPaddr2  IPv6addr   LVM        MailTo             portblock  SendArp  WAS        Xinetd
[root@node1 ha.d]# ls /usr/lib/heartbeat(查看/usr/lib/heartbeat目录文件及子目录) 
api_test          clmtest            crm_utils.pyo        haresources2cib.pyo  ipfail           pengine          stonithdtest
apphbd            crm_commands.py    cts                  hb_addnode           logtest          pingd            tengine
apphbtest         crm_commands.pyc   dopd                 hb_delnode           lrmadmin         plugins          TestHeartbeatComm
atest             crm_commands.pyo   drbd-peer-outdater   hb_setsite           lrmd             quorumd          transient-test.sh
attrd             crmd               findif               hb_setweight         lrmtest          quorumdtest      ttest
base64_md5_test   crm.dtd            ha_config            hb_standby           mach_down        ra-api-1.dtd     utillib.sh
BasicSanityCheck  crm_primitive.py   ha_logd              hb_takeover          mgmtd            recoverymgrd
ccm               crm_primitive.pyc  ha_logger            heartbeat            mgmtdtest        req_resource
ccm_testclient    crm_primitive.pyo  ha_propagate         ipctest              mlock            ResourceManager
cib               crm_utils.py       haresources2cib.py   ipctransientclient   ocf-returncodes  send_arp
cibmon            crm_utils.pyc      haresources2cib.pyc  ipctransientserver   ocf-shellfuncs   stonithd
提示:findif去找,评估一下VIP和那个网卡地址在同一网段内;
[root@node1 ha.d]# vim haresources(编辑heartbeat资源配置文件)

#               IPaddr::135.9.8.7/24/135.9.8.210(指定资源代理IPaddr)

#               IPaddr::135.9.8.7/24/eth0(配置在那个网卡的别名上)

#               IPaddr::135.9.8.7/24(VIP)/eth0/135.9.8.210(广播地址)

提示:如果想配置到那个网卡上,不让它自己去找;
[root@node1 ha.d]# ls resource.d/(查看resource.d目录文件及子目录)
apache        db2    Filesystem    ICP  IPaddr   IPsrcaddr  LinuxSCSI  LVSSyncDaemonSwap  OCF        Raid1    ServeRAID  WinPopup
AudibleAlarm  Delay  hto-mapfuncs  ids  IPaddr2  IPv6addr   LVM        MailTo             portblock  SendArp  WAS        Xinetd
提示:建议使用IPaddr2,因为功能更强大;
[root@node1 ha.d]# yum -y install httpd(安装httpd服务,-y所有询问回答yes)

HA2:

[root@node2 ~]# yum -y install httpd(安装httpd服务,-y所有询问回答yes)

HA1:

[root@node1 ha.d]# echo "<h1>node1.magedu.com</h1>" >> /var/www/html/index.html(显示字符串输出到index.html文件)
[root@node1 ha.d]# service httpd start(启动httpd服务)
Starting httpd:                                            [  OK  ]

测试:通过Windows的IE浏览器输入http://172.16.100.6访问页面,可以访问;

[root@node1 ha.d]# service httpd stop(停止httpd服务)
Stopping httpd:                                            [  OK  ]
[root@node1 ha.d]# chkconfig httpd off(关闭httpd在响应系统级别开机自动启动)

HA2:

[root@node2 ~]# echo "<h1>node2.magedu.com</h1>" >> /var/www/html/index.html(显示字符串输出到index.html文件)
[root@node2 ~]# service httpd start(启动httpd服务)
启动 httpd:                                               [确定]

测试:通过Windows的IE浏览器输入http://172.16.100.7访问页面,可以访问;

[root@node2 ~]# service httpd stop(停止httpd服务)
停止 httpd:                                               [确定]
[root@node2 ~]# chkconfig httpd off(关闭httpd在相应系统级别开机自动启动)
[root@node2 ~]# chkconfig --list httpd(查看httpd服务在相应系统级别启动情况)
httpd          	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭

HA1:

[root@node1 ~]# cd /etc/ha.d/(切换到/etc/ha.d目录)
[root@node1 ha.d]# vim haresources(编辑资源配置文件)

node1.magedu.com IPaddr::172.16.100.1/16/eth0 httpd(定义主节点node1,VIP:172.16.100.1/16,服务httpd)

[root@node1 ha.d]# vmstat 1(查看服务器状态值,1标识时间间隔)
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0  62876 183644 636572    0    0     4     9  238   54  0  4 96  0  0
 0  0      0  62876 183644 636572    0    0     0     0 1703   49  0  4 96  0  0
 0  0      0  62876 183644 636572    0    0     0     0 1697   50  0  5 95  0  0
 0  0      0  62876 183648 636572    0    0     0    56 1690   53  0  3 97  0  0
 0  0      0  62876 183648 636572    0    0     0     0 1704   48  0  4 96  0  0
 0  0      0  62876 183648 636572    0    0     0     0 1704   44  0  4 96  0  0
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@node1 ha.d]# scp -p authkeys haresources ha.cf node2:/etc/ha.d/(复制authkeys、haresources、ha.cf文件到node2主机的/etc/ha.d目录,-p保留原来文件属性)
authkeys                                                                                                 100%  691     0.7KB/s   00:00    
haresources                                                                                              100% 5957     5.8KB/s   00:00    
ha.cf                                                                                                    100%   10KB  10.4KB/s   00:00  
[root@node1 ha.d]# service heartbeat start(启动heartbeat服务)
Starting High-Availability services: 
2016/04/06_03:24:13 INFO:  Resource is stopped
                                                           [  OK  ]
[root@node1 ha.d]# ssh node2 'service heartbeat start'(启动node2主机heartbeat服务)
Starting High-Availability services: 
2016/04/06_03:25:12 INFO:  Resource is stopped
[  OK  ]
[root@node1 ha.d]# tail -f /var/log/messages(查看messages日志文件,-f追加内容显示)
Apr  6 14:34:36 localhost heartbeat: [30438]: info: remote resource transition completed.
Apr  6 14:34:36 localhost heartbeat: [30438]: info: node1.magedu.com wants to go standby [foreign]
Apr  6 14:34:36 localhost heartbeat: [30438]: info: standby: node2.magedu.com can take our foreign resources
Apr  6 14:34:36 localhost heartbeat: [3869]: info: give up foreign HA resources (standby).
Apr  6 14:34:36 localhost heartbeat: [3869]: info: foreign HA resource release completed (standby).
Apr  6 14:34:36 localhost heartbeat: [30438]: info: Local standby process completed [foreign].
Apr  6 14:34:37 localhost heartbeat: [30438]: WARN: 1 lost packet(s) for [node2.magedu.com] [12:14]
Apr  6 14:34:37 localhost heartbeat: [30438]: info: remote resource transition completed.
Apr  6 14:34:37 localhost heartbeat: [30438]: info: No pkts missing from node2.magedu.com!
Apr  6 14:34:37 localhost heartbeat: [30438]: info: Other node completed standby takeover of foreign resources.
[root@node1 ~]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      3494/./hpiod        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      3175/portmap        
tcp        0      0 0.0.0.0:852                 0.0.0.0:*                   LISTEN      3214/rpc.statd      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      3515/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      3527/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3564/sendmail       
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      30277/sshd          
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      3170/sshd           
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      3499/python         
tcp        0      0 :::80                       :::*                        LISTEN      3907/httpd          
tcp        0      0 :::22                       :::*                        LISTEN      3515/sshd           
tcp        0      0 ::1:6010                    :::*                        LISTEN      30277/sshd          
tcp        0      0 ::1:6011                    :::*                        LISTEN      3170/sshd
[root@node1 ~]# ifconfig(查看网卡接口信息) 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:324817 errors:0 dropped:0 overruns:0 frame:0
          TX packets:348551 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:40833408 (38.9 MiB)  TX bytes:52096399 (49.6 MiB)
          Interrupt:67 Base address:0x2000 

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.1  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:50542 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50542 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4343010 (4.1 MiB)  TX bytes:4343010 (4.1 MiB)

测试:通过Windows的IE浏览器访问172.16.100.1的页面,可以正常访问;

测试:实现让节点1出现故障,看节点2能不能正常运行,节点2能不能把资源取过去;

[root@node1 ~]# cd /usr/lib/heartbeat(切换到/usr/lib/heartbeat目录)
[root@node1 heartbeat]# ls(查看当前目录文件及子目录)
api_test          clmtest            crm_utils.pyo        haresources2cib.pyo  ipfail           pengine          stonithdtest
apphbd            crm_commands.py    cts                  hb_addnode           logtest          pingd            tengine
apphbtest         crm_commands.pyc   dopd                 hb_delnode           lrmadmin         plugins          TestHeartbeatComm
atest             crm_commands.pyo   drbd-peer-outdater   hb_setsite           lrmd             quorumd          transient-test.sh
attrd             crmd               findif               hb_setweight         lrmtest          quorumdtest      ttest
base64_md5_test   crm.dtd            ha_config            hb_standby           mach_down        ra-api-1.dtd     utillib.sh
BasicSanityCheck  crm_primitive.py   ha_logd              hb_takeover          mgmtd            recoverymgrd
ccm               crm_primitive.pyc  ha_logger            heartbeat            mgmtdtest        req_resource
ccm_testclient    crm_primitive.pyo  ha_propagate         ipctest              mlock            ResourceManager
cib               crm_utils.py       haresources2cib.py   ipctransientclient   ocf-returncodes  send_arp
cibmon            crm_utils.pyc      haresources2cib.pyc  ipctransientserver   ocf-shellfuncs   stonithd
提示:hb_standby是把自己转换成备节点,自己称为备节点对方就成为主节点了;
[root@node1 heartbeat]# ./hb_standby(执行hb_standby脚本)
2016/04/06_15:31:06 Going standby [all].
[root@node1 heartbeat]# tail -f /var/log/messages
Apr  6 15:31:07 localhost ResourceManager[5379]: info: Running /etc/init.d/httpd  stop
Apr  6 15:31:07 localhost ResourceManager[5379]: info: Running /etc/ha.d/resource.d/IPaddr 172.16.100.1/16/eth0 stop
Apr  6 15:31:07 localhost IPaddr[5471]: INFO: ifconfig eth0:0 down
Apr  6 15:31:07 localhost IPaddr[5442]: INFO:  Success
Apr  6 15:31:07 localhost heartbeat: [5366]: info: all HA resource release completed (standby).
Apr  6 15:31:07 localhost heartbeat: [4602]: info: Local standby process completed [all].
Apr  6 15:31:07 localhost heartbeat: [4602]: WARN: 1 lost packet(s) for [node2.magedu.com] [1008:1010]
Apr  6 15:31:07 localhost heartbeat: [4602]: info: remote resource transition completed.
Apr  6 15:31:07 localhost heartbeat: [4602]: info: No pkts missing from node2.magedu.com!
Apr  6 15:31:07 localhost heartbeat: [4602]: info: Other node completed standby takeover of all resources.(其它的备节点已经把资源拿走了)

HA2:

[root@node2 ha.d]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:8A:44:AB  
          inet addr:172.16.100.7  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8a:44ab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:114074 errors:0 dropped:0 overruns:0 frame:0
          TX packets:110543 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:23631368 (22.5 MiB)  TX bytes:21931417 (20.9 MiB)
          Interrupt:67 Base address:0x2000 

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:8A:44:AB  
          inet addr:172.16.100.1  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:600 errors:0 dropped:0 overruns:0 frame:0
          TX packets:600 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:71965 (70.2 KiB)  TX bytes:71965 (70.2 KiB)
[root@node2 ha.d]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l坚挺端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      3525/./hpiod        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      3177/portmap        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      3548/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      3562/cupsd          
tcp        0      0 0.0.0.0:856                 0.0.0.0:*                   LISTEN      3218/rpc.statd      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3603/sendmail       
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      18179/sshd          
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      3530/python         
tcp        0      0 :::80                       :::*                        LISTEN      20306/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      3548/sshd           
tcp        0      0 ::1:6011                    :::*                        LISTEN      18179/sshd

测试:通过Windows的IE浏览器访问172.16.100.1的页面,可以正常访问;

[root@node2 ha.d]# /usr/lib/heartbeat/hb_standby(执行hb_standby脚本)
2016/04/06_15:40:58 Going standby [all].

测试:通过Windows的IE浏览器访问172.16.100.1的页面,可以正常访问;

 

环境:再提供一个节点,让这个节点用来作为文件系统,让两个节点同时挂载,看能不能提供一模一样的页面,启动一台Linux主机,把某个目录通过NFS输出出来,让HA1和HA2都能够自动把它挂载至本地的/var/www/html上,当作网页目录去访问,把HA1和HA2的selinux关闭,不然会阻止挂这个文件系统并且当作网页文件去访问的;

 Director:

[root@localhost ~]# mkdir -pv /web/htdocs(创建/web/htdocs目录,-p递归创建,-v显示创建过程)
mkdir: 已创建目录 “/web”
mkdir: 已创建目录 “/web/htdocs”
[root@localhost ~]# vim /etc/exports(编辑exports文件)

/web/htdocs     172.16.0.0/16(ro)(将/web/dtdocs共享给172.16.0.0/16网段,ro只读访问)

[root@localhost ~]# service nfs start(启动nfs服务)
启动 NFS 服务:                                            [确定]
关掉 NFS 配额:                                            [确定]
启动 NFS 守护进程:                                        [确定]
启动 NFS mountd:                                          [确定]
[root@localhost ~]# service nfs restart(重启nfs服务)
关闭 NFS mountd:                                          [确定]
关闭 NFS 守护进程:                                        [确定]
关闭 NFS quotas:                                          [确定]
关闭 NFS 服务:                                            [确定]
启动 NFS 服务:                                            [确定]
关掉 NFS 配额:                                            [确定]
启动 NFS 守护进程:                                        [确定]
启动 NFS mountd:                                          [确定]
[root@localhost ~]# ifconfig(查看网卡接口信息)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F4:69:6B  
          inet addr:172.16.100.5  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fef4:696b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2530 errors:0 dropped:0 overruns:0 frame:0
          TX packets:445 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:541471 (528.7 KiB)  TX bytes:62191 (60.7 KiB)
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:178 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:15744 (15.3 KiB)  TX bytes:15744 (15.3 KiB)
[root@localhost ~]# showmount -e 172.16.100.5(查看nfs服务器172.16.100.5共享那些文件系统)
Export list for 172.16.100.5:
/web/htdocs 172.16.0.0/16

HA1:

[root@node1 heartbeat]# cd(切换到用户家目录)
[root@node1 ~]# ssh node2 '/etc/init.d/heartbeat stop'(停止node2主机的heartbeat服务)
Stopping High-Availability services: 
[  OK  ]
[root@node1 ~]# ifconfig(查看网卡接口信息)
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:346177 errors:0 dropped:0 overruns:0 frame:0
          TX packets:367575 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:44460811 (42.4 MiB)  TX bytes:55663938 (53.0 MiB)
          Interrupt:67 Base address:0x2000 

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.1  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:51195 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4401206 (4.1 MiB)  TX bytes:4401206 (4.1 MiB)
[root@node1 ~]# service heartbeat stop(停止heartbeat服务)
Stopping High-Availability services: 
                                                           [  OK  ]
[root@node1 ~]# setenforce 0(关闭selinux)

HA2:

[root@node2 ha.d]# setenforce 0(关闭selinux)

HA1:

[root@node1 ~]# mount 172.16.100.5:/web/htdocs /mnt/(挂载172.16.100.5:/web/htdocs到/mnt目录)
[root@node1 ~]# ls /mnt/(查看/mnt目录文件及子目录)

Director:

[root@localhost ~]# cd /web/htdocs/(切换到/web/htdocs目录)
[root@localhost htdocs]# ls(查看当前目录文件及子目录)
[root@localhost htdocs]# vim index.html(编辑index.html文件)

nfs server

HA1:

[root@node1 ~]# ls /mnt/(查看/mnt目录文件及子目录)
index.html
[root@node1 ~]# cat /mnt/index.html(查看index.html文件内容)
nfs server
[root@node1 ~]# umount /mnt(卸载/mnt目录挂载文件系统)
[root@node1 ~]# cd /etc/ha.d/(切换到/etc/ha.d目录)
[root@node1 ha.d]# ls(查看当前目录文件及子目录)
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@node1 ha.d]# vim haresources(编辑haresources文件)

node1.magedu.com IPaddr::172.16.100.1/16/eth0 Filesystem::172.16.100.5:/web/htdocs::/var/www/html::nfs httpd

[root@node1 ha.d]# ls(查看当前目录文件及子目录)
authkeys  ha.cf  harc  haresources  rc.d  README.config  resource.d  shellfuncs
[root@node1 ha.d]# scp haresources node2:/etc/ha.d/(复制haresources到node2主机/etc/ha.d目录)
haresources                                                                    100% 6013     5.9KB/s   00:00 
[root@node1 ha.d]# cd(切换到用户家目录)
[root@node1 ~]# service heartbeat start(启动heartbeat服务)
Starting High-Availability services: 
2016/04/06_16:46:05 INFO:  Resource is stopped
                                                           [  OK  ]
[root@node1 ~]# ssh node2 'service heartbeat start'(启动node2主机的heartbeat服务)
Starting High-Availability services: 
2016/04/06_16:46:41 INFO:  Resource is stopped
[  OK  ]
[root@node1 ~]# tail -f /var/log/messages(查看messages日志文件后10行,-f追加显示)
Apr  6 16:47:06 localhost hb_standby[7273]: Going standby [foreign].
Apr  6 16:47:06 localhost heartbeat: [6447]: info: node1.magedu.com wants to go standby [foreign]
Apr  6 16:47:07 localhost heartbeat: [6447]: info: standby: node2.magedu.com can take our foreign resources
Apr  6 16:47:07 localhost heartbeat: [7287]: info: give up foreign HA resources (standby).
Apr  6 16:47:07 localhost heartbeat: [7287]: info: foreign HA resource release completed (standby).
Apr  6 16:47:07 localhost heartbeat: [6447]: info: Local standby process completed [foreign].
Apr  6 16:47:07 localhost heartbeat: [6447]: WARN: 1 lost packet(s) for [node2.magedu.com] [40:42]
Apr  6 16:47:07 localhost heartbeat: [6447]: info: remote resource transition completed.
Apr  6 16:47:07 localhost heartbeat: [6447]: info: No pkts missing from node2.magedu.com!
Apr  6 16:47:07 localhost heartbeat: [6447]: info: Other node completed standby takeover of foreign resources.
[root@node1 ha.d]# netstat -tnlp(查看系统服务,-t代表tcp,-n以数字显示,-l监听端口,-p显示服务名称)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      3494/./hpiod        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      3175/portmap        
tcp        0      0 0.0.0.0:852                 0.0.0.0:*                   LISTEN      3214/rpc.statd      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      3515/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      3527/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3564/sendmail       
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      3170/sshd           
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      3499/python         
tcp        0      0 :::80                       :::*                        LISTEN      7336/httpd          
tcp        0      0 :::22                       :::*                        LISTEN      3515/sshd           
tcp        0      0 ::1:6011                    :::*                        LISTEN      3170/sshd  
[root@node1 resource.d]# ifconfig(查看网卡接口信息) 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.6  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fecc:faae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:362560 errors:0 dropped:0 overruns:0 frame:0
          TX packets:383212 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:46565335 (44.4 MiB)  TX bytes:58208933 (55.5 MiB)
          Interrupt:67 Base address:0x2000 

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:CC:FA:AE  
          inet addr:172.16.100.1  Bcast:172.16.100.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:51260 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51260 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4407334 (4.2 MiB)  TX bytes:4407334 (4.2 MiB)

测试:通过Windows的IE浏览器输入172.16.100.1访问页面,正常访问;

[root@node1 ~]# /usr/lib/heartbeat/hb_standby(执行hb_standby脚本) 
2016/04/06_17:49:26 Going standby [all].

测试:通过Windows的IE浏览器输入172.16.100.1访问页面,正常访问;

HA2:

[root@node2 ha.d]# mount(查看已经挂载的文件系统)
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sr0 on /media type iso9660 (ro)
172.16.100.5:/web/htdocs on /var/www/html type nfs (rw,addr=172.16.100.5)

提示:heartbeat-V2自带了两种资源管理器,除了haresources之外,还有个叫做CRM,CRM启动起来以后还完全支持通过图形接口来进行配置;