码迷,mamicode.com
首页 > 系统相关 > 详细

linux高可用之heartbeat_v1安装与配置

时间:2014-09-09 13:43:09      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:heartbeat   ha   webseven   

1.实验规划:

mytest1:192.169.201.7

mytest2:192.169.201.8

vip:192.169.201.100

NFS服务器mytest3:192.168.201.9 


2.设置各节点的hostname.

将如下信息写入各节点的/etc/hosts文件:

mytest1 192.169.201.7

mytest2 192.169.201.8

将各节点的主机名写入/etc/sysconfig/network文件中.

3.设置各节点的信息关系:

在mytest1上执行:

ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa

ssh-copy-id -i ~/.ssh/id_dsa.pub  root@mytest2

在mytest2上执行:

ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa

ssh-copy-id -i ~/.ssh/id_dsa.pub  root@mytest1


4.设置时间同步:

ntpdate  192.168.201.7


5.安装软件包:

heartbeat - Heartbeat subsystem for High-Availability Linux

heartbeat-gui - Provides a gui interface to manage heartbeat clusters

heartbeat-ldirectord - Monitor daemon for maintaining high availability resources

heartbeat-pils - Provides a general plugin and interface loading library

heartbeat-stonith - Provides an interface to Shoot The Other Node In The Head

perl-MailTools - Various mail-related perl modules

libnet - C library for portable packet creation and injection

yum --nogpgcheck install heartbeat-2.1.4-11.el5.x86_64.rpm \

heartbeat-gui-2.1.4-11.el5.x86_64.rpm  \

heartbeat-ldirectord-2.1.4-11.el5.x86_64.rpm \

heartbeat-pils-2.1.4-11.el5.x86_64.rpm \

heartbeat-stonith-2.1.4-11.el5.x86_64.rpm \

libnet-1.1.6-7.el5.x86_64.rpm 


6.修改配置文件:

6.0样例配置文件:

[root@mytest2 ha.d]# ls -l /usr/share/doc/heartbeat-2.1.4/

总计 460

-rw-r--r-- 1 root root   1873 2010-03-21 apphbd.cf

-rw-r--r-- 1 root root    645 2010-03-21 authkeys

-rw-r--r-- 1 root root   3470 2010-03-21 AUTHORS

-rw-r--r-- 1 root root 157643 2010-03-21 ChangeLog

-rw-r--r-- 1 root root  17989 2010-03-21 COPYING

-rw-r--r-- 1 root root  26532 2010-03-21 COPYING.LGPL

-rw-r--r-- 1 root root  12951 2010-03-21 DirectoryMap.txt

-rw-r--r-- 1 root root  24835 2010-03-21 faqntips.html

-rw-r--r-- 1 root root     87 2010-03-21 faqntips.txt

-rw-r--r-- 1 root root  32462 2010-03-21 GettingStarted.html

-rw-r--r-- 1 root root     99 2010-03-21 GettingStarted.txt

-rw-r--r-- 1 root root  10539 2010-03-21 ha.cf

-rw-r--r-- 1 root root  15809 2010-03-21 HardwareGuide.html

-rw-r--r-- 1 root root     97 2010-03-21 HardwareGuide.txt

-rw-r--r-- 1 root root   5905 2010-03-21 haresources

-rw-r--r-- 1 root root  19046 2010-03-21 hb_report.html

-rw-r--r-- 1 root root     89 2010-03-21 hb_report.txt

-rw-r--r-- 1 root root  34067 2010-03-21 heartbeat_api.html

-rw-r--r-- 1 root root     97 2010-03-21 heartbeat_api.txt

-rw-r--r-- 1 root root    871 2010-03-21 logd.cf

-rw-r--r-- 1 root root   1270 2010-03-21 README

-rw-r--r-- 1 root root   4654 2010-03-21 Requirements.html

-rw-r--r-- 1 root root     95 2010-03-21 Requirements.txt

-rw-r--r-- 1 root root  24104 2010-03-21 rsync.html

-rw-r--r-- 1 root root     81 2010-03-21 rsync.txt

-rw-r--r-- 1 root root    784 2010-03-21 startstop

cd /usr/share/doc/heartbeat-2.1.4/;

cp -p authkeys ha.cf haresource /etc/ha.d/


6.1密钥文件:

产生随机数:

[root@mytest1 ha.d]# dd if=/dev/random count=1 bs=512|md5sum

0+1 records in

0+1 records out

128 bytes (128 B) copied, 0.000448 seconds, 286 kB/s

ae0090b45f102e58084b6e3ce6f2d4c4  -

将两个节点的authkes文件修改为如下内容:

auth 1

1 md5 ae0090b45f102e58084b6e3ce6f2d4c4

6.2修改两节点的heartbeat服务的配置文件ha.cf,增加如下内容:

bcast   eth0

node    mytest1

node    mytest2

ping    192.168.201.2

6.3资源管理配置文件haresources

heartbeat默认通过/usr/lib64/heartbeat/findif将vip设置到与网卡上地址在同一网段的网卡上,如果需要明确指明,需要修改haresources配置文件.

查找服务脚本的默认路径是:

/etc/ha.d/resource.d

/etc/init.d/

在两节点的haresources中增加如下内容:

mytest1 IPaddr::192.168.201.100/24/eth0 httpd

7.安装httpd服务:

yum install httpd

在两个节点上执行如下命令:

echo "<h1>this is the `hostname` server</h1>" >/var/www/html/index.html 

8.启动heartbeat服务:

service heartbeat start

ssh mytest2 "service heartbeat start"

9.在浏览器访问vip地址测试.

显示访问的是mytest1的web服务.

10.主备切换.

/usr/lib64/heartbeat/hb_standby

11.在浏览器访问vip地址测试.

显示访问的是mytest2的web服务.

12.配置NFS服务器:

mkdr /myweb

echo "/myweb  192.168.201.0/24(ro)" >>/etc/exports

service nfs start

[root@mytest3 ~]# showmount -e

Export list for mytest3:

/myweb 192.168.201.0/24

echo "<h1>NFS server</h1>" > /myweb/index.html


13.在两个节点上手工挂载文件系统:

mount 192.168.201.9:/myweb  /mnt

umount /mnt

14.在两节点编辑haresources配置文件:

修改如下内容:

mytest1  IPaddr::192.168.201.100/24/eth0 httpd

修改后为如下内容:

mytest1  IPaddr::192.168.201.100/24/eth0 Filesystem::192.168.201.9:/myweb::/var/www/html::nfs httpd


15.启动服务,并验证:

service heartbeat start

ssh mytest2 "service heartbeat start"


16.至此heartbeat实验测试完毕.


本文出自 “webseven” 博客,请务必保留此出处http://webseven.blog.51cto.com/4388012/1549942

linux高可用之heartbeat_v1安装与配置

标签:heartbeat   ha   webseven   

原文地址:http://webseven.blog.51cto.com/4388012/1549942

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!