002.Heartbeat部署及httpd高可用
一 前期准备
1.1 依赖准备
1.2 环境准备
节点/主机名
|
业务IP
|
心跳IP
|
master1.yewu.com
|
192.168.88.100
|
192.168.77.100
|
master2.yewu.com
|
192.168.88.101
|
192.168.77.101
|
vip
|
192.168.88.88
|
# hostnamectl set-hostname master1.yewu.com
# hostnamectl set-hostname master2.yewu.com #分别配置主机名
# /etc/hosts
127.0.0.1 localhost.localdomain localhost
#public ip #业务host解析
192.168.88.100 master1.yewu.com master1
192.168.88.101 master2.yewu.com master2 #private ip #Heartbeat心跳解析
192.168.77.100 master1-private.ha.com master1-private
192.168.77.101 master2-private.ha.com master2-private
[root@master1 ~]# ifconfig |grep eth[0-9] -A1 #确认相应IP地址

[root@master1 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
[root@master1 ~]# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.88.101
[root@master2 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
[root@master2 ~]# ssh-copy-id -i ./.ssh/id_rsa.pub root@192.168.88.100
二 正式安装Heartbeat
2.1 下载相应包
[root@master1 ~]# wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
[root@master1 ~]# wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
[root@master1 ~]# wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz
2.2 安装cluster-glue
[root@master1 ~]# groupadd haclient
[root@master1 ~]# useradd -g haclient hacluster
[root@master1 ~]# tar xf 0a7add1d9996.tar.bz2
[root@master1 ~]# mv Reusable-Cluster-Components-glue--0a7add1d9996/ cluster_glue
[root@master1 ~]# cd cluster_glue/
[root@master1 cluster_glue]# ./autogen.sh
[root@master1 cluster_glue]# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'

[root@master1 cluster_glue]# make && make install
2.3 安装Resource Agents
[root@master1 ~]# tar xf v3.9.6.tar.gz
[root@master1 ~]# cd resource-agents-3.9.6/
[root@master1 resource-agents-3.9.6]# ./autogen.sh
[root@master1 resource-agents-3.9.6]# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'

[root@master1 resource-agents-3.9.6]# make && make install
ln -s /usr/local/heartbeat/lib/* /lib/
ln -s /usr/local/heartbeat/lib/* /lib64/ #将生成的动态库,添加快捷方式到/lib下
2.4 安装Heartbeat
[root@master1 ~]# tar xf 958e11be8686.tar.bz2
[root@master1 ~]# export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib"
[root@master1 ~]# cd Heartbeat-3-0-958e11be8686/
[root@master1 Heartbeat-3-0-958e11be8686]# ./bootstrap
[root@master1 Heartbeat-3-0-958e11be8686]# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'

[root@master1 Heartbeat-3-0-958e11be8686]# make && make install
2.5 Heartbeat优化
[root@master1 ~]# cp /root/Heartbeat-3-0-958e11be8686/doc/{ha.cf,haresources,authkeys} \
/usr/local/heartbeat/etc/ha.d/ #复制相关配置文件
[root@master1 ~]# chmod 600 /usr/local/heartbeat/etc/ha.d/authkeys
[root@master1 ~]# mkdir -pv /usr/local/heartbeat/usr/lib/ocf/lib/heartbeat/
[root@master1 ~]# cp /usr/lib/ocf/lib/heartbeat/ocf-* \
/usr/local/heartbeat/usr/lib/ocf/lib/heartbeat/
[root@master1 ~]# ln -svf /usr/local/heartbeat/lib64/heartbeat/plugins/RAExec/* \
/usr/local/heartbeat/lib/heartbeat/plugins/RAExec/
[root@master1 ~]# ln -svf /usr/local/heartbeat/lib64/heartbeat/plugins/* \
/usr/local/heartbeat/lib/heartbeat/plugins/
[root@master1 ~]# chkconfig --add heartbeat #CentOS7可省略
[root@master1 ~]# systemctl enable heartbeat.service
[root@master1 ~]# systemctl start heartbeat.service
三 配置Heartbeat
3.1 安装httpd服务
[root@master1 ~]# yum -y install httpd
[root@master1 ~]# systemctl stop httpd
[root@master1 ~]# systemctl disable httpd #master2也需要安装
[root@master1 ~]# echo "master1.yewu.com" >>/var/www/html/index.html
[root@master2 ~]# echo "master2.yewu.com" >>/var/www/html/index.html
3.2 配置authkeys
[root@master1 ~]# vi /usr/local/heartbeat/etc/ha.d/authkeys
auth 3
3 md5 Yes!
3.3 配置Heartbeat
[root@master1 ~]# vi /usr/local/heartbeat/etc/ha.d/ha.cf
logfile /var/log/ha-log #记录Heartbeat其他相关日志信息
logfacility local0 #设置heartbeat的日志,这里用的是系统日志
keepalive 2 #设定心跳(监测)时间间隔为2秒
deadtime 15 #宣告死亡时间
warntime 10 #心跳延时时间
initdead 60 #初始化时间
udpport 694 #用于通信的UDP端口
bcast eth1 #接受广播心跳的网卡接口
ucast eth1 192.168.77.101 #置对方机器心跳检测的IP
auto_failback off #关闭自动切回恢复正常的主节点
node master1.yewu.com #集群节点的名称,必须匹配uname -n的结果。
node master2.yewu.com
ping 192.168.88.1
respawn hacluster /usr/local/heartbeat/libexec/heartbeat/ipfail
3.4 配置haresources
[root@master1 ~]# ll /usr/local/heartbeat/etc/ha.d/resource.d/ #查看现有资源类型
[root@master1 ~]# vi /usr/local/heartbeat/etc/ha.d/haresources
master1.yewu.com IPaddr::192.168.88.88/24/eth0 apache
[root@master1 ~]# scp /usr/local/heartbeat/etc/ha.d/{ha.cf,haresources,authkeys} 192.168.88.101:/usr/local/heartbeat/etc/ha.d/ #将所有配置复制至master2节点
[root@master2 ~]# vi /usr/local/heartbeat/etc/ha.d/ha.cf
ucast eth1 192.168.77.100 #置对方机器心跳检测的IP
四 验证Heartbeat
4.1 master1单节点启动验证
[root@master1 ~]# systemctl start heartbeat.service
[root@master1 ~]# tail -f /var/log/ha-log #验证日志



4.2 master2启动并验证
[root@master2 ~]# systemctl start heartbeat.service
[root@master1 ~]# tail -f /var/log/ha-log #观察master2节点启动后的master1日志


[root@master1 ~]# shutdownr #模拟master1节点宕机
[root@master2 ~]# ifconfig #master2节点会自动接管vip


002.Heartbeat部署及httpd高可用的更多相关文章
- Heartbeat实现web服务器高可用
一.Heartbeat概述: Heartbeat的工作原理:heartbeat最核心的包括两个部分,心跳监测部分和资源接管部分,心跳监测可以通过网络链路和串口进行,而且支持冗余链路,它们之间相互发送报 ...
- 配置:heartbeat+nginx+mysqld+drbd高可用笔记(OK)
参考资料:http://www.centoscn.com/CentosServer/cluster/2015/0605/5604.html 背景需求: 使用heartbeat来做HA高可用,并且把 ...
- 使用二进制的方式部署 K8S-1.16 高可用集群
一.项目介绍 项目致力于让有意向使用原生kubernetes集群的企业或个人,可以方便的.系统的使用二进制的方式手工搭建kubernetes高可用集群.并且让相关的人员可以更好的理解kubernete ...
- 用Kolla在阿里云部署10节点高可用OpenStack
为展现 Kolla 的真正实力,我在阿里云使用 Ansible 自动创建 10 台虚机,部署一套多节点高可用 OpenStack 集群! 前言 上次 Kolla 已经表示了要打 10 个的愿望,这次我 ...
- 使用kubeadm部署一套高可用k8s集群
使用kubeadm部署一套高可用k8s集群 有疑问的地方可以看官方文档 准备环境 我的机器如下, 系统为ubuntu20.04, kubernetes版本1.21.0 hostname IP 硬件配置 ...
- Heartbeat实现集群高可用热备
公司最近需要针对服务器实现热可用热备,这几天也一直在琢磨这个方面的东西,今天做了一些Heartbeat方面的工作,在此记录下来,给需要的人以参考. Heartbeat 项目是 Linux-HA 工程的 ...
- MariaDB Galera Cluster 部署 + keepalived实现高可用
MariaDB Galera Cluster 部署 MariaDB作为Mysql的一个分支,在开源项目中已经广泛使用,例如大热的openstack,所以,为了保证服务的高可用性,同时提高系统的负载能力 ...
- kubeadm部署k8s1.9高可用集群--4部署master节点
部署master节点 kubernetes master 节点包含的组件: kube-apiserver kube-scheduler kube-controller-manager 本文档介绍部署一 ...
- 008.Kubernetes二进制部署Nginx实现高可用
一 Nginx代理实现kube-apiserver高可用 1.1 Nginx实现高可用 基于 nginx 代理的 kube-apiserver 高可用方案. 控制节点的 kube-controller ...
随机推荐
- B - Birthday Boy Gym - 102007B
题目链接:https://cn.vjudge.net/contest/283924#problem/B 题目大意:给你n个人的信息,让你找出一个时间,要求让你选择一天,使得这一天的前一个生日距离它最远 ...
- 根据href给当前导航添加样式
var href = window.location.href.split('/')[window.location.href.split('/').length-1].substr(0,20); i ...
- Your Database is downloaded and backed up on....(腾讯云的mysql被攻击)
今天发现自己的服务器被黑客攻击,自己的mysql服务器的库被删掉,并且新创了一个warning库,只有一个readme表.不知道原因,也许是自己再github上的项目暴漏了自己的密码,还要0.6比特币 ...
- Spring+SpringMVC+Mybatis整合(二)
目录结构:
- linux 下安装 oracle
http://yourcouner.blog.51cto.com/59520/91156 一.RedHat AS4系统安装: 磁盘配置: 设备 类型 大小 / ext3 39911 swap 1024 ...
- maven阿里云镜像
<mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorO ...
- Docker安装Zookeeper
⒈下载 docker pull zookeeper ⒉运行 docker run --name zk -p 2181:2181 -p 2888:2888 -p 3888:3888 --restart ...
- pyspider使用
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Created on 2018-11-08 22:33:55 # Project: qsbk fro ...
- springboot系列五、springboot常用注解使用说明
一.controller相关注解 1.@Controller 控制器,处理http请求. 2.@RespController Spring4之后新加的注解,原来返回json需要@ResponseBod ...
- windows2008r2系统破解登录密码方法
破解windows 2008 r2系统登录密码方法: 1.重启系统,使用windows2008r2安装光盘引导 按住shift+f10 2.切换到d:windows\system32目录(使用cmd. ...