1. اس فورم پر جواب بھیجنے کے لیے آپ کا صارف بننا ضروری ہے۔ اگر آپ ہماری اردو کے صارف ہیں تو لاگ ان کریں۔

Apache Fail Over with MON

'انفارمیشن ٹیکنالوجی' میں موضوعات آغاز کردہ از آدم, ‏24 جنوری 2007۔

  1. آدم
    آف لائن

    آدم ممبر

    شمولیت:
    ‏23 جنوری 2007
    پیغامات:
    2
    موصول پسندیدگیاں:
    0
    السلام علیکم و رحمہ اللہ
    ادہر جو ٹیوٹوریل پیش کیا جارہا ہے اسکا انگریزی ورژن آپ http://adamdesktop.blogspot.com/2006_10_01_archive.html
    سے حاصل کرسکتے ہیں۔ اس تمام مضمون میں تیکنیکی لفظوں کے معین اردو الفاظ مجھے معلوم نہیں۔ لہزا جن صاحب کو بھی اس بارے میں علم ہو وہ تصیح‌کرسکتا ہے۔ میں‌کوشش کروں گا کہ اپنے مفہوم کو مناسب الفاظ میں‌بیان کرسکوں۔

    یہ مضمون جاننے سے پہلے آپکو کیا کیا آنا چاہیے:
    ××××××××××××××××××××××××××××××××
    - لینکس کی مناسب کمانڈز۔
    - ویب سرور اور Apache کی تنصیب کے بارے میں علم ہو۔

    مو ضوع:
    -----------

    HA CLuster for Apache web server. یعنی
    ویب سرور اگر خدا نخواستہ کسی وجہ سے خراب ہو جائے تو صارفین کو ویب سروس کے حصول میںکوئی دقت نہ ہو۔

    سسٹم کی ضروریات:
    -----------------------------------
    دو کمپیوٹر کی مشینیں جو لینکس چلا رہی ہوں اور ایپاچی ویب سرور۔ ایک کمپیٹر آقا اور دوسرا غلام کہلائے گا عینی
    master and slave.
    Download Cluster Software: (کلسٹر کا سافٹ ویر ڈاونلوڈ کریں)
    ----------------------------------

    http://www.ultramonkey.org/download/3/rh.el.3/RPMS/

    اب ان سب ر پی ایمز کو ایک فولڈر میں محفوظ کرلیں ۔ نیچے دی گی سکرپٹ کو مناسب پیرمیشنز کے ساتھ چلائیں‌تو خود بخود سارے ر پی ایمز انسٹال ہو جائیںگے۔

    ************* install.sh ***************************************

    #! /bin/bash

    rpm -ivh libnet-1.1.0-1.rh.el.1.i386.rpm

    rpm -ivh libnet-debuginfo-1.1.0-1.rh.el.1.i386.rpm

    rpm -ivh heartbeat-pils-1.2.3-2.rh.el.3.0.i386.rpm

    rpm -ivh heartbeat-stonith-1.2.3-2.rh.el.3.0.i386.rpm

    rpm -ivh perl-Parse-RecDescent-1.80-1.rh.el.um.1.noarch.rpm

    rpm -ivh perl-Mail-IMAPClient-2.2.7-1.rh.el.um.1.noarch.rpm

    rpm -ivh perl-Net-SSLeay-1.23-1.rh.el.um.1.i386.rpm

    rpm -ivh perl-IO-Socket-SSL-0.92-1.rh.el.um.1.noarch.rpm

    rpm -ivh perl-Authen-SASL-2.03-1.rh.el.um.1.noarch.rpm

    rpm -ivh heartbeat-1.2.3-2.rh.el.3.0.i386.rpm

    rpm -ivh heartbeat-ldirectord-1.2.3-2.rh.el.3.0.i386.rpm

    rpm -ivh --nodeps heartbeat-ldirectord-1.2.3-2.rh.el.3.0.i386.rpm

    ################################

    اب یہ کمانڈ چلائیں:

    [root@hrdfphp02 ha]# vi install.sh

    [root@hrdfphp02 ha]# chmod 755 install.sh

    [root@hrdfphp02 ha]# ./install.sh

    اس سافٹ ویر کا آصل نام ہارٹ بیٹ ہے۔ جو مقبول عام زمانہ ہے۔
    اب اسے کنفیگر کرتے ہین:
    ---------------------------
    اب دونوں کمپیوٹروں‌ کی serial cables (null modems) کو ایک دوسرے سے باہم منسلک کردیں:
    اور درج ذیل کمانڈز چلائیں؛
    Enter the master and slave hosts in

    [root@HRDFMYSQL01 ha.d]# cat /etc/hosts

    # Do not remove the following line, or various programs

    # that requires network functionality will fail.

    127.0.0.1 HRDFMYSQL01 localhost.localdomain localhost

    212.100.220.66 HRDFMYSQL01

    212.100.220.67 HRDFMYSQL02

    [root@hrdfphp01 ~]# cd /etc/ha.d

    [root@hrdfphp01 ~]# vi ha.cf

    ********************** ha.cf ********************************************

    logfile /var/log/ha-log

    debugfile /var/log/ha-debug

    logfacility local0

    keepalive 1

    deadtime 20

    warntime 10

    initdead 60

    udpport 694

    #bcast eth1

    serial /dev/ttyS0

    #ucast eth1 192.168.16.5

    auto_failback on

    node HRDFPHP01

    node HRDFPHP02

    #respawn hacluster /usr/lib/heartbeat/ipfail # Failover on network failures

    [root@hrdfphp01 ha.d]# cat haresources

    HRDFPHP01 212.100.220.67 apache mon-start

    [root@hrdfphp01 ha.d]# cat authkeys

    auth 1

    1 crc


    Ha.cf and haresource یہ دونوں فائیلیں دونوں کمبپیوٹریوں‌پر ایک جیسی ہونی چاہیے۔ .

    Change /etc/ha.d/resource.d/apache to search for the conf file,
    and change it to /etc/httpd/conf/httpd.conf

    اب اپنے اپاچی کو کنفیگر کریں:
    ----------------------------------------------------------------------------------------------------------

    Change the /etc/httpd/conf/httpd.conf the Listen directive to the VIP:

    Listen 212.100.220.67:80

    [root@hrdfphp01 local] chkconfig –level 2345 httpd off

    [root@hrdfphp02 local] chkconfig –level 2345 httpd off

    کنفیگر کریں MON:

    [root@hrdfphp01 local] mkdir –p /usr/local/perl-module

    [root@hrdfphp01 local] cd /usr/local/perl-module

    Download mon from: http://www.kernel.org/software/mon/

    Download the Perl Modules from:
    http://search.cpan.org/author/PRYAN/Period-1.20/

    http://search.cpan.org/CPAN/authors/id/ ... .42.tar.gz

    http://search.cpan.org/CPAN/authors/id/ ... .tar.gz%20

    http://search.cpan.org/CPAN/authors/id/ ... .tar.gz%20

    [root@hrdfphp01 perl-module] mv mon-0.99-9.tar.gz /etc/ha.d
    [root@hrdfphp01 perl-module] tar xzvf

    Follow the perl modules installation by:

    perl Makefile.PL

    make

    make test

    make install

    [root@hrdfphp01 ha.d] cd /etc/ha.d; tar xzvf mon-0.99-9.tar.gz

    [root@hrdfphp01 ha.d] mv mon-0.99-9 mon

    [root@hrdfphp01 ha.d] cd mon

    [root@hrdfphp01 mon] vi etc/mon.cf

    alertdir = /etc/ha.d/mon/alert.d

    mondir = /etc/ha.d/mon/mon.d

    statedir = /etc/ha.d/mon/state.d

    logdir = /var/log/

    maxprocs = 20

    histlength = 100

    randstart = 10s

    authtype = getpwnam

    hostgroup web-fe 212.100.220.67

    watch web-fe

    service http

    interval 10s

    monitor http.monitor -p 80 -u /test.html

    allow_empty_group

    period wd {Sat-Fri}

    alert bring-ha-down.alert -S "web server (Master) down" \

    hrdfonline@gmail.com

    upalert mail.alert -S "web server (Master) is back up" \

    hrdfonline@gmail.com

    alertevery 600s

    alertafter 2

    [root@hrdfphp01 mon] cp etc/mon.cf .

    [root@hrdfphp01 mon]# cat mon/alert.d/bring-ha-down.alert

    /etc/ha.d/mon/alert.d/mail.alert $*

    /etc/init.d/heartbeat stop

    [root@hrdfphp01 mon]# cp mon-start ../resource.d/mon-start

    (check for the files for absolute paths)

    Now on Both Systems:

    [root@hrdfphp01 ha.d]#service heartbeat restart

    [root@hrdfphp02 ha.d]#service heartbeat restart

    [root@hrdfphp01 ha.d]# tail –f /var/log/ha-log

    Test Cases:

    Stop heartbeat service at master (hardware or system goes down or network unreachable, etc)

    Slave become master, logs shows:

    heartbeat: 2006/10/09_13:49:11 info: Received shutdown notice from 'hrdfphp01'.

    heartbeat: 2006/10/09_13:49:11 info: Resources being acquired from hrdfphp01.

    heartbeat: 2006/10/09_13:49:11 info: acquire local HA resources (standby).

    heartbeat: 2006/10/09_13:49:11 info: local HA resource acquisition completed (standby).

    heartbeat: 2006/10/09_13:49:11 info: No local resources [/usr/lib/heartbeat/ResourceManager listkeys hrdfphp02] to acquire.

    heartbeat: 2006/10/09_13:49:11 info: Standby resource acquisition done [all].

    heartbeat: 2006/10/09_13:49:11 info: Running /etc/ha.d/rc.d/status status

    heartbeat: 2006/10/09_13:49:11 info: Taking over resource group 212.100.220.67

    heartbeat: 2006/10/09_13:49:11 info: Acquiring resource group: hrdfphp01 212.100.220.67 apache mon-start

    heartbeat: 2006/10/09_13:49:11 info: Running /etc/ha.d/resource.d/IPaddr 212.100.220.67 start

    heartbeat: 2006/10/09_13:49:11 info: /sbin/ifconfig eth0:0 212.100.220.67 netmask 255.255.255.248 broadcast 212.100.220.71

    heartbeat: 2006/10/09_13:49:11 info: Sending Gratuitous Arp for 212.100.220.67 on eth0:0 [eth0]

    heartbeat: 2006/10/09_13:49:11 /usr/lib/heartbeat/send_arp -i 1010 -r 5 -p /var/lib/heartbeat/rsctmp/send_arp/send_arp-212.100.220.67 eth0 212.100.220.67 auto 212.100.220.67 ffffffffffff

    heartbeat: 2006/10/09_13:49:11 info: Running /etc/ha.d/resource.d/apache start

    heartbeat: 2006/10/09_13:49:12 info: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

    heartbeat: 2006/10/09_13:49:12 info: Running /etc/ha.d/resource.d/mon-start start

    heartbeat: 2006/10/09_13:49:12 info: /usr/lib/heartbeat/mach_down: nice_failback: foreign resources acquired

    heartbeat: 2006/10/09_13:49:12 info: mach_down takeover complete.

    heartbeat: 2006/10/09_13:49:12 info: mach_down takeover complete for node hrdfphp01.

    Slave now took over the Virtual IP:

    [root@hrdfphp02 ha]# ifconfig

    eth0 Link encap:Ethernet HWaddr 00:14:C2:58:AE:31

    inet addr:212.100.220.69 Bcast:212.100.220.71 Mask:255.255.255.248

    inet6 addr: fe80::214:c2ff:fe58:ae31/64 Scope:Link

    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    RX packets:1834 errors:0 dropped:0 overruns:0 frame:0

    TX packets:981 errors:0 dropped:0 overruns:0 carrier:0

    collisions:0 txqueuelen:1000

    RX bytes:270832 (264.4 KiB) TX bytes:465376 (454.4 KiB)

    Interrupt:201 Memory:f7cb0000-f7cc0000

    eth0:0 Link encap:Ethernet HWaddr 00:14:C2:58:AE:31

    inet addr:212.100.220.67 Bcast:212.100.220.71 Mask:255.255.255.248

    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    Interrupt:201 Memory:f7cb0000-f7cc0000

    eth1 Link encap:Ethernet HWaddr 00:14:C2:58:AE:30

    inet addr:192.168.16.3 Bcast:192.168.16.255 Mask:255.255.255.0

    inet6 addr: fe80::214:c2ff:fe58:ae30/64 Scope:Link

    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    RX packets:11629 errors:0 dropped:0 overruns:0 frame:0

    TX packets:6848 errors:0 dropped:0 overruns:0 carrier:0

    collisions:0 txqueuelen:1000

    RX bytes:3631751 (3.4 MiB) TX bytes:1121085 (1.0 MiB)

    Interrupt:209 Memory:f7ca0000-f7cb0000

    lo 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:4003064 errors:0 dropped:0 overruns:0 frame:0

    TX packets:4003064 errors:0 dropped:0 overruns:0 carrier:0

    collisions:0 txqueuelen:0

    RX bytes:378830313 (361.2 MiB) TX bytes:378830313 (361.2 MiB)

    Master Came back:

    [root@hrdfphp02 ha]# tail -f /var/log/ha-log

    heartbeat: 2006/10/09_13:52:27 info: Releasing resource group: hrdfphp01 212.100.220.67 apache mon-start

    heartbeat: 2006/10/09_13:52:27 info: Running /etc/ha.d/resource.d/mon-start stop

    heartbeat: 2006/10/09_13:52:27 info: Running /etc/ha.d/resource.d/apache stop

    heartbeat: 2006/10/09_13:52:28 Killing apache PID 29557

    heartbeat: 2006/10/09_13:52:29 info: Running /etc/ha.d/resource.d/IPaddr 212.100.220.67 stop

    heartbeat: 2006/10/09_13:52:29 info: /sbin/route -n del -host 212.100.220.67

    heartbeat: 2006/10/09_13:52:29 info: /sbin/ifconfig eth0:0 down

    heartbeat: 2006/10/09_13:52:29 info: IP Address 212.100.220.67 released

    heartbeat: 2006/10/09_13:52:29 info: foreign HA resource release completed (standby).

    heartbeat: 2006/10/09_13:52:29 info: Local standby process completed [foreign].

    heartbeat: 2006/10/09_13:52:30 WARN: 1 lost packet(s) for [hrdfphp01] [10:12]

    heartbeat: 2006/10/09_13:52:30 info: remote resource transition completed.

    heartbeat: 2006/10/09_13:52:30 info: No pkts missing from hrdfphp01!

    heartbeat: 2006/10/09_13:52:30 info: Other node completed standby takeover of foreign resources.

    Apache service goes down at Master:

    heartbeat: 2006/10/09_13:52:30 info: Other node completed standby takeover of foreign resources.

    heartbeat: 2006/10/09_13:54:48 info: Received shutdown notice from 'hrdfphp01'.

    heartbeat: 2006/10/09_13:54:48 info: Resources being acquired from hrdfphp01.

    heartbeat: 2006/10/09_13:54:48 info: acquire local HA resources (standby).

    heartbeat: 2006/10/09_13:54:48 info: No local resources [/usr/lib/heartbeat/ResourceManager listkeys hrdfphp02] to acquire.

    heartbeat: 2006/10/09_13:54:48 info: local HA resource acquisition completed (standby).

    heartbeat: 2006/10/09_13:54:48 info: Standby resource acquisition done [foreign].

    heartbeat: 2006/10/09_13:54:48 info: Running /etc/ha.d/rc.d/status status

    heartbeat: 2006/10/09_13:54:48 info: Taking over resource group 212.100.220.67

    heartbeat: 2006/10/09_13:54:48 info: Acquiring resource group: hrdfphp01 212.100.220.67 apache mon-start

    heartbeat: 2006/10/09_13:54:48 info: Running /etc/ha.d/resource.d/IPaddr 212.100.220.67 start

    heartbeat: 2006/10/09_13:54:48 info: /sbin/ifconfig eth0:0 212.100.220.67 netmask 255.255.255.248 broadcast 212.100.220.71

    heartbeat: 2006/10/09_13:54:48 info: Sending Gratuitous Arp for 212.100.220.67 on eth0:0 [eth0]

    heartbeat: 2006/10/09_13:54:48 /usr/lib/heartbeat/send_arp -i 1010 -r 5 -p /var/lib/heartbeat/rsctmp/send_arp/send_arp-212.100.220.67 eth0 212.100.220.67 auto 212.100.220.67 ffffffffffff

    heartbeat: 2006/10/09_13:54:49 info: Running /etc/ha.d/resource.d/apache start

    heartbeat: 2006/10/09_13:54:49 info: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

    heartbeat: 2006/10/09_13:54:49 info: Running /etc/ha.d/resource.d/mon-start start

    heartbeat: 2006/10/09_13:54:49 info: /usr/lib/heartbeat/mach_down: nice_failback: foreign resources acquired

    heartbeat: 2006/10/09_13:54:49 info: mach_down takeover complete.

    heartbeat: 2006/10/09_13:54:49 info: mach_down takeover complete for node hrdfphp01.

    Slave up after two minutes.
     
  2. محمدعبیداللہ
    آف لائن

    محمدعبیداللہ ممبر

    شمولیت:
    ‏23 فروری 2007
    پیغامات:
    1,054
    موصول پسندیدگیاں:
    1
    ملک کا جھنڈا:
    ماشاء اللہ کا اچھی شئیرنگ ہے پڑھی ہے کام کرنے کے بعد پھر آگے مدد چاہوں گا
     

اس صفحے کو مشتہر کریں