Linux 高可用(HA)集群之heartbeat基于crm进行资源管理详解
大纲
一、环境准备
二、拓扑准备
三、前提条件
四、安装相关软件
五、配置 heartbeat(crm 资源管理器)
六、crm资源管理器
七、crm图形界面配置详解
八、高可用集群架构回顾
九、crm配置资源
十、crm资源约束
十一、crm资源配置总结
相关系列文章:
一、环境准备
1.操作系统
CentOS 5.5 X86_64 最小化安装
说明:一般Heartbeat v2.x 都安装在CentOS 5.x系列中,而CentOS 6.x中都用Heartbeat v3.x。
2.相关软件(软件下载)
Heartbeat 2.1.4
Heartbeat-gui 2.1.4
Apache 2.2.3
Xmanager Enterprise 4
3.配置epel YUM源(两节点都要配置)
node1,node2:
[root@node src]# wget http://download.Fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@node src]# rpm -ivh epel-release-5-4.noarch.rpm
warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
[root@node src]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@node src]# yum list
4.关闭防火墙与SELinux (两节点都要配置)
node1,node2:
[root@node ~]# service iptables stop
[root@node ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
二、拓扑准备
说明:有两个节点分别为node1与node2,VIP为192.168.1.200,测试机是一台Windows7主机,NFS服务器为192.168.1.208
三、前提条件
1.节点之间主机名互相解析
node1,node2:
[root@node ~]# vim /etc/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
192.168.1.201 node1.test.com node1
192.168.1.202 node2.test.com node2
2.节点之间时间得同步
node1,node2:
[root@node ~]# yum -y install ntp
[root@node ~]# ntp 210.72.145.44
[root@node ~]# date
2013年 08月 07日 星期三 16:06:30 CST
3.节点之间配置SSH互信
node1:
[root@node1 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub [email protected]
[root@node1 ~]# ssh node2
[root@node2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:EA:CE:79
inet addr:192.168.1.202 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feea:ce79/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2591 errors:0 dropped:0 overruns:0 frame:0
TX packets:1931 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:556754 (543.7 KiB) TX bytes:465692 (454.7 KiB)
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
node2:
[root@node2 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
[root@node2 ~]# ssh-copy-id -i .ssh/id_rsa.pub [email protected]
[root@node2 ~]# ssh node1
[root@node1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:23:76:4D
inet addr:192.168.1.201 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe23:764d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4603 errors:0 dropped:0 overruns:0 frame:0
TX packets:3914 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:771007 (752.9 KiB) TX bytes:728391 (711.3 KiB)
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:2672 (2.6 KiB) TX bytes:2672 (2.6 KiB)
四、安装相关软件
1、客户端软件(Windows 7测试机)
重点说明:安装Xmanager Enterprise 4,如下图
注:得安装Xmanager Enterprise 4 所有套件,而不是只安装xshell软件。不然后面的crm图形界面无法打开的,切记!
2.安装heartbeat
heartbeat 安装组件说明
heartbeat 核心组件 *
heartbeat-devel 开发包
heartbeat-gui 图形管理接口 * (这个必须安装,这篇博文重点讲解图形资源管理器)
heartbeat-ldirectord 为lvs高可用提供规则自动生成及后端realserver健康状态检查的组件
heartbeat-pils 装载库插件接口 *
heartbeat-stonith 爆头接口 *
node1,node2:
[root@node ~]# yum -y install heartbeat*
3.安装httpd (在这篇博文中我们还介绍Web的高可用,因为比较简单容易理解,下面的博文中我们会讲解mysql高可用)
node1:
[root@node1~]# yum install -y httpd
[root@node1 ~]# service httpd start
启动 httpd: [确定]
[root@node1 ~]# echo "<h1>node1.test.com</h1>" > /var/www/html/index.html
测试
[root@node1 ha.d]# service httpd stop
停止 httpd: [确定]
[root@node1 ha.d]# chkconfig httpd off
[root@node1 ha.d]# chkconfig httpd --list
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
说明:测试完成后关闭服务,并让其开机不启动(注,httpd由heartbeat管理)
node2:
[root@node2~]# yum install -y httpd
[root@node2 ~]# service httpd start
启动 httpd: [确定]
[root@node2 ~]# echo "<h1>node2.test.com</h1>" > /var/www/html/index.html
测试
[root@node2 ha.d]# service httpd stop
停止 httpd: [确定]
[root@node2 ha.d]# chkconfig httpd off
[root@node2 ha.d]# chkconfig httpd --list
httpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关�� 5:关闭 6:关闭
说明:测试完成后关闭服务,并让其开机不启动(注,httpd由heartbeat管理)