zoukankan      html  css  js  c++  java
  • HA高可用配置

    HA 即 (high available)高可用,又被叫做双机热备,用于关键性业务。 简单理解就是,有两台机器A和B,正常是A提供服务,B待命闲置,当A宕机或服务宕掉,会切换至B机器继续提供服务。

    下面我们使用heartbeat来做HA集群,并且把nginx服务作为HA对应的服务。

    试验准备:
    两个机器, 都是centos6.5,网卡eth1 ip如下:
    aming   192.168.11.24
    aming1  192.168.11.23

    1. hostname 设置好,分别为aming  和 aming1 
    2. 关闭防火墙 iptables -F;  
        关闭selinux: setenforce 0
    3. vi /etc/hosts   // 增加内容如下:  
    192.168.11.24 aming   
    192.168.11.23 aming1  


    4. 安装epel扩展源:
    rpm -ivh  'http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm'
    5. 两个机器都安装heartbeat / libnet
    yum  install -y heartbeat*   libnet  nginx

    6.  主上(aming)配置
    cd /usr/share/doc/heartbeat-3.0.4/
    cp  authkeys  ha.cf haresources   /etc/ha.d/
    cd /etc/ha.d
    vi  authkeys  //加入

    auth 3
    3 md5 Hello!

    chmod 600 authkeys


    vi  haresources  //加入
    aming 192.168.11.10/24/eth1:0 nginx   


    vi  ha.cf   //改为如下内容:
    debugfile /var/log/ha-debug
    logfile /var/log/ha-log
    logfacility     local0
    keepalive 2
    deadtime 30
    warntime 10
    initdead 60
    udpport 694
    ucast eth1 192.168.11.23
    auto_failback on
    node    aming
    node    aming1
    ping 192.168.11.1
    respawn hacluster /usr/lib/heartbeat/ipfail


    7.  把主上的三个配置拷贝到从上:
    cd /etc/ha.d/
    scp  authkeys  ha.cf haresources   aming1:/etc/ha.d/

    8. 到从上(aming1) 编辑ha.cf
    vi  /etc/ha.d/ha.cf   //只需要更改一个地方
    ucast eth1 192.168.11.23 改为   ucast eth1 192.168.11.24  

    9.  启动heartbeat : 
    先主,后从
    service heartbeat start

    10. 检查测试 
    ifconfig 看是否有 eth1:0
    ps aux |grep nginx  看是否有nginx进程

    11.  测试1
    主上故意禁ping
    iptables -I INPUT -p icmp -j DROP

    12. 测试2
    主上停止heartbeat服务
    service heartbeat stop 

    关于heartbeat配置文件参考文档: http://blog.chinaunix.net/uid-20749043-id-1878328.html

    本文来自链接http://www.aminglinux.com/bbs/thread-7394-1-1.html

  • 相关阅读:
    C++使用之常量的定义
    GDB学习之道:GDB调试精粹及使用实例
    [置顶] 如何在Windows 7 64位安装Python,并使用Matplotlib绘图
    [每日一题] 11gOCP 1z0-052 :2013-09-15 Enterprise Manager Support Workbench..................B9
    【cocos2d-x】Win7下配置Cocos2d-x开发环境
    PE框架学习之道:PE框架——发送报文流程
    System.UriHostNameType.cs
    System.UrlComponents.cs
    System.UriFormat.cs
    System.UriKind.cs
  • 原文地址:https://www.cnblogs.com/cuizhipeng/p/4286167.html
Copyright © 2011-2022 走看看