大纲
一、环境准备
二、拓扑准备
三、前提条件
四、安装相关软件
五、配置 heartbeat
六、测试Web集群
七、问题汇总
八、共享存储
一、环境准备
1.操作系统
CentOS 5.5 X86_64 最小化安装
说明:一般Heartbeat v2.x 都安装在CentOS 5.x系列中,而CentOS 6.x中都用Heartbeat v3.x。
2.相关软件
Heartbeat 2.1.4
Apache 2.2.3
3.配置epel YUM源(两节点都要配置)
node1,node2:
[root@node src]# wget [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.18.200,测试机是一台Windows主机,NFS服务器为192.168.18.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.1localhost.localdomain localhost ::1localhost6.localdomain6 localhost6 192.168.18.201 node1.test.com node1 192.168.18.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 root@node2.test.com[root@node1 ~]# ssh node2[root@node2 ~]# ifconfig eth0Link encap:Ethernet HWaddr 00:0C:29:EA:CE:79inet addr:192.168.18.202 Bcast:192.168.18.255 Mask:255.255.255.0inet6 addr: fe80::20c:29ff:feea:ce79/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:41736 errors:0 dropped:0 overruns:0 frame:0TX packets:36201 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:35756480 (34.1 MiB) TX bytes:5698609 (5.4 MiB)loLink encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:8 errors:0 dropped:0 overruns:0 frame:0TX packets:8 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX 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 root@node1.test.com[root@node2 ~]# ssh node1[root@node1 ~]# ifconfig eth0Link encap:Ethernet HWaddr 00:0C:29:23:76:4Dinet addr:192.168.18.201 Bcast:192.168.18.255 Mask:255.255.255.0inet6 addr: fe80::20c:29ff:fe23:764d/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:35226 errors:0 dropped:0 overruns:0 frame:0TX packets:30546 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:32941174 (31.4 MiB) TX bytes:4670062 (4.4 MiB)loLink encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:8 errors:0 dropped:0 overruns:0 frame:0TX packets:8 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
四、安装相关软件 (两节点都要安装)
1.heartbeat 安装组件说明
注:带*表示必须安装
2.安装heartbeat
node1,node2:
[root@node ~]# yum -y install heartbeat*
3.安装httpd
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 httpd0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
说明:测试完成后关闭服务,并让其开机不启动(注,httpd由heartbeat管理)
往往为了自己的不能失败,而处心积虑前怕狼后怕虎,