Thursday, 2 July 2015

Install and configure Git - CentOS 7

In this article i'll try to explain how to install, configure and use Git.

Environment: CentOS 7
Git version: 1.8.3.1

Git is a distribute version control system used by developers, but since it can also store .files(files with '.') system admin's can use to store their customized configurations files like .bashrc, .vimrc or other important scripts ..etc

Git takes a snapshot of how the files look at that instant in time and will store a reference to it. It wouldn't matter to Git what data you insert as it will check-sum it using SHA1 algorithm and create 40-character hex key. Git is based on key-value data system.

- Install Git by using 'yum' 

#yum install git -y

# git --version
git version 1.8.3.1
#

I already have a Git account registered if you don't have, signup to http://www.github.com and complete your registration. create your first repository by '+' 
NOTE: repository name you choose or the directory name which you create should be the alike. Git usually sync the directory or the files from your laptop or desktop to the one having the same name as in the GitHub.

 


setup your name and e-mail (similar email ID that you used to create GitHub account) on your local laptop or desktop which must be run very first time inorder to setup Git.

sunilka@centos7]$ git config --global user.name "sunilka"
sunilka@centos7]$ git config --global user.email "sunilka@gmail.com"
sunilka@centos7]$ git config --list

Create a directory and initialize Git by running git init, after that you have .git created with few files and directory under it. According to Git it's now been the working tree. now, everything under it can be uploaded to GitHub.

sunilka@centos7]$ mkdir configs
sunilka@centos7]$ cd configs; git init
sunilka@centos7]$ ls -ld .git

few files were been created and added into the directory, the moment we added the files into Git it creates a hash checksum and refers it by checksum.

sunilka@centos7 configs]$ git ls-files --stage
100755 af7ec7a5b7b361c10dcbf3db7286f97ef7df57d6 0       ks.cfg
100755 3e84972fcf7f688f98999d1bd5c38eaf250efcc9 0       ks_centos7.cfg
sunilka@centos7 configs]$

Now, lest pust to Gitgub which is our remote repository. first check you have remote repository already existing there
sunilka@centos7 configs]$ git remote -v
sunilka@centos7 configs]$ 

add the remote repository, URL which you had while creating the repository.
sunilka@centos7 configs]$ git remote add origin https://github.com/sunilka/configs.git

sunilka@centos7 configs]$  git remote -v
sunilka@centos7 configs]$ 

where, 
      git remote add - add remote directory to Git
              origin - default name of the remote location

Push the file to GitHub using, use the same username and password which you use to create and access your GitHub account.
sunilka@centos7 configs]$ git push origin master

any changes made to the files, must be committed before Git push. 

sunilka@centos7 configs]$ git commit -m "CentOS 7 kickstart file" ks_centos7.cfg
[master 08632bb] CentOS 7 kickstart file
 1 file changed, 1 deletion(-)
sunilka@centos7 configs]$ git commit -m "CentOS 6 kickstart file" ks.cfg
[master 498a0ca] CentOS 6 kickstart file
 1 file changed, 2 deletions(-)
sunilka@centos7 configs]$ 

sunilka@centos7 configs]$ git push origin master
.
.
Counting objects: 9, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 591 bytes | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
   57a7eb3..498a0ca  master -> master
sunilka@centos7 configs]$ 

Take a look at your GitHub page, it should have been uploaded. 











you can make a localcopy from your GitHub account using the clone feature

sunilka@centos7 configs]$ mkdir gitclones
sunilka@centos7 configs]$ cd gitclones/
sunilka@centos7 gitclones]$ git clone https://github.com/sunilka/configs.git
Cloning into 'configs'...
remote: Counting objects: 10, done.
remote: Total 10 (delta 0), reused 0 (delta 0), pack-reused 10
Unpacking objects: 100% (10/10), done.
sunilka@centos7 gitclones]$ ls
configs
sunilka@centos7 gitclones]$ ls configs/
ks_centos7.cfg  ks.cfg
sunilka@centos7 gitclones]$

you have same files are in your GitHub repository. 

Thursday, 11 June 2015

Kernel up-gradation on OpenSUSE(13.2) to latest kernel (4.1)

OpenSUSE 13.2 had it's kernel version 3.16.6-2, I have upgraded the latest kernel version 4.1.0-rc7-1. 

Below are the steps involved :

1. Make sure you retain multiple kernel configurations in /etc/zypp/zypp.conf which includes the oldest. 
2. Add kernel HEAD repository and perform distribution upgrade from kernel HEAD repository.
3. Reboot the system.

# tail -2 /etc/zypp/zypp.conf
multiversion = provides:multiversion(kernel)
multiversion.kernels = latest,latest-1,running,oldest
#

Adding repository 'kernel-repo' ..................................................................................................................................[done]
Repository 'kernel-repo' successfully added
Enabled: Yes
Autorefresh: Yes
GPG check: Yes
#

# zypper lr kernel-repo
Alias          : kernel-repo
Name           : kernel-repo
Enabled        : Yes
Priority       : 99
Auto-refresh   : On
Keep Packages  : Off
Type           : NONE
GPG Check      : On
GPG Key URI    :
Path Prefix    :
Parent Service :
Repo Info Path : /etc/zypp/repos.d/kernel-repo.repo
MD Cache Path  : /var/cache/zypp/raw/kernel-repo
#

# zypper dist-upgrade -r kernel-repo
Retrieving repository 'kernel-repo' metadata ------------------------------------------------------------------------------------------------------------------------[\]

New repository or package signing key received:

  Repository:       kernel-repo
  Key Name:         Kernel OBS Project <Kernel@build.opensuse.org>
  Key Fingerprint:  4529410A B52F94C4 03BAB484 ECEEF210 03579C1D
  Key Created:      Wed Apr 22 17:55:51 2015
  Key Expires:      Fri Jun 30 17:55:51 2017
  Rpm Name:         gpg-pubkey-03579c1d-5537934f


Do you want to reject the key, trust temporarily, or trust always? [r/t/a/? shows all options] (r): a
Retrieving repository 'kernel-repo' metadata .....................................................................................................................[done]
Building repository 'kernel-repo' cache ..........................................................................................................................[done]
Loading repository data...
Reading installed packages...
Computing distribution upgrade...

The following NEW package is going to be installed:
  kernel-desktop-4.1.rc7-1.1.gabe587d

1 new package to install.
Overall download size: 48.1 MiB. Already cached: 0 B  After the operation, additional 221.3 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package kernel-desktop-4.1.rc7-1.1.gabe587d.x86_64                                                                      (1/1),  48.1 MiB (221.3 MiB unpacked)
Retrieving: kernel-desktop-4.1.rc7-1.1.gabe587d.x86_64.rpm .........................................................................................[done (365.2 KiB/s)]
Checking for file conflicts: .....................................................................................................................................[done]
(1/1) Installing: kernel-desktop-4.1.rc7-1.1.gabe587d ............................................................................................................[done]
Additional rpm output:
Creating initrd: /boot/initrd-4.1.0-rc7-1.gabe587d-desktop
Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.1.0-rc7-1.gabe587d-desktop 4.1.0-rc7-1.gabe587d-desktop
*** Including module: bash ***
*** Including module: warpclock ***
*** Including module: i18n ***
*** Including module: ifcfg ***
*** Including module: drm ***
*** Including module: plymouth ***
*** Including module: btrfs ***
*** Including module: kernel-modules ***
Omitting driver i2o_scsi
*** Including module: resume ***
*** Including module: rootfs-block ***
*** Including module: terminfo ***
*** Including module: udev-rules ***
Skipping udev rule: 91-permissions.rules
Skipping udev rule: 80-drivers-modprobe.rules
*** Including module: systemd ***
*** Including module: usrmount ***
*** Including module: base ***
*** Including module: fs-lib ***
*** Including module: shutdown ***
*** Including module: suse ***
*** Including modules done ***
*** Installing kernel module dependencies and firmware ***
*** Installing kernel module dependencies and firmware done ***
*** Resolving executable dependencies ***
*** Resolving executable dependencies done***
*** Hardlinking files ***
*** Hardlinking files done ***
*** Stripping files ***
*** Stripping files done ***
*** Generating early-microcode cpio image ***
*** Store current command line parameters ***
Stored kernel commandline:
 resume=UUID=963537e9-1bf1-49de-b90c-6227ade69572
root=UUID=940ff654-d7da-43f3-a4c6-ed18ecbb231f rootflags=rw,relatime,space_cache rootfstype=btrfs
*** Creating image file ***
*** Creating image file done ***
Update bootloader...
#
- Finally, reboot is required and you would boot up in the latest Linux Kernel 4.1.
# uname -r
4.1.0-rc7-1.gabe587d-desktop
#

Wednesday, 10 June 2015

Glances - Max information in Minimum space #CentOS 7

Glances is a cross-platform curses-based system monitoring tool which aims to present a maximum of information in a minimum of space.It can adapt dynamically the displayed information depending on the terminal size.

Glances is written in Python and uses the psutil library to get information from your system.

Environment : CentOS 7
Installation 
Actually, package exists for CentOS in EPEL repository and install using your favorite package managers. 

#yum install epel-release
#yum install -y glances.noarch

I found this utility very useful as I don't have to type multiple commands to monitor the system, instead all data would be displayed in one single screen, 

CPU information (user, system, and idle programs )
Memory & Swap information 
CPU load for 1min, 5min, 15mins
Total number of process currently running 
Network download/uploads of network connections
Disk read/write speed
Disk usages
Date and time at the right bottom


You can press 'h' hot keys for fine tuning. 


If any one are more interested to know on this utility  here it is, http://glances.readthedocs.org/en/latest/

Simple utility to capture all the data in one screen.

Saturday, 6 June 2015

script to build your local YUM repository - CentOS 7

If you had installed your CentOS 7 as Minimal installation and incase if you need to install, update security fixes now and then in your local network, it would be better if it's been configured as a YUM server, saving you internet bandwidth.

readers who would like to create local repository would only need to mount the installation image to the drive and provide the path which they think there is enough free space on the drive to build the repository.

how it works shortly,

checks for the installation image in the drive, if found mount and then copy the contents from installation media to the path where you wanted to build the repository. create the repository file in /etc/yum.repos.d and build the repository. query your repository and then safely unmount the device.

this can be downloaded from the 'github' as well
https://github.com/sunilka/bashrepo/blob/master/localcentosrepo7.sh

# chmod +x localcentosrepo7.sh
#./ localcentosrepo7.sh

code:
#!/bin/bash
#
# Description:
# If there are no requirement for you to pull packages from Internet to installing the packages,
# you can use this script to build your local repository at your desired localtion.

# Summary:
# You are required to mount the installation CD/DVD/ISO image in your drive.
# this script is designed so that it would check image is mounted and would then mount to the '/media' mount point.
# It would copy all the contents from the media to your desired folder where you wanted to build your repository
# YUM pointed also added to the repository mentioned which comes pre-defined in the script.
# creates and builds your repository.
# checks are you able to query your repository
# Finally, unmounts the your media which is mounted
# you can remove your CD/DVD/ISo from the drive.

# this script is designed and tested on CentOS7


# Author: sunlnx
# email : sunlnx@gmail.com
#
##################################################################################################################

LOCALREPO=localrepo
REPONAME=centos7
LOGFILE=/tmp/centosrepo_output.log

# Check your DVD is available in the drive
function check_drive {
blkid /dev/sr0 >/dev/null
if [ $? -eq 0 ]
then
return 0
else
return 1
fi
}

# mount your DVD to some temp mount point
function mount_drive {

#fucntion call to check_drive
check_drive

#getting the return status from the fucntion called.
DRIVESTAT=$?

#mount DVD/ISO to some mount point on successful

if [ $DRIVESTAT -eq 0 ]
then
echo "checking for /media as mount point"
if [ -d "/media" ]
then
echo "media exists && attempting to mounting image...."
mount /dev/sr0 /media 2>/dev/null
[ $? -eq 0 ] && echo "image mount successful!";echo || echo "image unable to mount";echo
else
echo "/media doesn't exist, creating and mounting image";echo
mkdir /media
mount /dev/sr0 /media >/dev/null;echo
fi

else
echo "Please insert the DVD/ISO image... exiting .."
exit
fi

}

#function call for mounting the media to mount point
mount_drive

#if you had installed minimal installation on the server, then you need to install the 'deps' package before
#creating the repository
echo --------------------------------
echo " Logs written @ $LOGFILE"
echo --------------------------------

echo;
echo "Installing the dependencies before creating reposiotry" 2>&1 | tee $LOGFILE
echo;
rpm -ivh /media/Packages/libxml2-python-2.9.1-5.el7.x86_64.rpm >>$LOGFILE 2>&1
rpm -ivh /media/Packages/deltarpm-3.6-3.el7.x86_64.rpm >>$LOGFILE 2>&1
rpm -ivh /media/Packages/python-deltarpm-3.6-3.el7.x86_64.rpm >>$LOGFILE 2>&1
rpm -ivh /media/Packages/createrepo-0.9.9-23.el7.noarch.rpm >>$LOGFILE 2>&1
echo;

#dump your packages from DVD to the folder which has capacity of 4.2GB in your hard disk space
echo "Enter your path to create your repository"
read DIR
echo

#on your mentioned path, creating directory localrepo in which all packages do exists
echo "creating folder '$LOCALREPO' in $DIR"
mkdir $DIR/$LOCALREPO
echo


#check capacity on the disk to store packages
read -n1 -p "$DIR has 4.2G of free space in the Disk or LV ?[y/n]:" ch
#echo "$DIR has 4.2G of free space in the Disk or LV ?:[y/n] "
#read ch
echo
case $ch in
y|Y) echo "copying packages to $DIR/$LOCALREPO"
cp -arvf /media/* $DIR/$LOCALREPO >>$LOGFILE 2>&1
[ $? -eq 0 ] && echo "copy completed" ;echo;
;;

n|N) echo "script aborted"
exit
;;

*)echo "Invalid option, re-run script"
exit
;;

esac

cat >/etc/yum.repos.d/$REPONAME.repo <>$LOGFILE 2>&1
echo;echo "repo build completed"

#cleaing the repository
echo "refreshing repository..";echo
yum clean all >>$LOGFILE 2>&1
echo "clean completed.." ;echo

#Listing repositories
echo "Listing repositories";echo
yum list all
yum grouplist

#unmount the mounted media
echo "umounting the /media";echo
umount /media
[ $? -eq 0 ] && echo "filesystem unmounted successfully !!" || echo "media unsuccessful"
echo;echo "it's safe to remove your installation image from the drive !"
echo;
echo "LOCAL YUM REPOSITORY CREATED & SUCCESSFUL !!! :) "

Thursday, 4 June 2015

Monitor your disks/filesystems

Here is the script which will monitor the disk space and will generate alert once the file system usage has crossed WARING or CRITICAL threshold. 

I have re-directed the alert to the local domain and it can be configured to your inbox. 

script is self explanatory and can be found here :

#!/bin/bash
#this will monitor the disk uaage of the partitions and would generate an e-mail to the concerned. alert had been set to below 90 as WARNING and ABOVE 95 as CRITICAL

#Change your domain name according to your domain's & email's to the user account
ADMIN=root
WARNING=90
CRITICAL=95

#sda1 is the boot partition and /dev/sda2 being swap parition which I want to exclude
#you can also add other partitions if you don't want to monitor
EXCLHDD=/dev/sda1 /dev/sda2

function disk_monitoring()
{
while read output
do
#echo $output
usedpar=$(echo $output | awk '{print $1}' | cut -d'%' -f1)
tpar=$(echo $output | awk '{print $2}')
if ([ $usedpar -eq $WARNING ] && [ $usedpar -lt $CRITICAL ])
then
echo "WARNING|FILESYSTEM - $tpar|$usedpar%|$HOSTNAME" | \
mail -s "WARNING|ALERT|Housekeep the FileSystem" $ADMIN@
elif [ $usedpar -ge $CRITICAL ]
then
echo "CRITICAL|FILESYSTEM - $tpar|$usedpar%|$HOSTNAME" | \
mail -s "CRITICAL|ALERT|Filesystem running out of space" $ADMIN
fi
done
}
if [ "$EXCLHDD" != "" ]
then
df -H | grep -vE "^Filesystem|tmpfs|$EXCLHDD" | awk '{print $5 " " $6}' | disk_monitoring
else
df -H | grep -vE "^Filesystem|tmpfs"| awk '{print $5 " " $6}' | disk_monitoring
fi

Monday, 25 May 2015

grub> Software RAID devices assemble after grub prompt - CentOS 7

Short story is that I tried to make few changes to the grub without having taken backup which costed me several hours to recover when I had only GRUB prompt. I installed the grub2-install and after reboot, I am at the same grub prompt where I was earlier. Hence, I decided to remove the /boot/grub2/grub.cfg file and again re-create the file, which had no luck for me.

I had installed my server using software RAID1, I am referring them by the descriptive names(md0, md1 and md2). I figured out my boot drive which is second partition of the first hard-disk drive, tried loading the kernel and initramfs as below - 

grub>set prefix=(hd0,msdos2)/grub2
grub>set root=(hd0,msdos2)
grub>linux16 /vmlinuz-3.10.0-123.el7.x86_64
grub>initrd16  /initramfs-3.10.0-123.el7.x86_64.img
grub>boot

it would start to boot, and unfortunately the system drops into the initramfs rescue shell with the following information in 'journalctl'.  

#  journalctl
Not switching root: /sysroot does not seem to be an OS tree.  <<<============= 
/etc/os-release is missing.
Initrd-switch-root.service: main process exited, code=exited, 
status=1/FAILURE
Failed to start Switch Root.  <<<<=====================
. . . . .
Triggering OnFailure= dependencies of initrd-switch-root.service.
Starting Emergency Shell. . .
Failed to issue method call: Invalid argument

From this log I had to start suspect that root file system was not mounted as it appears to me that there was 'md' devices weren't assembled to run or the naming could have been chaged in the device mappers or because it doesn't know the file system or layers under it.
So, I thought to assemble the RAID volumes, mount the root volumes and fix the grub devices to match what 'mdadm --detail' says ..

I had booted into 'CentOS' server install's DVD rescue system, Chose to execute a shell from the installer environment and not to use a root file system.

#cat /proc/mdstat

- this would show the meta devices, (md125, md126, md127), stop those devices. 
# mdadm -S /dev/md125
# mdadm -S /dev/md126
# mdadm -S /dev/md127

- Assemble the volumes 
# mdadm -Av --run /dev/md0 /dev/sda1 /dev/sdb1
# mdadm -Av --run /dev/md1 /dev/sda2 /dev/sdb2
# mdadm -Av --run /dev/md2 /dev/sda3 /dev/sdb3

- Check the outcome
# cat /proc/mdstat
# mdadm --detail /dev/md0
# mdadm --detail /dev/md1
# mdadm --detail /dev/md2

- create the directory 'sysroot' and would mount the root file system to fix the device maps.
# mkdir /sysroot
# mount -o bind /dev/ /sysroot/dev
# mount -o bind /proc /sysroot/proc
# mount -o bind /sys /sysroot/sys
# mount -o bind /dev/pts /sysroot/dev/pts 

- chroot into it
# chroot /sysroot /bin/bash

- correct your device names so that current names of the 'md' devices and their UUIDs are properly read by GRUB.
#cp -p /boot/grub2/device.map /boot/grub2/device.map.old
#for i in /dev/disk/by-id/md-uuid-*; do DEV=$(readlink $i); echo "(${DEV##*/}) $i"; done|sort|tee /boot/grub2/device.map

- Recrete your initramfs
#dracut -vf /boot/initramfs-3.10.0-123.el7.x86_64.img

- Just make sure that you install GRUB2 on the two drives which are eligible for booting
# grub2-install /dev/sda
# grub2-install /dev/sdb

- update the grub to make sure that latest configuration to take effect.
# grub2-mkconfig -o /boot/grub2/grub.cfg

- you can leave the chroot environment and reboot.

Monday, 27 April 2015

High-Availability (HA) Apache Cluster - CentOS 7

In this article, I would be walk through the steps required to build a high-availability apache cluster on CentOS 7. In CentOS 7(as in RHEL 7) the cluster stack has been moved to pacemaker/corosync, with a new command line tool(pcs) to manage the cluster.

Environment Description:
The cluster would be of 2-node(centos71 & centos72), iSCSI shared storage will be presented from the node iscsitarget which is around 1GB.
If you want to know on how to share disk from iscsi click here

Objective:
High availability cluster that is serving websites where its document root would be utilising a simple failover filesystem.
In a stable situation, cluster should look something like this:


There is one owner of the virtual IP, in this case that is centos71. The owner of the virtual IP also provides the service for the cluster at that moment. A client that is trying to reach our website via 192.168.229.134 will be served the webpages from the webserver running on centos71 . In the above situation, the second node is not doing anything besides waiting for centos71 to fail and take over. This scenario is called active-passive.

In case something happens to centos71 the system crashes, the node is no longer reachable or the webserver isn't responding anymore, centos72 will become the owner of the virtual IP and start its webserver to provide the same services as were running on centos71


Pre-requsites:
Configure both the cluster nodes with static IP, hostname, and make sure they are in the same subnet and could be reached each other by their nodenames.(either you could add it in /etc/hosts or configure your DNS server)

If you had configured your firewall, make sure you allow cluster traffic(incase if they are active on any nodes), in this example, I had shutdown the firewall.

Installation:
After your basic setup, install packages
[root@centos71 ~]# yum install corosync pcs pacemaker
[root@centos72 ~]# yum install corosync pcs pacemaker

To manage cluster nodes, we will use PCS. this allows us to have a single interface to manage all cluster nodes. By installing the necessary packages, Yum also created a user, hacluster, which can be used together with PCS to do the configuration of the cluster nodes.

[root@centos71 ~]# passwd hacluster
[root@centos72 ~]# passwd hacluster

Next, start the pcsd service on both nodes:
[root@centos71 ~]# systemctl start pcsd
[root@centos72 ~]# systemctl start pcsd

Since we will configure all nodes from one point, we need to authenticate on all nodes before we are allowed to change the configuration. Use the previously configured hacluster user and password to do this.

[root@centos71 ~]# pcs cluster auth centos71 centos72
From here, we can control the cluster by using PCS from centos71 It's no longer required to repeat all commands on both nodes.

Create the cluster and add nodes
[root@centos71 ~]# pcs cluster setup --name webcluster centos71 centos72

The above command creates the cluster node configuration in /etc/corosync.conf
After creating the cluster and adding nodes to it, we can start it
[root@centos71 ~]# pcs cluster start --all
centos72: Starting Cluster...
centos71: Starting Cluster...
[root@centos71 ~]#

check the status of the cluster after starting it:
[root@centos71 ~]# pcs status cluster
Cluster Status:
 Last updated: Sun Apr 26 18:17:32 2015
 Last change: Sun Apr 26 18:16:26 2015 via cibadmin on centos71
 Stack: corosync
 Current DC: centos71 (1) - partition with quorum
 Version: 1.1.10-29.el7-368c726
 2 Nodes configured
 0 Resources configured
[root@centos71 ~]#

Since we have simple cluster, we'll just disable the stonith and ignore quorum device.
[root@centos71 ~]# pcs property set stonith-enabled=false
[root@centos71 ~]# pcs property set no-quorum-policy=ignore

Next, create a partition on the 1GB LUN  – this will house a filesystem to be used as the DocumentRoot for our Apache installation.
I had configured multipath for the device, hence install device-mapper* on both nodes. 
[root@centos71 ~]# mpathconf --enable
[root@centos72 ~]# mpathconf --enable
[root@centos71 ~]# systemctl multipathd start
[root@centos72 ~]# systemctl multipathd start

Create partiton from any of the one node, and then only 'partprobe' the second by default you would have had the same mapper device for the newly added iSCSI device. 
[root@centos71 ~]# lsblk -i
sdb                       8:16   0 1016M  0 disk
`-mpatha                253:6    0 1016M  0 mpath
  `-mpatha1             253:7    0 1015M  0 part
[root@centos71 ~]#

[root@centos72 ~]# lsblk -i
sdb                       8:16   0 1016M  0 disk
`-mpatha                253:5    0 1016M  0 mpath
  `-mpatha1             253:6    0 1015M  0 part
[root@centos72 ~]#

[root@centos71 ~]# fdisk /dev/mapper/mpatha
[root@centos71 ~]# partprobe
[root@centos71 ~]# mkfs.ext4 /dev/mapper/mpatha1
[root@centos71 ~]# mount /dev/mapper/mpatha1 /var/www
[root@centos71 ~]# mkdir /var/www/html;mkdir /var/www/error; 
[root@centos71 ~]# echo "apache test page" >/var/www/html/index.html 
[root@centos71 ~]# umount /dev/mapper/mpatha1

Create the filesystem cluster resource fs_apache_shared, and would group it to "apachegroup" which will be used to group the resources together as one unit.
[root@centos71 ~]#  pcs resource create fs_apache_shared ocf:heartbeat:Filesystem device=/dev/mapper/mpatha1 fstype=ext4 directory="/var/www" --group=apachegroup
[root@centos71 ~]#

We will add a virtual IP to our cluster. This virtual IP is the IP address that which will be contacted to reach the services (the webserver in our case). A virtual IP is a resource.
[root@centos71 ~]# pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=192.168.229.134 cidr_netmask=24 --group=apachegroup

Create a file /etc/httpd/conf.d/serverstatus.conf with the following contents on both nodes:
[root@centos71 ~]# cat /etc/httpd/conf.d/serverstatus.conf
Listen 127.0.0.1:80
 <Location /server-status>
 SetHandler server-status
 Order deny,allow
 Deny from all
 Allow from 127.0.0.1
 </Location>
[root@centos71 ~]#

Disable the current Listen-statement in the Apache configuration in order to avoid trying to listen multiple times on the same port.
[root@centos71 ~]#  grep -w "Listen 80" /etc/httpd/conf/httpd.conf
#Listen 80
[root@centos72 ~]#  grep -w "Listen 80" /etc/httpd/conf/httpd.conf
#Listen 80

Now that Apache is ready to be controlled by our cluster, we'll add a resource for the webserver
[root@centos71 ~]# pcs resource create webserver ocf:heartbeat:apache configfile=/etc/httpd/conf/httpd.conf statusurl="http://localhost/server-status" --group=apachegroup

Testing:
Browse http://192.168.229.134, it must display a test page. move your resource groups to partner node, where you shouldn't expect any downtime to your apache service.

[root@centos71 ~]# pcs status
Cluster name: webcluster
Last updated: Sun Apr 26 21:20:14 2015
Last change: Sun Apr 26 21:19:09 2015 via cibadmin on centos71
Stack: corosync
Current DC: centos71 (1) - partition with quorum
Version: 1.1.10-29.el7-368c726
2 Nodes configured
3 Resources configured

Online: [ centos71 centos72 ]

Full list of resources:

 Resource Group: apachegroup
     fs_apache_shared   (ocf::heartbeat:Filesystem):    Started centos71
     virtual_ip (ocf::heartbeat:IPaddr2):       Started centos71
     webserver  (ocf::heartbeat:apache):        Started centos71

PCSD Status:
  centos71: Online
  centos72: Online

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled
[root@centos71 ~]#

[root@centos71 ~]# pcs resource move webserver
[root@centos71 ~]# pcs status
Cluster name: webcluster
Last updated: Sun Apr 26 21:21:00 2015
Last change: Sun Apr 26 21:20:57 2015 via crm_resource on centos71
Stack: corosync
Current DC: centos71 (1) - partition with quorum
Version: 1.1.10-29.el7-368c726
2 Nodes configured
3 Resources configured

Online: [ centos71 centos72 ]

Full list of resources:

 Resource Group: apachegroup
     fs_apache_shared   (ocf::heartbeat:Filesystem):    Started centos72
     virtual_ip (ocf::heartbeat:IPaddr2):       Started centos72
     webserver  (ocf::heartbeat:apache):        Started centos72

PCSD Status:
  centos71: Online
  centos72: Online

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/disabled
[root@centos71 ~]#

you can use df -h  to confirm file system failover, ip addr show to confirm IP address failover.