这里直接说heartbeat的配置
1.节点的名字必须跟uname -n 的名字相同,而且两个主机必须能通过主机名来访问。尽量不通过DNS 来访问。时钟时间保持一样。 2.双方的通信要必须通过SSL 的无障碍通信机制 3.双节点之间可以通过某个IP 来提供连接,但是这只是通信Ip,我们需要VIP 来对外提供服务。 4.我采用虚拟机的方式实现配置,操作系统使用rhel5.4,x86 平台 5.两个节点主机IP 分别为192.168.145.10(node1.a.com),以及 192.168.145.20(node2.a.com) 6.集群服务为lvs 的ipvsadm 服务 7.提供Web 服务的地址(VIP)为192.168.145.1011.准备工作
[root@localhost ~]# vim /etc/sysconfig/network
HOSTNAME=node1.a.com
[root@localhost ~]# hostname node1.a.com
重新登录
[root@localhost ~]# vim /etc/sysconfig/network
HOSTNAME=node2.a.com
[root@localhost ~]# hostname node2.a.com
我们首先要保证两节点之间时间相差不应该超过1 秒
[root@node1 ~]# hwclock -s
[root@node2 ~]# hwclock -s
分别在两个节点上设置
# vim /etc/hosts
192.168.145.10 node1.a.com node1
192.168.145.20 node2.a.com node2
生成密钥,确保通信正常
node1 节点
[root@node1 ~]# ssh-keygen -t rsa
[root@node1 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub node2
node2 节点
[root@node2 ~]# ssh-keygen -t rsa
[root@node2 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub node1
由于需要用到软件的依赖,这里配置yum,在node1 上
# vim /etc/yum.repos.d/rhel-debuginfo.repo
1 [rhel-server]
2 name=Red Hat Enterprise Linux server
3 baseurl=file:///mnt/cdrom/Server
4 enabled=1
5 gpgcheck=1
6 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-RedHat-release
7 [rhel-cluster]
8 name=Red Hat Enterprise Linux cluster
9 baseurl=file:///mnt/cdrom/Cluster
10 enabled=1
11 gpgcheck=1
12 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
13 [rhel-vt]
14 name=Red Hat Enterprise Linux vt
15 baseurl=file:///mnt/cdrom/VT
16 enabled=1
17 gpgcheck=1
18 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
- 3 -
19 [rhel-clusterstorage]
20 name=Red Hat Enterprise Linux clusterstorage
21 baseurl=file:///mnt/cdrom/ClusterStorage
22 enabled=1
23 gpgcheck=1
24 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
[root@node2 ~]# scp node1:/etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/
[root@node1 ~]# mkdir /mnt/cdrom
[root@node1 ~]# mount /dev/cdrom /mnt/cdrom
[root@node1 ~]# yum install -y ipvsadm //安装ipvsadm
添加规则访问192.168.145.101的80端口时采用rr调度算法,并且发送给Web服务器群集节点
[root@node1 ~]# ipvsadm -A -t 192.168.145.101:80 -s rr
[root@node1 ~]# ipvsadm -a -t 192.168.145.101:80 -r 192.168.145.100 -g
[root@node1 ~]# ipvsadm -a -t 192.168.145.101:80 -r 192.168.145.200 -g
[root@node1 ~]# service ipvsadm save //保存规则
安装heartbeat[root@node1 ~]# ll
总计 2736
-rw------- 1 root root 1287 08-11 23:13 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 08-11 15:20 Desktop
-rw-r--r-- 1 root root 1637238 10-25 18:34 heartbeat-2.1.4-9.el5.i386.rpm
--rw-r--r-- 1 root root 111742 10-25 18:34 heartbeat-ldirectord-2.1.4-9.el5.i386.rpm
-rw-r--r-- 1 root root 92070 10-25 18:34 heartbeat-pils-2.1.4-10.el5.i386.rpm
-rw-r--r-- 1 root root 179199 10-25 18:34 heartbeat-stonith-2.1.4-10.el5.i386.rpm
-rw-r--r-- 1 root root 35369 08-11 23:13 install.log
-rw-r--r-- 1 root root 3995 08-11 23:11 install.log.syslog
-rw-r--r-- 1 root root 56817 10-25 18:34 libnet-1.1.4-3.el5.i386.rpm
-rw-r--r-- 1 root root 92071 10-25 18:34 perl-MailTools-1.77-1.el5.noarch.rpm
[root@node1 ~]# yum localinstall –y heartbeat-2.1.4-9.el5.i386.rpm heartbeat-ldirectord-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 perl-MailTools-1.77-1.el5.noarch.rpm –-nogpgcheck //不进行签名检测安装