CentOS 7
Sponsored Link

Pacemaker : Add Resource (httpd)2015/06/23

 
Add httpd Resource to Cluster.
This example is based on the environment like follows.
                              10.0.0.50
                             (Virtual IP)
                                  |
+----------------------+          |          +----------------------+
| [       Node01     ] |10.0.0.51 | 10.0.0.52| [       Node02     ] |
|   node01.srv.world   +----------+----------+   node02.srv.world   |
|    httpd service     |                     |     httpd service    |
+----------------------+                     +----------------------+

[1]
[2]
Install Apache httpd, refer to here. (It's not necessary to start service)
[3] Enable httpd server-status on all Nodes.
[root@node01 ~]#
vi /etc/httpd/conf.d/server_status.conf
# create new

ExtendedStatus On

<Location /server-status>
    SetHandler server-status
    Require local
</Location>
[4] Change some settings and set virtual IP address.
# disable STONITH (Shoot The Other Node In The Head) option on here

[root@node01 ~]#
pcs property set stonith-enabled=false
# change to "ignore", it does not need for 2 nodes cluster

[root@node01 ~]#
pcs property set no-quorum-policy=ignore
# disable auto failbask

[root@node01 ~]#
pcs property set default-resource-stickiness="INFINITY"
# show settings

[root@node01 ~]#
pcs property list

Cluster Properties:
 cluster-infrastructure: corosync
 cluster-name: ha_cluster
 dc-version: 1.1.12-a14efad
 default-resource-stickiness: INFINITY
 have-watchdog: false
 no-quorum-policy: ignore
 stonith-enabled: false

# set virtual IP address

[root@node01 ~]#
pcs resource create Virtual_IP ocf:heartbeat:IPaddr2 ip=10.0.0.50 cidr_netmask=24 op monitor interval=30s
# show status

[root@node01 ~]#
pcs status resources

Virtual_IP (ocf::heartbeat:IPaddr2): Started
[5] Add httpd Resource. It's OK to set on a Node.
# add resource

[root@node01 ~]#
pcs resource create Web_Cluster \
ocf:heartbeat:apache \
configfile=/etc/httpd/conf/httpd.conf \
statusurl="http://127.0.0.1/server-status" \
op monitor interval=1min
# set that Web_Cluster and Virtual_IP are always on a same node

[root@node01 ~]#
pcs constraint colocation add Web_Cluster with Virtual_IP INFINITY
# set that the order of starting is Virtual_IP ⇒ Web_Cluster

[root@node01 ~]#
pcs constraint order Virtual_IP then Web_Cluster

Adding Virtual_IP Web_Cluster (kind: Mandatory) (Options: first-action=start then-action=start)
# show status

[root@node01 ~]#
pcs constraint

Location Constraints:
Ordering Constraints:
  start Virtual_IP then start Web_Cluster (kind:Mandatory)
Colocation Constraints:
  Web_Cluster with Virtual_IP (score:INFINITY)
[6] Access to the virtual IP address to verify the settings.
[7] Stop current active node manually and make sure resource will switch to another node normally.
[root@node01 ~]#
pcs cluster stop node01.srv.world

node01.srv.world: Stopping Cluster (pacemaker)...
node01.srv.world: Stopping Cluster (corosync)...
Matched Content