当前位置:首页 > RHEL下部署heartbeat,实现简单故障转移群集
RHEL下部署heartbeat,实现简单故障转移群集
实验环境:RHEL 5.5 64bit
实验需求:VM虚拟机、heartbeat安装包
实验目的:实现两台samba服务器之间的自动切换,以及磁盘的共享存储,达到简单故障转移的目的。 实验规划: HOSTA:
hostname:sev1.example.com sev1 eth0:192.168.138.10 eth1:192.168.1.10 (心跳端口) GW:192.168.138.2 主节点 HOSTB: hostname:sev2.example.com sev2 eth0:192.168.138.20 eth1:192.168.1.20 (心跳端口) GW:192.168.138.2 备用节点 实验步骤:
1、打开VMware虚拟机,首先安装2台虚拟主机,均使用RHEL 5.5 64bit操作系统。在安装操作系统的时候注意把samba服务安装好。(如果等系统安装好之后再装samba的话,依赖关系很杂,使用rpm安装不太方便!)
2、在HOSTA虚拟主机下修改虚拟配置,手动添加一个磁盘做共享,暂时命名为share,这里为了实现2台机器能自动挂载共享存储,需修改该磁盘的参数。在VM的根目录下找的新建的共享磁盘,修改share.vmx文件,添加如下几行参数: disk.locking = \
diskLib.dataCacheMaxSize=0 diskLib.dataCacheMaxReadAheadSize=0 diskLib.dataCacheMinReadAheadSize=0 diskLib.dataCachePageSize=4096 diskLib.maxUnsyncedWrites=0
scsi0:1.sharedBus = \(scsi是虚拟设备节点,根据实际情况修改即可) scsi0:1.shared = \
3、启动HOSTA,用root身份登录(方便以后操作),打开终端,使用fdisk -l命令查看磁盘,接着格式化该磁盘,这里我是想使用整个磁盘,所以就不分区,直接格式化成ext3格式,具体命令如下:
fdisk -l 查询该磁盘“盘符” /dev/sdb
fdisk /dev/sdb m(这里可以用不同的参数分区,就不多说了,自己百度) 重启之 终端输入 mkdir -p /home/share 新建挂载点 mkfs -t ext3 -c /dev/sdb 格式化为ext3
tips:手动挂载 mount /dev/sdb /home/share 测试成功! (记得unmount)
4、HOSTB的配置不需要新建磁盘,直接在添加硬盘的时候选择已存在的硬盘,指定到share这个磁盘,记得使用新建好挂载点之后要测试下,mount成功即可。
5、配置samba服务器:a、采用终端配置,直接终端输入vi /etc/samba/smb.conf (主配置文件)。b、图形化界面配置,路径为:管理-->服务器-->samba 。samba配置很简单,就不多说了,关键是要搞懂权限问题。(自己也有点模糊~!) 6、在HOSTA上安装heartbeat软件
这里采用rpm安装,直接把安装包CP到虚拟机里,heartbeat-2.1.3-3版本需要3个包,安装顺序如下:
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
安装方法:先cd到该目录,ls查看文件,rpm -ivh
heartbeat-pils-2.1.3-3.el5.centos.i386.rpm (注意使用tab键),根据提示安装即可。待3个包都安装好之后,最好rpm -q heartbeat -d 查看安装了哪些东西,这是一个好习惯哈。
7、heartbeat安装好之后,在/use/share/doc/heartbeat-2.1.3下找到以下3个文件:authkeys haresources ha.cf 把这三个文件cp到/etc/ha.d 下面。具体配置如下: a、ha.cf配置:
There are lots of options in this file. All you have to have is a set
# of nodes listed {\# and a value for \
# ATTENTION: As the configuration file is read line by line, # THE ORDER OF DIRECTIVE MATTERS!
# In particular, make sure that the udpport, serial baud rate # etc. are set before the heartbeat media are defined! # debug and log file directives go into effect when they # are encountered.
# All will be fine if you keep them ordered as in this example. # Note on logging:
# If any of debugfile, logfile and logfacility are defined then they # will be used. If debugfile and/or logfile are not defined and # logfacility is defined then the respective logging and debug # messages will be loged to syslog. If logfacility is not defined # then debugfile and logfile will be used to log messges. If
# logfacility is not defined and debugfile and/or logfile are not # defined then defaults will be used for debugfile and logfile as # required and messages will be sent there. # File to write debug messages to #debugfile /var/log/ha-debug
# File to write other messages to logfile /var/log/ha-log
# Facility to use for syslog()/logger logfacility local0
# A note on specifying \# The default time unit is seconds # 10 means ten seconds
# You can also specify them in milliseconds # 1500ms means 1.5 seconds
# keepalive: how long between heartbeats? keepalive 2
# deadtime: how long-to-declare-host-dead?
# If you set this too low you will get the problematic # split-brain (or cluster partition) problem.
# See the FAQ for how to use warntime to tune deadtime. deadtime 60
# warntime: how long before issuing \# See the FAQ for how to use warntime to tune deadtime. warntime 10
# Very first dead time (initdead)
# On some machines/OSes, etc. the network takes a while to come up # and start working right after you've been rebooted. As a result # we have a separate dead time for when things first come up. # It should be at least twice the normal dead time. initdead 120
# What UDP port to use for bcast/ucast communication? #
udpport 694
# Baud rate for serial ports... #baud 19200
# serial serialportname ... #serial /dev/ttyS0 # Linux #serial /dev/cuaa0 # FreeBSD #serial /dev/cuad0 # FreeBSD 6.x #serial /dev/cua/a # Solaris
# What interfaces to broadcast heartbeats over? bcast eth1 # Linux
#bcast eth1 eth2 # Linux #bcast le0 # Solaris #bcast le1 le2 # Solaris
# Set up a multicast heartbeat medium
# mcast [dev] [mcast group] [port] [ttl] [loop] # [dev] device to send/rcv heartbeats on
# [mcast group] multicast group to join (class D multicast address # 224.0.0.0 - 239.255.255.255)
# [port] udp port to sendto/rcvfrom (set this value to the # same value as \
# [ttl] the ttl value for outbound heartbeats. this effects # how far the multicast packet will propagate. (0-255) # Must be greater than zero.
# [loop] toggles loopback for outbound multicast heartbeats. # if enabled, an outbound packet will be looped back and # received by the interface it was sent on. (0 or 1) # Set this value to zero. #mcast eth0 225.0.0.1 694 1 0
# Set up a unicast / udp heartbeat medium # ucast [dev] [peer-ip-addr]
# [dev] device to send/rcv heartbeats on
# [peer-ip-addr] IP address of peer to send packets to ucast eth1 192.168.1.20
# About boolean values...
# Any of the following case-insensitive values will work for true: # true, on, yes, y, 1
# Any of the following case-insensitive values will work for false: # false, off, no, n, 0
# auto_failback: determines whether a resource will
# automatically fail back to its \# on whatever node is serving it until that node fails, or # an administrator intervenes.
# The possible values for auto_failback are: # on - enable automatic failbacks # off - disable automatic failbacks
# legacy - enable automatic failbacks in systems # where all nodes do not yet support # the auto_failback option.
# auto_failback \# \
# See the FAQ for information on how to convert
# from \# (i.e., using a \
# The default value for auto_failback is \# will issue a warning at startup. So, make sure you put # an auto_failback directive in your ha.cf file.
# (note: auto_failback can be any boolean or \#
auto_failback on
# Basic STONITH support
# Using this directive assumes that there is one stonith # device in the cluster. Parameters to this device are
# read from a configuration file. The format of this line is: # stonith
# NOTE: it is up to you to maintain this file on each node in the # cluster!
#stonith baytech /etc/ha.d/conf/stonith.baytech # STONITH support
# You can configure multiple stonith devices using this directive. # The format of the line is:
# stonith_host
#
共分享92篇相关文档