HeartBeat Haresources configuration

1. Introduction of Heartbeat:

The Heartbeat project is a component of the Linux-HA project and the most successful example of the current open source HA project. The full name of Linux-HA is High-Availability Linux. The goal of this open source project is: through the joint efforts of community developers, Provide a cluster solution that enhances the reliability, availability and serviceability (RAS) of Linux, which implements a highly available cluster system. Heartbeat detection service and cluster communication are two key components of high-availability clusters. In the Heartbeat project, the heartbeat module implements these two functions; heartbeat works on port 694 of the upd protocol to provide services.

2. Heartbeat version and components:

Description: Heartbeat has three versions: Heartbeat v1.x, Heartbeat v2.x, Heartbeat v3.x; Heartbeat v1.x and Heartbeat v2.x have a very simple structure, all modules are Concentrated in heartbeat. After the v3 version, the entire heartbeat project was split and divided into different projects for development.

1.Heartbeat v1.x and v2.x components

Heartbeat: Inter-node communication detection module;

ha-logd: cluster event log service;

CCM (Consensus Cluster Membership): Cluster membership consistency management module;

LRM (Local Resource Manager): Local resource management module;

Stonith Daemon: Disconnect or restart the problematic node from the cluster environment;

CRM (Cluster resource management): cluster resource management module;

Cluster policy engine: Cluster policy engine;

Cluster transition engine: Cluster transition engine (also called Strategy execution engine);

The difference between Heartbeat v1.x and Heartbeat v2.x: A new cluster resource manager crm is added to Heartbeat v2.x, the cluster resource manager in Heartbeat v1.x is haresource, Heartbeat v2. For compatibility with v1.x, haresource is retained, but at the same time a more powerful crm resource manager is added; there are two crm management methods, one is based on command line crmsh, the other is based on graphical interface hb_gui .

3. Test environment

OS: rhel6

web1: 192.168.10.111 hostname=web1.luochen.com httpd A network card (bridged)

web2:192.168.10.112 hostname=web2.luochen.com httpd a network card (bridged)

web3: nfs server (shared storage ) 192.168.10.114

VIP: 192.168.10.118

PS: Two web servers web1 and web2, failover can be realized between the two, for example, when the web1 node fails, the web2 node can automatically take over the resources of the web service , Can continue to respond to client requests; and web resources can be retrieved normally when web1 returns to normal.

< /p>

Four. Before installing heartbeat Preparation work

1. Node name (each node communicates through node name) to ensure that the name of each node in the cluster can be resolved with each other

Edit /etc/sysconfig/network file

HOSTNAME=we1.luochen.com< /span>

Edit /etc/hosts file

192.168.10.111 web1.luochen.com web1

192.168.10.112 web2.luochen.com web2

#sysctl kernel.hostname=web1.luochen.com

PS: It must be ensured that the result viewed by the uname -n command is the same as /etc/hosts The corresponding ip address resolution name in the file is the same

2. Ensure that the time between all nodes is consistent (NTP server is recommended)

Sync time with the same time server in all nodes

#ntpdate ntp-server-ip

3. Realize keyless authentication communication based on ssh

#ssh-keygen -t rsa -P” ####Generate a pair of public key and private key, id_rsa private key id_rsa.pub public key

Put the public key Copy to other nodes

#ssh-copy-id -i .ssh/id_rsa.pub [email protected] (you need to enter the password for the first time)

#ssh web2.luochen.com’date’;date #### Check whether the time is the same (execute the date command on web1 and web2 at the same time)

PS: If you want to realize the keyless authentication communication with web1 on web2, you must perform the same operation on web2

< span style="font-family:'Microsoft YaHei','Microsoft YaHei';font-size:14px;color:rgb(0,0,0);">Five, install heartbeat

1. Need to install rpm package

Heartbeat- 2.1.4-12.el6.x86_64.rpm

heartbeat-pils-2.1.4-12.el6.x86_64.rpm

heartbeat-stonith-2.1.4-12.el6.x86_64.rpm

< p> 2. Solve dependencies first

#yum -y install pe rl-TimeDate PyXML libnet net-snmp-libs

3. Install heartbeat

#rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith- 2.1.4-12.el6.x86_64.rpm (note that the installation here is related)

4. Copy the heartbeat software directory on web1 to web2

#scp -r heartbeat web2:/root

5. Perform the same on web2 Installation operation (remember to resolve dependencies)

6. There is no configuration file for heartbeat in the /etc/ha.d/ directory, and the sample configuration file is in /usr/share/doc/heartbeat-2.1.4 Directory

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

7. Edit the node authentication file (set the authentication mechanism and key, this file must Is 600 or 400 permissions)

#vim /etc/ha.d/authkeys

auth 2

2 shal keys

#chmod 600 /etc/ha.d/authkeys

8. Use the openssl command to generate a random number as a key

#openssl rand -base64 20

9. Edit the main configuration file

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

logfile /var/log/ha-log

Keepalive 1 ###Complete a heartbeat detection in 1 second

Deadtime 8###Deadtime I still cannot receive the heartbeat information within 8s, immediately kill

warntime 3 ###extended time

mcast eth0 255.0.1.1 694 1 0 ###bcast Broadcast mcast multicast ucast unicast

auto_failback on auto_failback on ###Automatic failover

node web1.luochen.com ###Add node

node web2.luochen.com

ping 172.16.0.1 172.16.0.1 ###arbitration equipment > Compression bz2 Compression bz2 Heartbeat ## Detection information

Compression_threshold 2 Compression_threshold 2 ###No compression below 2k p>

10. Edit Explorer File

#Vim /etc/ha.d/haresources

Define the main node:

web1.luochen.com 192.168.10.118/24/eth0 httpd ###Two resources VIP and httpd

11. Copy the three files to all nodes< /span>

# scp -p authkeys haresources ha.cf we b2.luochen.com:/etc/ha.d/ ###-p Keep file attributes

12. Configure web services on web1 and web2

#yum -y install httpd

< span style="font-family:'Microsoft YaHei','Microsoft YaHei';font-size:14px;color:rgb(0,0,0);"> #echo “web1 server “> /var/www/ html/index.html

#service httpd start

#curl http://192.168.10.111 ###Test whether the service starts normally

#service httpd stop #service httpd stop ###The service must not be started automatically, it can only be started by the heartbeat resource manager

#chkconfig httpd off

13. Start the heartbeat service (on web1)< /p>

#service heartbeat start< /span>

# ssh web2.luochen.com’service heartbeat start’ ###Start the heartbeat service on web2

14. Check the log file on web1 to see if the heartbeat service starts normally

#tail -40 /var/log/ha-log

Six, test< /span>

1. Test access to VIP on the host (192.168.10.118)

2. Stop web1 on web2 Heartbeat service

#ssh web1.luochen.com’service heartbeat stop’

3. Refresh on the host again to see if the page changes (if it changes, it proves that resources will be automatically transferred in case of failure)

Seven, in web3 (192.168 .10.114) to provide shared storage

1. Create a shared directory

# mkdir -pv /www/htdocs

#echo “

nfs server page

“> /www/htdocs/index.html

#vim /etc/exports

#setfacl -mu:apache:rwx /www/htdocs

#service nfs start

2. Modify the haresources configuration file on web1

#service heartbeat stop

#ssh web1.luochen.com’service heartbeat stop’

#vim /etc/ha.d/haresources

web1.luochen.com 192.168.10.118/24/eth0 Filesystem::192.168.10.114:/www/htdocs::/var/ www/html::nfs httpd

3. Restart the heartbeat service on both nodes

#service heartbeat start

#ssh web2.luochen.com’service heartbeat start’

4. Finally, it’s the test. . . . (Because the experiment has been done here, the steps are directly written silently, so there is no sticker)

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 = 2539 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.