CentOS 5
Sponsored Link

Monitor httpd
2008/08/15
  Configure 2 web servers as cluster. httpd is also needed.

The environment of 2 web servers are like below. And more, I set virual IP address [192.168.0.100].

(1) www1.server-linux.info
[eth0:192.168.0.21] [eth1:10.0.0.21]

(2) www2.server-linux.info
[eth0:192.168.0.22] [eth1:10.0.0.22]

(3) cluster.server-linux.info
[virtual IP:192.168.0.100]


[1] Configure like below on both Host. if httpd is running, stop it because they are controled by HeartBeat.
[root@www1 ~]#
/etc/rc.d/init.d/heartbeat stop

Stopping High-Availability services:
[  OK  ]
[root@www1 ~]#
cd /var/lib/heartbeat/crm

[root@www1 crm]#
rm -f cib.xml.*

[root@www1 crm]#
vi cib.xml


 <cib generated="true" admin_epoch="0" epoch="1" have_quorum="true" ignore_dtd="false" ccm_transition="2" num_peers="2" cib_feature_revision="2.0" dc_uuid="f8719a77-70b4-4e5f-851b-dafa7d65d3a2" num_updates="4" cib-last-written="Sun Jun 15 05:04:30 2008">
   <configuration>
     <crm_config>
       <cluster_property_set id="cib-bootstrap-options">
         <attributes>
           <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="2.1.3-node: 552305612591183b1628baa5bc6e903e0f1e26a3"/>
         </attributes>
       </cluster_property_set>
     </crm_config>
     <nodes>
       <node id="2bbd6408-ec01-4b8c-bb8e-207237af3a99" uname="www1.server-linux.info" type="normal"/>
       <node id="f8719a77-70b4-4e5f-851b-dafa7d65d3a2" uname="www2.server-linux.info" type="normal"/>
     </nodes>
     <resources/>
<= remove

# add these lines for httpd

     <resources>
       <group id="group_apache">
         <primitive id="ipaddr" class="ocf" type="IPaddr" provider="heartbeat">
         <instance_attributes id="ia_ipaddr">
           <attributes>
             <nvpair id="ia_ipaddr_ip" name="ip" value="192.168.0.100"/>
             <nvpair id="ia_ipaddr_nic" name="nic" value="eth0"/>
             <nvpair id="ia_ipaddr_netmask" name="netmask" value="24"/>
           </attributes>
         </instance_attributes>
       </primitive>
       <primitive id="apache" class="ocf" type="apache" provider="heartbeat">
         <instance_attributes id="ia_apache">
           <attributes>
             <nvpair id="ia_apache_configfile" name="configfile" value="/etc/httpd/conf/httpd.conf"/>
           </attributes>
         </instance_attributes>
         </primitive>
       </group>
     </resources>
     <constraints/>
   </configuration>
 </cib>

[root@www1 crm]#
[root@www1 ~]#
vi /etc/httpd/conf/httpd.conf


# line 134: change to virtual IP

Listen
192.168.0.100:80


# line 903: uncomment and change

<Location /server-status>
    SetHandler server-status
    Order deny,allow
#   Deny from all
    Allow from
all

</Location>

[root@www1 ~]#
/etc/rc.d/init.d/heartbeat start

Starting High-Availability services:
[  OK  ]
[2] Run crm_mon after some time passed, then following result is shown, it's OK. httpd is running on primary server.
[root@www1 ~]#
crm_mon -i 3

Defaulting to one-shot mode
You need to have curses available at compile time to enable console mode

============
Last updated: Sun Jun 15 05:58:18 2008
Current DC: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2)
2 Nodes configured.
1 Resources configured.
============

Node: www1.server-linux.info (2bbd6408-ec01-4b8c-bb8e-207237af3a99): online
Node: www2.server-linux.info (f8719a77-70b4-4e5f-851b-dafa7d65d3a2): online

Resource Group: group_apache
ipaddr
(heartbeat::ocf:IPaddr):
Started www1.server-linux.info

apache
(heartbeat::ocf:apache):
Started www1.server-linux.info

[3] Create a test page on both servers and access to virtual IP. Primary server replys normally like below.
 
[4] Shutdown HeartBeat on primary server and verify if HeartBeat works or not.
[root@www1 ~]#
/etc/rc.d/init.d/heartbeat stop

Stopping High-Availability services:
[  OK  ]
  Access to virtual IP address you set, then running server is switched normally like below.
 
[5] Start HeartBeat again on primary server and verify if HeartBeat works or not.
[root@www1 ~]#
/etc/rc.d/init.d/heartbeat start

Starting High-Availability services:
[  OK  ]
  Access to virtual IP address you set, then running server is switched normally like below.
 
 
Tweet