Heartbeat introduction and simple HTTPD high by HeartBeat

Heartbeat is an integral part of the Linux-HA project, which implements a highly available cluster system. Simply put, through heartbeat, resources and services can be quickly transferred from a failed server Go to another server that works normally.

Heartbeat has a lot in common with another lightweight and highly available open source software keepalived. In practical applications, we should compare the differences between the two software according to our own Select the most suitable software for your needs.

Keepalived communicates and elects through VRRP protocol

Heartbeat communicates and elects through heartbeat

Keepalived configuration , Simple to use, relatively simple functions

The configuration of heartbeat is relatively complex but powerful, with various tools, suitable for large cluster management

Here is simple and highly available for httpd by configuring heartbeat

Environment: centos 6.4

Heartbeat 3.0.4

ha1 192.168.1.209

ha2 192.168.1.208

vip 192.168.1.253

First configure ha1

< ol class="list-paddingleft-2" style="list-style-type:decimal;">

  • Modify hostname
    hostname ha1
    vi /etc/sysconfig/network

  • 2. Time synchronization
    yum -y install ntp
    service ntpd start
    netpdate 192.168.1.208

  • Establish mutual trust between two machines
    ssh-keygen -t rsa -f ~/.ssh/id_rsa -P”
    ssh-copy-id -i .ssh/id_rsa.pub [email protected]< /p>

  • Install heartbeat

  • yum -y install heartbeat*

    5. Provide configuration files for heartbeat
    cp -p /usr/share/doc/heartbeat-3.0.4/{authkeys,ha.cf,haresources} /etc/ha.d /
    vi authkeys
    Add the last line
    auth 1
    a md5 ff49e8aba5208b0130ade78042877661 (md5 value of any file)

    vi/etc/ha.d/ha.cf
    > Debugfile /var/log/ha-debug
    logfile /var/log/ha-log
    keepalive 2
    deadtime 30
    warntime 10
    initdead 120
    udpport 694
    bcast eth0
    auto_failback on
    node ha1
    node ha2
    ping 192.168.1.1

    vi /etc/ha.d/haresources
    ha1 IPaddr::192.168.1.253/ 24/eth0 httpd

    6. Install httpd

    yum -y install httpd

    Provide for httpd A marked default document

    echo “hello h1” >> /var/www/html/index.html

    Turn off the automatic start of httpd

    650) this.width=650;” src=”/wp-content/uploadshttp:/img.voidcn.com/vcimg/static/loading.png” title=” QQ picture20151107001428.png” alt=”wKioL1Y80gyCxjQ_AAH5VMTPmcU710.jpg” d=”4678754″ s=”383_0d1″ t=”jpg”>

    Test whether the cluster can be Normally accessed

    650) this.width=650;” src=”/wp-content/uploadshttp:/img.voidcn.com/vcimg /static/loading.png” title=”QQ图片20151107003152.png” alt=”wKioL1Y81hzDupRPAAH3jwilRhI802.jpg” d=”4678756″ s=”34a_b88″ t=”jpg”>

    < /p>

    Test whether the website can be accessed normally

    Leave a Comment

    Your email address will not be published.