CentOS 8
Sponsored Link

Pacemaker : Set Cluster Resource (httpd)2020/03/09

 
Set Apache httpd Cluster Resource and Configure Active/Passive Web Server.
This example is based on the environment like follows.
  1) Bacic Cluster setting is done
  2) Fence Divice is set
  3) LVM shared storage is set
                       +--------------------+
                       | [  ISCSI Target  ] |
                       |  storage.srv.world |
                       +----------+---------+
                         10.0.0.50|
                                  |
+----------------------+          |          +----------------------+
| [  Cluster Node#1  ] |10.0.0.51 | 10.0.0.52| [  Cluster Node#2  ] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|     Apache httpd     |          |          |     Apache httpd     |
+----------------------+          |          +----------------------+
                            vip:10.0.0.100
                                  |
                       +----------+---------+
                       | [     Clients    ] |
                       |                    |
                       +--------------------+

[1] On all Cluster Nodes, Install Apache httpd.
[root@node01 ~]#
dnf -y install httpd
[root@node01 ~]#
vi /etc/httpd/conf.d/server-status.conf
# create new (enable server-status)

<Location /server-status>
    SetHandler server-status
    Require local
</Location>

[root@node01 ~]#
vi /etc/logrotate.d/httpd
# line 7: change like follows

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        #/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
        /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c "PidFile /var/run/httpd/httpd.pid" -k graceful > /dev/null 2>/dev/null || true 
    endscript
}

# if Firewalld is running, allow service

[root@node01 ~]#
firewall-cmd --add-service={http,https} --permanent

success
[root@node01 ~]#
firewall-cmd --reload

success
[2] On a Node LVM shared storage is active, Copy httpd files and create a Test page.
[root@node02 ~]#
mount /dev/vg_ha/lv_ha /mnt

[root@node02 ~]#
cp -pR /var/www/* /mnt/

[root@node02 ~]#
echo "Test Page" > /mnt/html/index.html

[root@node02 ~]#
umount /mnt

[3] On a Node in Cluster, Add httpd resource.
[/dev/vg_ha/lv_ha] on the example below is LVM shared storage.
# create filesystem resource

[root@node01 ~]#
pcs resource create httpd_fs ocf:heartbeat:Filesystem device=/dev/vg_ha/lv_ha directory=/var/www fstype=ext4 --group ha_group
# create virtual IP address resource

[root@node01 ~]#
pcs resource create httpd_vip ocf:heartbeat:IPaddr2 ip=10.0.0.100 cidr_netmask=24 --group ha_group
# create Apache resource

[root@node01 ~]#
pcs resource create website ocf:heartbeat:apache configfile=/etc/httpd/conf/httpd.conf statusurl=http://127.0.0.1/server-status --group ha_group
[root@node01 ~]#
pcs status

Cluster name: ha_cluster
Stack: corosync
Current DC: node01.srv.world (version 2.0.2-3.el8_1.2-744a30d655) - partition with quorum
Last updated: Mon Mar  8 19:09:10 2020
Last change: Mon Mar  8 19:09:07 2020 by root via cibadmin on node01.srv.world

2 nodes configured
5 resources configured

Online: [ node01.srv.world node02.srv.world ]

Full list of resources:

 scsi-shooter   (stonith:fence_scsi):   Started node01.srv.world
 Resource Group: ha_group
     lvm_ha     (ocf::heartbeat:LVM-activate):  Started node02.srv.world
     httpd_fs   (ocf::heartbeat:Filesystem):    Started node02.srv.world
     httpd_vip  (ocf::heartbeat:IPaddr2):       Started node02.srv.world
     website    (ocf::heartbeat:apache):        Started node02.srv.world

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

# if SELinux is enabled, run restorecon on active Node

[root@node02 ~]#
restorecon -R /var/www
# access to vip to verify working

[root@node01 ~]#
curl http://10.0.0.100/index.html

Test Page
Matched Content