Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

第 124 章 heartbeat

目錄

124.1. heartbeat+ldirectord
124.1.1. heartbeat
124.1.2. ldirectord
124.1.3. test
124.2. Pacemaker

124.1. heartbeat+ldirectord

124.1.1. heartbeat

neo@ubuntu:~$ apt-cache search  heartbeat
heartbeat - Subsystem for High-Availability Linux
heartbeat-dev - Subsystem for High-Availability Linux - development files
ipvsadm - Linux Virtual Server support programs

neo@ubuntu:~$ sudo apt-get install heartbeat
			

124.1.2. ldirectord

當前環境

[root@backup ~]# cd /etc/ha.d/
[root@backup ha.d]# ls
authkeys       harc           ldirectord.cf  README.config  shellfuncs
ha.cf          haresources    rc.d/          resource.d/
			

heartbeat主要有三個配置檔案:

  1. /etc/ha.d/authkeys

  2. /etc/ha.d/ha.cf

  3. /etc/ha.d/haresources

過程 124.1. 配置步驟:

  1. /etc/ha.d/authkeys


    auth 3


    3 md5 hello


    [root@backup ha.d]# vi authkeys
    auth 3
    #1 crc
    #2 sha1 HI!
    3 md5 hello
    					
  2. /etc/ha.d/ha.cf

    master

    logfile /var/log/ha-log

    logfacility local0

    keepalive 2

    deadtime 30

    warntime 10

    initdead 120

    udpport 694

    ucast eth1 10.10.10.161

    ucast eth1 <backup node ip>

    auto_failback on



    node    master.example.org
    node    backup.example.org

    ping_group group1 10.10.10.160 10.10.10.161

    respawn hacluster /usr/lib/heartbeat/ipfail

    apiauth ipfail gid=haclient uid=hacluster

    [root@backup ha.d]# vi ha.cf
    logfile /var/log/ha-log
    					

    backup

    ucast eth1 master node ip

  3. /etc/ha.d/haresources

    <node> <vip>/<netmask>/<interface>/<vip> ldirectord

    master.example.org 211.100.37.164/32/eth0:0/211.100.37.164 ldirectord

    [root@master ha.d]# cat haresources
    master.example.org 211.100.37.164/32/eth0:0/211.100.37.164 ldirectord
    					

    backup.example.org 211.100.37.164/32/eth0:0/211.100.37.164 ldirectord

    [root@backup ha.d]# cat haresources
    backup.example.org 211.100.37.164/32/eth0:0/211.100.37.164 ldirectord
    					
  4. /etc/ha.d/ldirectord.cf

    checktimeout=3
    checkinterval=1
    autoreload=yes
    logfile="/var/log/ldirectord.log"
    quiescent=yes
    virtual=211.100.37.164:80
            real=10.10.0.7:80 gate
            real=10.10.0.8:80 gate
            real=10.10.0.9:80 gate
            service=http
            virtualhost=netkiller.8800.org
            scheduler=wrr
            protocol=tcp
            checkport=80
    ...
    					

124.1.3. test

debug

tail -f /var/log/ha-log
			

察看心跳監聽是否工作:

[root@master ha.d]# tcpdump -i eth1 icmp
[root@backup ha.d]# tcpdump -i eth1 icmp
			

IPaddr2 Script

IPAddr2::10.10.0.1/32/0:0/10.10.0.1

resource.d/IPaddr2 10.10.0.1/32/0:0/10.10.0.1 start