heartbeat安装配置及httpd高可用简单示例
2015-06-08 22:21
621 查看
注意事项:
1、节点名称:hostname、/etc/hosts
2、ssh互信
3、节点时间同步
heartbeat的三个配置文件:
authkeys:通信密钥文件
ha.cf:heartbeat服务配置文件
haresources:资源管理配置文件
安装配置(系统为CentOS6.5):
WAN IP:192.168.101.168
node1:192.168.101.21
node2:192.168.101.22
1、配置node1、node2节点名称、ssh互信、时间同步
node1:
# hostname node1.redhat.com
# vim /etc/sysconfig/network
HOSTNAME=node1.redhat.com
# vim /etc/hosts
192.168.101.21 node1.redhat.com node1
192.168.101.22 node2.redhat.com node2
# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node2
# ntpdate 0.centos.pool.ntp.org
node2:
# hostname node2.redhat.com
# vim /etc/sysconfig/networkHOSTNAME=node2.redhat.com
# vim /etc/hosts192.168.101.21 node1.redhat.com node1192.168.101.22 node2.redhat.com node2
# ssh-keygen -t rsa# ssh-copy-id -i ~/.ssh/id_rsa.pub node1
# ntpdate 0.centos.pool.ntp.org
2、node1、node2安装heartbeat# 注意:这里使用CentOS本地iso yum源+EPEL源安装。# yum install http://mirrors.zju.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm# yum install heartbeat cluster-glue resource-agents pacemaker httpd
3、node1配置heartbeat
# 拷贝配置文件至/etc/ha.d/# cp -p /usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources} /etc/ha.d/
# 配置生成通信密钥# openssl rand -base64 20tRlI5Dr/YHoE59kJ4yYOgNpVmDI=
# vim /etc/ha.d/authkeysauth 1
1 md5 tRlI5Dr/YHoE59kJ4yYOgNpVmDI=
# chmod 600 /etc/ha.d/authkeys
# 配置heartbeat主配置文件
# vim /etc/ha.d/ha.cf
logfile/var/log/ha-log # 日志文件路径
keepalive 1 # 心跳信息传递间隔时间,这里设置1秒
deadtime 30 # 节点超时时间,超过30s没有收到心跳信息则认为节点死亡
warntime 10 # 告警时间
initdead 120 # heartbeat首次启动等待时间,默认120秒,此时间设置为deadtime的两倍
udpport 694 # 心跳信息传递所使用的端口
mcast eth0 225.1.1.1 694 1 0 # 采用组播地址
auto_failback off # 是否开启故障恢复
nodenode1.redhat.com # 主节点名称,必须与uname -n一致
nodenode2.redhat.com # 备用节点名称
ping 192.168.101.254 # 通过ping网关来检测心跳信息是否正常
# 配置资源管理文件,绑定外网IP:192.168.101.168
# vim /etc/ha.d/haresources
node1.redhat.com IPaddr::192.168.101.168/24/eth0/ httpd
4、复制配置文件至node2
# scp -p /etc/ha.d/{ha.cf,authkeys,haresources} node2:/etc/ha.d/
5、创建httpd index.html页面并关闭开机自启动httpd
# echo "<h1>node1.redhat.com</h1>" > /var/www/html/index.html
# ssh node2 'echo "<h1>node2.redhat.com</h1>" > /var/www/html/index.html'
# chkconfig httpd off
# ssh node2 'chkconfig httpd off'
6、启动heartbeat
# 链接heartbeat各类脚本
# ln -s /usr/share/heartbeat/* /usr/lib64/heartbeat/
# /etc/init.d/heartbeat start
# ssh node2 '/etc/init.d/heartbeat start'
7、查看日志、绑定IP及浏览器访问
# tail /var/log/ha-log
# ifconfig http://192.168.101.168/
8、使用NFS共享存储
# NFS主机IP为:192.168.101.28
# NFS共享目录:/data/www/
# vim /data/www/index.html
NFS Server.
# 停止heartbeat
# ssh node2 '/etc/init.d/heartbeat stop'
# /etc/init.d/heartbeat stop
# node1修改资源配置文件并复制到node2
# vim /etc/ha.d/haresources
node1.redhat.com IPaddr::192.168.101.168/24/eth0/ Filesystem::192.168.101.28:/data/www::/var/www/html::nfs httpd
# scp /etc/ha.d/haresources node2:/etc/ha.d/
9、启动heartbeat
# /etc/init.d/heartbeat start
# ssh node2 '/etc/init.d/heartbeat start'
10、查看日志、绑定IP及浏览器访问
# tail /var/log/ha-log# ifconfighttp://192.168.101.168/
11、节点切换测试
# /usr/share/heartbeat/hb_standby
1、节点名称:hostname、/etc/hosts
2、ssh互信
3、节点时间同步
heartbeat的三个配置文件:
authkeys:通信密钥文件
ha.cf:heartbeat服务配置文件
haresources:资源管理配置文件
安装配置(系统为CentOS6.5):
WAN IP:192.168.101.168
node1:192.168.101.21
node2:192.168.101.22
1、配置node1、node2节点名称、ssh互信、时间同步
node1:
# hostname node1.redhat.com
# vim /etc/sysconfig/network
HOSTNAME=node1.redhat.com
# vim /etc/hosts
192.168.101.21 node1.redhat.com node1
192.168.101.22 node2.redhat.com node2
# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node2
# ntpdate 0.centos.pool.ntp.org
node2:
# hostname node2.redhat.com
# vim /etc/sysconfig/networkHOSTNAME=node2.redhat.com
# vim /etc/hosts192.168.101.21 node1.redhat.com node1192.168.101.22 node2.redhat.com node2
# ssh-keygen -t rsa# ssh-copy-id -i ~/.ssh/id_rsa.pub node1
# ntpdate 0.centos.pool.ntp.org
2、node1、node2安装heartbeat# 注意:这里使用CentOS本地iso yum源+EPEL源安装。# yum install http://mirrors.zju.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm# yum install heartbeat cluster-glue resource-agents pacemaker httpd
3、node1配置heartbeat
# 拷贝配置文件至/etc/ha.d/# cp -p /usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources} /etc/ha.d/
# 配置生成通信密钥# openssl rand -base64 20tRlI5Dr/YHoE59kJ4yYOgNpVmDI=
# vim /etc/ha.d/authkeysauth 1
1 md5 tRlI5Dr/YHoE59kJ4yYOgNpVmDI=
# chmod 600 /etc/ha.d/authkeys
# 配置heartbeat主配置文件
# vim /etc/ha.d/ha.cf
logfile/var/log/ha-log # 日志文件路径
keepalive 1 # 心跳信息传递间隔时间,这里设置1秒
deadtime 30 # 节点超时时间,超过30s没有收到心跳信息则认为节点死亡
warntime 10 # 告警时间
initdead 120 # heartbeat首次启动等待时间,默认120秒,此时间设置为deadtime的两倍
udpport 694 # 心跳信息传递所使用的端口
mcast eth0 225.1.1.1 694 1 0 # 采用组播地址
auto_failback off # 是否开启故障恢复
nodenode1.redhat.com # 主节点名称,必须与uname -n一致
nodenode2.redhat.com # 备用节点名称
ping 192.168.101.254 # 通过ping网关来检测心跳信息是否正常
# 配置资源管理文件,绑定外网IP:192.168.101.168
# vim /etc/ha.d/haresources
node1.redhat.com IPaddr::192.168.101.168/24/eth0/ httpd
4、复制配置文件至node2
# scp -p /etc/ha.d/{ha.cf,authkeys,haresources} node2:/etc/ha.d/
5、创建httpd index.html页面并关闭开机自启动httpd
# echo "<h1>node1.redhat.com</h1>" > /var/www/html/index.html
# ssh node2 'echo "<h1>node2.redhat.com</h1>" > /var/www/html/index.html'
# chkconfig httpd off
# ssh node2 'chkconfig httpd off'
6、启动heartbeat
# 链接heartbeat各类脚本
# ln -s /usr/share/heartbeat/* /usr/lib64/heartbeat/
# /etc/init.d/heartbeat start
# ssh node2 '/etc/init.d/heartbeat start'
7、查看日志、绑定IP及浏览器访问
# tail /var/log/ha-log
# ifconfig http://192.168.101.168/
8、使用NFS共享存储
# NFS主机IP为:192.168.101.28
# NFS共享目录:/data/www/
# vim /data/www/index.html
NFS Server.
# 停止heartbeat
# ssh node2 '/etc/init.d/heartbeat stop'
# /etc/init.d/heartbeat stop
# node1修改资源配置文件并复制到node2
# vim /etc/ha.d/haresources
node1.redhat.com IPaddr::192.168.101.168/24/eth0/ Filesystem::192.168.101.28:/data/www::/var/www/html::nfs httpd
# scp /etc/ha.d/haresources node2:/etc/ha.d/
9、启动heartbeat
# /etc/init.d/heartbeat start
# ssh node2 '/etc/init.d/heartbeat start'
10、查看日志、绑定IP及浏览器访问
# tail /var/log/ha-log# ifconfighttp://192.168.101.168/
11、节点切换测试
# /usr/share/heartbeat/hb_standby
相关文章推荐
- 计算机网络技术基础知识
- android从零开始(五)读取网络图片
- 计算机网络学习(7)网络层
- HttpClient之Get请求和Post请求示例
- 看懂信息检索和网络数据挖掘领域论文的必备知识总结
- 黑马程序员——网络编程总结(二)
- iOS开发网络数据之AFNetworking使用2.0和2.5
- 看《网络安全漏洞的罪与罚》有感
- 【经验总结】tcp_tw_recycle参数引发的故障
- Linux Tcp/ip UDP基本概念(6.8)
- NFS(网络文件系统)简述及使用
- 模拟http或https请求,实现ssl下的bugzilla登录、新增BUG,保持会话以及处理token
- 复杂网络盘传播搜索关键字
- Select和epoll的区别
- 我的异想天开博客,网络运营商
- Android 网络请求实现
- 微信公众号开发系列-Http请求包基类
- http://poj.org/problem?id=3984 迷宫问题
- “System.Web.HttpRequestBase”未被引用的程序
- WinXP 无线技巧“区域没有通过无线网络中的发现”一个可能的原因!