Heartbeat配置Linux高可用性集群 下载本文

内容发布更新时间 : 2024/6/13 16:17:27星期一 下面是文章的全部内容请认真阅读。

用Heartbeat配置Linux高可用性集群

1. 拓普图

2. 实验环境

操作系统:Red Hat Enterprise linux 5.0 32位系统 Heartbeat 安装软件包

heartbeat-pils-2.1.3-3.el5.centos.i386.rpm

heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm heartbeat-2.1.3-3.el5.centos.i386.rpm

1

3. 网络环境

主服务器:

Chun1.artemis.com 192.168.2.88 255.255.255.0(常规的网络) IP地址 10.0.0.1 255.0.0.0(heartbeat 专用网络) 备份服务器:

Chun2.artemis.com 192.168.2.119 255.255.255.0(常规网络) IP地址 10.0.0.2 255.0.0.0(heartbeat专用网络)

4. 安装heartbeat

创建用户和用户组

heartbeat需要haclient用户组和hacluster用户。

两个节点做同样的操作,并保证haclient和hacluster的ID一样。 groupadd haclient

useradd -g haclient hacluster

然后用 rpm –ivh 分别进行安装

rpm –ivh heartbeat-pils-2.1.3-3.el5.centos.i386.rpm rpm –ivh heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm rpm –ivh heartbeat-2.1.3-3.el5.centos.i386.rpm

注:编译安装 heatbeat注意 heartbeat编译安装有些不一样,用里面的Configureme 配上 configure ,然后再 make ,make install

修改系统主机名等相关信息,主机名修改在/etc/sysconfig/network文件中修改,改后重启生效。

修改主机名解析文件 ,/etc/hosts。内容如下:

# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.2.88 chun1.artemis.com chun1 10.0.0.1 chun1

192.168.2.119 chun2.artemis.com chun2 10.0.0.2 chun2

其中本机业务ip为 192.168.2.88,HA心跳用ip 为10.0.0.1 ,主机名为chun1。可以将此文件拷贝

2

至备机。目的就是要保证2台机器可以通过主机名通信,这里如果没有设置好可能会导至HA功能失败;

5. 配置heartbeat

从heart编译目录/doc 中拷贝文件ha.cf , haresource, authkeys 到 heartbeat的默认配置目录 /etc/ha.d/中。

Authkeys 设置 (authkeys 是个认证文件)

编辑 authkeys ,内容如下: #

# Authentication file. Must be mode 600 # #

# Must have exactly one auth directive at the front.

# auth send authentication using this method-id #

# Then, list the method and key that go with that method-id #

# Available methods: crc sha1, md5. Crc doesn't need/want a key. #

# You normally only have one authentication method-id listed in this file #

# Put more than one to make a smooth transition when changing auth # methods and/or keys. # #

# sha1 is believed to be the \#

# crc adds no security, except from packet corruption. # Use only on physically secure networks. #

#auth 1 #1 crc

#2 sha1 HI! #3 md5 Hello! auth 1 1 crc

注意:文件第1行的提示,要把文件属性改为 600 , 执行 chmod 600 /etc/ha.d/authkeys

3