Ads 468x60px

Pages

Subscribe:

Wednesday, July 20, 2011

Online VCS configuration of Apache http application

Onilne VCS configuration

As a part of my VCS learning, I was able to configure my first Service group to make my apache http a Highly Available aplication under Veritas Cluster .

This post is meant to show the procedure I followed to configure an application . Below is the hierarchy for my

service group apacheSG .

Application that I consider here is Apache http (You can find the installation procedure for apache http in my previous post).

Before we go with the steps to configure, check the pre-requisites that are required to configure a application under VCS . Below are the required setup

for any cluster build .

1. Two servers running Solaris 10.(You can consider other versions too, but

I have tried this on solaris 10)

2. Shared storage , a disk attached to both the servers .(It is optional for the setup

in which application is installed on both the servers).

3. An IP address (This is the IP address we use to access the application configured under VCS)

In my setup I have Apache installed under /apachevol Filesystem which is created from veritas volume 'apachevol' , apachevol is created under a shared disk group apachedg .

Below are the few screen shots that shows the diskgroup and veritas volume configured .

[root@solaris1 /]#vxdisk list

DEVICE TYPE DISK GROUP STATUS

c0t0d0s2 auto:none - - online invalid

c1t0d0s2 auto:cdsdisk disk apachedg online

[root@solaris1 /]#vxprint -g apachedg

TY NAME ASSOC KSTATE LENGTH PLOFFS STATE TUTIL0 PUTIL0

dg apachedg apachedg - - - - - -

dm disk c1t0d0s2 - 338576 - - - -

v apachevol fsgen ENABLED 307200 - ACTIVE - -

pl apachevol-01 apachevol ENABLED 307200 - ACTIVE - -

sd disk-01 apachevol-01 ENABLED 307200 0 - - -

[root@solaris1 /]#df -k /apachevol

Filesystem kbytes used avail capacity Mounted on

/dev/vx/dsk/apachedg/apachevol

153600 18488 126759 13% /apachevol

Note: Apache http is installed under /apachevol .

Before we start configuring , we need to make the configuration files (main.cf) read write . This can be done with haconf command as below .

#haconf -makerw

Procedure to create a service group has the flow which starts with creating service group .

i. Creating Service Group apacheSG:

Create a Service group and modify the SystemList attribute to include the server on which the service group needs to be HA .

#hagrp -add apacheSG

#hagrp -modify apacheSG SystemList solari1 0 solaris2 1

Set the AutoStartList Attribute to define the server on which SG should be made online on VCS startup .

#hagrp -modify apacheSG AutoStartList solaris1

ii. Creating resources to be under service group apacheSG :

Now create the Resources that are to be controlled by VCS . As per the hierarchy we will be creating the resources with names apacheApp , apacheNIC , apacheIP , apacheDG, apacheVol and apacheMnt .

You can create the resources in any order there is no specific order to follow .

We use hares command to add a new resource or modify an existing resource. Below is the syntax for the same .

hares –add

hares –modify

You can find the Resource types available with command ‘hatype –list’ and the resource attributes with ‘hatype –display

Ex: hatype –display Volume (will display the attributes for volume resource type)

1. Create NIC resource apacheNIC – Resource Type NIC

NIC is the physical device and so it is a persistent resource which mean it will be online on both the servers and it cannot be made offline as this requires to configure IP .

#hares -add apacheNIC NIC apacheSG

#hares -modify apacheNIC Critical 0

#hares -modify apacheNIC Device e1000g0

2. Create IP resource apacheIP – Resource Type ‘IP’

Public IP cannot be same for two servers in a cluster and so if we need to access the application we need to know first on which server the application is active as server IP changes when application failovers to other server in cluster . So we need an IP which is moved to the server where application is online . So service group needs to control that IP address when failover is initiated . so that application can be accessed with one constant IP irrespective of , on which server it is active .

Below are the commands to configure a IP resource and bind it to the interface .

#hares -add apacheIP IP apacheSG

#hares -modify apacheIP Critical 0

#hares -modify apacheIP Device e1000g0

#hares -modify apacheIP Address "xxx.xxx.xxx.xxx"

#hares -modify apacheIP NetMask "255.255.255.0"

3. Create Diskgroup resource apacheDG – Resource Type ‘DiskGroup’

Disk group resource is required as VCS will do import or deport of DG while Service Group failover and this is pre-requisite resource for Volume and Mount point . (As the Veritas disk group has this feature to import the DG and inturn the disks under the DG). We create the DG resource by specifying ‘DiskGroup’ type . Here the diskgroup name used is apachedg

#hares -add apacheDG DiskGroup apacheSG

#hares -modify apacheDG Critical 0

#hares -modify apacheDG DiskGroup apachedg

4. Create Volume resource apacheVol – Resource Type ‘Volume’

Volume resource is the pre-requisite for Mount point as we have the filesystem created on veritas volume created from disk group . Type we specify for this resource is Volume and the volume name used is apachevol

#hares -add apacheVol Volume apacheSG

#hares -modify apacheVol Critical 0

#hares -modify apacheVol Volume apachevol

#hares -modify apacheVol DiskGroup apacheDG

Note:Their might be more than one disk group on the server, so VCS need to know from which Disk group volume comes from , for that we have the DiskGroup attribute .

5. Create MountPoint Resource apacheMnt – Resource Type ‘MountPoint’

Mount point here is the one on which the application is installed and this mount point needs to be mounted before application needs to be started . Resource Type for this is ‘Mount’ and MountPoint used here is “/apachevol” on which apache http is used .

hares -add apacheMnt Mount apacheSG

hares -modify apacheMnt Critical 0

hares -modify apacheMnt MountPoint /apachevol

hares -modify apacheMnt BlockDevice /dev/vx/dsk/apachedg/apachevol

hares -modify apacheMnt FSType vxfs

hares -modify apacheMnt FsckOpt %-y

6. Create Apache Resource apacheApp –Resource Type ‘ Apache’

Now configure the Apache resource which holds the application start and stop process . Required attributes should be configured before resource can be enabled .

hares -add apacheApp Apache apacheSG

hares -modify apacheApp Critical 0

hares -modify apacheApp httpdDir /apachevol/bin

hares -modify apacheApp PidFile /apachevol/logs/http.pid

hares -modify apacheApp ConfigFile /apachevol/conf/httpd.conf

hares -modify apacheApp EnvFile /apachevol/bin/envvars

Now Enable all the resources so that resources can be OFFLINE or ONLINE .

#hares –modify apacheApp Enable

#hares –modify apacheMnt Enable

#hares –modify apacheDG Enable

#hares –modify apacheIP Enable

#hares –modify apacheNIC Enable

#hares –modify apacheVol Enable

Testing the VCS SG :

You would have observed in resources configuration , we mentioned all the resources as Non-Critical by specifying Critical attribute to ‘0’ . Generally Critical attribute should be set to ‘1’ when that attribute is required for the Service Group to be completely online , if that Critical attribute is ‘0’ it specifies that the Service Group can be online even that resource is in offline state . Use the below command to online the resources manually .

hares –online -sys

Prior to changing the Critical attribute try to make the resources online on one server and check if all the resources comes online , if their exists any issues (like resource become FAULTED) , re-check the configuration and try again until all the resources comes online without any issues (Please follow the dependency hierarchy while making the individual resource online) . Once the SG shows online status , we are now ready to define the dependencies so that VCS handles the process of online/offline resources .

Link the VCS Resources :

We are now ready to define the resource dependencies and link the resource , this is required as VCS needs to identify which resource should be online before other resources are made online . In the figure you can find the hierarchy of resource dependencies .

#hares –link apacheApp apacheIP

#hares –link apacheApp apacheMnt

#hares –link apacheIP apacheNIC

#hares –link apacheMnt apacheVol

#hares –link apacheVol apacheDG

Now you can use the hagrp commands to control the service group . General VCS Service group operation involves switch , online or offline resources . Below are the commands you can use to perform these operations .

hares –online -sys

hares –offline -sys

hares –switch -to

Final Review of apacheSG :

Hmm atlast we are done with configuring and testing of our apacheSG . Below commands shows some final review of the service group .

[root@solaris2 /]#hastatus -sum

-- SYSTEM STATE

-- System State Frozen

A solaris1 RUNNING 0

A solaris2 RUNNING 0

-- GROUP STATE

-- Group System Probed AutoDisabled State

B apacheSG solaris1 Y N OFFLINE

B apacheSG solaris2 Y N ONLINE

Output defining online resources .

[root@solaris2 /]#hares -display -attribute State -group apacheSG -sys solaris2

#Resource Attribute System Value

apacheApp State solaris2 ONLINE

apacheDG State solaris2 ONLINE

apacheIP State solaris2 ONLINE

apacheMnt State solaris2 ONLINE

apacheNIC State solaris2 ONLINE

apacheVol State solaris2 ONLINE

Output defining dependencies .

[root@solaris2 /]#hares -dep

#Group Parent Child

apacheSG apacheApp apacheMnt

apacheSG apacheApp apacheIP

apacheSG apacheIP apacheNIC

apacheSG apacheMnt apacheVol

apacheSG apacheVol apacheDG

2 comments:

Unknown said...

Your great Bro....!!!

Mohammed said...

is there any way , we can have achieve Load balanchin or Active/Active cluster for Apache Webserve and at backend we have Tomcat Application servers.

Post a Comment