heartbeat-gui
一、简介gui
heartbeat的v2版本将v1中haresources配置文件使用GUI图形配置接口来配置高可用集群。更加便捷,直观。
二、准备条件和资源规划见上文http://www.cnblogs.com/jym1/p/8073164.html
三、heartbeat-gui配置
1、安装
解决依赖关系 [root@node1 heartbeat]# yum install libtool-ltdl -y [root@node1 heartbeat]# yum install net-snmp-libs libnet PyXML pygtk2-libglade -y [root@node1 heartbeat]# rpm -ivh heartbeat-pils-2.1.4-12.el6.x86_64.rpm [root@node1 heartbeat]# rpm -ivh heartbeat-stonith-2.1.4-12.el6.x86_64.rpm [root@node1 heartbeat]# yum -y localinstall heartbeat-2.1.4-12.el6.x86_64.rpm 安装gui [root@node1 heartbeat]# yum -y localinstall heartbeat-gui-2.1.4-12.el6.x86_64.rpm
heartbeat 安装组件说明
heartbeat 核心组件 *
heartbeat-devel 开发包
heartbeat-gui 图形管理接口 * (这个必须安装,这篇博文重点讲解图形资源管理器)
heartbeat-ldirectord 为lvs高可用提供规则自动生成及后端realserver健康状态检查的组件
heartbeat-pils 装载库插件接口 *
heartbeat-stonith 爆头接口 *
2、配置
复制配置文件至/etc/ha.d目录下 [root@node1 ~]# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,haresources,authkeys} /etc/ha.d/ 配置认证文件 auth 2 #1 crc 2 sha1 XUcb+fkiktY49z6zVHTy2A #3 md5 Hello! [root@node2 heartbeat-2.1.4]# openssl rand -base64 16 XUcb+fkiktY49z6zVHTy2A== 配置ha.cf文件,定义集群的工作方式 定义日志文件位置(二选一) logfacility为将日志交由syslog管理 logfile /var/log/ha-log #logfacility local0 多长时间发送一次心跳信息,默认为2秒 #keepalive 2 多长时间宣布某节点死亡,默认30秒 #deadtime 30 多长时间警告对方心跳信息延迟了,默认10秒 #warntime 10 第一次死去时间,避免因网络问题导致宣布死亡 #initdead 120 使用udp694端口传递心跳,并选择哪种方式传递心跳 #udpport 694 串行线缆传递心跳 #serial /dev/ttyS0 # Linux #serial /dev/cuaa0 # FreeBSD #serial /dev/cuad0 # FreeBSD 6.x #serial /dev/cua/a # Solaris 串行线缆的工作频率 #baud 19200 广播传递心跳 #bcast eth0 # Linux #bcast eth1 eth2 # Linux #bcast le0 # Solaris #bcast le1 le2 # Solaris 多播传递心跳,网卡必须支持多播,ifconfig | grep MULTICAST mcast eth0 225.0.0.1 694 1 0 #端口694,TTL为1,不允许回传为0 #启用网卡支持多播 [root@node1 ha.d]# ip link set eth0 multicast on 单薄传递心跳 #ucast eth0 192.168.1.2 自动故障转回 auto_failback on 指明节点 #node ken3 #node kathy node node1 node node2 加入crm开启这行,on或者respawn都可以 crm on 指明网关为ping node设备(仲裁设备) #ping 10.10.10.254 ping 192.168.0.1 指明一个组为ping node设备(仲裁设备) #ping_group group1 10.10.10.254 10.10.10.253 指明节点间传送的压缩算法 compression bz2 指明节点间传送数据压缩的最小数据为2KB compression_threshold 2 配置haresource文件,加入资源 node1 192.168.0.17/24/eth0/192.168.0.255 httpd
3、配置双节点
[root@node1 ha.d]# scp /etc/ha.d/{ha.cf,authkeys} node2:/etc/ha.d/ ha.cf 100% 10KB 10.3KB/s 00:00 authkeys 100% 662 0.7KB/s 00:00 [root@node1 ha.d]# scp /etc/ha.d/haresources node2:/etc/ha.d/ haresources 100% 5952 5.8KB/s 00:00 将认证文件的权限改为600 [root@node1 ha.d]# chmod 600 authkeys ; ssh node2 'chmod 600 /etc/ha.d/authkeys ' 启动服务 [root@node1 ha.d]# service heartbeat start; ssh node2 'service heartbeat start' logd is already running Starting High-Availability services: Done. logd is already running Starting High-Availability services: Done.
此时以禁用haresource资源管理器,下面使用gui界面配置资源
4、gui配置
因为gui需要用户密码登录,因此为hacluster设置密码 [root@node1 ~]# echo "linus" | passwd --stdin hacluster Changing password for user hacluster. passwd: all authentication tokens updated successfully. 将Resources配置文件通过脚本生成crm,可省略,crm会自动生成 [root@node2 crm]# cd /usr/lib64/heartbeat [root@node2 heartbeat]# ./haresources2cib.py /etc/ha.d/haresources 因为gui需要图形化界面支持,所以安装KDE桌面,远程软件中xshell支持,CRT等不支持 xshell配置步骤如下 File --> Properties --> SSH --> Tunneling --> Forward X11 connections to下的Xmanager [root@node1 ~]# yum groupinstall KDE Desktop -y 安装完毕后退出xshell,重新登录后即可 查看状态 [root@node2 ha.d]# crm_mon 命令行接口 [root@node2 ha.d]# crm_sh /usr/sbin/crm_sh:31: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module. from popen2 import Popen3 crm # nodes crm nodes # list <node id="da321285-0881-449f-b249-d912a65c1954" uname="node2" type="normal"/> <node id="0b161e79-35d1-44a9-a09a-e7ae7e80659d" uname="node1" type="normal"/> crm nodes # status <node_state id="da321285-0881-449f-b249-d912a65c1954" uname="node2" crmd="online" crm-debug-origin="do_lrm_query" shutdown="0" in_ccm="true" ha="active" join="member" expected="member"> <node_state id="0b161e79-35d1-44a9-a09a-e7ae7e80659d" uname="node1" crmd="online" crm-debug-origin="do_lrm_query" shutdown="0" in_ccm="true" ha="active" join="member" expected="member"> 查看端口与服务是否正常(所有节点一致) [root@node1 ~]# ss -tunlp | grep heartbeat udp UNCONN 0 0 225.0.10.1:694 *:* users:(("heartbeat",3451,8),("heartbeat",3452,8)) udp UNCONN 0 0 *:36708 *:* users:(("heartbeat",3451,7),("heartbeat",3452,7)) [root@node1 ~]# ss -tunlp | grep mgmtd tcp LISTEN 0 10 *:5560 *:* users:(("mgmtd",3463,10)) [root@node1 ~]# ps -ef | grep heartbeat root 3445 1 0 19:42 ? 00:00:00 heartbeat: master control process nobody 3450 3445 0 19:42 ? 00:00:00 heartbeat: FIFO reader nobody 3451 3445 0 19:42 ? 00:00:00 heartbeat: write: mcast eth0 nobody 3452 3445 0 19:42 ? 00:00:00 heartbeat: read: mcast eth0 nobody 3453 3445 0 19:42 ? 00:00:00 heartbeat: write: ping 192.168.0.1 nobody 3454 3445 0 19:42 ? 00:00:00 heartbeat: read: ping 192.168.0.1 498 3457 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/ccm 498 3458 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/cib nobody 3459 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/lrmd -r nobody 3460 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/stonithd 498 3461 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/attrd 498 3462 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/crmd root 3463 3445 0 19:42 ? 00:00:00 /usr/lib64/heartbeat/mgmtd -v root 4208 3476 0 19:50 pts/2 00:00:00 grep heartbeat 启动gui [root@node1 ~]# hb_gui &
图形界面如下
登录后界面如下
配置资源
loction,order,colocation是位置顺序序列的约束条件
定义组资源
之后在定义资源的时候选择加入组即可
定义约束关系(序列约束)
其余约束关系定义,位置约束要选明score
资源约束(3种类型):
位置约束(locations):资源更倾向于哪个节点上 ,使用数值表示;
inf: 无穷大
n: 表示数值,要对节点间的做比较来决定最后落在那个节点上(此处n为正值)
-n: 同上,如果节点间的位置约束均为负值,则最后运行于接近正值的节点上
-inf: 负无穷(只要有其它选择,就不会选择此节点 )
排列约束(Colocations):资源运行在同一节点的倾向性;
inf: 无限倾向于在一起
-inf: 无限倾向于不在一起
顺序约束(orders):资源启动次序及关闭次序;
位置约束说明
ID:表示为约束记录起一个名字
from to:表示那一个资源与那一个资源(此处写上面定义资源名字即可)
score:在一起的可能性(也可以是数值,比如10,-10)
INFINITY:webip必须要和webserver在一个节点上
-INFINITY:webipbu不和webserver在一个节点上
一般来说,我们可以将资源定义为组,也可以将基本资源使用约束关系定义。
高可用集群启动顺序:webip --> webfilesystem(nfs)-->webserver