How to achieve high availability of Linux service clusters (Heartbeat)

Source: Internet
Author: User
Tags openssl md5 sha1 node server

The high availability of services is another option in the server cluster. To ensure that our services are not spof, we use heartbeat to solve this problem. Simply put, that is, when our primary server is disconnected, our secondary node server can quickly take over the services of the primary node server, thus ensuring that our services will not experience spof. (Of course, we are only doing a small experiment on single point of failure (spof). Specifically, there will not be only one heartbeat communication channel, and there will usually be shared storage devices on servers, if you don't want to talk about it, start preparing the experiment environment)

We need to prepare three VMS: one client and two heartbeat servers. The two servers are configured first, and the other are configured according to the following steps.) The experiment topology is shown below: 1 first configure master node: Host Name: node1.example.com # Vim/etc/hosts192.168.0.165. node1.example.com node1194250.166 node2.example. CM node2 # Vim/etc/sysconfig/networkhostname = node1.example.com # hostname node1.example.com # uname-N (check the current host name) 1. configure the Internet IP address as 192.168.0.165 heartbeat channel address 192.168.10.20 2. install and configure HTTPd service # Yum install httpd. conf # Vim/var/www/h TML/index.html # service httpd start # elinks 192.168.0.220 (test WWW Service) 3. start configuring heartbeat: first install eight packages: libnet-1.4.3-el5.i386heartbeat-2.1.4-9.el5.i386heartbeat-devel-2.1.4.9.el5.i386heartbeat-gui-2.1.4-9.el5.i386heartbeat-ldirectord-2.1.4-9.el5.i386heartbeat-pils-2.1.4. -10. el5.imo-heartbeat-stonith-2.1.4-10.el5.i386perl-MailTools-1.77-1.el5.noarch # Yum--nogpgcheck install *. rpm can be installed together with these packages (if rpm is used for installation, there will be a lot of Dependencies We recommend that you use yum for installation.) 4. # cd/etc/ha. d/(next copy several important files to this directory) # cp/usr/share/doc/heartbeat-2.1.4/ha. cf. /# cp/usr/share/doc/heartbeat-2.1.4/haresources. /# cp/usr/share/doc/heartbeat-2.1.4/authkeys. /# ls (check whether the copy is complete) # Vim authkeys add two lines of auth 11 sha1 at the end (the above command can also be used to configure the authkeys file) # echo-ne "auth 1/N1 sha1">/etc/ha. d/authkeys # dd If =/dev/urandom BS = 512 COUNT = 1 | OpenSSL MD5>/etc/ha. d/authkeys (append key) # Cat Authkeys (check to see if the key is appended. The key must be in the same line as 1 sha1) # chmod 0600 authkeys (modify the permission) # Vim ha. cf make sure that the following lines are not commented out. COMNODE node2.example.com # Vim haresources (set floating IP address and Service) add a line of information in the file: node1.example.com 192.168.0.169 httpd # cd/etc/ha. D (add our HTTPd service to the resource. in D :) # Ln-S/etc/init. d/httpd/etc/ha. d/resource. d/# cd resource. d/# ls (check if the link has been successfully created) (to simplify our experiment, clone a virtual machine to backup the server secondary node .) Shut down the master node and clone a secondary node. However, modify the secondary node as follows: modify its host name # Vim/etc/hosts # Vim/etc/sysconfig/Network # hostname node2.example.com # uname-N modify its IP address and set the Internet IP address to 192.168.0.166 Intranet heartbeat communication address to 192.168.10.30 # service network restart test the connectivity of the entire network: # Ping 192.168.0.165 # Ping 192.168.0.166 # Ping 192.168.10.20 # Ping 192.168.10.30 it is best to test both the master node and the secondary node. Check whether the 80 service is enabled, # netstat-tnlp | grep 80 at this time, port 80 of the master and slave nodes should not be enabled to enable heartbeat service on the master and slave nodes # service heartbeat start # ifconfig (on the master node) next, the floating IP address eth0: 0 has already appeared.) Check port 80 on the master node. Now it is enabled. Visit the client to test it.

On the master node # cd/usr/lib/heartbeat #. /hb_standby will stop the node, so that the HTTPd service will be transferred to the secondary node and viewed on the secondary node: Access 192.168.0.169 on the client (haha, the secondary node will successfully replace the resources of the primary node) use the packet capture tool to test: learn about their heartbeat # tcpdump-I eth1 UDP port 694

 

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.