Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on swebtools.com

Search Suggest

Configure VCS Cluster for Apache Web Server with HA on Linux


Configure VCS Cluster for Apache Web Server with HA on Linux

This post will help you with Configure VCS Cluster for Apache Web Server with HA on Linux.

If you are interested in learning, Request you to go through the below recommended tutorial.




This article shows you how to configure Veritas cluster server for apache webserver with high availability on Linux.

How to Configure VCS Cluster for Apache Web Server with HA on Linux


Our Lab Environment
1. Two server nodes (node1 and node2) with RHEL 7.0 - 64 Bit, both nodes are accessible each other.
2. Symantec Storage Foundation with High Availability (SFHA) 6.2 installed on both nodes. Refer this link to see how to install the VCS Cluster on Linux.
3. Three network cards on each nodes. (one for public network link and other two are for private network links)
4. Installed httpd apache package on both nodes using yum, but not started or enabled to start the service during the boot. because cluster should take care of start and stop. Refer this link to configure yum repo server on Linux.
5. One shared iSCSI Volume from iSCSI storage and mapped to both nodes (/dev/sdb). Refer this link to create a iSCSI Volume and map or access a ISCSI Volume on nodes.
6. Create a Volume using LVM and export the Volumegroup from node1 and import to node2 as below.

On Node1: 
pvcreate /dev/sdb
vgcreate vgapache /dev/sdb
lvcreate -n lvapache -l 100%FREE vgapache
mkfs.ext4 /dev/vgapache/lvapache
vgchange -a n vgapache
vgexport vgapache

On Node2:
vgimport vgapache
vgchange -a y vgapache

Required Skills:
Basics concepts of Veritas Cluster server
How to Install Veritas Cluster server (VCS) on Linux
How to Setup VCS Cluster nodes for configuring services for high availability

Once you have configured two VCS Cluster nodes. We can proceed to create a Service group for Apache Webserver on VCS Cluster.


Before creating a service group for webserver, need to remember the following things.
ALSO WATCH THIS "VCS CLUSTER CONFIGURATION HIGH AVAILABILITY APACHE WEB SERVER" TUTORIAL VIDEO FREE ON OUR YOUTUBE CHANNEL

1. Assign a unique name and instance number to service group (websg1) and resources (Example : webnic1, webip1, webmnt1, webvg1, webvol1, webapache1).
2. Define the resource dependencies. (Example : To assign ip address, nic should be activated. so dependency of ip address is nic card.)

Below image shows the service group and their resources which are required to bring our service group.
create Servicegroup for apache webserver

List of resources are,
webnic1, webip1, webvg1, webvol1, Webmnt1, webapache1,

Steps involved to create a Servicegroup for apache webserver,
1. Make the VCS cluster configuration file into writable.
2. How to create a Service Group (websg1).
3. How to create a resources to the service group.
3a. How to add a NIC resource (webnic1) to the service group
3b. how to add a IP resource (webip1) to the service group
3c. How to add a Volumegroup (webvg1) resource to the Service group
3d. How to add a Volume resource (webvol1) to the Service group
3e. How to add a Mount resource (webmnt1) to the Service group
3f. How to add a Apache resource (webapache1) to the Service group
4. How to create a resource dependencies or how to link a resources.
5. Make the VCS cluster configuration file into readonly
6. Check the VCS Cluster status
7. Create a Webpage content for testing purpose.
8. Switch the Servicegroup manually from node1 to node2 to check the failover.

1. Make the VCS cluster configuration file into writable
We should make the configuration file as writeable to make changes.
[root@node1 ~]# haconf -makerw

2. How to create a Service Group (websg1)
Create a dedicated servicegroup for Apache webserver.
[root@node1 ~]# hagrp -add websg1
VCS NOTICE V-16-1-10136 Group added; populating SystemList and setting the Parallel attribute recommended before adding resources.

Where websg1 is the unique service group name and instance number for our servicegroup.
Above command shows you to change the recommended attributes (SystemList and AutoStartList)
[root@node1 ~]# hagrp -modify websg1 SystemList node1 0 node2 1

Define the default node to start the service group automatically.
[root@node1 ~]# hagrp -modify websg1 AutoStartList node1

After the changes done with service group websg1, lets create a resources and add those resources to the service groups.

3. How to create a resources to the service group

3a. How to add a NIC resource (webnic1) to the service group
[root@node1 ~]# hares -add webnic1 NIC websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webnic1 is the NIC resource name, NIC is the resource type and websg1 is our servicegroup name. Above resource webnic1 added and tells you to enable the required attributes.

Set webnic1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webnic1 Critical 0

Define the network device to be used by this resource webnic1.
[root@node1 ~]# hares -modify webnic1 Device enp0s3

Assign the Networkhosts to the resource webnic1.
[root@node1 ~]# hares -modify webnic1 NetworkHosts 192.168.2.0

Enable the resource webnic1.
[root@node1 ~]# hares -modify webnic1 Enabled 1

Check the status of the resource webnic1.
[root@node1 ~]# hares -state webnic1
#Resource    Attribute             System     Value
webnic1      State                 node1      ONLINE
webnic1      State                 node2      ONLINE

3b. how to add a IP resource (webip1) to the service group
[root@node1 ~]# hares -add webip1 IP websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webip1 is the IP resource name, IP is the resource type and websg1 is our servicegroup name. Above resource webip1 added and gives you an output to enable the required attributes.

Set webip1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webip1 Critical 0

Define the network device to be used by this resource webip1.
[root@node1 ~]# hares -modify webip1 Device enp0s3

Assign the Virtual IP address to the resource webip1. so end users will be using this IP to access the webservice.
[root@node1 ~]# hares -modify webip1 Address 192.168.2.80

Assign the Netmask to the resource webip1.
[root@node1 ~]# hares -modify webip1 NetMask 255.255.255.0

Enable the resource webip1.
[root@node1 ~]# hares -modify webip1 Enabled 1

Make the resource webip1 online.
[root@node1 ~]# hares -online webip1 -sys node1

Check the status of the resource webip1.
[root@node1 ~]# hares -state webip1
#Resource    Attribute             System     Value
webip1      State                 node1      ONLINE
webip1      State                 node2      OFFLINE

3c. How to add a Volumegroup (webvg1) resource to the Service group
[root@node1 ~]# hares -add webvg1 LVMVolumeGroup websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webvg1 is the Diskgroup resource name, LVMVolumeGroup is the resource type and websg1 is our servicegroup name. Above resource webvg1 added and tells you to enable the required attributes.

Set webvg1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webvg1 Critical 0

Define the Volumegroup to be used by this resource webvg1.
[root@node1 ~]# hares -modify webvg1 VolumeGroup vgapache

Enable the resource webvg1.
[root@node1 ~]# hares -modify webvg1 Enabled 1

Make the resource webvg1 online.
[root@node1 ~]# hares -online webvg1 -sys node1

Check the status of the resource webvg1.
[root@node1 ~]# hares -state webvg1
#Resource    Attribute             System     Value
webvg1      State                 node1      ONLINE
webvg1      State                 node2      OFFLINE

3d. How to add a Volume resource (webvol1) to the Service group
[root@node1 ~]# hares -add webvol1 LVMLogicalVolume websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webvol1 is the Diskgroup resource name, LVMLogicalVolume is the resource type and websg1 is our servicegroup name. Above resource webvol1 added and tells you to enable the required attributes.

Set webvol1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webvol1 Critical 0

Define the Logical Volume to be used by this resource webvol1.
[root@node1 ~]# hares -modify webvol1 LogicalVolume lvapache

Define the Volumegroup to be used by this resource webvol1.
[root@node1 ~]# hares -modify webvol1 VolumeGroup vgapache

Enable the resource webvol1.
[root@node1 ~]# hares -modify webvol1 Enabled 1

Make the resource webvol1 online.
[root@node1 ~]# hares -online webvol1 -sys node1

Check the status of the resource webvol1.
[root@node1 ~]# hares -state webvol1
#Resource    Attribute             System     Value
webvol1      State                 node1      ONLINE
webvol1      State                 node2      OFFLINE

3e. How to add a Mount resource (webmnt1) to the Service group
[root@node1 ~]# hares -add webmnt1 Mount websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webmnt1 is the Mount resource name, Mount is the resource type and websg1 is our servicegroup name. Above resource webmnt1 added and tells you to enable the required attributes.

Set webvol1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webmnt1 Critical 0

Define the MountPoint to be used by this resource webmnt1.
[root@node1 ~]# hares -modify webmnt1 MountPoint /var/www/html

Define the Block device to be used by this resource webmnt1
[root@node1 ~]# hares -modify webmnt1 BlockDevice /dev/mapper/vgapache-lvapache

Note: Use only the mapper paths, dont use /dev/webvg1/webvol1.

Define the Filesystem type to be used by this resource webmnt1.
[root@node1 ~]# hares -modify webmnt1 FSType ext4

Define the Filesystem check options to be used by this resource webmnt1.
[root@node1 ~]# hares -modify webmnt1 FsckOpt %-y

Enable the resource webmnt1.
[root@node1 ~]# hares -modify webmnt1 Enabled 1

Make the resource webmnt1 online.
[root@node1 ~]# hares -online webmnt1 -sys node1

Check the status of the resource webmnt1.
[root@node1 ~]# hares -state webmnt1
#Resource    Attribute             System     Value
webmnt1      State                 node1      ONLINE
webmnt1      State                 node2      OFFLINE

3f. How to add a Apache resource (webapache1) to the Service group
[root@node1 ~]# hares -add webapache1 Apache websg1
VCS NOTICE V-16-1-10242 Resource added. Enabled attribute must be set before agent monitors

Where webapache1 is the resource name, Apache is the resource type and websg1 is our servicegroup name. Above resource webapache1 added and tells you to enable the required attributes.

Set webapache1 as non-critical. (0- Non Critical and 1 - Critical)
[root@node1 ~]# hares -modify webapache1 Critical 0

Define the ConfigFile to be used by this resource webapache1.
[root@node1 ~]# hares -modify webapache1 ConfigFile /etc/httpd/conf/httpd.conf

Define full path of the directory in which the httpd binary file is located to be used by this resource webapache1
[root@node1 ~]# hares -modify webapache1 httpdDir /usr/sbin

Enable the resource webapache1.
[root@node1 ~]# hares -modify webapache1 Enabled 1

4. How to create a resource dependencies or how to link a resources
Lets define the resource dependencies by linking the resources, this is required as VCS needs to identify which resource should be online before other resources are made online.
hares -link webip1 webnic1
hares -link webvol1 webvg1
hares -link webmnt1 webvol1
hares -link webapache1 webip1
hares -link webapache1 webmnt1

Check the dependencies belongs to the servicegroup websg1.
[root@node1 ~]# hares -dep | grep websg1

Check the status of the resource webapache1.
[root@node1 ~]# hares -state webapache1
#Resource    Attribute             System     Value
webapache1      State                 node1      ONLINE
webapache1      State                 node2      OFFLINE

Note : Wait for few minutes, If status not showing online on node1, then manually run the below command.
[root@node1 ~]# hagrp -online websg1 -sys node1

5. Make the VCS cluster configuration file into readonly
haconf -dump -makero

6. Check the VCS Cluster status
[root@node1 ~]# hastatus -sum
-- SYSTEM STATE
-- System               State                Frozen
A  node1                RUNNING              0
A  node2                RUNNING              0
-- GROUP STATE
-- Group           System               Probed     AutoDisabled    State
B  websg1          node1                Y          N               ONLINE
B  websg1          node2                Y          N               OFFLINE

Output shows that our servicegroup websg1 is online on node1 and offline on node2. Our Cluster is ready to serve the webpage content.

7. Create a Webpage content for testing purpose.
Create a “index.html” or keep your webpage content under /var/www/html. For testing purpose, We have added the content in the file index.html as "Welcome to VCS Tutorial by Learnitguide.net".

Test the Webpage:
Go to any client which are in the same network and type the address in the browser “http://192.168.2.80”

You will see the content successfully. Thats all about the configurations.

8. Switch the Servicegroup manually from node1 to node2 to check the failover.
Lets check the failover working or not manually..

Execute the below command to switch the servicegroup manually from node1 to node2.

On Node1:
hagrp -switch websg1 -to node2

Check cluster status
[root@node1 ~]# hastatus -sum
-- SYSTEM STATE
-- System               State                Frozen
A  node1                RUNNING              0
A  node2                RUNNING              0
-- GROUP STATE
-- Group           System               Probed     AutoDisabled    State
B  websg1          node1                Y          N               OFFLINE
B  websg1          node2                Y          N               ONLINE

Output shows that our servicegroup websg1 is online on node2 and offline on node1.

Thats all about the configuration of VCS Cluster for Apache webserver with high availability on Linux.

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.

configure vcs cluster linux, how to configure vcs cluster in linux, configure two node vcs cluster, veritas cluster configuration in linux