centos7 源码编译安装heartbeat 以及结合nginx测试高可用

1、环境
CentOS Linux release 7.4.1708 (Core) 3.10.0-693.el7.x86_64
主(heartbeat27=uname -n)
10.0.0.27(ip) 10.0.10.27(心跳) 10.0.0.29(vip)
备(heartbeat28=uname -n)
10.0.0.28(ip) 10.0.10.28(心跳) 10.0.0.29(vip)
2、cat /etc/hosts
10.0.0.27 heartbeat27
10.0.0.28 heartbeat28

3、heartbeat27:(主执行)
route add -host 10.0.10.28 dev ens37
route -n
echo ‘/usr/sbin/route add -host 10.0.10.28 dev ens37‘ >> /etc/rc.d/rc.local
4、heartbeat28:(备执行)
route add -host 10.0.10.27 dev ens37
route -n
echo ‘/usr/sbin/route add -host 10.0.10.27 dev ens37‘ >> /etc/rc.d/rc.local

5、下载对应的源码包并解压
wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/958e11be8686.tar.bz2
wget http://hg.linux-ha.org/glue/archive/0a7add1d9996.tar.bz2
wget https://github.com/ClusterLabs/resource-agents/archive/v3.9.6.tar.gz

                tar xf v3.9.6.tar.gz
                tar jxf 0a7add1d9996.tar.bz2
                tar jxf 958e11be8686.tar.bz2 

6、安装基础的依赖包
yum install gcc gcc-c++ autoconf automake libtool glib2-devel libxml2-devel bzip2 bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel -y

asciidoc  (yum未安装成功)
asciidoc-8.6.9.tar.gz
tar xf asciidoc-8.6.9.tar.gza
./configure
make
make install

7、安装上述三个安装包
groupadd haclient
useradd -g haclient hacluster
7.1、安装Reusable-Cluster-Components-glue--0a7add1d9996
cd Reusable-Cluster-Components-glue--0a7add1d9996
./autogen.sh (看到 Now run ./configure 表示自动生成完成)
./configure --prefix=/usr/local/heartbeat (必须将Cluster Glue和resource-agents和heartbeat都安装在同一目录 因为heartbeat需要依赖这些库)


                                configure 成功之后的状态:
                                                        cluster-glue configuration:
                                                                        Version                  = 1.0.12 (Build: 0a7add1d9996b6d869d441da6c82fb7b8abcef4f)
                                                                        Features                 =
                                                                        Prefix                   = /usr/local/heartbeat
                                                                        Executables              = /usr/local/heartbeat/sbin
                                                                        Man pages                = /usr/local/heartbeat/share/man
                                                                        Libraries                = /usr/local/heartbeat/lib
                                                                        Header files             = /usr/local/heartbeat/include
                                                                        Arch-independent files   = /usr/local/heartbeat/share
                                                                        Documentation            = /usr/local/heartbeat/share/doc/cluster-glue
                                                                        State information        = /usr/local/heartbeat/var
                                                                        System configuration     = /usr/local/heartbeat/etc
                                                                        Use system LTDL          = yes
                                                                        HA group name            = haclient
                                                                        HA user name             = hacluster

        make (可能会报错,a2x: ERROR: "xmllint" --nonet --noout --valid "/home/Reusable-Cluster-Components-glue--b5f160509785/doc/hb_report.8.xml" returned non-zero exit status 4
                                                    gmake[2]: *** [hb_report.8] Error 1
                                                    gmake[2]: Leaving directory `/home/Reusable-Cluster-Components-glue--b5f160509785/doc‘
                                                    gmake[1]: *** [all-recursive] Error 1
                                                    gmake[1]: Leaving directory `/home/Reusable-Cluster-Components-glue--b5f160509785/doc‘
                                                    make: * [all-recursive] Error 1)
        执行此命令   yum -y install docbook-style-xsl
        make
        make install

7.2、安装resource-agents-3.9.6/
cd resource-agents-3.9.6/
./autogen.sh
./configure --prefix=/usr/local/heartbeat


                        configure成功之后:
                                                    resource-agents configuration:
                                                    Version                  = UNKNOWN
                                                    Build Version            = 02beac55c1da0ad99a5a19bd3b2333bcff7e916c
                                                    Features                 =
                                                    Prefix                   = /usr/local/heartbeat
                                                    Executables              = /usr/local/heartbeat/sbin
                                                    Man pages                = /usr/local/heartbeat/share/man
                                                    Libraries                = /usr/local/heartbeat/lib
                                                    Header files             = /usr/local/heartbeat/include
                                                    Arch-independent files   = /usr/local/heartbeat/share
                                                    Documentation            = /usr/local/heartbeat/share/doc/resource-agents
                                                    State information        = /usr/local/heartbeat/var
                                                    System configuration     = /usr/local/heartbeat/etc
                                                    HA_BIN directory prefix  = /usr/local/heartbeat/libexec
                                                    RA state files           = /usr/local/heartbeat/var/run/resource-agents
                                                    AIS Plugins              =
                                                    CFLAGS                   =  -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib -ggdb3  -fgnu89-inline -fstack-protector-all -Wall -

        ln -s  /usr/local/heartbeat/lib/* /lib/
        ln -s  /usr/local/heartbeat/lib/* /lib64/
        make
        make install

7.3、安装Heartbeat-3-0-958e11be8686/
cd Heartbeat-3-0-958e11be8686/
./bootstrap
./configure --prefix=/usr/local/heartbeat(报错:configure: error: in /root/Heartbeat-3-0-958e11be8686‘:<br/>configure: error: Core development headers were not found<br/>Seeconfig.log‘ for more details)
执行该命令:export CFLAGS="$CFLAGS -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib"
./configure --prefix=/usr/local/heartbeat

                configure成功之后:
                                        heartbeat configuration:
                                        Version                  = "3.0.6"
                                        Executables              = "/usr/local/heartbeat/sbin"
                                        Man pages                = "/usr/local/heartbeat/share/man"
                                        Libraries                = "/usr/local/heartbeat/lib64"
                                        Header files             = "/usr/local/heartbeat/include"
                                        Arch-independent files   = "/usr/local/heartbeat/share"
                                        Documentation files      = "/usr/local/heartbeat/share/doc/heartbeat"
                                        State information        = "/usr/local/heartbeat/var"
                                        System configuration     = "/usr/local/heartbeat/etc"
                                        Init (rc) scripts        = "/etc/rc.d/init.d"
                                        Init (rc) defaults       = "/etc/sysconfig"
                                        Use system LTDL          = "yes"
                                        HA group name            = "haclient"
                                        HA group id              = "1000"
                                        HA user name             = "hacluster"
                                        HA user user id          = "1000"
                                        Build dopd plugin        = "yes"
                                        Enable times kludge      = "yes"
                                        CC_WARNINGS              = " -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-qual -Wcast-align -Wbad-function-cast -Winline -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -Werror "
                                        Mangled CFLAGS           = " -I/usr/local/heartbeat/include -L/usr/local/heartbeat/lib  -Wall -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wdeclaration-after-statement -Wpointer-arith -Wwrite-strings -Wcast-qual -Wcast-align -Wbad-function-cast -Winline -Wmissing-format-attribute -Wformat=2 -Wformat-security -Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -Werror  -ggdb3 -funsigned-char"
                                        Libraries                = "-lbz2 -lz -lc -luuid -lrt -ldl  -lltdl"
                                        RPATH enabled            = ""
                                        Distro-style RPMs        = "no"


make(错误:?/usr/local/heartbeat/include/heartbeat/glue_config.h:105:0: error: "HA_HBCONF_DIR" redefined [-Werror]
glue.config.h中 宏?HA_HBCONF_DIR被定义了多次)
vi 编辑/usr/local/heartbeat/include/heartbeat/glue_config.h 注释掉最后一行 定义宏的代码
make
make install

cd /usr/local/heartbeat/share/doc/heartbeat
cp ?ha.cf authkeys?haresources? /usr/local/heartbeat/etc/ha.d

vim /usr/local/heartbeat/etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694

ucast ens37 10.0.10.28

        auto_failback on
        node    heartbeat27
        node    heartbeat28

ping 10.0.10.28

        respawn hacluster /usr/local/heartbeat/libexec/heartbeat/ipfail(此处可能会出现问题:使用find / -name ipfail查找对应的路径)

ln -svf /usr/local/heartbeat/lib64/heartbeat/plugins/RAExec/ /usr/local/heartbeat/lib/heartbeat/plugins/RAExec/
ln -svf /usr/local/heartbeat/lib64/heartbeat/plugins/
/usr/local/heartbeat/lib/heartbeat/plugins/

vim /usr/local/heartbeat/etc/ha.d/authkeys
修改:
auth 3 表示使用id为3的验证 下边需要定义一个3的验证算法 #(这里要保持一致,输了2下面就对应2,输了3下面就对应3)
3 md5 Hello! #口令(Hello!)随便给 主从配置相同即可
chmod 600 /usr/local/heartbeat/etc/ha.d/authkeys

辅助ip
ip addr add 10.0.0.29/24 dev ens33 label ens33:1

vim /usr/local/heartbeat/etc/ha.d/haresources

heartbeat27 10.0.0.29/24/ens33:1 nginx

cd /usr/local/heartbeat/etc/ha.d/
scp authkeys ha.cf haresources [email protected]:/usr/local/heartbeat/etc/ha.d/ 然后修改新一下文件:
修改ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694

ucast ens37 10.0.10.27

            auto_failback on
            node    heartbeat27
            node    heartbeat28

ping 10.0.10.27

            respawn hacluster /usr/local/heartbeat/libexec/heartbeat/ipfail(此处可能会出现问题:使用find / -name ipfail查找对应的路径)
修改haresources 文件

heartbeat28 10.0.0.29/24/ens33:1 nginx

chmod 600 /usr/local/heartbeat/etc/ha.d/authkeys

安装nginx(http://blog.51cto.com/13754781/2299553)
修改默认的index.html页面,做测试(主要是为了直观的检验有无主动切换)
设置开机自启动(http://blog.51cto.com/13754781/2296191)
启动nginx

service heartbeat start

service heartbeat status
heartbeat OK [pid 1422 et al] is running on heartbeat27 [heartbeat27]...

浏览器中输入vip (windows中要做解析)
可以通过关闭主备服务器,观察页面呈现的形式,即可。

注意加粗的区别!!!!

排版不是很好,解决问题就好!欢迎交流!!

原文地址:http://blog.51cto.com/13754781/2308311

时间: 2024-10-10 10:03:07

centos7 源码编译安装heartbeat 以及结合nginx测试高可用的相关文章

源码编译安装Heartbeat

一.Heartbeat介绍 官方站点:http://linux-ha.org/wiki/Main_Pageheartbeat可以资源(VIP地址及程序服务)从一台有故障的服务器快速的转移到另一台正常的服务器提供服务,heartbeat和keepalived相似,heartbeat可以实现failover功能,但不能实现对后端的健康检查. 二.简要规划 系统环境 系统 OEL6.6 系统位数 x86_64 内核版本 3.8.13-44.1.1.el6uek.x86_64 软件环境 Heartbea

centos7 源码编译安装TensorFlow CPU 版本

一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. 但是在编译之中,发现很多坑,由此记录一下. 环境相关: 系统:centos7 python版本:2.7.5 二.准备 1. 安装相关依赖 # 一般会缺失的依赖 yum -y install java-1.8.0-openjdk-devel automake autoconf libtool libi

centos7 源码编译安装 nginx

安装步骤 下载 nginx 源码包 官网 $ wget http://nginx.org/download/nginx-1.16.0.tar.gz 解压 nginx 压缩包 $ tar -zxvf nginx-1.16.0.tar.gz 运行 configure 文件检测程序 $ cd nginx-1.16.0 $ ./configure --prefix=/usr/local/nginx checking for OS + Linux 3.10.0-957.12.2.el7.x86_64 x8

CentOS7源码编译安装FreeRadius3.17

(一)环境简介1.OS:Centos7.42.软件:Freeradiusd3.17(ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-3.0.17.tar.gz)3.网站:https://freeradius.org/ (二)安装1.yum安装所需的依赖包[[email protected] raddb]#yum install openssl openssl-devel libtalloc-devel libtalloc* -y

CentOS7 源码编译安装Tengine

简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.它的目的是打造一个高效.安全的Web平台. 发展 Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验. 从2011年12月开始,Tengine成为一个开源项目,Tengine团队在积极地开发和维护着它.Tengine团队的核心成员来自于淘宝.搜狗等互联网企业.Tengine是社区合作的成果,我们欢迎大家参与其中,贡献自己的力量. 一.安装编

CentOS7源码编译安装PHP7.2

一.环境 CentOS7 二.相关资源 PHP官方网站 PHP官方下载页 三.编译安装 1. 下载php 下载并解压 # 下载php wget https://www.php.net/distributions/php-7.2.16.tar.gz # 解压 tar -zxvf php-7.2.16.tar.gz 查看目录 [[email protected] ~]# ll 总用量 19232 drwxrwxr-x 14 root root 4096 3月 5 19:05 php-7.2.16 -

centos7 源码编译安装 php

准备工作 下载 PHP 源码包并解压 $ wget https://www.php.net/distributions/php-7.2.19.tar.bz2 $ tar -jxvf php-7.2.19.tar.bz2 进入 PHP 源码包目录 $ cd php-7.2.19 配置和构建 PHP 常用配置项及其说明 如果看着麻烦可以直接看下面的总结步骤 --prefix=/usr/local/php7 # 配置安装目录 --with-config-file-path=/usr/local/php

centos7 源码编译安装nginx教程 nginx安装脚本

安装nginx需要pcre zlib openssl的库,下文都是在官网直接下载用作编译安装 该nginx安装教程,有安装maxmind IP 库 该nginx安装教程有安装openrestry 系统使用了centos 7 该教材有修改最大打开文件描述符数到最大 该教程是nginx安装的shell脚本 #!/bin/bash yum install epel-release -y yum install gcc gcc-c++ make automake autoconf libtool ipt

centos7源码编译安装Ansible详细部署

一.基础介绍==========================================================================================ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统配置.批量程序部署.批量运行命令等功能.ansible是基于模块工作的,本身没有批量部署的能力.真正具有批量部署的是ansible所运行的