共计 6103 个字符,预计需要花费 16 分钟才能阅读完成。
HeartBeat 基于 Resources 简单配置
实验环境:RedHat5.8 i386
为使实验顺利,请关闭防火墙与 selinux
软件包:下载地址:http://dl.Fedoraproject.org/pub/epel/5/i386/repoview/letter_h.group.html
heartbeat – Heartbeat subsystem for High-Availability Linux
heartbeat-devel – Heartbeat development package
heartbeat-gui – Provides a gui interface to manage heartbeat clusters
heartbeat-ldirectord – Monitor daemon for maintaining high availability resources, 为 ipvs 高可用提供规则自动生成及后端 realserver 健康状态检查的组件;
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-1.77-1.el5.noarch.rpm
libnet-1.1.4-3.el5.i386.rpm
1、名称解析必需用 /etc/hosts,节点名称必须与 uname - n 命令结果保持一致;
# vim /etc/hosts
2、ssh 互信通信
node1
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ”
# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.100.8
# ssh 192.168.100.8
node2
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ”
# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.100.7
# ssh 192.168.100.7
3、各节点时间要同步
# hwclock -w
当然上面这是在实验环境使用,在生产环境配置 ntp 服务就可以了
4、安装软件包
# ls
rw-r–r– 1 root root 1637238 Mar 20 08:56 heartbeat-2.1.4-9.el5.i386.rpm
-rw-r–r– 1 root root 230890 Mar 20 08:56 heartbeat-gui-2.1.4-9.el5.i386.rpm
-rw-r–r– 1 root root 92070 Mar 20 08:56 heartbeat-pils-2.1.4-10.el5.i386.rpm
-rw-r–r– 1 root root 179199 Mar 20 08:56 heartbeat-stonith-2.1.4-10.el5.i386.rpm
-rw-r–r– 1 root root 56817 Mar 20 08:56 libnet-1.1.4-3.el5.i386.rpm
-rw-r–r– 1 root root 92071 Mar 20 08:56 perl-MailTools-1.77-1.el5.noarch.rpm
# yum –nogpgcheck localinstall *.rpm -y
注:这一步可以自动解决依赖关系,前提是你的本地 yum 源己配置好了
5、启动服务
# yum install httpd -y
httpd 必须关闭且开机不能自动启动
node1
# echo “<h1>node1.neo.com</h1>” >/var/www/html/index.html
# chkconfig httpd off
node2
# chkconfig httpd off
# echo “<h1>node2.neo.com</h1>” >/var/www/html/index.html
这里面要三个配置文件:
1、密钥文件;
2、heartbeat 服务的配置文件 ha.cf
3、资源管理配置文件 haresources
# cp /usr/share/doc/heartbeat-2.1.4/{authkeys,ha.cf,haresources} /etc/ha.d/
# chmod 600 authkeys
# vim authkeys 添加两行
auth 1
1 md5 d41d8cd98f00b204e9800998ecf8427e
注:后面一串是用 md5sum 生成的随机数,用户自己随意定义都成,但格式需一致
# vim ha.cf
logfile /var/log/heartbeat.log
logfacility local0
keepalive 1
bcast eth0
node node1.neo.com
node node2.neo.com
ping 192.168.100.2
# vim haresources
node1.neo.com IPaddr::192.168.100.5/24/eth0 httpd
# scp -p authkeys haresources ha.cf 192.168.100.8:/etc/ha.d/
# service heartbeat start
# ssh 192.168.100.8 ‘service heartbeat start’
注:这里最好是使用主节点远程启动从节点,关闭时先关闭从节点再关闭主节点
查看日志状态:/var/log/message
故障测试:
# cd /usr/lib/heartbeat
# ./hb_standby
此脚本是 heartbeat 自带的一个故障测试文件
# ifconfig eth0 可以看到在 node2 上有个接口 eth0:0
推荐阅读:
Linux 高可用(HA)集群之 heartbeat 基于 crm 进行资源管理详解 http://www.linuxidc.com/Linux/2013-08/89167.htm
Heartbeat+httpd+NFS 实现高可用的 Web 服务器 http://www.linuxidc.com/Linux/2013-08/88520.htm
Linux 高可用(HA)集群之 Heartbeat 详解 http://www.linuxidc.com/Linux/2013-08/88521.htm
Linux 高可用性方案之 Heartbeat 的 CRM 配置 http://www.linuxidc.com/Linux/2012-05/60838.htm
高可用集群 Heartbeat v1 实例 http://www.linuxidc.com/Linux/2013-09/90757.htm
LVS+heartbeat+ldirectord 高可用负载均衡集群解决方案 http://www.linuxidc.com/Linux/2011-09/42911.htm
实验共享存储自动挂载:
# service 192.168.100.8 ‘service heartbeat stop’
# service heartbeat stop
新建一台虚拟机启动 nfs 服务
# mkdir /web/htdocs -p
# echo “<h1>FS.neo.com</h1>” >/web/htdocs/index.html
# service nfs start
# vim /etc/exports
/web/htdocs 192.168.100.0/24(ro)
# service iptables stop
# getenforce 0
# vim /etc/ha.d/haresources
node1.neo.com IPaddr::192.168.100.5/24/eth0 Filesystem::192.168.100.9:/web/htdocs::/var/www/html::nfs httpd
注:此处为一行
# scp /etc/ha.d/haresources 192.168.100.8:/etc/ha.d/
# service heartbeat start
# ssh 192.168.100.8 ‘service heartbeat start’
HeartBeat 基于 Resources 简单配置
实验环境:RedHat5.8 i386
为使实验顺利,请关闭防火墙与 selinux
软件包:下载地址:http://dl.Fedoraproject.org/pub/epel/5/i386/repoview/letter_h.group.html
heartbeat – Heartbeat subsystem for High-Availability Linux
heartbeat-devel – Heartbeat development package
heartbeat-gui – Provides a gui interface to manage heartbeat clusters
heartbeat-ldirectord – Monitor daemon for maintaining high availability resources, 为 ipvs 高可用提供规则自动生成及后端 realserver 健康状态检查的组件;
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-1.77-1.el5.noarch.rpm
libnet-1.1.4-3.el5.i386.rpm
1、名称解析必需用 /etc/hosts,节点名称必须与 uname - n 命令结果保持一致;
# vim /etc/hosts
2、ssh 互信通信
node1
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ”
# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.100.8
# ssh 192.168.100.8
node2
# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ”
# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.100.7
# ssh 192.168.100.7
3、各节点时间要同步
# hwclock -w
当然上面这是在实验环境使用,在生产环境配置 ntp 服务就可以了
4、安装软件包
# ls
rw-r–r– 1 root root 1637238 Mar 20 08:56 heartbeat-2.1.4-9.el5.i386.rpm
-rw-r–r– 1 root root 230890 Mar 20 08:56 heartbeat-gui-2.1.4-9.el5.i386.rpm
-rw-r–r– 1 root root 92070 Mar 20 08:56 heartbeat-pils-2.1.4-10.el5.i386.rpm
-rw-r–r– 1 root root 179199 Mar 20 08:56 heartbeat-stonith-2.1.4-10.el5.i386.rpm
-rw-r–r– 1 root root 56817 Mar 20 08:56 libnet-1.1.4-3.el5.i386.rpm
-rw-r–r– 1 root root 92071 Mar 20 08:56 perl-MailTools-1.77-1.el5.noarch.rpm
# yum –nogpgcheck localinstall *.rpm -y
注:这一步可以自动解决依赖关系,前提是你的本地 yum 源己配置好了
5、启动服务
# yum install httpd -y
httpd 必须关闭且开机不能自动启动
node1
# echo “<h1>node1.neo.com</h1>” >/var/www/html/index.html
# chkconfig httpd off
node2
# chkconfig httpd off
# echo “<h1>node2.neo.com</h1>” >/var/www/html/index.html
这里面要三个配置文件:
1、密钥文件;
2、heartbeat 服务的配置文件 ha.cf
3、资源管理配置文件 haresources
# cp /usr/share/doc/heartbeat-2.1.4/{authkeys,ha.cf,haresources} /etc/ha.d/
# chmod 600 authkeys
# vim authkeys 添加两行
auth 1
1 md5 d41d8cd98f00b204e9800998ecf8427e
注:后面一串是用 md5sum 生成的随机数,用户自己随意定义都成,但格式需一致
# vim ha.cf
logfile /var/log/heartbeat.log
logfacility local0
keepalive 1
bcast eth0
node node1.neo.com
node node2.neo.com
ping 192.168.100.2
# vim haresources
node1.neo.com IPaddr::192.168.100.5/24/eth0 httpd
# scp -p authkeys haresources ha.cf 192.168.100.8:/etc/ha.d/
# service heartbeat start
# ssh 192.168.100.8 ‘service heartbeat start’
注:这里最好是使用主节点远程启动从节点,关闭时先关闭从节点再关闭主节点
查看日志状态:/var/log/message
故障测试:
# cd /usr/lib/heartbeat
# ./hb_standby
此脚本是 heartbeat 自带的一个故障测试文件
# ifconfig eth0 可以看到在 node2 上有个接口 eth0:0
推荐阅读:
Linux 高可用(HA)集群之 heartbeat 基于 crm 进行资源管理详解 http://www.linuxidc.com/Linux/2013-08/89167.htm
Heartbeat+httpd+NFS 实现高可用的 Web 服务器 http://www.linuxidc.com/Linux/2013-08/88520.htm
Linux 高可用(HA)集群之 Heartbeat 详解 http://www.linuxidc.com/Linux/2013-08/88521.htm
Linux 高可用性方案之 Heartbeat 的 CRM 配置 http://www.linuxidc.com/Linux/2012-05/60838.htm
高可用集群 Heartbeat v1 实例 http://www.linuxidc.com/Linux/2013-09/90757.htm
LVS+heartbeat+ldirectord 高可用负载均衡集群解决方案 http://www.linuxidc.com/Linux/2011-09/42911.htm