Heartbeat installation configuration and httpd high availability simple example

Source: Internet
Author: User

Precautions:

1. Node Name: hostname,/etc/hosts

2. SSH Trust

3, Node time synchronization


Three configuration files for heartbeat:

Authkeys: Communication key File

Ha.cf:heartbeat Service configuration file

Haresources: Resource Management configuration file


Installation configuration (System is CentOS6.5):

WAN ip:192.168.101.168

node1:192.168.101.21

node2:192.168.101.22


1, configuration Node1, node2 node name, SSH Trust, time synchronization

Node1:

# hostname Node1.redhat.com


# vim/etc/sysconfig/network

Hostname=node1.redhat.com


# vim/etc/hosts

192.168.101.21 node1.redhat.com Node1

192.168.101.22 node2.redhat.com Node2


# ssh-keygen-t RSA

# ssh-copy-id-i ~/.ssh/id_rsa.pub Node2


# ntpdate 0.centos.pool.ntp.org


Node2:

# hostname Node2.redhat.com


# vim/etc/sysconfig/network

Hostname=node2.redhat.com


# vim/etc/hosts

192.168.101.21 node1.redhat.com Node1

192.168.101.22 node2.redhat.com Node2


# ssh-keygen-t RSA

# ssh-copy-id-i ~/.ssh/id_rsa.pub Node1


# ntpdate 0.centos.pool.ntp.org


2, Node1, Node2 installation Heartbeat

Note: This is installed using the CentOS local ISO yum source +epel source.

# yum Install http://mirrors.zju.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm

# Yum Install heartbeat cluster-glue resource-agents pacemaker httpd


3, Node1 configuration Heartbeat

# Copy config file to/etc/ha.d/

# cp-p/usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources}/etc/ha.d/


# Configure generate Communication key

# OpenSSL Rand-base64 20

Trli5dr/yhoe59kj4yyognpvmdi=


# Vim/etc/ha.d/authkeys

Auth 1

1 MD5 trli5dr/yhoe59kj4yyognpvmdi=

# chmod 600/etc/ha.d/authkeys


# Configure the heartbeat master configuration file

# VIM/ETC/HA.D/HA.CF

LogFile/var/log/ha-log # log file path

KeepAlive 1 # Heartbeat Message delivery interval, set here for 1 seconds

Deadtime 30 # Node Timeout time, more than 30s no heartbeat information is considered node dead

Warntime 10 # Alarm Time

Initdead # Heartbeat First start wait time, default 120 seconds, this time set to deadtime twice times

Udpport 694 # The port used by heartbeat messaging

Mcast eth0 225.1.1.1 694 1 0 # with multicast address

Auto_failback off # Whether to turn on recovery

Nodenode1.redhat.com # Master node name, must be consistent with Uname-n

Nodenode2.redhat.com # Alternate nodes name

Ping 192.168.101.254 # to detect if the heartbeat information is normal by pinging the gateway


# Configure resource management files, bind extranet ip:192.168.101.168

# vim/etc/ha.d/haresources

Node1.redhat.com ipaddr::192.168.101.168/24/eth0/httpd


4. Copy the configuration file to Node2

# scp-p/etc/ha.d/{ha.cf,authkeys,haresources} node2:/etc/ha.d/


5. Create httpd index.html page and turn off boot httpd

# echo "

# ssh Node2 ' echo '


# chkconfig httpd off

# ssh Node2 ' chkconfig httpd off '


6. Start Heartbeat

# links Heartbeat Various scripts

# ln-s/usr/share/heartbeat/*/usr/lib64/heartbeat/

#/etc/init.d/heartbeat Start

# ssh Node2 '/etc/init.d/heartbeat start '


7. View logs, bind IP, and browser access

# Tail/var/log/ha-log

# ifconfig

http://192.168.101.168/


8. Using NFS shared storage

# NFS Host IP is: 192.168.101.28

# NFS Shared directory:/data/www/

# vim/data/www/index.html

NFS Server.


# Stop Heartbeat

# ssh Node2 '/etc/init.d/heartbeat stop '

#/etc/init.d/heartbeat Stop


# Node1 Modify the resource profile and copy it to Node2

# vim/etc/ha.d/haresources

Node1.redhat.com Ipaddr::192.168.101.168/24/eth0/filesystem::192.168.101.28:/data/www::/var/www/html::nfs httpd

# scp/etc/ha.d/haresources Node2:/etc/ha.d/


9. Start Heartbeat

#/etc/init.d/heartbeat Start

# ssh Node2 '/etc/init.d/heartbeat start '


10. View logs, bind IP, and browser access

# Tail/var/log/ha-log

# ifconfig

http://192.168.101.168/


11. Node Switching test

#/usr/share/heartbeat/hb_standby


Heartbeat installation configuration and httpd high availability simple example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.