heartbeat v1 + ldirctord

一、实验环境介绍

硬件:lenovo T410S

软件:VMWARE workstation

SO:   Centos 6.6

二、实验目的

通过ldirectord实现LVS的高可用和后端RS的健康状态监控

三、网路拓扑

四、实验环境准备

1、配置NTP服务器确保时间同步

[[email protected] ha.d]# vim /etc/ntp.conf

添加如下

restrict 192.168.239.0 mask 255.255.255.0 nomodify #允许哪些个网段的主机过来同步

注释下面的时间服务器

#server 0.centos.pool.ntp.org iburst

#server 1.centos.pool.ntp.org iburst

#server 2.centos.pool.ntp.org iburst

#server 3.centos.pool.ntp.org iburst

server server s1a.time.edu.cn                      #去该NTP服务器同步时间

[[email protected] ha.d]# ntpdate s1a.time.edu.cn

[[email protected] ha.d]# service ntpd start

2、节点之间名称相互通信

[[email protected] ha.d]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.239.133 node1.hailang.com node1

192.168.239.134 node2.hailang.com node2

[[email protected] ha.d]# hostname node1.hailang.com

[[email protected] ha.d]# uname -n

3、SSH互相认证

[[email protected] ha.d]# ssh-keygen -t rsa

[[email protected] ha.d]# ssh-copy-id ~/.ssh/id_isa.pub 192.168.239.134

[[email protected] ha.d]# ssh node2.hailang.com

4、关闭防火墙和SELINUX

[[email protected] ha.d]# service iptables stop

[[email protected] ha.d]# setenforce 0

5、配置yum源

[[email protected] ha.d]# vim /etc/yum.repos.d/epel.repo

[epel]

name=Extra Packages for Enterprise Linux 6 - $basearch

baseurl=http://mirrors.aliyun.com/epel/6/$basearch

http://mirrors.aliyuncs.com/epel/6/$basearch

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

6、httpd(node1提供页面的内容为sorry node1,node2提供页面的内容为sorry node2)

[[email protected] ha.d]# yum -y install httpd

[[email protected] ha.d]# service httpd statrt

[[email protected] ha.d]# vim /var/www/html/index.html

node1

五、安装并配置herartbeat v1 和ldirectord

1、安装(133和134)

[[email protected] ~]# yum install perl-TimeDate net-snmp-libs libnet PyXML

[[email protected] ~]# rpm -ivh heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-2.1.4-12.el6.x86_64.rpm  heartbeat-stonith-2.1.4-12.el6.x86_64.rpm heartbeat-ldirectord-2.1.4-12.el6.x86_64.rpm

2、配置(133和134)

[[email protected] ~]# cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,authkeys,haresources} /etc/ha.d/

[[email protected] ~]# cp/usr/share/doc/heartbeat-ldirectord-2.1.4/ldirectord.cf /etc/ha.d/

1)ha.cf

[[email protected] ~]# vim /etc/ha.d/ha.cf

logfile /var/log/ha-log

keepalive 2

deadtime 30

warntime 10

initdead 120

udpport 694

mcast eth0 225.0.0.1 694 1 0

auto_failback on

node node1.hailang.com

node node2.hailang.com

ping 192.168.239.1

2)authkeys

[[email protected] ~]# vim /etc/ha.d/authkeys

auth 1

1 crc

3)vim /etc/ha.d/ldirectord.cf

checktimeout=3

checkinterval=1

autoreload=yes

quiescent=yes

virtual=192.168.239.200:80

real=192.168.239.135:80 gate

real=192.168.239.128:80 gate

fallback=127.0.0.1:80 gate

service=http

request="index.html"

receive="ok"

scheduler=rr

3)haresources

node1.hailang.com  192.168.239.200/32/eth0/192.168.239.200                       ldirectord::/etc/ha.d/ldirectord.cf

4)在128和135服务器上设置内核参数

[[email protected] ~]# echo 1 >/proc/sys/net/ipv4/conf/lo/arp_ignore

[[email protected] ~]# echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore

[[email protected] ~]# echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce

[[email protected] ~]# echo 2 >/proc/sys/net/ipv4/conf/lo/arp_announce

[[email protected] ~]# ifconfig lo:0 192.168.239.200 netmask 255.255.255.255 broadcast         192.168.239.200

[[email protected] ~]# route add -host 192.168.239.200 dev lo

5)在128和135服务器上启动httpd服务并关闭防火墙且提供测试页面

[[email protected] ~]# service httpd start

Starting httpd:                                            [  OK  ]

[[email protected] ~]# service iptables stop

[[email protected] ~]# vim /var/www/html/index.html

3、启动(133和134)

[[email protected] ha.d]# service heartbeat start

4、测试

1)访问http://192.168.239.200

结果:在128和135之间切换

2)停掉128服务器的http服务

[[email protected] ~]# service http stop

结果:显示135页面

3)停掉128和135服务器的http服务

结果:显示133的sorry页面

4)停掉133服务器的heartbeat

[[email protected] ~]# cd /usr/lib64/heartbeat/

[[email protected] heartbeat]# ./hb_standby

结果:显示134的sorry页面

时间: 2024-08-10 21:09:54

heartbeat v1 + ldirctord的相关文章

heartbeat v1 实现 MariaDB数据库的高可用

MariaDB数据库服务的高可用: 使用 heartbeat v1 版实现两个节点的 MariaDB数据库服务的高可用. 节点: node1        192.168.60.33 node2        192.168.60.88 MySQL数据库的数据文件使用nfs共享文件系统解决 nfs Server       192.168.60.22 架构如下图: 一.heartbeat 节点之间通信要求的设置: (1).解决节点的主机名解析 因为 heartbeat 的节点间通讯基于名称.基于

HA高可用方案之heartbeat v1的安装配置

配置前提: 1.时间必须同步,建议使用ntp协议 2.节点之间必须要通过主机名互相通信:通信中使用的名字必须与其节点上"uname -n"命令展示出的名字一致 3.需要仲裁设备 4.双方root用户能基于ssh密钥方式进行通信 5.本地资源必须能够正常运行,本文将使用httpd作为案例 注意:定义为集群服务中的任意资源都不能开机自动启动,因为他们将由CRM启动 安装方法: [[email protected] heartbeat1]# yum -y install net-snmp-l

基于heartbeat v1+ldirectord实现LVS集群高可用

前言 高可用集群,High Availability Cluster,简称HA Cluster,是指以减少服务中断时间为目的的服务器集群技术.通过上文可以看出,LVS集群本身并不能实现高可用,比如Director Server不能检测Real Server的健康度,一旦其中一台或全部Real Server宕机,Director Server还会继续转发请求,导致站点无法访问,同样,如果Director Server宕机站点就更不可能正常运转了.本文将讲解如何基于heartbeat v1实现LVS

http、mysql高可用 heartbeat v1

HA(High Availability)指的是通过尽量缩短因日常维护操作(计划)和突发的系统崩溃(非计划)所导致的停机时间,以提高系统和应用的可用性. HA集群架构: 整体的HA结构分为三层: 1,Messaging Layer: 基础事务层 在基础架构上实现心跳信息探测.双方节点可以随时探测到对方的心跳信息,以实现对对方主机工作状态的探测.三类控制信息:心跳(Heartbeats ),集群事务信息(Cluster Transition Messages),重传信息(Retransmissio

HA集群之Heartbeat v1 高可用安装讲解

什么是高可用集群        高可用集群是指一组通过硬件和软件连接起来的独立计算机,它们在用户面前表现为一个单一系统,在这样的一组计算机系统内部的一个或者多个节点停止工作,服务会从故障节点切换到正常工作的节点上运行,不会引起服务中断.从这个定义可以看出,集群必须检测节点和服务何时失效,何时恢复为可用.这个任务通常由一组被称为"心跳"的代码完成.在Linux-HA里这个功能由一个叫做heartbeat的程序完成. Heartbeat简介        Heartbeat是Linux-H

基于heartbeat v1配置mysql和httpd的高可用双主模型

一.配置高可用集群的前提:(以两节点的heartbeat为例) ⑴时间必须保持同步 ⑵节点之间必须用名称互相通信 建议使用/etc/hosts,而不要用DNS 集群中使用的主机名为`uname -n`表示的主机名: ⑶ping node(仅偶数节点才需要) ⑷ssh密钥认证进行无障碍通信: 二.heartbeat v1的配置 程序主配置文件:ha.cf 认证密钥:authkeys, 其权限必须为组和其它无权访问: 资源配置文件:haresources /usr/share/doc/heartbe

heartbeat v1

一.实验环境介绍 硬件:lenovo T410S 软件:VMWARE workstation SO:   Centos 6.6 二.网络拓扑 网卡类型:NAT RIP:       192.168.239.133    node1.hailang.com 192.168.239.134    node2.hailang.com VIP:       192.168.239.200 三.实验环境准备 1.配置NTP服务器确保时间同步 [[email protected] ha.d]# vim /e

heartbeat v1版CRM的高可用web集群的实现

实验环境规划: 实验环境: CentOS release 6.6(Final)  三台 IP地址: Node1: eth0:172.16.31.10/16 Node2:  eth0:172.16.31.11/16 Client: eth0:172.16.31.12/16 集群架构图 : 一.heartbeat特性介绍: 1.实现底层心跳传递 2.启动关闭集群服务 3.工作节点多达16个节点,由一个主节点和其他备节点组成 对称和非对称节点 4.启动时心跳信息由主节点发送 基于UDP的单播(Unic

Heartbeat(v1)+Httpd+NFS高可用

一.Heartbeat原理介绍 请点击此处 二.环境准备 1.拓扑结构图