HA 高可用之V1版

    HA(High Available), 高可用性群集,是保证业务连续性的有效解决方案,一般有两个或两个以上的节点,且分为活动节点及备用节点。通常把正在执行业务的称为活动节点,而作为活动节点的一个备份的则称为备用节点。当活动节点出现问题,导致正在运行的业务(任务)不能正常运行时,备用节点此时就会侦测到,并立即接续活动节点来执行业务。从而实现业务的不中断或短暂中断。


RA:resource agent 能够接收CRM调度用于对某一个资源进行调度的工具

    {start|stop|restart|status} 


在高可用集群中,任何服务都不一个自启动,而是有CRM管理启动与否


RHEL OR CentOS高可用集群解决方案:

RHEL 5版本:

自带: RHCS(cman+rgmanager)

    选用第三方:corosync+pacemaker, heartbeat(v1或v2), keepalived


RHEL 6版本:

自带:RHCS(cman+rgmanager)

    corosync+rgmanager

    cman+pacemaker 6.5之后默认就是cman+pacemaker 

    heartbeat v3 + pacemaker 6.4之后 

    keepalived


Messaging Layer类型: 底层的心跳消息会话,定义信息通信HMC消息认证码、心跳信息间隔传递时长、刚启动系统缓冲、事物信息传递方式(压缩),TCP/UDP传递协议?

hearbeat端口:694/udp端口:694/udp

支持单播、组播等方式传递消息

    heartbeat v1, v2, v3

    (OpenAIS)corosync

    cman

CRM类型: Cluster Resources Manager,为那些非ha-ware的应用程序提供调用的基础平台

一般情况下,一个高可用服务包括多个资源,从属于同一个服务的多个资源必须运行于一个节点上

    heartbeat v1: haresources (配置接口:配置文件,文件名也叫haresources)

    heartbeat v2: crm (各节点均运行进程crmd,配置接口:客户端crmsh(shell),heartbeat-GUI)

    heartbeat v3 = heartbeat + pacemaker + cluster-glue: 

    pacemaker: 

    配置接口:

    CLI: crm(SuSE), pcs

    GUI: hawk, LCMC, pacemaker-mgmt

    cman + rgmanager:

    resource group manager: Failover Domain

    配置接口:

    RHCS: RedHat Cluster Suite

    配置接口:Conga (完全生命令周期的配置接口)


RA类型:resource agent,能够接收CRM调度用于对某一个资源进行调度的工具

    heartbeat legacy: heartbeat的传统类型

    LSB:/etc/rc.d/init.d/*

    OCF: Open Cluster Framework

    provider: pacemaker

    linbit

    STONITH: 

    

配置HA高可用集群:

大概过程:

1、配置ssh不需要密码即可访问、同步时间

2、上传hearbeat包

3、安装hearbeat:

解决依赖关系:

[root@node1 heartbeat2]# yum install perl-TimeDate net-snmp-libs libnet PyXML

[root@node1 heartbeat2]# rpm -ivh /tmp/libnet-1.1.6-7.el6.x86_64.rpm

[root@node1 heartbeat2]# rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm

2、编辑主配置文件:

logfile /var/log/ha-log  #日志存放目录

keepalive 1000ms  #or 1 #每间隔多久发送一次心跳信息

deadtime 8 #多长时间认为对方挂掉

warntime 4 #多长时间没有收到对方的心跳会发出警报,必须小于deadtime

initdead 120  #系统刚启动后等待会话时间

udpport 694  #端口号

#baud   19200  #限制串行口速率,非串行口不用启动

#bcast  eth0  #广播

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 #设备,不需要配合

node    node1.a.com #HA集群内所有主机的全名,且不能写IP地址

node    node2.a.com 

ping    192.168.10.1  #ping的地址,完成仲裁

compression     bz2 数据压缩格式

compression_threshold 2 #低于多大的数据不压缩,单位为KB

各主机编辑/var/www/html/index.html,测试http访问可用正常被访问,但是不能设置为开机启动

[root@node2 htdocs]# service httpd stop

[root@node2 htdocs]# chkconfig  httpd off

3、定义集群资源:

[root@node2 ha.d]# vim haresources #定义集群资源

node1.a.com           192.168.10.19/24/eth0               httpd

优先使用的主机    资源VIP(虚拟IP)/掩码/指定网卡        定义的服务


4、启动服务:

node1:

[root@node1 ha.d]# /etc/init.d/heartbeat start

    Starting High-Availability services:

    2015/01/08_17:19:02 INFO:  Resource is stopped

    Done.

    node2:

[root@node2 ~]# /etc/init.d/heartbeat  restart

    Stopping High-Availability services: 

    Done.

    Waiting to allow resource takeover to complete:

    Done.

    Starting High-Availability services: 

    2015/01/08_17:30:20 INFO:  Resource is stopped

    Done.

wKioL1SvRMbhxoEfAAOVBs2ENxI549.jpg

查看日志:

[root@node2 ~]# tail /var/log/ha-log 

heartbeat[2875]: 2015/01/08_17:30:22 info: remote resource transition completed.

heartbeat[2875]: 2015/01/08_17:30:22 info: remote resource transition completed.

heartbeat[2875]: 2015/01/08_17:30:22 info: Local Resource acquisition completed. (none)

heartbeat[2875]: 2015/01/08_17:30:23 info: node1.a.com wants to go standby [foreign]

heartbeat[2875]: 2015/01/08_17:30:23 info: standby: acquire [foreign] resources from node1.a.com

heartbeat[2901]: 2015/01/08_17:30:23 info: acquire local HA resources (standby).

heartbeat[2901]: 2015/01/08_17:30:23 info: local HA resource acquisition completed (standby).

heartbeat[2875]: 2015/01/08_17:30:23 info: Standby resource acquisition done [foreign].

heartbeat[2875]: 2015/01/08_17:30:23 info: Initial resource acquisition complete (auto_failback)

heartbeat[2875]: 2015/01/08_17:30:24 info: remote resource transition completed.


5、在客户机访问192.168.10.19测试:

测试结果一定是可以访问192.168.10.19并且优先显示node1的网页内容


wKiom1SvQ9iSe0UEAABoiYDk-IM603.jpg

将node1的heartbeat服务关闭测试能否迁移至node2:

wKioL1SvRQqAK1q9AAB9YNDt10Q269.jpg

测试结果可以

再将node1打开,测试能否迁移至node1:

结果可以


6、在另外一个节点启动NFS服务共享给集群使用,并创建一个index.html文件:

node3:

[root@node3 ~]mkdir  -pv /www/htdocs 

[root@node3 ~]vim /etc/export 

    /www/htdocs  *(rw)

[root@node3 ~]setfacl -m u:apache:rwx /www/htdocs

[root@node3 ~]vim /www/htdocs/index.html

   <h1> Page in NFS</h1>

[root@node3 ~service nfs restart


配置客户端使用NFS:

停止node1和node2的heartbeat服务:

[root@node1 ha.d]service heartbeat stop

[root@node1 ha.d]ssh node2 'service heartbeat stop'


[root@node1 ha.d]vim /etc/ha.c/haresources

node1.a.com 192.168.10.19/24/eth0  Filesystem:192.168.10.135::/www/htdocs::/var/www/html::nfs httpd

优先运行的主机  VIP   文件系统::共享NFS的服务器IP::共享目录::挂载至本地目录::文件系统格式  http服务

[root@node1 ha.d]# scp haresources  node2:/etc/ha.d/ 


7、重新在客户端访问能否读取NFS的Page页:

wKioL1SvRraCymydAACEBCchKsw786.jpg

手动将主节点切换为备用节点,服务是会自动切换至另外一个节点之上继续运行:

wKioL1SvR6rQfCMxAAA3-l3rQF4252.jpg


你可能感兴趣的:(status,资源,解决方案,start,第三方)