HEARTBEAT installation configuration and HTTPD high availability simple example

Notes:

1. Node name: hostname, /etc/hosts

2. ssh mutual trust

3. Node time synchronization

Three configuration files of heartbeat:

authkeys: communication key file

ha.cf: Heartbeat service configuration file

haresources: resource management configuration file

Installation configuration (system is CentOS6.5):

< p>WAN IP: 192.168.101.168

node1: 192.168.101.21

node2: 192.168.101.22

1. Configure node1, node2 node name, ssh mutual 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

< p style="white-space:normal;"># ssh-keygen -t rsa

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

# ntpdate 0.centos.pool.ntp.org

2, node1, node2 install heartbeat< /p>

# Note: CentOS is used here Local iso yum source + EPEL source installation.

# 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 the configuration file to /etc/ha.d/

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

# Configure to generate a communication key

#openssl rand -base64 20

tRlI5Dr/YHoE59kJ4yYOgNpVmDI=

# vim /etc/ha.d/authkeys< /span>

auth 1

1 md5 tRlI5Dr/YHoE59kJ4yYOgNpVmDI=

#chmod 600 /etc/ha.d/authkeys

< /p>

# Configure the main heartbeat configuration file

# vim /etc/ha .d/ha.cf

logfile/var/log/ha- log heart information # log file path

keepalive 1 # Beat Interval time, set 1 second here

deadtime 30 Deadtime 30 # Node Timeout, if no heartbeat message is received for more than 30s, the node is considered dead

warntime 10 # warning time

The waiting time for the first start of heartbeat, the default is 120 seconds, this time is set to twice the deadtime

udpport 694 # The port used for heartbeat information transmission

mcast eth0 225.1 .1.1 694 1 0 # Use multicast address

auto_failback off # Whether to enable fault recovery

nodenode1.redhat.com # Main Node name, must be consistent with uname -n

node< span class="Apple-tab-span" style="font-family:'Microsoft YaHei','Microsoft YaHei';font-size:14px;white-space:pre;">node2.redhat. com # Standby node name

ping 192.168.101.254 Pass # Pass Ping the gateway to check whether the heartbeat information is normal

# Configure resource management files and bind the external network IP: 192.168.101.168

# vim /etc/ha.d/haresources

< p>node1.redhat.com IPaddr::192.168.101.168/24/eth0/ httpd

4. Copy configuration File to node2

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

5. Create a httpd index.html page and close the boot-up httpd

# echo “

node1.redhat.com

“> /var/www/html/index.html

# ssh node2’echo “

node2. redhat.com

” > /var/www/html/index.html’

# chkconfig httpd off

# ssh node2’chkconfig httpd off’

6. Start heartbeat

# Link various heartbeat 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. Use NFS to share storage

# The 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/heart beat stop’

# /etc/init.d/ heartbeat stop

# node1 modify the resource configuration file 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

< span style="font-family:'Microsoft YaHei','Microsoft YaHei';font-size:14px;"># scp /etc/ha.d/haresources node2:/etc/ha.d/

9, start heartbeat< /span>

# /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

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2569 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.