Heartbeat httpd NFS for highly available web clusters

Source: Internet
Author: User
Tags rsync

One environment preparation

Two topological structures

Three-premise conditions

Four installation related software

Five Configuration Heartbeat

Six test web clusters

Summary of seven issues

Eight shared storage

One environment preparation

Operating system

CentOS 6.4 x86_64 Minimized installation

If the centos5.5 installation is v2.x using the Yum installation, the CentOS 6.4 installation is v3.x

YUM installs Vim man NTP "Development tools" "Server Platform Development" "desktop Platform development"

Configuring the Epel YUM source

Turn off firewall SELinux

Two topological structures

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" IMAGE_THUMB1 "border=" 0 "alt=" image_thumb1 "src=" HTTP://IMG1.51CTO.COM/ATTACHMENT/201407/6 /158322_1404636731ibrk.png "" 853 "height=" 596 ">

Three prerequisites (two nodes are configured)

Host names between 1 nodes can be resolved with each other

Web1, WEB2

[Email protected] ~]# vim/etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 :: 1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.200.132  web1.daphne.com  web1192.168.200.133  web2.daphne.com  web2

2 time synchronization between nodes

[Email protected] ~]# ntpdate ntp.api.bz

Configuring SSH trust between 3 nodes

Four installation related software

1 Heartbeat Component Description

    • Heartbeat Core Components
    • Heartbeat-gui Graphics Management Interface
    • Heartbeat-ldirectord provides automatic rules generation and backend Realserver health status inspection components for LVS high availability
    • Heartbeat-pils Loading library plug-in interface
    • Heartbeat-stonith

2 Installing Heartbeat

heartbeat-2.1.4-12.el6.x86_64.rpm
heartbeat-gui-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

Yum install PyXML libnet pygtk2-libglade Net-snmp-libsyum Install Libtool-ltd (note  to be installed from source Library, not Epel) Lyum install  LIBNETRPM-IVH heartbeat-*

3 Installing HTTPD

[[email protected] ~]# yum install httpd[[email protected] ~]# cd/var/www/html/[[email protected] html]# vim index.html W Eb1[[email protected] ~]# service httpd start

Test

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image_thumb11 "border=" 0 "alt=" image_thumb11 "src=" http://img1.51cto.com/attachment/201407 /6/158322_1404636731cldq.png "" 861 "height=" 131 ">

After the test, shut down the service so that it does not start

[[email protected] ~]# serivce httpd off[[email protected] ~]# chkconfig httpd of[[email protected] ~]# chkconfig--list H TTPDHTTPD          0:off1:off2:off3:off4:off5:off6:off

All of the above operations are done on two nodes

Five Configuration Heartbeat

1 Description of the configuration file

[Email protected] ~]# cd/etc/ha.d/[[email protected] ha.d]# lsauthkeys  harc         rc.d           resource.dha.cf     Haresources  readme.config  Shellfuncs

Description The installed heartbeat does not have a configuration file by default, but provides a sample configuration file

[[email protected] ha.d]# cd/usr/share/doc/heartbeat-2.1.4/[[email protected] heartbeat-2.1.4]# ls apphbd.cf         faqntips.html        haresources         requirements.htmlauthkeys          faqntips.txt         hb_report.html      Requirements.txtauthors           gettingstarted.html  hb_report.txt       rsync.htmlchangelog         GettingStarted.txt   heartbeat_api.html  rsync.txtcopying           ha.cf                heartbeat_api.txt   STARTSTOPCOPYING.LGPL      hardwareguide.html   logd.cfDirectoryMap.txt  HardwareGuide.txt    README
We need  Authkeys ha.cf haresources three configuration files
[email protected] heartbeat-2.1.4]# CP Authkeys HA.CF haresources/etc/ha.d/

2 Configuring Authkeys

3 Configuring the Ha.cf file

Changing the way heartbeat information is propagated can be broadcast unicast using multicast

Bcast  eth0

Configure the number of nodes in the cluster

Node Web1.daphne.comnode web2.daphne.com

4 Configuring Haresources

[Email protected] ha.d]# vim haresources web1.daphne.com 192.168.200.10/24/eth0 httpd

5 Copy the above three files to Web2

[Email protected] ha.d]# SCP authkeys ha.cf haresources web2:/etc/ha.d/

6 Starting Web1 and WEB2

Start the backup node first

[[Email protected] ~]# service heartbeat  Start[[email protected] ~]# service heartbeat  start

Six test web clusters

View IP

[[email protected] ha.d]# ifconfigeth0 Link encap:ethernet HWaddr 00:0c:29:7d:c1:d7 inet addr:192.16          8.200.132 bcast:192.168.200.255 mask:255.255.255.0 Inet6 addr:fe80::20c:29ff:fe7d:c1d7/64 scope:link          Up broadcast RUNNING multicast mtu:1500 metric:1 RX packets:9069 errors:0 dropped:0 overruns:0 frame:0 TX packets:9159 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1707993  (1.6 MiB)    TX bytes:1846141 (1.7 MiB) eth0:0 Link encap:ethernet HWaddr 00:0c:29:7d:c1:d7 inet addr:192.168.200.10 bcast:192.168.200.255 mask:255.255.255 .0 up broadcast RUNNING multicast mtu:1500 metric:1lo Link encap:local Loopback inet addr:127          .0.0.1 mask:255.0.0.0 Inet6 Addr::: 1/128 scope:host up LOOPBACK RUNNING mtu:16436 metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px;  border-top:0px; border-right:0px; padding-top:0px "title=" image_thumb12 "border=" 0 "alt=" image_thumb12 "src=" http://img1.51cto.com/attachment/201407 /6/158322_1404636731gd3u.png "" 861 "height=" 131 ">
Failure Demo
Close the heartbeat on the Web1
[Email protected] ~]# service heartbeat stopstopping high-availability Services:done.

View IP on the WEB2

Ifconfigeth0 Link encap:ethernet HWaddr 00:0c:29:61:e4:6b inet addr:192.168.200.133 bcast:192.168.200.25  5 mask:255.255.255.0 Inet6 addr:fe80::20c:29ff:fe61:e46b/64 scope:link up broadcast RUNNING multicast          mtu:1500 metric:1 RX packets:8230 errors:0 dropped:0 overruns:0 frame:0 TX packets:8164 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1698974 (    1.6 MiB) TX bytes:1680369 (1.6 MiB) eth0:0 Link encap:ethernet HWaddr 00:0c:29:61:e4:6b inet addr:192.168.200.10 bcast:192.168.200.255 mask:255.255.255 .0 up broadcast RUNNING multicast mtu:1500 metric:1lo Link encap:local Loopback inet addr:127          .0.0.1 mask:255.0.0.0 Inet6 Addr::: 1/128 scope:host up LOOPBACK RUNNING mtu:16436 metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 Collisions:0 txqueuelen:0 RX bytes:0  (0.0 b) TX bytes:0 (0.0 b)

Test

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image_thumb15 "border=" 0 "alt=" image_thumb15 "src=" http://img1.51cto.com/attachment/201407 /6/158322_1404636732lysh.png "" 871 "height=" 119 ">

Summary of seven issues

File synchronization between nodes

1rsync+inotify combination scheme To resolve synchronization problems between nodes

2 shared storage Scenarios

Eight shared storage

1 Configuring Server for NFS

[[email protected] ~]# yum install nfs*[[email protected] ~]# mkdir-pv/web/html/[[email protected] ~]# Vim/web/html/ind ex.html [[email protected] ~]# vim/etc/exports/web/html/192.168.200.0/24 (rw,async) [[email protected] ~]# service RPCBI nd start[[email protected] ~]# service NFS Start

Node Test mount

Web1

[[email protected] ~]# mount-t NFS 192.168.200.138:/web/html/mnt[[email protected] ~]# Cd/mnt[[email protected] mnt]# L Sindex.html[[email protected] ~]# umount/mnt

Modify the Haresource file

[Email protected] ha.d]# vim/etc/ha.d/haresourcesweb1.daphne.com 192.168.200.10/24/eth0 Filesystem: : 192.168.200.138:/web/html::/var/www/html::nfs  httpd

Synchronizing the Haresource configuration file

[[email protected] ha.d]# Cd/etc/ha.d/[[email protected] ha.d]# SCP haresources web2:/etc/ha.d/

Restart Heartbeat

[[Email protected] ~]# service heartbeat restart[[email protected] ~]# service heartbeat restart

Testing Web Services

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image_thumb17 "border=" 0 "alt=" image_thumb17 "src=" http://img1.51cto.com/attachment/201407 /6/158322_1404636732xmif.png "" 862 "height=" 136 ">

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.