Adding and Deleting Cluster Resources (corosync pacemaker)

In our previous tutorial, we have shown you how to install corosync and pacemaker.

We will show you now how to add resources.

Before starting the configurations, please  disable STONITH (Shoot The Other Node In The Head) with CRM command:

crm configure property stonith-enabled=false

check if stonith diabled:

[root@node1 ~]# crm configure show
 node node1
 node node2
property $id="cib-bootstrap-options" 
 dc..-version="1.1.10-14el6_52-368c726" 
 cluster-infrastructure="classic openais (with plugin)" 
 expected-quorum-votes="2" 
 stonith-enabled="false"

Add Cluster Resources

The cluster resource is defined by a Resource Agent and most know cluster agent classes are:

LSB (Linux Standard Base) – These are common cluster resource agents found in /etc/init.d directory (init scripts).

Example:

[root@node1 ~]# crm ra list lsb
NetworkManager    abrt-ccpp         abrt-oops         abrtd             acpid             atd               auditd            autofs
blk-availability  bluetooth         certmonger        cntlmd            corosync          corosync-notifyd  cpuspeed          cups
dnsmasq           firstboot         haldaemon         halt              htcacheclean      httpd             ip6tables         iptables
irqbalance        kdump             killall           lvm2-lvmetad      lvm2-monitor      mdmonitor         messagebus        netconsole
netfs             network           nfs               nfslock           ntpd              ntpdate           oddjobd           pacemaker
pacemaker_remote  portreserve       psacct            quota_nld         rdisc             restorecond       rngd              rpcbind
rpcgssd           rpcidmapd         rpcsvcgssd        rsyslog           sandbox           saslauthd         single            smartd
snmpd             snmptrapd         spawn-fcgi        spice-vdagentd    sshd              sssd              udev-post         wdaemon
winbind           wpa_supplicant    ypbind
[root@node1 ~]#

OCF (Open Cluster Framework) – These are actually extended LSB cluster resource agents and usually support additional parameters

example:

[root@node1 ~]# crm ra list ocf
ASEHAagent.sh       AoEtarget           AudibleAlarm        CTDB                ClusterMon          Delay               Dummy
EvmsSCC             Evmsd               Filesystem          HealthCPU           HealthSMART         ICP                 IPaddr
IPaddr2             IPsrcaddr           IPv6addr            LVM                 LinuxSCSI           MailTo              ManageRAID
ManageVE            Pure-FTPd           Raid1               Route               SAPDatabase         SAPInstance         SendArp
ServeRAID           SphinxSearchDaemon  Squid               Stateful            SysInfo             SystemHealth        VIPArip
VirtualDomain       WAS                 WAS6                WinPopup            Xen                 Xinetd              anything
apache              apache.sh           asterisk            clusterfs.sh        conntrackd          controld            db2
dhcpd               drbd                drbd.sh             eDir88              ethmonitor          exportfs            fio
fs.sh               iSCSILogicalUnit    iSCSITarget         ids                 ip.sh               iscsi               jboss
ldirectord          lvm.sh              lvm_by_lv.sh        lvm_by_vg.sh        lxc                 mysql               mysql-proxy
mysql.sh            named               named.sh            netfs.sh            nfsclient.sh        nfsexport.sh        nfsserver
nfsserver.sh        nginx               ocf-shellfuncs      openldap.sh         oracle              oracledb.sh         orainstance.sh
oralistener.sh      oralsnr             pgsql               ping                pingd               portblock           postfix
postgres-8.sh       pound               proftpd             remote              rsyncd              rsyslog             samba.sh
script.sh           scsi2reservation    service.sh          sfex                slapd               smb.sh              svclib_nfslock
symlink             syslog-ng           tomcat              tomcat-5.sh         tomcat-6.sh         varnish             vm.sh
vmware              zabbixserver
[root@node1 ~]#

Cluster Resource Name: Cluster_Server
Resource Agent: ocf:heartbeat:IPaddr2 (get this info with “crm ra meta IPaddr2″)
IP address: 192.168.1.200
Netmask: 24
Monitor interval: 30 seconds (get this info with “crm ra meta IPaddr2″)

Run the command in one of the nodes:

crm configure primitive Cluster_Server  ocf:heartbeat:IPaddr2 params ip=192.168.1.200 cidr_netmask="24" op monitor interval="30s"

 Check Cluster Configuration:

[root@node1 ~]# crm configure show
node node1
node node2
primitive Cluster_Server ocf::heartbeatIPaddr2 
        params ip="192.168.1.200" cidr_netmask="24" 
        op monitor interval="30s"
property $id="cib-bootstrap-options" 
        dc..-version="1.1.10-14el6_52-368c726" 
        cluster-infrastructure="classic openais (with plugin)" 
        expected-quorum-votes="2" 
        stonith-enabled="false" 
        no-quorum-policy="ignore"
[root@node1 ~]#

 Cluster  Status:

[root@node1 ~]# crm status
Last updated: Thu Mar  6 11:20:52 2014
Last change: Thu Mar  6 09:57:49 2014 via cibadmin on node1
Stack: classic openais (with plugin)
Current DC: node2 - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured, 2 expected votes
1 Resources configured
Online: [ node1 node2 ]
 Cluster_Server (ocf::heartbeat:IPaddr2):       Started node2

 Add Apache (httpd) Resource:

crm configure primitive Apache ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min

If you have any warning like this:

WARNING: Apache: default timeout 20s for start is smaller than the advised 40s
WARNING: Apache: default timeout 20s for stop is smaller than the advised 60s

fix it with:

crm configure property default-action-timeout="240"

Check:

[root@node1 ~]# crm  status
Last updated: Thu Mar  6 11:39:44 2014
Last change: Thu Mar  6 11:39:36 2014 via cibadmin on node1
Stack: classic openais (with plugin)
Current DC: node2 - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured, 2 expected votes
2 Resources configured
Online: [ node1 node2 ]
 Cluster_Server (ocf::heartbeat:IPaddr2):       Started node2
 Apache (ocf::heartbeat:apache):        Started node1
[root@node1 ~]#

That means  (http://192.168.1.200) should be live even if node1 or node down.

Deleting Apache (httpd) Resource

 crm resource stop Apache
 crm configure delete Apache

Deleting IP Address Resource

crm resource stop Cluster_Server
crm configure delete Cluster_Server