diff --git a/doc/Clusters_from_Scratch/en-US/Ch-Active-Active.xml b/doc/Clusters_from_Scratch/en-US/Ch-Active-Active.xml index f655447e2a..329cfd7178 100644 --- a/doc/Clusters_from_Scratch/en-US/Ch-Active-Active.xml +++ b/doc/Clusters_from_Scratch/en-US/Ch-Active-Active.xml @@ -1,722 +1,721 @@ %BOOK_ENTITIES; ]> Conversion to Active/Active
Requirements The primary requirement for an Active/Active cluster is that the data required for your services are available, simultaneously, on both machines. Pacemaker makes no requirement on how this is achieved, you could use a SAN if you had one available, however since DRBD supports multiple Primaries, we can also use that. The only hitch is that we need to use a cluster-aware filesystem (and the one we used earlier with DRBD, ext4, is not one of those). Both OCFS2 and GFS2 are supported, however here we will use GFS2 which comes with &DISTRO; &DISTRO_VERSION; .
Install a Cluster Filesystem - GFS2 The first thing to do is install gfs2-utils on each machine. [root@pcmk-1 ~]# yum install -y gfs2-utils gfs-pcmk Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package gfs-pcmk.x86_64 0:3.0.5-2.fc12 set to be updated --> Processing Dependency: libSaCkpt.so.3(OPENAIS_CKPT_B.01.01)(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64 --> Processing Dependency: dlm-pcmk for package: gfs-pcmk-3.0.5-2.fc12.x86_64 --> Processing Dependency: libccs.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64 --> Processing Dependency: libdlmcontrol.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64 --> Processing Dependency: liblogthread.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64 --> Processing Dependency: libSaCkpt.so.3()(64bit) for package: gfs-pcmk-3.0.5-2.fc12.x86_64 ---> Package gfs2-utils.x86_64 0:3.0.5-2.fc12 set to be updated --> Running transaction check ---> Package clusterlib.x86_64 0:3.0.5-2.fc12 set to be updated ---> Package dlm-pcmk.x86_64 0:3.0.5-2.fc12 set to be updated ---> Package openaislib.x86_64 0:1.1.0-1.fc12 set to be updated --> Finished Dependency Resolution Dependencies Resolved ===========================================================================================  Package                Arch               Version                   Repository        Size =========================================================================================== Installing:  gfs-pcmk               x86_64             3.0.5-2.fc12              custom           101 k  gfs2-utils             x86_64             3.0.5-2.fc12              custom           208 k Installing for dependencies:  clusterlib             x86_64             3.0.5-2.fc12              custom            65 k  dlm-pcmk               x86_64             3.0.5-2.fc12              custom            93 k  openaislib             x86_64             1.1.0-1.fc12              fedora            76 k Transaction Summary =========================================================================================== Install       5 Package(s) Upgrade       0 Package(s) Total download size: 541 k Downloading Packages: (1/5): clusterlib-3.0.5-2.fc12.x86_64.rpm                                |  65 kB     00:00 (2/5): dlm-pcmk-3.0.5-2.fc12.x86_64.rpm                                  |  93 kB     00:00 (3/5): gfs-pcmk-3.0.5-2.fc12.x86_64.rpm                                  | 101 kB     00:00 (4/5): gfs2-utils-3.0.5-2.fc12.x86_64.rpm                                | 208 kB     00:00 (5/5): openaislib-1.1.0-1.fc12.x86_64.rpm                                |  76 kB     00:00 ------------------------------------------------------------------------------------------- Total                                                           992 kB/s | 541 kB     00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction   Installing     : clusterlib-3.0.5-2.fc12.x86_64                                       1/5   Installing     : openaislib-1.1.0-1.fc12.x86_64                                       2/5   Installing     : dlm-pcmk-3.0.5-2.fc12.x86_64                                         3/5   Installing     : gfs-pcmk-3.0.5-2.fc12.x86_64                                         4/5   Installing     : gfs2-utils-3.0.5-2.fc12.x86_64                                       5/5 Installed:   gfs-pcmk.x86_64 0:3.0.5-2.fc12                    gfs2-utils.x86_64 0:3.0.5-2.fc12 Dependency Installed:   clusterlib.x86_64 0:3.0.5-2.fc12   dlm-pcmk.x86_64 0:3.0.5-2.fc12   openaislib.x86_64 0:1.1.0-1.fc12   Complete! [root@pcmk-1 x86_64]# If this step fails, it is likely that your version/distribution does not ship the "Pacemaker" versions of dlm_controld and/or gfs_controld. Normally these files would be called dlm_controld.pcmk and gfs_controld.pcmk and live in the /usr/sbin directory. If you cannot locate an installation source for these files, you will need to install a package called cman and reconfigure Corosync to use it as outlined in . When using CMAN, you can skip where dlm-clone and gfs-clone are created, and proceed directly to .
Setup Pacemaker-GFS2 Integration GFS2 needs two services to be running, the first is the user-space interface to the kernel’s distributed lock manager (DLM). The DLM is used to co-ordinate which node(s) can access a given file (and when) and integrates with Pacemaker to obtain node membership The list of nodes the cluster considers to be available information and fencing capabilities. The second service is GFS2’s own control daemon which also integrates with Pacemaker to obtain node membership data.
Add the DLM service The DLM control daemon needs to run on all active cluster nodes, so we will use the shells interactive mode to create a cloned resource. [root@pcmk-1 ~]# crm crm(live)# cib new stack-glue INFO: stack-glue shadow CIB created crm(stack-glue)# configure primitive dlm ocf:pacemaker:controld op monitor interval=120s crm(stack-glue)# configure clone dlm-clone dlm meta interleave=true crm(stack-glue)# configure show xml crm(stack-glue)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \         params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4" primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \ op monitor interval="120s" ms WebDataClone WebData \         meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone dlm-clone dlm \ meta interleave="true" location prefer-pcmk-1 WebSite 50: pcmk-1 colocation WebSite-with-WebFS inf: WebSite WebFS colocation fs_on_drbd inf: WebFS WebDataClone:Master colocation website-with-ip inf: WebSite ClusterIP order WebFS-after-WebData inf: WebDataClone:promote WebFS:start order WebSite-after-WebFS inf: WebFS WebSite order apache-after-ip inf: ClusterIP WebSite property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100” TODO: Explain the meaning of the interleave option Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response crm(stack-glue)# cib commit stack-glue INFO: commited 'stack-glue' shadow CIB to the cluster crm(stack-glue)# quit bye [root@pcmk-1 ~]# crm_mon ============ Last updated: Thu Sep  3 20:49:54 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 5 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] WebSite (ocf::heartbeat:apache):        Started pcmk-2 Master/Slave Set: WebDataClone         Masters: [ pcmk-1 ]         Slaves: [ pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2 Clone Set: dlm-clone Started: [ pcmk-2 pcmk-1 ] WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-2
Add the GFS2 service Once the DLM is active, we can add the GFS2 control daemon. Use the crm shell to create the gfs-control cluster resource: [root@pcmk-1 ~]# crm crm(live)# cib new gfs-glue --force INFO: gfs-glue shadow CIB created crm(gfs-glue)# configure primitive gfs-control ocf:pacemaker:controld params daemon=gfs_controld.pcmk args="-g 0" op monitor interval=120s crm(gfs-glue)# configure clone gfs-clone gfs-control meta interleave=true Now ensure Pacemaker only starts the gfs-control service on nodes that also have a copy of the dlm service (created above) already running crm(gfs-glue)# configure colocation gfs-with-dlm INFINITY: gfs-clone dlm-clone crm(gfs-glue)# configure order start-gfs-after-dlm mandatory: dlm-clone gfs-clone Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response crm(gfs-glue)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \         params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype="ext4" primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \         op monitor interval="120s" primitive gfs-control ocf:pacemaker:controld \ params daemon=”gfs_controld.pcmk” args=”-g 0” \ op monitor interval="120s" ms WebDataClone WebData \         meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone dlm-clone dlm \         meta interleave="true" clone gfs-clone gfs-control \ meta interleave="true" location prefer-pcmk-1 WebSite 50: pcmk-1 colocation WebSite-with-WebFS inf: WebSite WebFS colocation fs_on_drbd inf: WebFS WebDataClone:Master colocation gfs-with-dlm inf: gfs-clone dlm-clone colocation website-with-ip inf: WebSite ClusterIP order WebFS-after-WebData inf: WebDataClone:promote WebFS:start order WebSite-after-WebFS inf: WebFS WebSite order apache-after-ip inf: ClusterIP WebSite order start-gfs-after-dlm inf: dlm-clone gfs-clone property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100” crm(gfs-glue)# cib commit gfs-glue INFO: commited 'gfs-glue' shadow CIB to the cluster crm(gfs-glue)# quit bye [root@pcmk-1 ~]# crm_mon ============ Last updated: Thu Sep  3 20:49:54 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 6 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] WebSite (ocf::heartbeat:apache):        Started pcmk-2 Master/Slave Set: WebDataClone         Masters: [ pcmk-1 ]         Slaves: [ pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2 Clone Set: dlm-clone         Started: [ pcmk-2 pcmk-1 ] Clone Set: gfs-clone Started: [ pcmk-2 pcmk-1 ] WebFS   (ocf::heartbeat:Filesystem):    Started pcmk-1
Create a GFS2 Filesystem
Preparation Before we do anything to the existing partition, we need to make sure it is unmounted. We do this by tell the cluster to stop the WebFS resource. This will ensure that other resources (in our case, Apache) using WebFS are not only stopped, but stopped in the correct order. [root@pcmk-1 ~]# crm_resource --resource WebFS --set-parameter target-role --meta --parameter-value Stopped [root@pcmk-1 ~]# crm_mon ============ Last updated: Thu Sep  3 15:18:06 2009 Stack: openais Current DC: pcmk-1 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 6 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] Master/Slave Set: WebDataClone         Masters: [ pcmk-1 ]         Slaves: [ pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1 Clone Set: dlm-clone         Started: [ pcmk-2 pcmk-1 ] Clone Set: gfs-clone         Started: [ pcmk-2 pcmk-1 ] Note that both Apache and WebFS have been stopped.
Create and Populate an GFS2 Partition Now that the cluster stack and integration pieces are running smoothly, we can create an GFS2 partition. This will erase all previous content stored on the DRBD device. Ensure you have a copy of any important data. We need to specify a number of additional parameters when creating a GFS2 partition. First we must use the -p option to specify that we want to use the the Kernel’s DLM. Next we use -j to indicate that it should reserve enough space for two journals (one per node accessing the filesystem). Lastly, we use -t to specify the lock table name. The format for this field is clustername:fsname. For the fsname, we just need to pick something unique and descriptive and since we haven’t specified a clustername yet, we will use the default (pcmk). To specify an alternate name for the cluster, locate the service section containing “name: pacemaker” in corosync.conf and insert the following line anywhere inside the block: clustername: myname Do this on each node in the cluster and be sure to restart them before continuing. -mkfs.gfs2 -p lock_dlm -j 2 -t pcmk:web /dev/drbd1 -[root@pcmk-1 ~]# mkfs.gfs2 -t pcmk:web -p lock_dlm -j 2 /dev/vdb -This will destroy any data on /dev/vdb. +[root@pcmk-1 ~]# mkfs.gfs2 -p lock_dlm -j 2 -t pcmk:web /dev/drbd1 +This will destroy any data on /dev/drbd1. It appears to contain: data Are you sure you want to proceed? [y/n] y -Device:                    /dev/vdb +Device:                    /dev/drbd1 Blocksize:                 4096 Device Size                1.00 GB (131072 blocks) Filesystem Size:           1.00 GB (131070 blocks) Journals:                  2 Resource Groups:           2 Locking Protocol:          "lock_dlm" Lock Table:                "pcmk:web" UUID:                      6B776F46-177B-BAF8-2C2B-292C0E078613 [root@pcmk-1 ~]# Then (re)populate the new filesystem with data (web pages). For now we’ll create another variation on our home page. [root@pcmk-1 ~]# mount /dev/drbd1 /mnt/ [root@pcmk-1 ~]# cat <<-END >/mnt/index.html <html> <body>My Test Site - GFS2</body> </html> END [root@pcmk-1 ~]# umount /dev/drbd1 [root@pcmk-1 ~]# drbdadm verify wwwdata [root@pcmk-1 ~]#
Reconfigure the Cluster for GFS2 [root@pcmk-1 ~]# crm crm(live)# cib new GFS2 INFO: GFS2 shadow CIB created crm(GFS2)# configure delete WebFS crm(GFS2)# configure primitive WebFS ocf:heartbeat:Filesystem params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2” Now that we’ve recreated the resource, we also need to recreate all the constraints that used it. This is because the shell will automatically remove any constraints that referenced WebFS. crm(GFS2)# configure colocation WebSite-with-WebFS inf: WebSite WebFS crm(GFS2)# configure colocation fs_on_drbd inf: WebFS WebDataClone:Master crm(GFS2)# configure order WebFS-after-WebData inf: WebDataClone:promote WebFS:start crm(GFS2)# configure order WebSite-after-WebFS inf: WebFS WebSite crm(GFS2)# configure colocation WebFS-with-gfs-control INFINITY: WebFS gfs-clone crm(GFS2)# configure order start-WebFS-after-gfs-control mandatory: gfs-clone WebFS crm(GFS2)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \ params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2” primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \         op monitor interval="120s" primitive gfs-control ocf:pacemaker:controld \    params daemon=”gfs_controld.pcmk” args=”-g 0” \         op monitor interval="120s" ms WebDataClone WebData \         meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone dlm-clone dlm \         meta interleave="true" clone gfs-clone gfs-control \         meta interleave="true" colocation WebFS-with-gfs-control inf: WebFS gfs-clone colocation WebSite-with-WebFS inf: WebSite WebFS colocation fs_on_drbd inf: WebFS WebDataClone:Master colocation gfs-with-dlm inf: gfs-clone dlm-clone colocation website-with-ip inf: WebSite ClusterIP order WebFS-after-WebData inf: WebDataClone:promote WebFS:start order WebSite-after-WebFS inf: WebFS WebSite order apache-after-ip inf: ClusterIP WebSite order start-WebFS-after-gfs-control inf: gfs-clone WebFS order start-gfs-after-dlm inf: dlm-clone gfs-clone property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100” Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response crm(GFS2)# cib commit GFS2 INFO: commited 'GFS2' shadow CIB to the cluster crm(GFS2)# quit bye [root@pcmk-1 ~]# crm_mon ============ Last updated: Thu Sep  3 20:49:54 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 6 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] WebSite (ocf::heartbeat:apache):        Started pcmk-2 Master/Slave Set: WebDataClone         Masters: [ pcmk-1 ]         Slaves: [ pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2 Clone Set: dlm-clone         Started: [ pcmk-2 pcmk-1 ] Clone Set: gfs-clone         Started: [ pcmk-2 pcmk-1 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-1
Reconfigure Pacemaker for Active/Active Almost everything is in place. Recent versions of DRBD are capable of operating in Primary/Primary mode and the filesystem we’re using is cluster aware. All we need to do now is reconfigure the cluster to take advantage of this. This will involve a number of changes, so we’ll again use interactive mode. [root@pcmk-1 ~]# crm [root@pcmk-1 ~]# cib new active There’s no point making the services active on both locations if we can’t reach them, so lets first clone the IP address. Cloned IPaddr2 resources use an iptables rule to ensure that each request only processed by one of the two clone instances. The additional meta options tell the cluster how many instances of the clone we want (one “request bucket” for each node) and that if all other nodes fail, then the remaining node should hold all of them. Otherwise the requests would be simply discarded. [root@pcmk-1 ~]# configure clone WebIP ClusterIP  \         meta globally-unique=”true” clone-max=”2” clone-node-max=”2” Now we must tell the ClusterIP how to decide which requests are processed by which hosts. To do this we must specify the clusterip_hash parameter. Open the ClusterIP resource [root@pcmk-1 ~]# configure edit  ClusterIP And add the following to the params line clusterip_hash="sourceip" So that the complete definition looks like: primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" clusterip_hash="sourceip" \         op monitor interval="30s" Here is the full transcript [root@pcmk-1 ~]# crm crm(live)# cib new active INFO: active shadow CIB created crm(active)# configure clone WebIP ClusterIP  \         meta globally-unique=”true” clone-max=”2” clone-node-max=”2” crm(active)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \         params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2” primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \         op monitor interval="120s" primitive gfs-control ocf:pacemaker:controld \    params daemon=”gfs_controld.pcmk” args=”-g 0” \         op monitor interval="120s" ms WebDataClone WebData \         meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone WebIP ClusterIP \ meta globally-unique=”true” clone-max=”2” clone-node-max=”2” clone dlm-clone dlm \         meta interleave="true" clone gfs-clone gfs-control \         meta interleave="true" colocation WebFS-with-gfs-control inf: WebFS gfs-clone colocation WebSite-with-WebFS inf: WebSite WebFS colocation fs_on_drbd inf: WebFS WebDataClone:Master colocation gfs-with-dlm inf: gfs-clone dlm-clone colocation website-with-ip inf: WebSite WebIP order WebFS-after-WebData inf: WebDataClone:promote WebFS:start order WebSite-after-WebFS inf: WebFS WebSite order apache-after-ip inf: WebIP WebSite order start-WebFS-after-gfs-control inf: gfs-clone WebFS order start-gfs-after-dlm inf: dlm-clone gfs-clone property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100” Notice how any constraints that referenced ClusterIP have been updated to use WebIP instead. This is an additional benefit of using the crm shell. Next we need to convert the filesystem and Apache resources into clones. Again, the shell will automatically update any relevant constraints. crm(active)# configure clone WebFSClone WebFS crm(active)# configure clone WebSiteClone WebSite The last step is to tell the cluster that it is now allowed to promote both instances to be Primary (aka. Master). crm(active)# configure edit WebDataClone Change master-max to 2 crm(active)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \         params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2” primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \         op monitor interval="120s" primitive gfs-control ocf:pacemaker:controld \    params daemon=”gfs_controld.pcmk” args=”-g 0” \         op monitor interval="120s" ms WebDataClone WebData \         meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone WebFSClone WebFS clone WebIP ClusterIP  \         meta globally-unique=”true” clone-max=”2” clone-node-max=”2” clone WebSiteClone WebSite clone dlm-clone dlm \         meta interleave="true" clone gfs-clone gfs-control \         meta interleave="true" colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone colocation fs_on_drbd inf: WebFSClone WebDataClone:Master colocation gfs-with-dlm inf: gfs-clone dlm-clone colocation website-with-ip inf: WebSiteClone WebIP order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start order WebSite-after-WebFS inf: WebFSClone WebSiteClone order apache-after-ip inf: WebIP WebSiteClone order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone order start-gfs-after-dlm inf: dlm-clone gfs-clone property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100” Review the configuration before uploading it to the cluster, quitting the shell and watching the cluster’s response crm(active)# cib commit active INFO: commited 'active' shadow CIB to the cluster crm(active)# quit bye [root@pcmk-1 ~]# crm_mon ============ Last updated: Thu Sep  3 21:37:27 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 6 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] Master/Slave Set: WebDataClone         Masters: [ pcmk-1 pcmk-2 ] Clone Set: dlm-clone         Started: [ pcmk-2 pcmk-1 ] Clone Set: gfs-clone         Started: [ pcmk-2 pcmk-1 ] Clone Set: WebIP Started: [ pcmk-1 pcmk-2 ] Clone Set: WebFSClone Started: [ pcmk-1 pcmk-2 ] Clone Set: WebSiteClone Started: [ pcmk-1 pcmk-2 ]
Testing Recovery TODO: Put one node into standby to demonstrate failover
diff --git a/doc/Clusters_from_Scratch/en-US/Ch-Active-Passive.xml b/doc/Clusters_from_Scratch/en-US/Ch-Active-Passive.xml index 593a9c5d5a..29197d2bc4 100644 --- a/doc/Clusters_from_Scratch/en-US/Ch-Active-Passive.xml +++ b/doc/Clusters_from_Scratch/en-US/Ch-Active-Passive.xml @@ -1,408 +1,408 @@ %BOOK_ENTITIES; ]> Creating an Active/Passive Cluster
Exploring the Existing Configuration When Pacemaker starts up, it automatically records the number and details of the nodes in the cluster as well as which stack is being used and the version of Pacemaker being used. This is what the base configuration should look like. [root@pcmk-2 ~]# crm configure show node pcmk-1 node pcmk-2 property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes="2" For those that are not of afraid of XML, you can see the raw configuration by appending “xml” to the previous command. [root@pcmk-2 ~]# crm configure show xml <?xml version="1.0" ?> <cib admin_epoch="0" crm_feature_set="3.0.1" dc-uuid="pcmk-1" epoch="13" have-quorum="1" num_updates="7" validate-with="pacemaker-1.0">   <configuration>     <crm_config>       <cluster_property_set id="cib-bootstrap-options">         <nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f"/>         <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="openais"/>         <nvpair id="cib-bootstrap-options-expected-quorum-votes" name="expected-quorum-votes" value="2"/>       </cluster_property_set>     </crm_config>     <rsc_defaults/>     <op_defaults/>     <nodes>       <node id="pcmk-1" type="normal" uname="pcmk-1"/>       <node id="pcmk-2" type="normal" uname="pcmk-2"/>     </nodes>     <resources/>     <constraints/>   </configuration> </cib> The last XML you’ll see in this document Before we make any changes, its a good idea to check the validity of the configuration. [root@pcmk-1 ~]# crm_verify -L crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option crm_verify[2195]: 2009/08/27_16:57:12 ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity Errors found during check: config not valid   -V may provide more details [root@pcmk-1 ~]# As you can see, the tool has found some errors. In order to guarantee the safety of your data If the data is corrupt, there is little point in continuing to make it available , Pacemaker ships with STONITH A common node fencing mechanism. Used to ensure data integrity by powering off “bad” nodes. enabled. However it also knows when no STONITH configuration has been supplied and reports this as a problem (since the cluster would not be able to make progress if a situation requiring node fencing arose). For now, we will disable this feature and configure it later in the Configuring STONITH section. It is important to note that the use of STONITH is highly encouraged, turning it off tells the cluster to simply pretend that failed nodes are safely powered off. Some vendors will even refuse to support clusters that have it disabled. To disable STONITH, we set the stonith-enabled cluster option to false.
crm configure property stonith-enabled=false crm_verify -L
With the new cluster option set, the configuration is now valid. The use of stonith-enabled=false is completely inappropriate for a production cluster. We use it here to defer the discussion of its configuration which can differ widely from one installation to the next. See for information on why STONITH is important and details on how to configure it.
Adding a Resource The first thing we should do is configure an IP address. Regardless of where the cluster service(s) are running, we need a consistent address to contact them on. Here I will choose and add 192.168.122.101 as the floating address, give it the imaginative name ClusterIP and tell the cluster to check that its running every 30 seconds. The chosen address must not be one already associated with a physical node crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip=192.168.122.101 cidr_netmask=32 \         op monitor interval=30s The other important piece of information here is ocf:heartbeat:IPaddr2. This tells Pacemaker three things about the resource you want to add. The first field, ocf, is the standard to which the resource script conforms to and where to find it. The second field is specific to OCF resources and tells the cluster which namespace to find the resource script in, in this case heartbeat. The last field indicates the name of the resource script. To obtain a list of the available resource classes, run [root@pcmk-1 ~]# crm ra classes heartbeat lsb ocf / heartbeat pacemaker stonith To then find all the OCF resource agents provided by Pacemaker and Heartbeat, run [root@pcmk-1 ~]# crm ra list ocf pacemaker ClusterMon     Dummy          Stateful       SysInfo        SystemHealth   controld ping           pingd           [root@pcmk-1 ~]# crm ra list ocf heartbeat AoEtarget              AudibleAlarm           ClusterMon             Delay Dummy                  EvmsSCC                Evmsd                  Filesystem ICP                    IPaddr                 IPaddr2                IPsrcaddr LVM                    LinuxSCSI              MailTo                 ManageRAID ManageVE               Pure-FTPd              Raid1                  Route SAPDatabase            SAPInstance            SendArp                ServeRAID SphinxSearchDaemon     Squid                  Stateful               SysInfo VIPArip                VirtualDomain          WAS                    WAS6 WinPopup               Xen                    Xinetd                 anything apache                 db2                    drbd                   eDir88 iSCSILogicalUnit       iSCSITarget            ids                    iscsi ldirectord             mysql                  mysql-proxy            nfsserver oracle                 oralsnr                pgsql                  pingd portblock              rsyncd                 scsi2reservation       sfex tomcat                 vmware                 [root@pcmk-1 ~]# Now verify that the IP resource has been added and display the cluster’s status to see that it is now active. [root@pcmk-1 ~]# crm configure show node pcmk-1 node pcmk-2 primitive ClusterIP ocf:heartbeat:IPaddr2 \ params ip="192.168.122.101" cidr_netmask="32" \ op monitor interval="30s" property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes="2" \         stonith-enabled="false" \ [root@pcmk-1 ~]# crm_mon ============ Last updated: Fri Aug 28 15:23:48 2009 Stack: openais Current DC: pcmk-1 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-1
Perform a Failover Being a high-availability cluster, we should test failover of our new resource before moving on. First, find the node on which the IP address is running. [root@pcmk-1 ~]# crm resource status ClusterIP resource ClusterIP is running on: pcmk-1 [root@pcmk-1 ~]# Shut down Pacemaker and Corosync on that machine. [root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop Signaling Pacemaker Cluster Manager to terminate: [ OK ] Waiting for cluster services to unload:. [ OK ] [root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop Stopping Corosync Cluster Engine (corosync): [ OK ] Waiting for services to unload: [ OK ] [root@pcmk-1 ~]# Once Corosync is no longer running, go to the other node and check the cluster status with crm_mon. [root@pcmk-2 ~]# crm_mon ============ Last updated: Fri Aug 28 15:27:35 2009 Stack: openais Current DC: pcmk-2 - partition WITHOUT quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-2 ] OFFLINE: [ pcmk-1 ] There are three things to notice about the cluster’s current state. The first is that, as expected, pcmk-1 is now offline. However we can also see that ClusterIP isn’t running anywhere!
Quorum and Two-Node Clusters This is because the cluster no longer has quorum, as can be seen by the text “partition WITHOUT quorum” (emphasised green) in the output above. In order to reduce the possibility of data corruption, Pacemaker’s default behavior is to stop all resources if the cluster does not have quorum. A cluster is said to have quorum when more than half the known or expected nodes are online, or for the mathematically inclined, whenever the following equation is true: total_nodes < 2 * active_nodes Therefore a two-node cluster only has quorum when both nodes are running, which is no longer the case for our cluster. This would normally make the creation of a two-node cluster pointless Actually some would argue that two-node clusters are always pointless, but that is an argument for another time. , however it is possible to control how Pacemaker behaves when quorum is lost. In particular, we can tell the cluster to simply ignore quorum altogether. [root@pcmk-1 ~]# crm configure property no-quorum-policy=ignore [root@pcmk-1 ~]# crm configure show node pcmk-1 node pcmk-2 primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" \         op monitor interval="30s" property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes="2" \         stonith-enabled="false" \         no-quorum-policy="ignore" After a few moments, the cluster will start the IP address on the remaining node. Note that the cluster still does not have quorum. [root@pcmk-2 ~]# crm_mon ============ Last updated: Fri Aug 28 15:30:18 2009 Stack: openais Current DC: pcmk-2 - partition WITHOUT quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-2 ] OFFLINE: [ pcmk-1 ] ClusterIP (ocf::heartbeat:IPaddr): Started pcmk-2 Now simulate node recovery by restarting the cluster stack on pcmk-1 and check the cluster’s status. [root@pcmk-1 ~]# /etc/init.d/corosync start Starting Corosync Cluster Engine (corosync): [ OK ] [root@pcmk-1 ~]# /etc/init.d/pacemaker start Starting Pacemaker Cluster Manager: [ OK ] [root@pcmk-1 ~]# crm_mon ============ Last updated: Fri Aug 28 15:32:13 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1 Here we see something that some may consider surprising, the IP is back running at its original location!
Prevent Resources from Moving after Recovery In some circumstances it is highly desirable to prevent healthy resources from being moved around the cluster. Move resources almost always requires a period of downtime and for complex services like Oracle databases, this period can be quite long. To address this, Pacemaker has the concept of resource stickiness which controls how much a service prefers to stay running where it is. You may like to think of it as the “cost” of any downtime. By default, Pacemaker assumes there is zero cost associated with moving resources and will do so to achieve “optimal It should be noted that Pacemaker’s definition of optimal may not always agree with that of a human’s. The order in which Pacemaker processes lists of resources and nodes create implicit preferences (required in order to create a stabile solution) in situations where the administrator had not explicitly specified some. ” resource placement. We can specify a different stickiness for every resource, but it is often sufficient to change the default. -crm configure rsc_defaults resource-stickiness=100 +[root@pcmk-2 ~]# crm configure rsc_defaults resource-stickiness=100 [root@pcmk-2 ~]# crm configure show node pcmk-1 node pcmk-2 primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip="192.168.122.101" cidr_netmask="32" \         op monitor interval="30s" property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes="2" \         stonith-enabled="false" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \ resource-stickiness="100" If we now retry the failover test, we see that as expected ClusterIP still moves to pcmk-2 when pcmk-1 is taken offline. [root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/pacemaker stop Signaling Pacemaker Cluster Manager to terminate: [ OK ] Waiting for cluster services to unload:. [ OK ] [root@pcmk-1 ~]# ssh pcmk-1 -- /etc/init.d/corosync stop Stopping Corosync Cluster Engine (corosync):               [  OK  ] Waiting for services to unload:                            [  OK  ] [root@pcmk-1 ~]# ssh pcmk-2 -- crm_mon -1 ============ Last updated: Fri Aug 28 15:39:38 2009 Stack: openais Current DC: pcmk-2 - partition WITHOUT quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-2 ] OFFLINE: [ pcmk-1 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2 However when we bring pcmk-1 back online, ClusterIP now remains running on pcmk-2. [root@pcmk-1 ~]# /etc/init.d/corosync start Starting Corosync Cluster Engine (corosync): [ OK ] [root@pcmk-1 ~]# /etc/init.d/pacemaker start Starting Pacemaker Cluster Manager: [ OK ] [root@pcmk-1 ~]# crm_mon ============ Last updated: Fri Aug 28 15:41:23 2009 Stack: openais Current DC: pcmk-2 - partition with quorum Version: 1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f 2 Nodes configured, 2 expected votes 1 Resources configured. ============ Online: [ pcmk-1 pcmk-2 ] ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2
diff --git a/doc/Clusters_from_Scratch/en-US/Ch-Stonith.xml b/doc/Clusters_from_Scratch/en-US/Ch-Stonith.xml index 5b88f4c69a..eb8d76f7bf 100644 --- a/doc/Clusters_from_Scratch/en-US/Ch-Stonith.xml +++ b/doc/Clusters_from_Scratch/en-US/Ch-Stonith.xml @@ -1,161 +1,160 @@ %BOOK_ENTITIES; ]> Configure STONITH
Why You Need STONITH STONITH is an acronym for Shoot-The-Other-Node-In-The-Head and it protects your data from being corrupted by rouge nodes or concurrent access. Just because a node is unresponsive, this doesn’t mean it isn’t accessing your data. The only way to be 100% sure that your data is safe, is to use STONITH so we can be certain that the node is truly offline, before allowing the data to be accessed from another node. STONITH also has a role to play in the event that a clustered service cannot be stopped. In this case, the cluster uses STONITH to force the whole node offline, thereby making it safe to start the service elsewhere.
What STONITH Device Should You Use It is crucial that the STONITH device can allow the cluster to differentiate between a node failure and a network one. The biggest mistake people make in choosing a STONITH device is to use remote power switch (such as many onboard IMPI controllers) that shares power with the node it controls. In such cases, the cluster cannot be sure if the node is really offline, or active and suffering from a network fault. Likewise, any device that relies on the machine being active (such as SSH-based “devices” used during testing) are inappropriate.
Configuring STONITH Find the correct driver: stonith -L Since every device is different, the parameters needed to configure it will vary. To find out the parameters required by the device: stonith -t {type} -n Hopefully the developers chose names that make sense, if not you can query for some additional information by finding an active cluster node and running: lrmadmin -M stonith {type} pacemaker The output should be XML formatted text containing additional parameter descriptions Create a file called stonith.xml containing a primitive resource with a class of stonith, a type of {type} and a parameter for each of the values returned in step 2 Create a clone from the primitive resource if the device can shoot more than one node and supports multiple simultaneous connections. Upload it into the CIB using cibadmin: cibadmin -C -o resources --xml-file stonith.xml
Example Assuming we have an IBM BladeCenter containing our two nodes and the management interface is active on 192.168.122.31, then we would chose the external/ibmrsa driver in step 2 and obtain the following list of parameters -stonith -t external/ibmrsa -n [root@pcmk-1 ~]# stonith -t external/ibmrsa -n hostname  ipaddr  userid  passwd  type Assuming we know the username and password for the management interface, we would create a STONITH resource with the shell [root@pcmk-1 ~]# crm crm(live)# cib new stonith INFO: stonith shadow CIB created crm(stonith)# configure primitive rsa-fencing stonith::external/ibmrsa \         params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \         op monitor interval="60s" crm(stonith)# configure clone Fencing rsa-fencing And finally, since we disabled it earlier, we need to re-enable STONITH crm(stonith)# configure property stonith-enabled="true" crm(stonith)# configure show node pcmk-1 node pcmk-2 primitive WebData ocf:linbit:drbd \         params drbd_resource="wwwdata" \         op monitor interval="60s" primitive WebFS ocf:heartbeat:Filesystem \         params device="/dev/drbd/by-res/wwwdata" directory="/var/www/html" fstype=”gfs2” primitive WebSite ocf:heartbeat:apache \         params configfile="/etc/httpd/conf/httpd.conf" \         op monitor interval="1min" primitive ClusterIP ocf:heartbeat:IPaddr2 \         params ip=”192.168.122.101” cidr_netmask=”32” clusterip_hash=”sourceip” \         op monitor interval="30s" primitive dlm ocf:pacemaker:controld \         op monitor interval="120s" primitive gfs-control ocf:pacemaker:controld \    params daemon=”gfs_controld.pcmk” args=”-g 0” \         op monitor interval="120s" primitive rsa-fencing stonith::external/ibmrsa \ params hostname=”pcmk-1 pcmk-2" ipaddr=192.168.122.31 userid=mgmt passwd=abc123 type=ibm \ op monitor interval="60s" ms WebDataClone WebData \         meta master-max="2" master-node-max="1" clone-max="2" clone-node-max="1" notify="true" clone Fencing rsa-fencing clone WebFSClone WebFS clone WebIP ClusterIP  \         meta globally-unique=”true” clone-max=”2” clone-node-max=”2” clone WebSiteClone WebSite clone dlm-clone dlm \         meta interleave="true" clone gfs-clone gfs-control \         meta interleave="true" colocation WebFS-with-gfs-control inf: WebFSClone gfs-clone colocation WebSite-with-WebFS inf: WebSiteClone WebFSClone colocation fs_on_drbd inf: WebFSClone WebDataClone:Master colocation gfs-with-dlm inf: gfs-clone dlm-clone colocation website-with-ip inf: WebSiteClone WebIP order WebFS-after-WebData inf: WebDataClone:promote WebFSClone:start order WebSite-after-WebFS inf: WebFSClone WebSiteClone order apache-after-ip inf: WebIP WebSiteClone order start-WebFS-after-gfs-control inf: gfs-clone WebFSClone order start-gfs-after-dlm inf: dlm-clone gfs-clone property $id="cib-bootstrap-options" \         dc-version="1.1.5-bdd89e69ba545404d02445be1f3d72e6a203ba2f" \         cluster-infrastructure="openais" \         expected-quorum-votes=”2” \         stonith-enabled="true" \         no-quorum-policy="ignore" rsc_defaults $id="rsc-options" \         resource-stickiness=”100”