diff --git a/doc/sphinx/Clusters_from_Scratch/active-active.rst b/doc/sphinx/Clusters_from_Scratch/active-active.rst index 0d27174637..d12dfa4756 100644 --- a/doc/sphinx/Clusters_from_Scratch/active-active.rst +++ b/doc/sphinx/Clusters_from_Scratch/active-active.rst @@ -1,343 +1,343 @@ .. index:: single: storage; active/active Convert Storage to Active/Active -------------------------------- The primary requirement for an active/active cluster is that the data required for your services is available, simultaneously, on both machines. Pacemaker makes no requirement on how this is achieved; you could use a Storage Area Network (SAN) if you had one available, but since DRBD supports multiple Primaries, we can continue to use it here. .. index:: single: GFS2 single: DLM single: filesystem; GFS2 Install Cluster Filesystem Software ################################### The only hitch is that we need to use a cluster-aware filesystem. The one we used earlier with DRBD, xfs, is not one of those. Both OCFS2 and GFS2 are supported; here, we will use GFS2. On both nodes, install Distributed Lock Manager (DLM) and the GFS2 command- line utilities required by cluster filesystems: .. code-block:: console # dnf config-manager --set-enabled resilientstorage # dnf install -y dlm gfs2-utils Configure the Cluster for the DLM ################################# The DLM control daemon needs to run on both nodes, so we'll start by creating a resource for it (using the ``ocf:pacemaker:controld`` resource agent), and clone it: .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib dlm_cfg [root@pcmk-1 ~]# pcs -f dlm_cfg resource create dlm \ ocf:pacemaker:controld op monitor interval=60s [root@pcmk-1 ~]# pcs -f dlm_cfg resource clone dlm clone-max=2 clone-node-max=1 [root@pcmk-1 ~]# pcs resource status * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Unpromoted: [ pcmk-2 ] * WebFS (ocf:heartbeat:Filesystem): Started pcmk-1 Activate our new configuration, and see how the cluster responds: .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib-push dlm_cfg --config CIB updated [root@pcmk-1 ~]# pcs resource status * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Unpromoted: [ pcmk-2 ] * WebFS (ocf:heartbeat:Filesystem): Started pcmk-1 * Clone Set: dlm-clone [dlm]: * Started: [ pcmk-1 pcmk-2 ] [root@pcmk-1 ~]# pcs resource config Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) Clone: WebData-clone Meta Attrs: clone-max=2 clone-node-max=1 notify=true promotable=true promoted-max=1 promoted-node-max=1 Resource: WebData (class=ocf provider=linbit type=drbd) Attributes: drbd_resource=wwwdata Operations: demote interval=0s timeout=90 (WebData-demote-interval-0s) monitor interval=29s role=Promoted (WebData-monitor-interval-29s) monitor interval=31s role=Unpromoted (WebData-monitor-interval-31s) notify interval=0s timeout=90 (WebData-notify-interval-0s) promote interval=0s timeout=90 (WebData-promote-interval-0s) reload interval=0s timeout=30 (WebData-reload-interval-0s) start interval=0s timeout=240 (WebData-start-interval-0s) stop interval=0s timeout=100 (WebData-stop-interval-0s) Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=xfs Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) Clone: dlm-clone Meta Attrs: interleave=true ordered=true Resource: dlm (class=ocf provider=pacemaker type=controld) Operations: monitor interval=60s (dlm-monitor-interval-60s) start interval=0s timeout=90s (dlm-start-interval-0s) stop interval=0s timeout=100s (dlm-stop-interval-0s) Create and Populate GFS2 Filesystem ################################### Before we do anything to the existing partition, we need to make sure it is unmounted. We do this by telling the cluster to stop the ``WebFS`` resource. This will ensure that other resources (in our case, ``WebSite``) using ``WebFS`` are not only stopped, but stopped in the correct order. .. code-block:: console [root@pcmk-1 ~]# pcs resource disable WebFS [root@pcmk-1 ~]# pcs resource * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Stopped * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Unpromoted: [ pcmk-2 ] * WebFS (ocf:heartbeat:Filesystem): Stopped (disabled) * Clone Set: dlm-clone [dlm]: * Started: [ pcmk-1 pcmk-2 ] You can see that both ``WebSite`` and ``WebFS`` have been stopped, and that ``pcmk-1`` is currently running the promoted instance for the DRBD device. Now we can create a new GFS2 filesystem on the DRBD device. .. WARNING:: This will erase all previous content stored on the DRBD device. Ensure you have a copy of any important data. .. IMPORTANT:: Run the next command on whichever node has the DRBD Primary role. Otherwise, you will receive the message: .. code-block:: console /dev/drbd1: Read-only file system .. code-block:: console [root@pcmk-1 ~]# mkfs.gfs2 -p lock_dlm -j 2 -t mycluster:web /dev/drbd1 It appears to contain an existing filesystem (xfs) This will destroy any data on /dev/drbd1 Are you sure you want to proceed? [y/n] y Discarding device contents (may take a while on large devices): Done Adding journals: Done Building resource groups: Done Creating quota file: Done Writing superblock and syncing: Done Device: /dev/drbd1 Block size: 4096 Device size: 0.50 GB (131059 blocks) Filesystem size: 0.50 GB (131055 blocks) Journals: 2 Journal size: 8MB Resource groups: 4 Locking protocol: "lock_dlm" Lock table: "mycluster:web" UUID: 19712677-7206-4660-a079-5d17341dd720 The ``mkfs.gfs2`` command required a number of additional parameters: * ``-p lock_dlm`` specifies that we want to use DLM-based locking. * ``-j 2`` indicates that the filesystem should reserve enough space for two journals (one for each node that will access the filesystem). * ``-t mycluster:web`` specifies the lock table name. The format for this field is ``:``. For ``CLUSTERNAME``, we need to use the same value we specified originally with ``pcs cluster setup --name`` (which is also the value of ``cluster_name`` in ``/etc/corosync/corosync.conf``). If you are unsure what your cluster name is, you can look in ``/etc/corosync/corosync.conf`` or execute the command ``pcs cluster corosync | grep cluster_name``. Now we can (re-)populate the new filesystem with data (web pages). We'll create yet another variation on our home page. .. code-block:: console [root@pcmk-1 ~]# mount /dev/drbd1 /mnt [root@pcmk-1 ~]# cat <<-END >/mnt/index.html My Test Site - GFS2 END [root@pcmk-1 ~]# chcon -R --reference=/var/www/html /mnt [root@pcmk-1 ~]# umount /dev/drbd1 [root@pcmk-1 ~]# drbdadm verify wwwdata Reconfigure the Cluster for GFS2 ################################ With the ``WebFS`` resource stopped, let's update the configuration. .. code-block:: console [root@pcmk-1 ~]# pcs resource config WebFS Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=xfs Meta Attrs: target-role=Stopped Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) The fstype option needs to be updated to ``gfs2`` instead of ``xfs``. .. code-block:: console [root@pcmk-1 ~]# pcs resource update WebFS fstype=gfs2 [root@pcmk-1 ~]# pcs resource config WebFS Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=gfs2 Meta Attrs: target-role=Stopped Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) GFS2 requires that DLM be running, so we also need to set up new colocation and ordering constraints for it: .. code-block:: console [root@pcmk-1 ~]# pcs constraint colocation add WebFS with dlm-clone [root@pcmk-1 ~]# pcs constraint order dlm-clone then WebFS Adding dlm-clone WebFS (kind: Mandatory) (Options: first-action=start then-action=start) [root@pcmk-1 ~]# pcs constraint Location Constraints: Resource: WebSite Enabled on: Node: pcmk-2 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebData-clone then start WebFS (kind:Mandatory) start WebFS then start WebSite (kind:Mandatory) start dlm-clone then start WebFS (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) WebFS with WebData-clone (score:INFINITY) (rsc-role:Started) (with-rsc-role:Promoted) WebSite with WebFS (score:INFINITY) WebFS with dlm-clone (score:INFINITY) Ticket Constraints: We also need to update the ``no-quorum-policy`` property to ``freeze``. By default, the value of ``no-quorum-policy`` is set to ``stop`` indicating that once quorum is lost, all the resources on the remaining partition will immediately be stopped. Typically this default is the safest and most optimal option, but unlike most resources, GFS2 requires quorum to function. When quorum is lost both the applications using the GFS2 mounts and the GFS2 mount itself cannot be correctly stopped. Any attempts to stop these resources without quorum will fail, which will ultimately result in the entire cluster being fenced every time quorum is lost. To address this situation, set ``no-quorum-policy`` to ``freeze`` when GFS2 is in use. This means that when quorum is lost, the remaining partition will do -nothing until quorum is regained. +nothing until quorum is regained. .. code-block:: console [root@pcmk-1 ~]# pcs property set no-quorum-policy=freeze .. index:: pair: filesystem; clone Clone the Filesystem Resource ############################# Now that we have a cluster filesystem ready to go, we can configure the cluster so both nodes mount the filesystem. Clone the ``Filesystem`` resource in a new configuration. Notice how ``pcs`` automatically updates the relevant constraints again. .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib active_cfg [root@pcmk-1 ~]# pcs -f active_cfg resource clone WebFS [root@pcmk-1 ~]# pcs -f active_cfg constraint Location Constraints: Resource: WebSite Enabled on: Node: pcmk-2 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebData-clone then start WebFS-clone (kind:Mandatory) start WebFS-clone then start WebSite (kind:Mandatory) start dlm-clone then start WebFS-clone (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) WebFS-clone with WebData-clone (score:INFINITY) (rsc-role:Started) (with-rsc-role:Promoted) WebSite with WebFS-clone (score:INFINITY) WebFS-clone with dlm-clone (score:INFINITY) Ticket Constraints: Tell the cluster that it is now allowed to promote both instances to be DRBD Primary. .. code-block:: console [root@pcmk-1 ~]# pcs -f active_cfg resource update WebData-clone promoted-max=2 Finally, load our configuration to the cluster, and re-enable the ``WebFS`` resource (which we disabled earlier). .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib-push active_cfg --config CIB updated [root@pcmk-1 ~]# pcs resource enable WebFS After all the processes are started, the status should look similar to this. .. code-block:: console [root@pcmk-1 ~]# pcs resource * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 pcmk-2 ] * Clone Set: dlm-clone [dlm]: * Started: [ pcmk-1 pcmk-2 ] * Clone Set: WebFS-clone [WebFS]: * Started: [ pcmk-1 pcmk-2 ] Test Failover ############# Testing failover is left as an exercise for the reader. With this configuration, the data is now active/active. The website administrator could change HTML files on either node, and the live website will show the changes even if it is running on the opposite node. If the web server is configured to listen on all IP addresses, it is possible to remove the constraints between the ``WebSite`` and ``ClusterIP`` resources, and clone the ``WebSite`` resource. The web server would always be ready to serve web pages, and only the IP address would need to be moved in a failover. diff --git a/doc/sphinx/Clusters_from_Scratch/ap-configuration.rst b/doc/sphinx/Clusters_from_Scratch/ap-configuration.rst index b71e9af67c..0bd92a1f9f 100644 --- a/doc/sphinx/Clusters_from_Scratch/ap-configuration.rst +++ b/doc/sphinx/Clusters_from_Scratch/ap-configuration.rst @@ -1,345 +1,345 @@ Configuration Recap ------------------- Final Cluster Configuration ########################### .. code-block:: console [root@pcmk-1 ~]# pcs resource * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 pcmk-2 ] * Clone Set: dlm-clone [dlm]: * Started: [ pcmk-1 pcmk-2 ] * Clone Set: WebFS-clone [WebFS]: * Started: [ pcmk-1 pcmk-2 ] .. code-block:: console [root@pcmk-1 ~]# pcs resource op defaults Meta Attrs: op_defaults-meta_attributes timeout=240s .. code-block:: console [root@pcmk-1 ~]# pcs stonith * fence_dev (stonith:some_fence_agent): Started pcmk-1 .. code-block:: console [root@pcmk-1 ~]# pcs constraint Location Constraints: Resource: WebSite Enabled on: Node: pcmk-2 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebData-clone then start WebFS-clone (kind:Mandatory) start WebFS-clone then start WebSite (kind:Mandatory) start dlm-clone then start WebFS-clone (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) WebFS-clone with WebData-clone (score:INFINITY) (rsc-role:Started) (with-rsc-role:Promoted) WebSite with WebFS-clone (score:INFINITY) WebFS-clone with dlm-clone (score:INFINITY) Ticket Constraints: .. code-block:: console [root@pcmk-1 ~]# pcs status Cluster name: mycluster Cluster Summary: * Stack: corosync * Current DC: pcmk-1 (version 2.1.2-4.el9-ada5c3b36e2) - partition with quorum * Last updated: Wed Jul 27 08:57:57 2022 * Last change: Wed Jul 27 08:55:00 2022 by root via cibadmin on pcmk-1 * 2 nodes configured * 9 resource instances configured Node List: * Online: [ pcmk-1 pcmk-2 ] Full List of Resources: * fence_dev (stonith:some_fence_agent): Started pcmk-1 * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 pcmk-2 ] * Clone Set: dlm-clone [dlm]: * Started: [ pcmk-1 pcmk-2 ] * Clone Set: WebFS-clone [WebFS]: * Started: [ pcmk-1 pcmk-2 ] Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled .. code-block:: console [root@pcmk-1 ~]# pcs config Cluster Name: mycluster Corosync Nodes: pcmk-1 pcmk-2 Pacemaker Nodes: pcmk-1 pcmk-2 - + Resources: Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) Clone: WebData-clone Meta Attrs: clone-max=2 clone-node-max=1 notify=true promotable=true promoted-max=2 promoted-node-max=1 Resource: WebData (class=ocf provider=linbit type=drbd) Attributes: drbd_resource=wwwdata Operations: demote interval=0s timeout=90 (WebData-demote-interval-0s) monitor interval=29s role=Promoted (WebData-monitor-interval-29s) monitor interval=31s role=Unpromoted (WebData-monitor-interval-31s) notify interval=0s timeout=90 (WebData-notify-interval-0s) promote interval=0s timeout=90 (WebData-promote-interval-0s) reload interval=0s timeout=30 (WebData-reload-interval-0s) start interval=0s timeout=240 (WebData-start-interval-0s) stop interval=0s timeout=100 (WebData-stop-interval-0s) Clone: dlm-clone Meta Attrs: interleave=true ordered=true Resource: dlm (class=ocf provider=pacemaker type=controld) Operations: monitor interval=60s (dlm-monitor-interval-60s) start interval=0s timeout=90s (dlm-start-interval-0s) stop interval=0s timeout=100s (dlm-stop-interval-0s) Clone: WebFS-clone Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=gfs2 Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) - + Stonith Devices: Resource: fence_dev (class=stonith type=some_fence_agent) Attributes: pcmk_delay_base=pcmk-1:5s;pcmk-2:0s pcmk_host_map=pcmk-1:almalinux9-1;pcmk-2:almalinux9-2 Operations: monitor interval=60s (fence_dev-monitor-interval-60s) Fencing Levels: - + Location Constraints: Resource: WebSite Enabled on: Node: pcmk-2 (score:50) (id:location-WebSite-pcmk-2-50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) (id:order-ClusterIP-WebSite-mandatory) promote WebData-clone then start WebFS-clone (kind:Mandatory) (id:order-WebData-clone-WebFS-mandatory) start WebFS-clone then start WebSite (kind:Mandatory) (id:order-WebFS-WebSite-mandatory) start dlm-clone then start WebFS-clone (kind:Mandatory) (id:order-dlm-clone-WebFS-mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) (id:colocation-WebSite-ClusterIP-INFINITY) WebFS-clone with WebData-clone (score:INFINITY) (rsc-role:Started) (with-rsc-role:Promoted) (id:colocation-WebFS-WebData-clone-INFINITY) WebSite with WebFS-clone (score:INFINITY) (id:colocation-WebSite-WebFS-INFINITY) WebFS-clone with dlm-clone (score:INFINITY) (id:colocation-WebFS-dlm-clone-INFINITY) Ticket Constraints: - + Alerts: No alerts defined - + Resources Defaults: Meta Attrs: build-resource-defaults resource-stickiness=100 Operations Defaults: Meta Attrs: op_defaults-meta_attributes timeout=240s - + Cluster Properties: cluster-infrastructure: corosync cluster-name: mycluster dc-version: 2.1.2-4.el9-ada5c3b36e2 have-watchdog: false last-lrm-refresh: 1658896047 no-quorum-policy: freeze stonith-enabled: true - + Tags: No tags defined - + Quorum: Options: Node List ######### .. code-block:: console [root@pcmk-1 ~]# pcs status nodes Pacemaker Nodes: Online: pcmk-1 pcmk-2 Standby: Standby with resource(s) running: Maintenance: Offline: Pacemaker Remote Nodes: Online: Standby: Standby with resource(s) running: Maintenance: Offline: Cluster Options ############### .. code-block:: console [root@pcmk-1 ~]# pcs property Cluster Properties: cluster-infrastructure: corosync cluster-name: mycluster dc-version: 2.1.2-4.el9-ada5c3b36e2 have-watchdog: false no-quorum-policy: freeze stonith-enabled: true The output shows cluster-wide configuration options, as well as some baseline- level state information. The output includes: * ``cluster-infrastructure`` - the cluster communications layer in use * ``cluster-name`` - the cluster name chosen by the administrator when the cluster was created * ``dc-version`` - the version (including upstream source-code hash) of ``pacemaker`` used on the Designated Controller, which is the node elected to determine what actions are needed when events occur * ``have-watchdog`` - whether watchdog integration is enabled; set automatically when SBD is enabled * ``stonith-enabled`` - whether nodes may be fenced as part of recovery .. NOTE:: This command is equivalent to ``pcs property config``. Resources ######### Default Options _______________ .. code-block:: console [root@pcmk-1 ~]# pcs resource defaults Meta Attrs: build-resource-defaults resource-stickiness=100 This shows cluster option defaults that apply to every resource that does not explicitly set the option itself. Above: * ``resource-stickiness`` - Specify how strongly a resource prefers to remain on its current node. Alternatively, you can view this as the level of aversion to moving healthy resources to other machines. Fencing _______ .. code-block:: console [root@pcmk-1 ~]# pcs stonith status * fence_dev (stonith:some_fence_agent): Started pcmk-1 [root@pcmk-1 ~]# pcs stonith config Resource: fence_dev (class=stonith type=some_fence_agent) Attributes: pcmk_delay_base=pcmk-1:5s;pcmk-2:0s pcmk_host_map=pcmk-1:almalinux9-1;pcmk-2:almalinux9-2 Operations: monitor interval=60s (fence_dev-monitor-interval-60s) Service Address _______________ Users of the services provided by the cluster require an unchanging address with which to access it. .. code-block:: console [root@pcmk-1 ~]# pcs resource config ClusterIP Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) DRBD - Shared Storage _____________________ Here, we define the DRBD service and specify which DRBD resource (from ``/etc/drbd.d/\*.res``) it should manage. We make it a promotable clone resource and, in order to have an active/active setup, allow both instances to be promoted at the same time. We also set the notify option so that the cluster will tell the ``drbd`` agent when its peer changes state. .. code-block:: console [root@pcmk-1 ~]# pcs resource config WebData-clone Clone: WebData-clone Meta Attrs: clone-max=2 clone-node-max=1 notify=true promotable=true promoted-max=2 promoted-node-max=1 Resource: WebData (class=ocf provider=linbit type=drbd) Attributes: drbd_resource=wwwdata Operations: demote interval=0s timeout=90 (WebData-demote-interval-0s) monitor interval=29s role=Promoted (WebData-monitor-interval-29s) monitor interval=31s role=Unpromoted (WebData-monitor-interval-31s) notify interval=0s timeout=90 (WebData-notify-interval-0s) promote interval=0s timeout=90 (WebData-promote-interval-0s) reload interval=0s timeout=30 (WebData-reload-interval-0s) start interval=0s timeout=240 (WebData-start-interval-0s) stop interval=0s timeout=100 (WebData-stop-interval-0s) [root@pcmk-1 ~]# pcs constraint ref WebData-clone Resource: WebData-clone colocation-WebFS-WebData-clone-INFINITY order-WebData-clone-WebFS-mandatory Cluster Filesystem __________________ The cluster filesystem ensures that files are read and written correctly. We need to specify the block device (provided by DRBD), where we want it mounted and that we are using GFS2. Again, it is a clone because it is intended to be active on both nodes. The additional constraints ensure that it can only be started on nodes with active DLM and DRBD instances. .. code-block:: console [root@pcmk-1 ~]# pcs resource config WebFS-clone Clone: WebFS-clone Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=gfs2 Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) [root@pcmk-1 ~]# pcs constraint ref WebFS-clone Resource: WebFS-clone colocation-WebFS-WebData-clone-INFINITY colocation-WebSite-WebFS-INFINITY colocation-WebFS-dlm-clone-INFINITY order-WebData-clone-WebFS-mandatory order-WebFS-WebSite-mandatory order-dlm-clone-WebFS-mandatory Apache ______ Lastly, we have the actual service, Apache. We need only tell the cluster where to find its main configuration file and restrict it to running on a node that has the required filesystem mounted and the IP address active. .. code-block:: console [root@pcmk-1 ~]# pcs resource config WebSite Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) [root@pcmk-1 ~]# pcs constraint ref WebSite Resource: WebSite colocation-WebSite-ClusterIP-INFINITY colocation-WebSite-WebFS-INFINITY location-WebSite-pcmk-2-50 order-ClusterIP-WebSite-mandatory order-WebFS-WebSite-mandatory diff --git a/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst b/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst index 437b5f8556..5cdbe2f64c 100644 --- a/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst +++ b/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst @@ -1,313 +1,313 @@ Set up a Cluster ---------------- Simplify Administration With a Cluster Shell ############################################ In the dark past, configuring Pacemaker required the administrator to read and write XML. In true UNIX style, there were also a number of different commands that specialized in different aspects of querying and updating the cluster. In addition, the various components of the cluster stack (Corosync, Pacemaker, etc.) had to be configured separately, with different configuration tools and formats. All of that has been greatly simplified with the creation of higher-level tools, whether command-line or GUIs, that hide all the mess underneath. Command-line cluster shells take all the individual aspects required for managing and configuring a cluster, and pack them into one simple-to-use command-line tool. They even allow you to queue up several changes at once and commit them all at once. Two popular command-line shells are ``pcs`` and ``crmsh``. Clusters from Scratch is based on ``pcs`` because it comes with |CFS_DISTRO|, but both have similar functionality. Choosing a shell or GUI is a matter of personal preference and what comes with (and perhaps is supported by) your choice of operating system. Install the Cluster Software ############################ Fire up a shell on both nodes and run the following to activate the High Availability repo. .. code-block:: console # dnf config-manager --set-enabled highavailability .. IMPORTANT:: This document will show commands that need to be executed on both nodes with a simple ``#`` prompt. Be sure to run them on each node individually. Now, we'll install ``pacemaker``, ``pcs``, and some other command-line tools that will make our lives easier: .. code-block:: console # dnf install -y pacemaker pcs psmisc policycoreutils-python3 - + .. NOTE:: This document uses ``pcs`` for cluster management. Other alternatives, such as ``crmsh``, are available, but their syntax will differ from the examples used here. Configure the Cluster Software ############################## .. index:: single: firewall Allow cluster services through firewall _______________________________________ On each node, allow cluster-related services through the local firewall: .. code-block:: console # firewall-cmd --permanent --add-service=high-availability success # firewall-cmd --reload success .. NOTE :: If you are using ``iptables`` directly, or some other firewall solution besides ``firewalld``, simply open the following ports, which can be used by various clustering components: TCP ports 2224, 3121, and 21064, and UDP port 5405. If you run into any problems during testing, you might want to disable the firewall and SELinux entirely until you have everything working. This may create significant security issues and should not be performed on machines that will be exposed to the outside world, but may be appropriate during development and testing on a protected host. To disable security measures: .. code-block:: console [root@pcmk-1 ~]# setenforce 0 [root@pcmk-1 ~]# sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config [root@pcmk-1 ~]# systemctl mask firewalld.service [root@pcmk-1 ~]# systemctl stop firewalld.service [root@pcmk-1 ~]# iptables --flush Enable ``pcs`` Daemon _____________________ Before the cluster can be configured, the ``pcs`` daemon must be started and enabled to start at boot time on each node. This daemon works with the ``pcs`` command-line interface to manage synchronizing the Corosync configuration across all nodes in the cluster, among other functions. Start and enable the daemon by issuing the following commands on each node: .. code-block:: console # systemctl start pcsd.service # systemctl enable pcsd.service Created symlink from /etc/systemd/system/multi-user.target.wants/pcsd.service to /usr/lib/systemd/system/pcsd.service. The installed packages will create an |CRM_DAEMON_USER| user with a disabled password. While this is fine for running ``pcs`` commands locally, the account needs a login password in order to perform such tasks as syncing the Corosync configuration, or starting and stopping the cluster on other nodes. This tutorial will make use of such commands, so now we will set a password for the |CRM_DAEMON_USER| user, using the same password on both nodes: .. code-block:: console # passwd hacluster Changing password for user hacluster. New password: Retype new password: passwd: all authentication tokens updated successfully. .. NOTE:: Alternatively, to script this process or set the password on a different machine from the one you're logged into, you can use the ``--stdin`` option for ``passwd``: .. code-block:: console [root@pcmk-1 ~]# ssh pcmk-2 -- 'echo mysupersecretpassword | passwd --stdin hacluster' Configure Corosync __________________ On either node, use ``pcs host auth`` to authenticate as the ``hacluster`` user: .. code-block:: console [root@pcmk-1 ~]# pcs host auth pcmk-1 pcmk-2 Username: hacluster Password: pcmk-2: Authorized pcmk-1: Authorized Next, use ``pcs cluster setup`` on the same node to generate and synchronize the Corosync configuration: .. code-block:: console [root@pcmk-1 ~]# pcs cluster setup mycluster pcmk-1 pcmk-2 No addresses specified for host 'pcmk-1', using 'pcmk-1' No addresses specified for host 'pcmk-2', using 'pcmk-2' Destroying cluster on hosts: 'pcmk-1', 'pcmk-2'... pcmk-2: Successfully destroyed cluster pcmk-1: Successfully destroyed cluster Requesting remove 'pcsd settings' from 'pcmk-1', 'pcmk-2' pcmk-1: successful removal of the file 'pcsd settings' pcmk-2: successful removal of the file 'pcsd settings' Sending 'corosync authkey', 'pacemaker authkey' to 'pcmk-1', 'pcmk-2' pcmk-1: successful distribution of the file 'corosync authkey' pcmk-1: successful distribution of the file 'pacemaker authkey' pcmk-2: successful distribution of the file 'corosync authkey' pcmk-2: successful distribution of the file 'pacemaker authkey' Sending 'corosync.conf' to 'pcmk-1', 'pcmk-2' pcmk-1: successful distribution of the file 'corosync.conf' pcmk-2: successful distribution of the file 'corosync.conf' Cluster has been successfully set up. .. NOTE:: If you'd like, you can specify an ``addr`` option for each node in the ``pcs cluster setup`` command. This will create an explicit name-to-address mapping for each node in ``/etc/corosync/corosync.conf``, eliminating the need for hostname resolution via DNS, ``/etc/hosts``, and the like. .. code-block:: console [root@pcmk-1 ~]# pcs cluster setup mycluster \ pcmk-1 addr=192.168.122.101 pcmk-2 addr=192.168.122.102 If you received an authorization error for either of those commands, make sure you configured the ``hacluster`` user account on each node with the same password. The final ``corosync.conf`` configuration on each node should look something like the sample in :ref:`sample-corosync-configuration`. Explore pcs ########### Start by taking some time to familiarize yourself with what ``pcs`` can do. .. code-block:: console [root@pcmk-1 ~]# pcs - + Usage: pcs [-f file] [-h] [commands]... Control and configure pacemaker and corosync. - + Options: -h, --help Display usage and exit. -f file Perform actions on file instead of active CIB. Commands supporting the option use the initial state of the specified file as their input and then overwrite the file with the state reflecting the requested operation(s). A few commands only use the specified file in read-only mode since their effect is not a CIB modification. --debug Print all network traffic and external commands run. --version Print pcs version information. List pcs capabilities if --full is specified. --request-timeout Timeout for each outgoing request to another node in seconds. Default is 60s. --force Override checks and errors, the exact behavior depends on the command. WARNING: Using the --force option is strongly discouraged unless you know what you are doing. Commands: cluster Configure cluster options and nodes. resource Manage cluster resources. stonith Manage fence devices. constraint Manage resource constraints. property Manage pacemaker properties. acl Manage pacemaker access control lists. qdevice Manage quorum device provider on the local host. quorum Manage cluster quorum settings. booth Manage booth (cluster ticket manager). status View cluster status. config View and manage cluster configuration. pcsd Manage pcs daemon. host Manage hosts known to pcs/pcsd. node Manage cluster nodes. alert Manage pacemaker alerts. client Manage pcsd client configuration. dr Manage disaster recovery configuration. tag Manage pacemaker tags. As you can see, the different aspects of cluster management are separated into categories. To discover the functionality available in each of these categories, one can issue the command ``pcs help``. Below is an example of all the options available under the status category. .. code-block:: console [root@pcmk-1 ~]# pcs status help Usage: pcs status [commands]... View current cluster and resource status Commands: [status] [--full] [--hide-inactive] View all information about the cluster and resources (--full provides more details, --hide-inactive hides inactive resources). resources [] [node=] [--hide-inactive] Show status of all currently configured resources. If --hide-inactive is specified, only show active resources. If a resource or tag id is specified, only show status of the specified resource or resources in the specified tag. If node is specified, only show status of resources configured for the specified node. cluster View current cluster status. corosync View current membership information as seen by corosync. quorum View current quorum status. qdevice [--full] [] Show runtime status of specified model of quorum device provider. Using --full will give more detailed output. If is specified, only information about the specified cluster will be displayed. booth Print current status of booth on the local node. nodes [corosync | both | config] View current status of nodes from pacemaker. If 'corosync' is specified, view current status of nodes from corosync instead. If 'both' is specified, view current status of nodes from both corosync & pacemaker. If 'config' is specified, print nodes from corosync & pacemaker configuration. pcsd []... Show current status of pcsd on nodes specified, or on all nodes configured in the local cluster if no nodes are specified. xml View xml version of status (output from crm_mon -r -1 -X). Additionally, if you are interested in the version and supported cluster stack(s) available with your Pacemaker installation, run: .. code-block:: console [root@pcmk-1 ~]# pacemakerd --features Pacemaker 2.1.2-4.el9 (Build: ada5c3b36e2) Supporting v3.13.0: agent-manpages cibsecrets corosync-ge-2 default-concurrent-fencing default-resource-stickiness default-sbd-sync generated-manpages monotonic nagios ncurses remote systemd diff --git a/doc/sphinx/Clusters_from_Scratch/index.rst b/doc/sphinx/Clusters_from_Scratch/index.rst index 74fe2503af..3477ccd538 100644 --- a/doc/sphinx/Clusters_from_Scratch/index.rst +++ b/doc/sphinx/Clusters_from_Scratch/index.rst @@ -1,49 +1,40 @@ Clusters from Scratch ===================== *Step-by-Step Instructions for Building Your First High-Availability Cluster* -Abstract --------- This document provides a step-by-step guide to building a simple high-availability cluster using Pacemaker. The example cluster will use: * |CFS_DISTRO| |CFS_DISTRO_VER| as the host operating system * Corosync to provide messaging and membership services * Pacemaker 2 as the cluster resource manager * DRBD as a cost-effective alternative to shared storage * GFS2 as the cluster filesystem (in active/active mode) Given the graphical nature of the install process, a number of screenshots are included. However, the guide is primarily composed of commands, the reasons for executing them, and their expected outputs. -Table of Contents ------------------ - .. toctree:: :maxdepth: 3 :numbered: intro installation cluster-setup verification fencing active-passive apache shared-storage active-active ap-configuration ap-corosync-conf ap-reading - -Index ------ - -* :ref:`genindex` -* :ref:`search` + :ref:`genindex` + :ref:`search` diff --git a/doc/sphinx/Clusters_from_Scratch/installation.rst b/doc/sphinx/Clusters_from_Scratch/installation.rst index e7f9e2d8d5..02f5be975f 100644 --- a/doc/sphinx/Clusters_from_Scratch/installation.rst +++ b/doc/sphinx/Clusters_from_Scratch/installation.rst @@ -1,466 +1,466 @@ Installation ------------ Install |CFS_DISTRO| |CFS_DISTRO_VER| ################################################################################################ Boot the Install Image ______________________ -Download the latest |CFS_DISTRO| |CFS_DISTRO_VER| DVD ISO by navigating to +Download the latest |CFS_DISTRO| |CFS_DISTRO_VER| DVD ISO by navigating to the |CFS_DISTRO| `mirrors list `_, selecting the latest 9.x version for your machine's architecture, selecting a download mirror that's close to you, and finally selecting the latest .iso file that has “dvd” in its name. Use the image to boot a virtual machine, or burn it to a DVD or USB drive and boot a physical server from that. After starting the installation, select your language and keyboard layout at the welcome screen. .. figure:: images/WelcomeToAlmaLinux.png :align: center :alt: Installation Welcome Screen |CFS_DISTRO| |CFS_DISTRO_VER| Installation Welcome Screen Installation Options ____________________ At this point, you get a chance to tweak the default installation options. .. figure:: images/InstallationSummary.png :align: center :alt: Installation Summary Screen |CFS_DISTRO| |CFS_DISTRO_VER| Installation Summary Screen Click on the **SOFTWARE SELECTION** section (try saying that 10 times quickly). The default environment, **Server with GUI**, does have add-ons with much of the software we need, but we will change the environment to a **Minimal Install** here, so that we can see exactly what software is required later, and press **Done**. .. figure:: images/SoftwareSelection.png :align: center :alt: Software Selection Screen |CFS_DISTRO| |CFS_DISTRO_VER| Software Selection Screen Configure Network _________________ In the **NETWORK & HOST NAME** section: - Edit **Host Name:** as desired. For this example, we will enter ``pcmk-1.localdomain`` and then press **Apply**. - Select your network device, press **Configure...**, select the **IPv4 Settings** tab, and select **Manual** from the **Method** dropdown menu. Then assign the machine a fixed IP address with an appropriate netmask, gateway, and DNS server. For this example, we'll use ``192.168.122.101`` for the address, ``24`` for the netmask, and ``192.168.122.1`` for the gateway and DNS server. - Press **Save**. - Flip the switch to turn your network device on (if it is not on already), and press **Done**. .. figure:: images/NetworkAndHostName.png :align: center :alt: Editing network settings |CFS_DISTRO| |CFS_DISTRO_VER| Network Interface Screen .. IMPORTANT:: Do not accept the default network settings. Cluster machines should never obtain an IP address via DHCP, because DHCP's periodic address renewal will interfere with Corosync. Configure Disk ______________ By default, the installer's automatic partitioning will use LVM (which allows us to dynamically change the amount of space allocated to a given partition). However, it allocates all free space to the ``/`` (a.k.a. **root**) partition, which cannot be reduced in size later (dynamic increases are fine). In order to follow the DRBD and GFS2 portions of this guide, we need to reserve space on each machine for a replicated volume. Enter the **INSTALLATION DESTINATION** section and select the disk where you want to install the OS. Then under **Storage Configuration**, select **Custom** and press **Done**. .. figure:: images/ManualPartitioning.png :align: center :alt: Installation Destination Screen |CFS_DISTRO| |CFS_DISTRO_VER| Installation Destination Screen On the **MANUAL PARTITIONING** screen that comes next, click the option to create mountpoints automatically. Select the ``/`` mountpoint and reduce the **Desired Capacity** down to 4 GiB or so. (The installer will not allow you to proceed if the ``/`` filesystem is too small to install all required packages.) .. figure:: images/ManualPartitioning.png :align: center :alt: Manual Partitioning Screen |CFS_DISTRO| |CFS_DISTRO_VER| Manual Partitioning Screen Then select **Modify…** next to the volume group name. In the **CONFIGURE VOLUME GROUP** dialog box that appears, change the **Size policy** to **As large as possible**, to make the reclaimed space available inside the LVM volume group. We’ll add the additional volume later. .. figure:: images/ConfigureVolumeGroup.png :align: center :alt: Configure Volume Group Dialog |CFS_DISTRO| |CFS_DISTRO_VER| Configure Volume Group Dialog Press **Done**. Finally, in the **SUMMARY OF CHANGES** dialog box, press **Accept Changes**. .. figure:: images/SummaryOfChanges.png :align: center :alt: Summary of Changes Dialog |CFS_DISTRO| |CFS_DISTRO_VER| Summary of Changes Dialog Configure Time Synchronization ______________________________ It is highly recommended to enable NTP on your cluster nodes. Doing so ensures all nodes agree on the current time and makes reading log files significantly easier. |CFS_DISTRO| will enable NTP automatically. If you want to change any time-related settings (such as time zone or NTP server), you can do this in the **TIME & DATE** section. In this example, we configure the time zone as UTC (Coordinated Universal Time). .. figure:: images/TimeAndDate.png :align: center :alt: Time & Date Screen |CFS_DISTRO| |CFS_DISTRO_VER| Time & Date Screen Root Password ______________________________ In order to continue to the next step, a **Root Password** must be set. Be sure to check the box marked **Allow root SSH login with password**. .. figure:: images/RootPassword.png :align: center :alt: Root Password Screen |CFS_DISTRO| |CFS_DISTRO_VER| Root Password Screen Press **Done**. (Depending on the password you chose, you may need to do so twice.) Finish Install ______________ Select **Begin Installation**. Once it completes, **Reboot System** as instructed. After the node reboots, you'll see a login prompt on the console. Login using ``root`` and the password you created earlier. .. figure:: images/ConsolePrompt.png :align: center :alt: Console Prompt |CFS_DISTRO| |CFS_DISTRO_VER| Console Prompt .. NOTE:: From here on, we're going to be working exclusively from the terminal. Configure the OS ################ Verify Networking _________________ Ensure that the machine has the static IP address you configured earlier. .. code-block:: console [root@pcmk-1 ~]# ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever - inet6 ::1/128 scope host + inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp1s0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:32:cf:a9 brd ff:ff:ff:ff:ff:ff inet 192.168.122.101/24 brd 192.168.122.255 scope global noprefixroute enp1s0 valid_lft forever preferred_lft forever - inet6 fe80::c3e1:3ba:959:fa96/64 scope link noprefixroute + inet6 fe80::c3e1:3ba:959:fa96/64 scope link noprefixroute valid_lft forever preferred_lft forever .. NOTE:: If you ever need to change the node's IP address from the command line, follow these instructions, replacing ``${conn}`` with the name of your network connection. You can find the list of all network connection names by running ``nmcli con show``; you can get details for each connection by running ``nmcli con show ${conn}``. .. code-block:: console [root@pcmk-1 ~]# nmcli con mod ${conn} ipv4.addresses "${new_address}" [root@pcmk-1 ~]# nmcli con up ${conn} Next, ensure that the routes are as expected: .. code-block:: console [root@pcmk-1 ~]# ip route - default via 192.168.122.1 dev enp1s0 proto static metric 100 + default via 192.168.122.1 dev enp1s0 proto static metric 100 192.168.122.0/24 dev enp1s0 proto kernel scope link src 192.168.122.101 metric 100 If there is no line beginning with ``default via``, then use ``nmcli`` to add a gateway: .. code-block:: console [root@pcmk-1 ~]# nmcli con mod ${conn} ipv4.gateway "${new_gateway_addr}" [root@pcmk-1 ~]# nmcli con up ${conn} Now, check for connectivity to the outside world. Start small by testing whether we can reach the gateway we configured. .. code-block:: console [root@pcmk-1 ~]# ping -c 1 192.168.122.1 PING 192.168.122.1 (192.168.122.1) 56(84) bytes of data. 64 bytes from 192.168.122.1: icmp_seq=1 ttl=64 time=0.492 ms - + --- 192.168.122.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.492/0.492/0.492/0.000 ms Now try something external; choose a location you know should be available. .. code-block:: console [root@pcmk-1 ~]# ping -c 1 www.clusterlabs.org PING mx1.clusterlabs.org (95.217.104.78) 56(84) bytes of data. 64 bytes from mx1.clusterlabs.org (95.217.104.78): icmp_seq=1 ttl=54 time=134 ms - + --- mx1.clusterlabs.org ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 133.987/133.987/133.987/0.000 ms Login Remotely ______________ The console isn't a very friendly place to work from, so we will now switch to accessing the machine remotely via SSH where we can use copy and paste, etc. From another host, check whether we can see the new host at all: .. code-block:: console [gchin@gchin ~]$ ping -c 1 192.168.122.101 PING 192.168.122.101 (192.168.122.101) 56(84) bytes of data. 64 bytes from 192.168.122.101: icmp_seq=1 ttl=64 time=0.344 ms - + --- 192.168.122.101 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.344/0.344/0.344/0.000 ms - + Next, login as ``root`` via SSH. .. code-block:: console [gchin@gchin ~]$ ssh root@192.168.122.101 The authenticity of host '192.168.122.101 (192.168.122.101)' can't be established. ECDSA key fingerprint is SHA256:NBvcRrPDLIt39Rf0Tz4/f2Rd/FA5wUiDOd9bZ9QWWjo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.122.101' (ECDSA) to the list of known hosts. - root@192.168.122.101's password: + root@192.168.122.101's password: Last login: Tue Jan 10 20:46:30 2021 - [root@pcmk-1 ~]# + [root@pcmk-1 ~]# Apply Updates _____________ Apply any package updates released since your installation image was created: .. code-block:: console [root@pcmk-1 ~]# dnf update -y .. index:: single: node; short name Use Short Node Names ____________________ During installation, we filled in the machine's fully qualified domain name (FQDN), which can be rather long when it appears in cluster logs and status output. See for yourself how the machine identifies itself: .. code-block:: console [root@pcmk-1 ~]# uname -n pcmk-1.localdomain We can use the ``hostnamectl`` tool to strip off the domain name: .. code-block:: console [root@pcmk-1 ~]# hostnamectl set-hostname $(uname -n | sed s/\\..*//) Now, check that the machine is using the correct name: .. code-block:: console [root@pcmk-1 ~]# uname -n pcmk-1 You may want to reboot to ensure all updates take effect. Repeat for Second Node ###################### Repeat the installation steps so far, so that you have two nodes ready to have the cluster software installed. For the purposes of this document, the additional node is called ``pcmk-2`` with address ``192.168.122.102``. Configure Communication Between Nodes ##################################### Configure Host Name Resolution ______________________________ Confirm that you can communicate between the two new nodes: .. code-block:: console [root@pcmk-1 ~]# ping -c 3 192.168.122.102 PING 192.168.122.102 (192.168.122.102) 56(84) bytes of data. 64 bytes from 192.168.122.102: icmp_seq=1 ttl=64 time=1.22 ms 64 bytes from 192.168.122.102: icmp_seq=2 ttl=64 time=0.795 ms 64 bytes from 192.168.122.102: icmp_seq=3 ttl=64 time=0.751 ms - + --- 192.168.122.102 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2054ms rtt min/avg/max/mdev = 0.751/0.923/1.224/0.214 ms Now we need to make sure we can communicate with the machines by their name. Add entries for the machines to ``/etc/hosts`` on both nodes. You can add entries for the machines to your DNS server if you have one, but this can create a single-point-of-failure (SPOF) if the DNS server goes down [#]_. If you add entries to ``/etc/hosts``, they should look something like the following: .. code-block:: console [root@pcmk-1 ~]# grep pcmk /etc/hosts 192.168.122.101 pcmk-1.localdomain pcmk-1 192.168.122.102 pcmk-2.localdomain pcmk-2 We can now verify the setup by again using ``ping``: .. code-block:: console [root@pcmk-1 ~]# ping -c 3 pcmk-2 PING pcmk-2.localdomain (192.168.122.102) 56(84) bytes of data. 64 bytes from pcmk-2.localdomain (192.168.122.102): icmp_seq=1 ttl=64 time=0.295 ms 64 bytes from pcmk-2.localdomain (192.168.122.102): icmp_seq=2 ttl=64 time=0.616 ms 64 bytes from pcmk-2.localdomain (192.168.122.102): icmp_seq=3 ttl=64 time=0.809 ms - + --- pcmk-2.localdomain ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2043ms rtt min/avg/max/mdev = 0.295/0.573/0.809/0.212 ms .. index:: SSH Configure SSH _____________ SSH is a convenient and secure way to copy files and perform commands remotely. For the purposes of this guide, we will create a key without a password (using the ``-N`` option) so that we can perform remote actions without being prompted. .. WARNING:: Unprotected SSH keys (those without a password) are not recommended for servers exposed to the outside world. We use them here only to simplify the demo. Create a new key and allow anyone with that key to log in: .. index:: single: SSH; key .. topic:: Creating and Activating a New SSH Key .. code-block:: console [root@pcmk-1 ~]# ssh-keygen -f ~/.ssh/id_rsa -N "" Generating public/private rsa key pair. Your identification has been saved in /root/.ssh/id_rsa Your public key has been saved in /root/.ssh/id_rsa.pub The key fingerprint is: SHA256:h5AFPmXsGU4woOxRLYHW9lnU2wIQVOxpSRrsXbo/AX8 root@pcmk-1 The key's randomart image is: +---[RSA 3072]----+ | o+*BX*. | | .oo+.+*O o | | .+. +=% O o | | . . =o%.o . | | . .S+.. | | ..o E | | . o | | o | | . | +----[SHA256]-----+ [root@pcmk-1 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys Install the key on the other node: .. code-block:: console [root@pcmk-1 ~]# ssh-copy-id pcmk-2 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host 'pcmk-2 (192.168.122.102)' can't be established. ED25519 key fingerprint is SHA256:QkJnJ3fmszY7kAuuZ7wxUC5CC+eQThSCF13XYWnZJPo. This host key is known by the following other names/addresses: ~/.ssh/known_hosts:1: 192.168.122.102 Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys - root@pcmk-2's password: - + root@pcmk-2's password: + Number of key(s) added: 1 - + Now try logging into the machine, with: "ssh 'pcmk-2'" and check to make sure that only the key(s) you wanted were added. Test that you can now run commands remotely, without being prompted: .. code-block:: console [root@pcmk-1 ~]# ssh pcmk-2 -- uname -n pcmk-2 Finally, repeat this same process on the other node. For convenience, you can also generate an SSH key on your administrative machine and use ``ssh-copy-id`` to copy it to both cluster nodes. .. [#] You can also avoid this SPOF by specifying an ``addr`` option for each node when creating the cluster. We will discuss this in a later section. diff --git a/doc/sphinx/Clusters_from_Scratch/shared-storage.rst b/doc/sphinx/Clusters_from_Scratch/shared-storage.rst index dea3e58027..898e921b0c 100644 --- a/doc/sphinx/Clusters_from_Scratch/shared-storage.rst +++ b/doc/sphinx/Clusters_from_Scratch/shared-storage.rst @@ -1,645 +1,645 @@ .. index:: pair: storage; DRBD Replicate Storage Using DRBD ---------------------------- Even if you're serving up static websites, having to manually synchronize the contents of that website to all the machines in the cluster is not ideal. For dynamic websites, such as a wiki, it's not even an option. Not everyone can afford network-attached storage, but somehow the data needs to be kept in sync. Enter DRBD, which can be thought of as network-based RAID-1 [#]_. Install the DRBD Packages ######################### DRBD itself is included in the upstream kernel [#]_, but we do need some utilities to use it effectively. |CFS_DISTRO| does not ship these utilities, so we need to enable a third-party repository to get them. Supported packages for many OSes are available from DRBD's maker `LINBIT `_, but here we'll use the free `ELRepo `_ repository. On both nodes, import the ELRepo package signing key, and enable the repository: .. code-block:: console [root@pcmk-1 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org [root@pcmk-1 ~]# dnf install -y https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm Now, we can install the DRBD kernel module and utilities: .. code-block:: console # dnf install -y kmod-drbd9x drbd9x-utils DRBD will not be able to run under the default SELinux security policies. If you are familiar with SELinux, you can modify the policies in a more fine-grained manner, but here we will simply exempt DRBD processes from SELinux control: .. code-block:: console # dnf install -y policycoreutils-python-utils # semanage permissive -a drbd_t We will configure DRBD to use port 7789, so allow that port from each host to the other: .. code-block:: console [root@pcmk-1 ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" \ source address="192.168.122.102" port port="7789" protocol="tcp" accept' success [root@pcmk-1 ~]# firewall-cmd --reload success .. code-block:: console [root@pcmk-2 ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" \ source address="192.168.122.101" port port="7789" protocol="tcp" accept' success [root@pcmk-2 ~]# firewall-cmd --reload success .. NOTE:: In this example, we have only two nodes, and all network traffic is on the same LAN. In production, it is recommended to use a dedicated, isolated network for cluster-related traffic, so the firewall configuration would likely be different; one approach would be to add the dedicated network interfaces to the trusted zone. .. NOTE:: If the ``firewall-cmd --add-rich-rule`` command fails with ``Error: INVALID_RULE: unknown element`` ensure that there is no space at the beginning of the second line of the command. Allocate a Disk Volume for DRBD ############################### DRBD will need its own block device on each node. This can be a physical disk partition or logical volume, of whatever size you need for your data. For this document, we will use a 512MiB logical volume, which is more than sufficient for a single HTML file and (later) GFS2 metadata. .. code-block:: console [root@pcmk-1 ~]# vgs - VG #PV #LV #SN Attr VSize VFree + VG #PV #LV #SN Attr VSize VFree almalinux_pcmk-1 1 2 0 wz--n- <19.00g <13.00g [root@pcmk-1 ~]# lvcreate --name drbd-demo --size 512M almalinux_pcmk-1 Logical volume "drbd-demo" created. [root@pcmk-1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert - drbd-demo almalinux_pcmk-1 -wi-a----- 512.00m - root almalinux_pcmk-1 -wi-ao---- 4.00g - swap almalinux_pcmk-1 -wi-ao---- 2.00g + drbd-demo almalinux_pcmk-1 -wi-a----- 512.00m + root almalinux_pcmk-1 -wi-ao---- 4.00g + swap almalinux_pcmk-1 -wi-ao---- 2.00g Repeat for the second node, making sure to use the same size: .. code-block:: console [root@pcmk-1 ~]# ssh pcmk-2 -- lvcreate --name drbd-demo --size 512M cs_pcmk-2 Logical volume "drbd-demo" created. Configure DRBD ############## There is no series of commands for building a DRBD configuration, so simply run this on both nodes to use this sample configuration: .. code-block:: console # cat </etc/drbd.d/wwwdata.res resource "wwwdata" { device minor 1; meta-disk internal; net { protocol C; allow-two-primaries yes; fencing resource-and-stonith; verify-alg sha1; } handlers { fence-peer "/usr/lib/drbd/crm-fence-peer.9.sh"; unfence-peer "/usr/lib/drbd/crm-unfence-peer.9.sh"; } on "pcmk-1" { disk "/dev/almalinux_pcmk-1/drbd-demo"; node-id 0; } on "pcmk-2" { disk "/dev/almalinux_pcmk-2/drbd-demo"; node-id 1; } connection { host "pcmk-1" address 192.168.122.101:7789; host "pcmk-2" address 192.168.122.102:7789; } } END .. IMPORTANT:: Edit the file to use the hostnames, IP addresses, and logical volume paths of your nodes if they differ from the ones used in this guide. .. NOTE:: Detailed information on the directives used in this configuration (and other alternatives) is available in the `DRBD User's Guide `_. The guide contains a wealth of information on such topics as core DRBD concepts, replication settings, network connection options, quorum, split- brain handling, administrative tasks, troubleshooting, and responding to disk or node failures, among others. The ``allow-two-primaries: yes`` option would not normally be used in an active/passive cluster. We are adding it here for the convenience of changing to an active/active cluster later. Initialize DRBD ############### With the configuration in place, we can now get DRBD running. These commands create the local metadata for the DRBD resource, ensure the DRBD kernel module is loaded, and bring up the DRBD resource. Run them on one node: .. code-block:: console [root@pcmk-1 ~]# drbdadm create-md wwwdata initializing activity log initializing bitmap (16 KB) to all zero Writing meta data... New drbd meta data block successfully created. success [root@pcmk-1 ~]# modprobe drbd [root@pcmk-1 ~]# drbdadm up wwwdata --== Thank you for participating in the global usage survey ==-- The server's response is: you are the 25212th user to install this version - + We can confirm DRBD's status on this node: - + .. code-block:: console [root@pcmk-1 ~]# drbdadm status wwwdata role:Secondary disk:Inconsistent pcmk-2 connection:Connecting Because we have not yet initialized the data, this node's data is marked as ``Inconsistent`` Because we have not yet initialized the second node, the ``pcmk-2`` connection is ``Connecting`` (waiting for connection). Now, repeat the above commands on the second node, starting with creating ``wwwdata.res``. After giving it time to connect, when we check the status of the first node, it shows: .. code-block:: console [root@pcmk-1 ~]# drbdadm status wwwdata role:Secondary disk:Inconsistent pcmk-2 role:Secondary peer-disk:Inconsistent You can see that ``pcmk-2 connection:Connecting`` longer appears in the output, meaning the two DRBD nodes are communicating properly, and both nodes are in ``Secondary`` role with ``Inconsistent`` data. To make the data consistent, we need to tell DRBD which node should be considered to have the correct data. In this case, since we are creating a new resource, both have garbage, so we'll just pick ``pcmk-1`` and run this command on it: .. code-block:: console [root@pcmk-1 ~]# drbdadm primary --force wwwdata .. NOTE:: If you are using a different version of DRBD, the required syntax may be different. See the documentation for your version for how to perform these commands. If we check the status immediately, we'll see something like this: .. code-block:: console [root@pcmk-1 ~]# drbdadm status wwwdata role:Primary disk:UpToDate pcmk-2 role:Secondary peer-disk:Inconsistent It will be quickly followed by this: .. code-block:: console [root@pcmk-1 ~]# drbdadm status wwwdata role:Primary disk:UpToDate pcmk-2 role:Secondary replication:SyncSource peer-disk:Inconsistent We can see that the first node has the ``Primary`` role, its partner node has the ``Secondary`` role, the first node's data is now considered ``UpToDate``, and the partner node's data is still ``Inconsistent``. After a while, the sync should finish, and you'll see something like: .. code-block:: console [root@pcmk-1 ~]# drbdadm status wwwdata role:Primary disk:UpToDate pcmk-1 role:Secondary peer-disk:UpToDate [root@pcmk-2 ~]# drbdadm status wwwdata role:Secondary disk:UpToDate pcmk-1 role:Primary peer-disk:UpToDate Both sets of data are now ``UpToDate``, and we can proceed to creating and populating a filesystem for our ``WebSite`` resource's documents. Populate the DRBD Disk ###################### On the node with the primary role (``pcmk-1`` in this example), create a filesystem on the DRBD device: .. code-block:: console [root@pcmk-1 ~]# mkfs.xfs /dev/drbd1 meta-data=/dev/drbd1 isize=512 agcount=4, agsize=32765 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=131059, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=1368, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 Discarding blocks...Done. .. NOTE:: In this example, we create an xfs filesystem with no special options. In a production environment, you should choose a filesystem type and options that are suitable for your application. Mount the newly created filesystem, populate it with our web document, give it the same SELinux policy as the web document root, then unmount it (the cluster will handle mounting and unmounting it later): .. code-block:: console [root@pcmk-1 ~]# mount /dev/drbd1 /mnt [root@pcmk-1 ~]# cat <<-END >/mnt/index.html My Test Site - DRBD END [root@pcmk-1 ~]# chcon -R --reference=/var/www/html /mnt [root@pcmk-1 ~]# umount /dev/drbd1 Configure the Cluster for the DRBD device ######################################### One handy feature ``pcs`` has is the ability to queue up several changes into a file and commit those changes all at once. To do this, start by populating the file with the current raw XML config from the CIB. .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib drbd_cfg Using ``pcs``'s ``-f`` option, make changes to the configuration saved in the ``drbd_cfg`` file. These changes will not be seen by the cluster until the ``drbd_cfg`` file is pushed into the live cluster's CIB later. Here, we create a cluster resource for the DRBD device, and an additional *clone* resource to allow the resource to run on both nodes at the same time. .. code-block:: console [root@pcmk-1 ~]# pcs -f drbd_cfg resource create WebData ocf:linbit:drbd \ drbd_resource=wwwdata op monitor interval=29s role=Promoted \ monitor interval=31s role=Unpromoted [root@pcmk-1 ~]# pcs -f drbd_cfg resource promotable WebData \ promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 \ notify=true [root@pcmk-1 ~]# pcs resource status * ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf::heartbeat:apache): Started pcmk-1 [root@pcmk-1 ~]# pcs resource config Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) After you are satisfied with all the changes, you can commit them all at once by pushing the ``drbd_cfg`` file into the live CIB. .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib-push drbd_cfg --config CIB updated .. NOTE:: All the updates above can be done in one shot as follows: .. code-block:: console [root@pcmk-1 ~]# pcs resource create WebData ocf:linbit:drbd \ drbd_resource=wwwdata op monitor interval=29s role=Promoted \ monitor interval=31s role=Unpromoted \ promotable promoted-max=1 promoted-node-max=1 clone-max=2 \ clone-node-max=1 notify=true Let's see what the cluster did with the new configuration: .. code-block:: console [root@pcmk-1 ~]# pcs resource status * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-2 * WebSite (ocf:heartbeat:apache): Started pcmk-2 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Unpromoted: [ pcmk-2 ] [root@pcmk-1 ~]# pcs resource config Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) Clone: WebData-clone Meta Attrs: clone-max=2 clone-node-max=1 notify=true promotable=true promoted-max=1 promoted-node-max=1 Resource: WebData (class=ocf provider=linbit type=drbd) Attributes: drbd_resource=wwwdata Operations: demote interval=0s timeout=90 (WebData-demote-interval-0s) monitor interval=29s role=Promoted (WebData-monitor-interval-29s) monitor interval=31s role=Unpromoted (WebData-monitor-interval-31s) notify interval=0s timeout=90 (WebData-notify-interval-0s) promote interval=0s timeout=90 (WebData-promote-interval-0s) reload interval=0s timeout=30 (WebData-reload-interval-0s) start interval=0s timeout=240 (WebData-start-interval-0s) stop interval=0s timeout=100 (WebData-stop-interval-0s) We can see that ``WebData-clone`` (our DRBD device) is running as ``Promoted`` (DRBD's primary role) on ``pcmk-1`` and ``Unpromoted`` (DRBD's secondary role) on ``pcmk-2``. .. IMPORTANT:: The resource agent should load the DRBD module when needed if it's not already loaded. If that does not happen, configure your operating system to load the module at boot time. For |CFS_DISTRO| |CFS_DISTRO_VER|, you would run this on both nodes: .. code-block:: console # echo drbd >/etc/modules-load.d/drbd.conf Configure the Cluster for the Filesystem ######################################## Now that we have a working DRBD device, we need to mount its filesystem. In addition to defining the filesystem, we also need to tell the cluster where it can be located (only on the DRBD Primary) and when it is allowed to start (after the Primary was promoted). We are going to take a shortcut when creating the resource this time. Instead of explicitly saying we want the ``ocf:heartbeat:Filesystem`` script, we are only going to ask for ``Filesystem``. We can do this because we know there is only one resource script named ``Filesystem`` available to Pacemaker, and that ``pcs`` is smart enough to fill in the ``ocf:heartbeat:`` portion for us correctly in the configuration. If there were multiple ``Filesystem`` scripts from different OCF providers, we would need to specify the exact one we wanted. Once again, we will queue our changes to a file and then push the new configuration to the cluster as the final step. .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib fs_cfg [root@pcmk-1 ~]# pcs -f fs_cfg resource create WebFS Filesystem \ device="/dev/drbd1" directory="/var/www/html" fstype="xfs" Assumed agent name 'ocf:heartbeat:Filesystem' (deduced from 'Filesystem') [root@pcmk-1 ~]# pcs -f fs_cfg constraint colocation add \ WebFS with Promoted WebData-clone [root@pcmk-1 ~]# pcs -f fs_cfg constraint order \ promote WebData-clone then start WebFS Adding WebData-clone WebFS (kind: Mandatory) (Options: first-action=promote then-action=start) We also need to tell the cluster that Apache needs to run on the same machine as the filesystem and that it must be active before Apache can start. .. code-block:: console [root@pcmk-1 ~]# pcs -f fs_cfg constraint colocation add WebSite with WebFS [root@pcmk-1 ~]# pcs -f fs_cfg constraint order WebFS then WebSite Adding WebFS WebSite (kind: Mandatory) (Options: first-action=start then-action=start) Review the updated configuration. .. code-block:: console [root@pcmk-1 ~]# pcs -f fs_cfg constraint Location Constraints: Resource: WebSite Enabled on: Node: pcmk-1 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebData-clone then start WebFS (kind:Mandatory) start WebFS then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) WebFS with WebData-clone (score:INFINITY) (rsc-role:Started) (with-rsc-role:Promoted) WebSite with WebFS (score:INFINITY) Ticket Constraints: After reviewing the new configuration, upload it and watch the cluster put it into effect. .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib-push fs_cfg --config CIB updated [root@pcmk-1 ~]# pcs resource status * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-2 * WebSite (ocf:heartbeat:apache): Started pcmk-2 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-2 ] * Unpromoted: [ pcmk-1 ] * WebFS (ocf:heartbeat:Filesystem): Started pcmk-2 [root@pcmk-1 ~]# pcs resource config Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2) Attributes: cidr_netmask=24 ip=192.168.122.120 Operations: monitor interval=30s (ClusterIP-monitor-interval-30s) start interval=0s timeout=20s (ClusterIP-start-interval-0s) stop interval=0s timeout=20s (ClusterIP-stop-interval-0s) Resource: WebSite (class=ocf provider=heartbeat type=apache) Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://localhost/server-status Operations: monitor interval=1min (WebSite-monitor-interval-1min) start interval=0s timeout=40s (WebSite-start-interval-0s) stop interval=0s timeout=60s (WebSite-stop-interval-0s) Clone: WebData-clone Meta Attrs: clone-max=2 clone-node-max=1 notify=true promotable=true promoted-max=1 promoted-node-max=1 Resource: WebData (class=ocf provider=linbit type=drbd) Attributes: drbd_resource=wwwdata Operations: demote interval=0s timeout=90 (WebData-demote-interval-0s) monitor interval=29s role=Promoted (WebData-monitor-interval-29s) monitor interval=31s role=Unpromoted (WebData-monitor-interval-31s) notify interval=0s timeout=90 (WebData-notify-interval-0s) promote interval=0s timeout=90 (WebData-promote-interval-0s) reload interval=0s timeout=30 (WebData-reload-interval-0s) start interval=0s timeout=240 (WebData-start-interval-0s) stop interval=0s timeout=100 (WebData-stop-interval-0s) Resource: WebFS (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/drbd1 directory=/var/www/html fstype=xfs Operations: monitor interval=20s timeout=40s (WebFS-monitor-interval-20s) start interval=0s timeout=60s (WebFS-start-interval-0s) stop interval=0s timeout=60s (WebFS-stop-interval-0s) Test Cluster Failover ##################### Previously, we used ``pcs cluster stop pcmk-2`` to stop all cluster services on ``pcmk-2``, failing over the cluster resources, but there is another way to safely simulate node failure. We can put the node into *standby mode*. Nodes in this state continue to run ``corosync`` and ``pacemaker`` but are not allowed to run resources. Any resources found active there will be moved elsewhere. This feature can be particularly useful when performing system administration tasks such as updating packages used by cluster resources. Put the active node into standby mode, and observe the cluster move all the resources to the other node. The node's status will change to indicate that it can no longer host resources, and eventually all the resources will move. .. code-block:: console [root@pcmk-1 ~]# pcs node standby pcmk-2 [root@pcmk-1 ~]# pcs status Cluster name: mycluster Cluster Summary: * Stack: corosync * Current DC: pcmk-1 (version 2.1.2-4.el9-ada5c3b36e2) - partition with quorum * Last updated: Wed Jul 27 05:28:01 2022 * Last change: Wed Jul 27 05:27:57 2022 by root via cibadmin on pcmk-1 * 2 nodes configured * 6 resource instances configured Node List: * Node pcmk-2: standby * Online: [ pcmk-1 ] Full List of Resources: * fence_dev (stonith:some_fence_agent): Started pcmk-1 * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Stopped: [ pcmk-2 ] * WebFS (ocf:heartbeat:Filesystem): Started pcmk-1 - + Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Once we've done everything we needed to on ``pcmk-2`` (in this case nothing, we just wanted to see the resources move), we can unstandby the node, making it eligible to host resources again. .. code-block:: console [root@pcmk-1 ~]# pcs node unstandby pcmk-2 [root@pcmk-1 ~]# pcs status Cluster name: mycluster Cluster Summary: * Stack: corosync * Current DC: pcmk-1 (version 2.1.2-4.el9-ada5c3b36e2) - partition with quorum * Last updated: Wed Jul 27 05:28:50 2022 * Last change: Wed Jul 27 05:28:47 2022 by root via cibadmin on pcmk-1 * 2 nodes configured * 6 resource instances configured Node List: * Online: [ pcmk-1 pcmk-2 ] Full List of Resources: * fence_dev (stonith:some_fence_agent): Started pcmk-1 * ClusterIP (ocf:heartbeat:IPaddr2): Started pcmk-1 * WebSite (ocf:heartbeat:apache): Started pcmk-1 * Clone Set: WebData-clone [WebData] (promotable): * Promoted: [ pcmk-1 ] * Unpromoted: [ pcmk-2 ] * WebFS (ocf:heartbeat:Filesystem): Started pcmk-1 - + Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Notice that ``pcmk-2`` is back to the ``Online`` state, and that the cluster resources stay where they are due to our resource stickiness settings configured earlier. .. [#] See http://www.drbd.org for details. .. [#] Since version 2.6.33 diff --git a/doc/sphinx/Clusters_from_Scratch/verification.rst b/doc/sphinx/Clusters_from_Scratch/verification.rst index 08fab3148c..d6b35eac59 100644 --- a/doc/sphinx/Clusters_from_Scratch/verification.rst +++ b/doc/sphinx/Clusters_from_Scratch/verification.rst @@ -1,222 +1,222 @@ Start and Verify Cluster ------------------------ Start the Cluster ################# Now that Corosync is configured, it is time to start the cluster. The command below will start the ``corosync`` and ``pacemaker`` services on both nodes in the cluster. .. code-block:: console [root@pcmk-1 ~]# pcs cluster start --all pcmk-1: Starting Cluster... pcmk-2: Starting Cluster... .. NOTE:: An alternative to using the ``pcs cluster start --all`` command is to issue either of the below command sequences on each node in the cluster separately: .. code-block:: console # pcs cluster start Starting Cluster... or .. code-block:: console # systemctl start corosync.service # systemctl start pacemaker.service .. IMPORTANT:: In this example, we are not enabling the ``corosync`` and ``pacemaker`` services to start at boot. If a cluster node fails or is rebooted, you will need to run ``pcs cluster start [ | --all]`` to start the cluster on it. While you can enable the services to start at boot (for example, using ``pcs cluster enable [ | --all]``), requiring a manual start of cluster services gives you the opportunity to do a post-mortem investigation of a node failure before returning it to the cluster. Verify Corosync Installation ################################ First, use ``corosync-cfgtool`` to check whether cluster communication is happy: .. code-block:: console [root@pcmk-1 ~]# corosync-cfgtool -s Local node ID 1, transport knet LINK ID 0 udp addr = 192.168.122.101 status: nodeid: 1: localhost nodeid: 2: connected We can see here that everything appears normal with our fixed IP address (not a ``127.0.0.x`` loopback address) listed as the ``addr``, and ``localhost`` and ``connected`` for the statuses of nodeid 1 and nodeid 2, respectively. If you see something different, you might want to start by checking the node's network, firewall, and SELinux configurations. Next, check the membership and quorum APIs: .. code-block:: console - [root@pcmk-1 ~]# corosync-cmapctl | grep members + [root@pcmk-1 ~]# corosync-cmapctl | grep members runtime.members.1.config_version (u64) = 0 - runtime.members.1.ip (str) = r(0) ip(192.168.122.101) + runtime.members.1.ip (str) = r(0) ip(192.168.122.101) runtime.members.1.join_count (u32) = 1 runtime.members.1.status (str) = joined runtime.members.2.config_version (u64) = 0 - runtime.members.2.ip (str) = r(0) ip(192.168.122.102) + runtime.members.2.ip (str) = r(0) ip(192.168.122.102) runtime.members.2.join_count (u32) = 1 runtime.members.2.status (str) = joined - [root@pcmk-1 ~]# pcs status corosync + [root@pcmk-1 ~]# pcs status corosync Membership information ---------------------- Nodeid Votes Name 1 1 pcmk-1 (local) 2 1 pcmk-2 You should see both nodes have joined the cluster. Verify Pacemaker Installation ################################# Now that we have confirmed that Corosync is functional, we can check the rest of the stack. Pacemaker has already been started, so verify the necessary processes are running: .. code-block:: console [root@pcmk-1 ~]# ps axf PID TTY STAT TIME COMMAND 2 ? S 0:00 [kthreadd] ...lots of processes... 17121 ? SLsl 0:01 /usr/sbin/corosync -f 17133 ? Ss 0:00 /usr/sbin/pacemakerd 17134 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-based 17135 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-fenced 17136 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-execd 17137 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-attrd 17138 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-schedulerd 17139 ? Ss 0:00 \_ /usr/libexec/pacemaker/pacemaker-controld If that looks OK, check the ``pcs status`` output: .. code-block:: console [root@pcmk-1 ~]# pcs status Cluster name: mycluster WARNINGS: No stonith devices and stonith-enabled is not false Cluster Summary: * Stack: corosync * Current DC: pcmk-2 (version 2.1.2-4.el9-ada5c3b36e2) - partition with quorum * Last updated: Wed Jul 27 00:09:55 2022 * Last change: Wed Jul 27 00:07:08 2022 by hacluster via crmd on pcmk-2 * 2 nodes configured * 0 resource instances configured Node List: * Online: [ pcmk-1 pcmk-2 ] Full List of Resources: * No resources Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Finally, ensure there are no start-up errors from ``corosync`` or ``pacemaker`` (aside from messages relating to not having STONITH configured, which are OK at this point): .. code-block:: console [root@pcmk-1 ~]# journalctl -b | grep -i error .. NOTE:: Other operating systems may report startup errors in other locations (for example, ``/var/log/messages``). Repeat these checks on the other node. The results should be the same. Explore the Existing Configuration ################################## For those who are not of afraid of XML, you can see the raw cluster configuration and status by using the ``pcs cluster cib`` command. .. topic:: The last XML you'll see in this document .. code-block:: console [root@pcmk-1 ~]# pcs cluster cib .. code-block:: xml Before we make any changes, it's a good idea to check the validity of the configuration. .. code-block:: console [root@pcmk-1 ~]# pcs cluster verify --full Error: invalid cib: (unpack_resources) error: Resource start-up disabled since no STONITH resources have been defined (unpack_resources) error: Either configure some or disable STONITH with the stonith-enabled option (unpack_resources) error: NOTE: Clusters with shared data need STONITH to ensure data integrity crm_verify: Errors found during check: config not valid Error: Errors have occurred, therefore pcs is unable to continue As you can see, the tool has found some errors. The cluster will not start any resources until we configure STONITH. diff --git a/doc/sphinx/Pacemaker_Administration/agents.rst b/doc/sphinx/Pacemaker_Administration/agents.rst index f6df901cdf..c85c14d6af 100644 --- a/doc/sphinx/Pacemaker_Administration/agents.rst +++ b/doc/sphinx/Pacemaker_Administration/agents.rst @@ -1,1182 +1,1182 @@ .. index:: single: resource agent Resource Agents --------------- Action Completion ################# If one resource depends on another resource via constraints, the cluster will interpret an expected result as sufficient to continue with dependent actions. This may cause timing issues if the resource agent start returns before the service is not only launched but fully ready to perform its function, or if the resource agent stop returns before the service has fully released all its claims on system resources. At a minimum, the start or stop should not return before a status command would return the expected (started or stopped) result. .. index:: single: OCF resource agent single: resource agent; OCF OCF Resource Agents ################### .. index:: single: OCF resource agent; location Location of Custom Scripts __________________________ OCF Resource Agents are found in ``/usr/lib/ocf/resource.d/$PROVIDER`` When creating your own agents, you are encouraged to create a new directory under ``/usr/lib/ocf/resource.d/`` so that they are not confused with (or overwritten by) the agents shipped by existing providers. So, for example, if you choose the provider name of big-corp and want a new resource named big-app, you would create a resource agent called ``/usr/lib/ocf/resource.d/big-corp/big-app`` and define a resource: - + .. code-block: xml .. index:: single: OCF resource agent; action Actions _______ All OCF resource agents are required to implement the following actions. .. list-table:: **Required Actions for OCF Agents** :class: longtable - :widths: 1 4 3 + :widths: 15 25 60 :header-rows: 1 * - Action - Description - Instructions * - .. _start_action: .. index:: single: OCF resource agent; start single: start action start - Start the resource - Return :ref:`OCF_SUCCESS ` on success and an appropriate error code otherwise. Must not report success until the resource is fully active. * - .. _stop_action: .. index:: single: OCF resource agent; stop single: stop action stop - Stop the resource - Return :ref:`OCF_SUCCESS ` on success and an appropriate error code otherwise. Must not report success until the resource is fully stopped. * - .. _monitor_action: .. index:: single: OCF resource agent; monitor single: monitor action monitor - Check the resource's state - Return :ref:`OCF_SUCCESS ` if the resource is running, :ref:`OCF_NOT_RUNNING ` if it is stopped, and any other :ref:`OCF exit code ` if it is failed. **Note:** The monitor action should test the state of the resource on the local machine only. * - .. _meta_data_action: .. index:: single: OCF resource agent; meta-data single: meta-data action meta-data - Describe the resource - Provide information about this resource in the XML format defined by the OCF standard. Return :ref:`OCF_SUCCESS `. **Note:** This is *not* required to be performed as root. OCF resource agents may optionally implement additional actions. Some are used only with advanced resource types such as clones. .. list-table:: **Optional Actions for OCF Resource Agents** :class: longtable: - :widths: 1 4 3 + :widths: 15 45 40 :header-rows: 1 * - Action - Description - Instructions * - .. _validate_all_action: .. index:: single: OCF resource agent; validate-all single: validate-all action validate-all - Validate the instance parameters provided. - Return :ref:`OCF_SUCCESS ` if parameters are valid, :ref:`OCF_ERR_ARGS ` if not valid, and :ref:`OCF_ERR_CONFIGURED ` if resource is not configured. * - .. _promote_action: .. index:: single: OCF resource agent; promote single: promote action promote - Bring the local instance of a promotable clone resource to the promoted role. - Return :ref:`OCF_SUCCESS ` on success. * - .. _demote_action: .. index:: single: OCF resource agent; demote single: demote action demote - Bring the local instance of a promotable clone resource to the unpromoted role. - Return :ref:`OCF_SUCCESS ` on success. * - .. _notify_action: .. index:: single: OCF resource agent; notify single: notify action notify - Used by the cluster to send the agent pre- and post-notification events telling the resource what has happened and what will happen. - Must not fail. Must return :ref:`OCF_SUCCESS `. * - .. _reload_action: .. index:: single: OCF resource agent; reload single: reload action reload - Reload the service's own configuration. - Not used by Pacemaker. * - .. _reload_agent_action: .. index:: single: OCF resource agent; reload-agent single: reload-agent action reload-agent - Make effective any changes in instance parameters marked as reloadable in the agent's meta-data. - This is used when the agent can handle a change in some of its parameters more efficiently than stopping and starting the resource. * - .. _recover_action: .. index:: single: OCF resource agent; recover single: recover action recover - Restart the service. - Not used by Pacemaker. .. important:: If you create a new OCF resource agent, use `ocf-tester` to verify that the agent complies with the OCF standard properly. .. index:: single: OCF resource agent; return code How Are OCF Return Codes Interpreted? _____________________________________ The first thing the cluster does is to check the return code against the expected result. If the result does not match the expected value, then the operation is considered to have failed, and recovery action is initiated. There are three types of failure recovery: .. list-table:: **Types of Recovery Performed by the Cluster** :class: longtable - :widths: 1 5 5 + :widths: 10 45 45 :header-rows: 1 * - Type - Description - Action Taken by the Cluster * - .. _soft_error: .. index:: single: OCF resource agent; soft error soft - A transient error - Restart the resource or move it to a new location * - .. _hard_error: .. index:: single: OCF resource agent; hard error hard - A non-transient error that may be specific to the current node - Move the resource elsewhere and prevent it from being retried on the current node * - .. _fatal_error: .. index:: single: OCF resource agent; fatal error fatal - A non-transient error that will be common to all cluster nodes (for example, a bad configuration was specified) - Stop the resource and prevent it from being started on any cluster node .. _ocf_return_codes: OCF Return Codes ________________ The following table outlines the various OCF return codes and the type of recovery the cluster will initiate when a failure code is received. Although counterintuitive, even actions that return ``OCF_SUCCESS`` can be considered to have failed, if ``OCF_SUCCESS`` was not the expected return value. .. list-table:: **OCF Exit Codes and Their Recovery Types** :class: longtable - :widths: 1 3 6 2 + :widths: 8 32 50 10 :header-rows: 1 * - Exit Code - OCF Alias - Description - Recovery * - .. _OCF_SUCCESS: .. index:: single: OCF_SUCCESS single: OCF return code; OCF_SUCCESS pair: OCF return code; 0 0 - OCF_SUCCESS - Success. The command completed successfully. This is the expected result for all start, stop, promote, and demote actions. - :ref:`soft ` * - .. _OCF_ERR_GENERIC: .. index:: single: OCF_ERR_GENERIC single: OCF return code; OCF_ERR_GENERIC pair: OCF return code; 1 1 - OCF_ERR_GENERIC - Generic "there was a problem" error code. - :ref:`hard ` * - .. _OCF_ERR_ARGS: .. index:: single: OCF_ERR_ARGS single: OCF return code; OCF_ERR_ARGS pair: OCF return code; 2 2 - OCF_ERR_ARGS - The resource's parameter values are not valid on this machine (for example, a value refers to a file not found on the local host). - :ref:`hard ` * - .. _OCF_ERR_UNIMPLEMENTED: .. index:: single: OCF_ERR_UNIMPLEMENTED single: OCF return code; OCF_ERR_UNIMPLEMENTED pair: OCF return code; 3 3 - OCF_ERR_UNIMPLEMENTED - The requested action is not implemented. - :ref:`hard ` * - .. _OCF_ERR_PERM: .. index:: single: OCF_ERR_PERM single: OCF return code; OCF_ERR_PERM pair: OCF return code; 4 4 - OCF_ERR_PERM - The resource agent does not have sufficient privileges to complete the task. - :ref:`hard ` * - .. _OCF_ERR_INSTALLED: .. index:: single: OCF_ERR_INSTALLED single: OCF return code; OCF_ERR_INSTALLED pair: OCF return code; 5 5 - OCF_ERR_INSTALLED - The tools required by the resource are not installed on this machine. - :ref:`hard ` * - .. _OCF_ERR_CONFIGURED: .. index:: single: OCF_ERR_CONFIGURED single: OCF return code; OCF_ERR_CONFIGURED pair: OCF return code; 6 6 - OCF_ERR_CONFIGURED - The resource's parameter values are inherently invalid (for example, a required parameter was not given). - :ref:`fatal ` * - .. _OCF_NOT_RUNNING: .. index:: single: OCF_NOT_RUNNING single: OCF return code; OCF_NOT_RUNNING pair: OCF return code; 7 7 - OCF_NOT_RUNNING - The resource is safely stopped. This should only be returned by monitor actions, not stop actions. - N/A * - .. _OCF_RUNNING_PROMOTED: .. index:: single: OCF_RUNNING_PROMOTED single: OCF return code; OCF_RUNNING_PROMOTED pair: OCF return code; 8 8 - OCF_RUNNING_PROMOTED - The resource is running in the promoted role. - :ref:`soft ` * - .. _OCF_FAILED_PROMOTED: .. index:: single: OCF_FAILED_PROMOTED single: OCF return code; OCF_FAILED_PROMOTED pair: OCF return code; 9 9 - OCF_FAILED_PROMOTED - The resource is (or might be) in the promoted role but has failed. The resource will be demoted, stopped, and then started (and possibly promoted) again. - :ref:`soft ` * - .. _OCF_DEGRADED: .. index:: single: OCF_DEGRADED single: OCF return code; OCF_DEGRADED pair: OCF return code; 190 190 - OCF_DEGRADED - The resource is properly active, but in such a condition that future failures are more likely. - none * - .. _OCF_DEGRADED_PROMOTED: .. index:: single: OCF_DEGRADED_PROMOTED single: OCF return code; OCF_DEGRADED_PROMOTED pair: OCF return code; 191 191 - OCF_DEGRADED_PROMOTED - The resource is properly active in the promoted role, but in such a condition that future failures are more likely. - none * - other - *none* - Custom error code. - soft Exceptions to the recovery handling described above: * Probes (non-recurring monitor actions) that find a resource active (or in the promoted role) will not result in recovery action unless it is also found active elsewhere. * The recovery action taken when a resource is found active more than once is determined by the resource's ``multiple-active`` property. * Recurring actions that return ``OCF_ERR_UNIMPLEMENTED`` do not cause any type of recovery. * Actions that return one of the "degraded" codes will be treated the same as if they had returned success, but status output will indicate that the resource is degraded. .. _ocf_env_vars: Environment Variables _____________________ Pacemaker sets certain environment variables when it executes an OCF resource agent. Agents can check these variables to get information about resource parameters or the execution environment. **Note:** Pacemaker may set other environment variables for its own purposes. They may be present in the agent's environment, but Pacemaker is not providing them for the agent's use, and so the agent should not rely on any variables not listed in the table below. .. list-table:: **OCF Environment Variables** :class: longtable - :widths: 1 6 + :widths: 50 50 :header-rows: 1 * - Environment Variable - Description * - .. _OCF_CHECK_LEVEL: .. index:: single: OCF_CHECK_LEVEL single: environment variable; OCF_CHECK_LEVEL OCF_CHECK_LEVEL - Requested intensity level of checks in ``monitor`` and ``validate-all`` actions. Usually set as an operation attribute; see Pacemaker Explained for an example. * - .. _OCF_EXIT_REASON_PREFIX: .. index:: single: OCF_EXIT_REASON_PREFIX single: environment variable; OCF_EXIT_REASON_PREFIX OCF_EXIT_REASON_PREFIX - Prefix for printing fatal error messages from the resource agent. * - .. _OCF_RA_VERSION_MAJOR: .. index:: single: OCF_RA_VERSION_MAJOR single: environment variable; OCF_RA_VERSION_MAJOR OCF_RA_VERSION_MAJOR - Major version number of the OCF Resource Agent API. If the script does not support this revision, it should report an error. See the `OCF specification `_ for an explanation of the versioning scheme used. The version number is split into two numbers for ease of use in shell scripts. These two may be used by the agent to determine whether it is run under an OCF-compliant resource manager. * - .. _OCF_RA_VERSION_MINOR: .. index:: single: OCF_RA_VERSION_MINOR single: environment variable; OCF_RA_VERSION_MINOR OCF_RA_VERSION_MINOR - Minor version number of the OCF Resource Agent API. See :ref:`OCF_RA_VERSION_MAJOR ` for more details. * - .. _OCF_RESKEY_crm_feature_set: .. index:: single: OCF_RESKEY_crm_feature_set single: environment variable; OCF_RESKEY_crm_feature_set OCF_RESKEY_crm_feature_set - ``crm_feature_set`` on the DC (or on the local node, if the agent is run by ``crm_resource``). * - .. _OCF_RESKEY_CRM_meta_interval: .. index:: single: OCF_RESKEY_CRM_meta_interval single: environment variable; OCF_RESKEY_CRM_meta_interval OCF_RESKEY_CRM_meta_interval - Interval (in milliseconds) of the current operation. * - .. _OCF_RESKEY_CRM_meta_name: .. index:: single: OCF_RESKEY_CRM_meta_name single: environment variable; OCF_RESKEY_CRM_meta_name OCF_RESKEY_CRM_meta_name - Name of the current operation. * - .. _OCF_RESKEY_CRM_meta_notify: .. index:: single: OCF_RESKEY_CRM_meta_notify_* single: environment variable; OCF_RESKEY_CRM_meta_notify_* OCF_RESKEY_CRM_meta_notify_* - See :ref:`Clone Notifications `. * - .. _OCF_RESKEY_CRM_meta_on_node: .. index:: single: OCF_RESKEY_CRM_meta_on_node single: environment variable; OCF_RESKEY_CRM_meta_on_node OCF_RESKEY_CRM_meta_on_node - Name of the node where the current operation is running. * - .. _OCF_RESKEY_CRM_meta_on_node_uuid: .. index:: single: OCF_RESKEY_CRM_meta_on_node_uuid single: environment variable; OCF_RESKEY_CRM_meta_on_node_uuid OCF_RESKEY_CRM_meta_on_node_uuid - Cluster-layer ID of the node where the current operation is running (or node name for Pacemaker Remote nodes). * - .. _OCF_RESKEY_CRM_meta_physical_host: .. index:: single: OCF_RESKEY_CRM_meta_physical_host single: environment variable; OCF_RESKEY_CRM_meta_physical_host OCF_RESKEY_CRM_meta_physical_host - If the node where the current operation is running is a guest node, the host on which the container is running. * - .. _OCF_RESKEY_CRM_meta_timeout: .. index:: single: OCF_RESKEY_CRM_meta_timeout single: environment variable; OCF_RESKEY_CRM_meta_timeout OCF_RESKEY_CRM_meta_timeout - Timeout (in milliseconds) of the current operation. * - .. _OCF_RESKEY_CRM_meta: .. index:: single: OCF_RESKEY_CRM_meta_* single: environment variable; OCF_RESKEY_CRM_meta_* OCF_RESKEY_CRM_meta_* - Each of a resource's meta-attributes is converted to an environment variable prefixed with "OCF_RESKEY_CRM_meta\_". See Pacemaker Explained for some meta-attributes that have special meaning to Pacemaker. * - .. _OCF_RESKEY: .. index:: single: OCF_RESKEY_* single: environment variable; OCF_RESKEY_* OCF_RESKEY_* - Each of a resource's instance parameters is converted to an environment variable prefixed with "OCF_RESKEY\_". * - .. _OCF_RESOURCE_INSTANCE: .. index:: single: OCF_RESOURCE_INSTANCE single: environment variable; OCF_RESOURCE_INSTANCE OCF_RESOURCE_INSTANCE - The name of the resource instance. * - .. _OCF_RESOURCE_PROVIDER: .. index:: single: OCF_RESOURCE_PROVIDER single: environment variable; OCF_RESOURCE_PROVIDER OCF_RESOURCE_PROVIDER - The name of the resource agent provider. * - .. _OCF_RESOURCE_TYPE: .. index:: single: OCF_RESOURCE_TYPE single: environment variable; OCF_RESOURCE_TYPE OCF_RESOURCE_TYPE - The name of the resource type. * - .. _OCF_ROOT: .. index:: single: OCF_ROOT single: environment variable; OCF_ROOT OCF_ROOT - The root of the OCF directory hierarchy. * - .. _OCF_TRACE_FILE: .. index:: single: OCF_TRACE_FILE single: environment variable; OCF_TRACE_FILE OCF_TRACE_FILE - The absolute path or file descriptor to write trace output to, if ``OCF_TRACE_RA`` is set to true. Pacemaker sets this only to ``/dev/stderr`` and only when running a resource agent via ``crm_resource``. * - .. _OCF_TRACE_RA: .. index:: single: OCF_TRACE_RA single: environment variable; OCF_TRACE_RA OCF_TRACE_RA - If set to true, enable tracing of the resource agent. Trace output is written to ``OCF_TRACE_FILE`` if set; otherwise, it's written to a file in ``OCF_RESKEY_trace_dir`` if set or in a default directory if not. Pacemaker sets this to true only when running a resource agent via ``crm_resource`` with one or more ``-V`` flags. * - .. _PCMK_DEBUGLOG: .. _HA_DEBUGLOG: .. index:: single: PCMK_DEBUGLOG single: environment variable; PCMK_DEBUGLOG single: HA_DEBUGLOG single: environment variable; HA_DEBUGLOG PCMK_DEBUGLOG (and HA_DEBUGLOG) - Where to write resource agent debug logs. Pacemaker sets this to ``PCMK_logfile`` if set to a value other than ``none`` and if debugging is enabled for the executor. * - .. _PCMK_LOGFACILITY: .. _HA_LOGFACILITY: .. index:: single: PCMK_LOGFACILITY single: environment variable; PCMK_LOGFACILITY single: HA_LOGFACILITY single: environment variable; HA_LOGFACILITY PCMK_LOGFACILITY (and HA_LOGFACILITY) - Syslog facility for resource agent logs. Pacemaker sets this to ``PCMK_logfacility`` if set to a value other than ``none`` or ``/dev/null``. * - .. _PCMK_LOGFILE: .. _HA_LOGFILE: .. index:: single: PCMK_LOGFILE: single: environment variable; PCMK_LOGFILE: single: HA_LOGFILE: single: environment variable; HA_LOGFILE: PCMK_LOGFILE (and HA_LOGFILE) - Where to write resource agent logs. Pacemaker sets this to ``PCMK_logfile`` if set to a value other than ``none``. * - .. _PCMK_service: .. index:: single: PCMK_service single: environment variable; PCMK_service PCMK_service - The name of the Pacemaker subsystem or command-line tool that's executing the resource agent. Specific values are subject to change; useful mainly for logging. Clone Resource Agent Requirements _________________________________ Any resource can be used as an anonymous clone, as it requires no additional support from the resource agent. Whether it makes sense to do so depends on your resource and its resource agent. Resource Agent Requirements for Globally Unique Clones ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Globally unique clones require additional support in the resource agent. In particular, it must respond with ``OCF_SUCCESS`` only if the node has that exact instance active. All other probes for instances of the clone should result in ``OCF_NOT_RUNNING`` (or one of the other OCF error codes if they are failed). Individual instances of a clone are identified by appending a colon and a numerical offset (for example, ``apache:2``). A resource agent can find out how many copies there are by examining the ``OCF_RESKEY_CRM_meta_clone_max`` environment variable and which instance it is by examining ``OCF_RESKEY_CRM_meta_clone``. The resource agent must not make any assumptions (based on ``OCF_RESKEY_CRM_meta_clone``) about which numerical instances are active. In particular, the list of active copies is not always an unbroken sequence, nor does it always start at 0. Resource Agent Requirements for Promotable Clones ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Promotable clone resources require two extra actions, ``demote`` and ``promote``, which are responsible for changing the state of the resource. Like ``start`` and ``stop``, they should return ``OCF_SUCCESS`` if they completed successfully or a relevant error code if they did not. The states can mean whatever you wish, but when the resource is started, it must begin in the unpromoted role. From there, the cluster will decide which instances to promote. In addition to the clone requirements for monitor actions, agents must also *accurately* report which state they are in. The cluster relies on the agent to report its status (including role) accurately and does not indicate to the agent what role it currently believes it to be in. .. list-table:: **Role Implications of OCF Return Codes** :class: longtable - :widths: 1 3 + :widths: 50 50 :header-rows: 1 * - Monitor Return Code - Description * - :ref:`OCF_NOT_RUNNING ` - .. index:: single: OCF_NOT_RUNNING single: OCF return code; OCF_NOT_RUNNING Stopped * - :ref:`OCF_SUCCESS ` - .. index:: single: OCF_SUCCESS single: OCF return code; OCF_SUCCESS Running (Unpromoted) * - :ref:`OCF_RUNNING_PROMOTED ` - .. index:: single: OCF_RUNNING_PROMOTED single: OCF return code; OCF_RUNNING_PROMOTED Running (Promoted) * - :ref:`OCF_FAILED_PROMOTED ` - .. index:: single: OCF_FAILED_PROMOTED single: OCF return code; OCF_FAILED_PROMOTED Failed (Promoted) * - Other - Failed (Unpromoted) .. _clone_notifications: Clone Notifications ~~~~~~~~~~~~~~~~~~~ If the clone has the ``notify`` meta-attribute set to ``true`` and the resource agent supports the ``notify`` action, Pacemaker will call the action when appropriate, passing a number of extra variables. These variables, when combined with additional context, can be used to calculate the current state of the cluster and what is about to happen to it. .. index:: single: clone; environment variables single: notify; environment variables .. list-table:: **Environment Variables Supplied with Clone Notify Actions** :class: longtable - :widths: 1 1 + :widths: 50 50 :header-rows: 1 * - Variable - Description * - .. _OCF_RESKEY_CRM_meta_notify_type: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_type single: OCF_RESKEY_CRM_meta_notify_type OCF_RESKEY_CRM_meta_notify_type - Allowed values: ``pre``, ``post`` * - .. _OCF_RESKEY_CRM_meta_notify_operation: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_operation single: OCF_RESKEY_CRM_meta_notify_operation OCF_RESKEY_CRM_meta_notify_operation - Allowed values: ``start``, ``stop`` * - .. _OCF_RESKEY_CRM_meta_notify_start_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_start_resource single: OCF_RESKEY_CRM_meta_notify_start_resource OCF_RESKEY_CRM_meta_notify_start_resource - Resources to be started * - .. _OCF_RESKEY_CRM_meta_notify_stop_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_stop_resource single: OCF_RESKEY_CRM_meta_notify_stop_resource OCF_RESKEY_CRM_meta_notify_stop_resource - Resources to be stopped * - .. _OCF_RESKEY_CRM_meta_notify_active_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_active_resource single: OCF_RESKEY_CRM_meta_notify_active_resource OCF_RESKEY_CRM_meta_notify_active_resource - Resources that are running * - .. _OCF_RESKEY_CRM_meta_notify_inactive_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_inactive_resource single: OCF_RESKEY_CRM_meta_notify_inactive_resource OCF_RESKEY_CRM_meta_notify_inactive_resource - Resources that are not running * - .. _OCF_RESKEY_CRM_meta_notify_start_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_start_uname single: OCF_RESKEY_CRM_meta_notify_start_uname OCF_RESKEY_CRM_meta_notify_start_uname - Nodes on which resources will be started * - .. _OCF_RESKEY_CRM_meta_notify_stop_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_stop_uname single: OCF_RESKEY_CRM_meta_notify_stop_uname OCF_RESKEY_CRM_meta_notify_stop_uname - Nodes on which resources will be stopped * - .. _OCF_RESKEY_CRM_meta_notify_active_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_active_uname single: OCF_RESKEY_CRM_meta_notify_active_uname OCF_RESKEY_CRM_meta_notify_active_uname - Nodes on which resources are running The variables come in pairs, such as ``OCF_RESKEY_CRM_meta_notify_start_resource`` and ``OCF_RESKEY_CRM_meta_notify_start_uname``, and should be treated as an array of whitespace-separated elements. ``OCF_RESKEY_CRM_meta_notify_inactive_resource`` is an exception, as the matching ``uname`` variable does not exist since inactive resources are not running on any node. Thus, in order to indicate that ``clone:0`` will be started on ``sles-1``, ``clone:2`` will be started on ``sles-3``, and ``clone:3`` will be started on ``sles-2``, the cluster would set: .. topic:: Notification Variables .. code-block:: none OCF_RESKEY_CRM_meta_notify_start_resource="clone:0 clone:2 clone:3" OCF_RESKEY_CRM_meta_notify_start_uname="sles-1 sles-3 sles-2" .. note:: Pacemaker will log but otherwise ignore failures of notify actions. Interpretation of Notification Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **Pre-notification (stop):** * Active resources: ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * Inactive resources: ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` **Post-notification (stop) / Pre-notification (start):** * Active resources * ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Inactive resources * ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources that were started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources that were stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` **Post-notification (start):** * Active resources: * ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Inactive resources: * ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources that were started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources that were stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` Extra Notifications for Promotable Clones ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. index:: single: clone; environment variables single: promotable; environment variables .. list-table:: **Extra Environment Variables Supplied for Promotable Clones** :class: longtable - :widths: 1 1 + :widths: 50 50 :header-rows: 1 * - Variable - Description * - .. _OCF_RESKEY_CRM_meta_notify_promoted_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_promoted_resource single: OCF_RESKEY_CRM_meta_notify_promoted_resource OCF_RESKEY_CRM_meta_notify_promoted_resource - Resources that are running in the promoted role * - .. _OCF_RESKEY_CRM_meta_notify_unpromoted_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_unpromoted_resource single: OCF_RESKEY_CRM_meta_notify_unpromoted_resource OCF_RESKEY_CRM_meta_notify_unpromoted_resource - Resources that are running in the unpromoted role * - .. _OCF_RESKEY_CRM_meta_notify_promote_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_promote_resource single: OCF_RESKEY_CRM_meta_notify_promote_resource OCF_RESKEY_CRM_meta_notify_promote_resource - Resources to be promoted * - .. _OCF_RESKEY_CRM_meta_notify_demote_resource: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_demote_resource single: OCF_RESKEY_CRM_meta_notify_demote_resource OCF_RESKEY_CRM_meta_notify_demote_resource - Resources to be demoted * - .. _OCF_RESKEY_CRM_meta_notify_promote_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_promote_uname single: OCF_RESKEY_CRM_meta_notify_promote_uname OCF_RESKEY_CRM_meta_notify_promote_uname - Nodes on which resources will be promoted * - .. _OCF_RESKEY_CRM_meta_notify_demote_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_demote_uname single: OCF_RESKEY_CRM_meta_notify_demote_uname OCF_RESKEY_CRM_meta_notify_demote_uname - Nodes on which resources will be demoted * - .. _OCF_RESKEY_CRM_meta_notify_promoted_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_promoted_uname single: OCF_RESKEY_CRM_meta_notify_promoted_uname OCF_RESKEY_CRM_meta_notify_promoted_uname - Nodes on which resources are running in the promoted role * - .. _OCF_RESKEY_CRM_meta_notify_unpromoted_uname: .. index:: single: environment variable; OCF_RESKEY_CRM_meta_notify_unpromoted_uname single: OCF_RESKEY_CRM_meta_notify_unpromoted_uname OCF_RESKEY_CRM_meta_notify_unpromoted_uname - Nodes on which resources are running in the unpromoted role Interpretation of Promotable Notification Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **Pre-notification (demote):** * Active resources: ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * Promoted resources: ``$OCF_RESKEY_CRM_meta_notify_promoted_resource`` * Unpromoted resources: ``$OCF_RESKEY_CRM_meta_notify_unpromoted_resource`` * Inactive resources: ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources to be demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` **Post-notification (demote) / Pre-notification (stop):** * Active resources: ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * Promoted resources: * ``$OCF_RESKEY_CRM_meta_notify_promoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Unpromoted resources: ``$OCF_RESKEY_CRM_meta_notify_unpromoted_resource`` * Inactive resources: ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources to be demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources that were demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` **Post-notification (stop) / Pre-notification (start)** * Active resources: * ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Promoted resources: * ``$OCF_RESKEY_CRM_meta_notify_promoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Unpromoted resources: * ``$OCF_RESKEY_CRM_meta_notify_unpromoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Inactive resources: * ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources to be demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources that were demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources that were stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` **Post-notification (start) / Pre-notification (promote)** * Active resources: * ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Promoted resources: * ``$OCF_RESKEY_CRM_meta_notify_promoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Unpromoted resources: * ``$OCF_RESKEY_CRM_meta_notify_unpromoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Inactive resources: * ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources to be demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources that were started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources that were demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources that were stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` **Post-notification (promote)** * Active resources: * ``$OCF_RESKEY_CRM_meta_notify_active_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Promoted resources: * ``$OCF_RESKEY_CRM_meta_notify_promoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Unpromoted resources: * ``$OCF_RESKEY_CRM_meta_notify_unpromoted_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Inactive resources: * ``$OCF_RESKEY_CRM_meta_notify_inactive_resource`` * plus ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * minus ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources to be promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources to be demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources to be stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` * Resources that were started: ``$OCF_RESKEY_CRM_meta_notify_start_resource`` * Resources that were promoted: ``$OCF_RESKEY_CRM_meta_notify_promote_resource`` * Resources that were demoted: ``$OCF_RESKEY_CRM_meta_notify_demote_resource`` * Resources that were stopped: ``$OCF_RESKEY_CRM_meta_notify_stop_resource`` .. index:: single: resource agent; LSB single: LSB resource agent single: init script LSB Resource Agents (Init Scripts) ################################## LSB Compliance ______________ The relevant part of the `LSB specifications `_ includes a description of all the return codes listed here. - + Assuming `some_service` is configured correctly and currently inactive, the following sequence will help you determine if it is LSB-compatible: #. Start (stopped): - + .. code-block:: none # /etc/init.d/some_service start ; echo "result: $?" * Did the service start? * Did the echo command print ``result: 0`` (in addition to the init script's usual output)? #. Status (running): - + .. code-block:: none # /etc/init.d/some_service status ; echo "result: $?" * Did the script accept the command? * Did the script indicate the service was running? * Did the echo command print ``result: 0`` (in addition to the init script's usual output)? #. Start (running): - + .. code-block:: none # /etc/init.d/some_service start ; echo "result: $?" * Is the service still running? * Did the echo command print ``result: 0`` (in addition to the init script's usual output)? #. Stop (running): - + .. code-block:: none # /etc/init.d/some_service stop ; echo "result: $?" * Was the service stopped? * Did the echo command print ``result: 0`` (in addition to the init script's usual output)? #. Status (stopped): - + .. code-block:: none # /etc/init.d/some_service status ; echo "result: $?" * Did the script accept the command? * Did the script indicate the service was not running? * Did the echo command print ``result: 3`` (in addition to the init script's usual output)? #. Stop (stopped): - + .. code-block:: none # /etc/init.d/some_service stop ; echo "result: $?" * Is the service still stopped? * Did the echo command print ``result: 0`` (in addition to the init script's usual output)? #. Status (failed): This step is not readily testable and relies on manual inspection of the script. The script can use one of the error codes (other than 3) listed in the LSB spec to indicate that it is active but failed. This tells the cluster that before moving the resource to another node, it needs to stop it on the existing one first. If the answer to any of the above questions is no, then the script is not LSB-compliant. Your options are then to either fix the script or write an OCF agent based on the existing script. diff --git a/doc/sphinx/Pacemaker_Administration/alerts.rst b/doc/sphinx/Pacemaker_Administration/alerts.rst index 05424dca0b..7a421efc41 100644 --- a/doc/sphinx/Pacemaker_Administration/alerts.rst +++ b/doc/sphinx/Pacemaker_Administration/alerts.rst @@ -1,343 +1,343 @@ .. index:: single: alert; agents Alert Agents ------------ .. index:: single: alert; sample agents Using the Sample Alert Agents ############################# - + Pacemaker provides several sample alert agents, installed in ``/usr/share/pacemaker/alerts`` by default. - + While these sample scripts may be copied and used as-is, they are provided mainly as templates to be edited to suit your purposes. See their source code for the full set of instance attributes they support. - + .. topic:: Sending cluster events as SNMP v2c traps .. code-block:: xml .. note:: **SNMP alert agent attributes** The ``timestamp-format`` meta-attribute should always be set to ``%Y-%m-%d,%H:%M:%S.%01N`` when using the SNMP agent, to match the SNMP standard. The SNMP agent provides a number of instance attributes in addition to the one used in the example above. The most useful are ``trap_version``, which defaults to ``2c``, and ``trap_community``, which defaults to ``public``. See the source code for more details. .. topic:: Sending cluster events as SNMP v3 traps .. code-block:: xml .. note:: **SNMP v3 trap configuration** To use SNMP v3, ``trap_version`` must be set to ``3``. ``trap_community`` will be ignored. The example above uses the ``trap_options`` instance attribute to override the security level, authentication protocol, authentication user, and authentication password from snmp.conf. These will be passed to the snmptrap command. Passing the password on the command line is considered insecure; specify authentication and privacy options suitable for your environment. .. topic:: Sending cluster events as e-mails .. code-block:: xml .. index:: single: alert; agent development Writing an Alert Agent ###################### - + .. index:: single: alert; environment variables single: environment variable; alert agents -.. list-table:: **Environment variables passed to alert agents** +.. list-table:: **Environment Variables Passed to Alert Agents** :class: longtable - :widths: 1 3 1 + :widths: 30 50 20 :header-rows: 1 - + * - Environment Variable - Description - Alert Types * - .. _CRM_alert_kind: - + .. index:: single: environment variable; CRM_alert_kind single: CRM_alert_kind CRM_alert_kind - The type of alert (``node``, ``fencing``, ``resource``, or ``attribute``) - all * - .. _CRM_alert_node: .. index:: single: environment variable; CRM_alert_node single: CRM_alert_node CRM_alert_node - Name of affected node - all * - .. _CRM_alert_node_sequence: - + .. index:: single: environment variable; CRM_alert_node_sequence single: CRM_alert_node_sequence - + CRM_alert_node_sequence - A sequence number increased whenever an alert is being issued on the local node, which can be used to reference the order in which alerts have been issued by Pacemaker. An alert for an event that happened later in time reliably has a higher sequence number than alerts for earlier events. This number has no cluster-wide meaning. - all * - .. _CRM_alert_recipient: - + .. index:: single: environment variable; CRM_alert_recipient single: CRM_alert_recipient - + CRM_alert_recipient - The configured recipient - all * - .. _CRM_alert_timestamp: - + .. index:: single: environment variable; CRM_alert_timestamp single: CRM_alert_timestamp - + CRM_alert_timestamp - A timestamp created prior to executing the agent, in the format specified by the ``timestamp-format`` meta-attribute. This allows the agent to have a reliable, high-precision time of when the event occurred, regardless of when the agent itself was invoked (which could potentially be delayed due to system load, etc.). - all * - .. _CRM_alert_timestamp_epoch: - + .. index:: single: environment variable; CRM_alert_timestamp_epoch single: CRM_alert_timestamp_epoch - + CRM_alert_timestamp_epoch - The same time as ``CRM_alert_timestamp``, expressed as the integer number of seconds since January 1, 1970. This (along with ``CRM_alert_timestamp_usec``) can be useful for alert agents that need to format time in a specific way rather than let the user configure it. - all * - .. _CRM_alert_timestamp_usec: - + .. index:: single: environment variable; CRM_alert_timestamp_usec single: CRM_alert_timestamp_usec - + CRM_alert_timestamp_usec - The same time as ``CRM_alert_timestamp``, expressed as the integer number of microseconds since ``CRM_alert_timestamp_epoch``. - all * - .. _CRM_alert_version: - + .. index:: single: environment variable; CRM_alert_version single: CRM_alert_version - + CRM_alert_version - The version of Pacemaker sending the alert - all * - .. _CRM_alert_desc: - + .. index:: single: environment variable; CRM_alert_desc single: CRM_alert_desc - + CRM_alert_desc - Detail about event. For ``node`` alerts, this is the node's current state (``member`` or ``lost``). For ``fencing`` alerts, this is a summary of the requested fencing operation, including origin, target, and fencing operation error code, if any. For ``resource`` alerts, this is a readable string equivalent of ``CRM_alert_status``. - ``node``, ``fencing``, ``resource`` * - .. _CRM_alert_nodeid: - + .. index:: single: environment variable; CRM_alert_nodeid single: CRM_alert_nodeid - + CRM_alert_nodeid - ID of node whose status changed - ``node`` * - .. _CRM_alert_rc: - + .. index:: single: environment variable; CRM_alert_rc single: CRM_alert_rc - + CRM_alert_rc - The numerical return code of the fencing or resource operation - ``fencing``, ``resource`` * - .. _CRM_alert_task: - + .. index:: single: environment variable; CRM_alert_task single: CRM_alert_task - + CRM_alert_task - The requested fencing or resource operation - ``fencing``, ``resource`` * - .. _CRM_alert_exec_time: - + .. index:: single: environment variable; CRM_alert_exec_time single: CRM_alert_exec_time - + CRM_alert_exec_time - The (wall-clock) time, in milliseconds, that it took to execute the action. If the action timed out, ``CRM_alert_status`` will be 2, ``CRM_alert_desc`` will be "Timed Out", and this value will be the action timeout. May not be supported on all platforms. *(since 2.0.1)* - ``resource`` * - .. _CRM_alert_interval: - + .. index:: single: environment variable; CRM_alert_interval single: CRM_alert_interval - + CRM_alert_interval - The interval of the resource operation - ``resource`` * - .. _CRM_alert_rsc: - + .. index:: single: environment variable; CRM_alert_rsc single: CRM_alert_rsc - + CRM_alert_rsc - The name of the affected resource - ``resource`` * - .. _CRM_alert_status: - + .. index:: single: environment variable; CRM_alert_status single: CRM_alert_status - + CRM_alert_status - A numerical code used by Pacemaker to represent the operation result - ``resource`` * - .. _CRM_alert_target_rc: - + .. index:: single: environment variable; CRM_alert_target_rc single: CRM_alert_target_rc - + CRM_alert_target_rc - The expected numerical return code of the operation - ``resource`` * - .. _CRM_alert_attribute_name: - + .. index:: single: environment variable; CRM_alert_attribute_name single: CRM_alert_attribute_name - + CRM_alert_attribute_name - The name of the node attribute that changed - ``attribute`` * - .. _CRM_alert_attribute_value: - + .. index:: single: environment variable; CRM_alert_attribute_value single: CRM_alert_attribute_value - + CRM_alert_attribute_value - The new value of the node attribute that changed - ``attribute`` Special concerns when writing alert agents: - + * Alert agents may be called with no recipient (if none is configured), so the agent must be able to handle this situation, even if it only exits in that case. (Users may modify the configuration in stages, and add a recipient later.) - + * If more than one recipient is configured for an alert, the alert agent will be called once per recipient. If an agent is not able to run concurrently, it should be configured with only a single recipient. The agent is free, however, to interpret the recipient as a list. - + * When a cluster event occurs, all alerts are fired off at the same time as separate processes. Depending on how many alerts and recipients are configured, and on what is done within the alert agents, a significant load burst may occur. The agent could be written to take this into consideration, for example by queueing resource-intensive actions into some other instance, instead of directly executing them. - + * Alert agents are run as the |CRM_DAEMON_USER| user, which has a minimal set of permissions. If an agent requires additional privileges, it is recommended to configure ``sudo`` to allow the agent to run the necessary commands as another user with the appropriate privileges. - + * As always, take care to validate and sanitize user-configured parameters, such as ``CRM_alert_timestamp`` (whose content is specified by the user-configured ``timestamp-format``), ``CRM_alert_recipient,`` and all instance attributes. Mostly this is needed simply to protect against configuration errors, but if some user can modify the CIB without having |CRM_DAEMON_USER| access to the cluster nodes, it is a potential security concern as well, to avoid the possibility of code injection. diff --git a/doc/sphinx/Pacemaker_Administration/index.rst b/doc/sphinx/Pacemaker_Administration/index.rst index c8fd7220b5..1b071e0556 100644 --- a/doc/sphinx/Pacemaker_Administration/index.rst +++ b/doc/sphinx/Pacemaker_Administration/index.rst @@ -1,39 +1,28 @@ Pacemaker Administration ======================== *Managing Pacemaker Clusters* -Abstract --------- -This document has instructions and tips for system administrators who -manage high-availability clusters using Pacemaker. - - -Table of Contents ------------------ +This document has instructions and tips for system administrators who manage +high-availability clusters using Pacemaker. .. toctree:: :maxdepth: 3 :numbered: intro installing cluster options configuring tools administrative moving troubleshooting upgrading alerts agents pcs-crmsh - - -Index ------ - -* :ref:`genindex` -* :ref:`search` + :ref:`genindex` + :ref:`search` diff --git a/doc/sphinx/Pacemaker_Administration/intro.rst b/doc/sphinx/Pacemaker_Administration/intro.rst index 067e293849..aa1c2da696 100644 --- a/doc/sphinx/Pacemaker_Administration/intro.rst +++ b/doc/sphinx/Pacemaker_Administration/intro.rst @@ -1,21 +1,21 @@ Introduction ------------ The Scope of this Document ########################## The purpose of this document is to help system administrators learn how to manage a Pacemaker cluster. - + System administrators may be interested in other parts of the `Pacemaker documentation set `_ such as *Clusters from Scratch*, a step-by-step guide to setting up an example cluster, and *Pacemaker Explained*, an exhaustive reference for cluster configuration. Multiple higher-level tools (both command-line and GUI) are available to simplify cluster management. However, this document focuses on the lower-level command-line tools that come with Pacemaker itself. The concepts are applicable to the higher-level tools, though the syntax would differ. .. include:: ../shared/pacemaker-intro.rst diff --git a/doc/sphinx/Pacemaker_Administration/moving.rst b/doc/sphinx/Pacemaker_Administration/moving.rst index 3d6a92af51..2c3c4449a7 100644 --- a/doc/sphinx/Pacemaker_Administration/moving.rst +++ b/doc/sphinx/Pacemaker_Administration/moving.rst @@ -1,305 +1,303 @@ Moving Resources ---------------- .. index:: single: resource; move Moving Resources Manually ######################### There are primarily two occasions when you would want to move a resource from its current location: when the whole node is under maintenance, and when a single resource needs to be moved. .. index:: single: standby mode single: node; standby mode Standby Mode ____________ Since everything eventually comes down to a score, you could create constraints for every resource to prevent them from running on one node. While Pacemaker configuration can seem convoluted at times, not even we would require this of administrators. Instead, you can set a special node attribute which tells the cluster "don't let anything run here". There is even a helpful tool to help query and set it, called ``crm_standby``. To check the standby status of the current machine, run: .. code-block:: none # crm_standby -G A value of ``on`` indicates that the node is *not* able to host any resources, while a value of ``off`` says that it *can*. You can also check the status of other nodes in the cluster by specifying the `--node` option: .. code-block:: none # crm_standby -G --node sles-2 To change the current node's standby status, use ``-v`` instead of ``-G``: .. code-block:: none # crm_standby -v on Again, you can change another host's value by supplying a hostname with ``--node``. A cluster node in standby mode will not run resources, but still contributes to quorum, and may fence or be fenced by nodes. Moving One Resource ___________________ When only one resource is required to move, we could do this by creating location constraints. However, once again we provide a user-friendly shortcut as part of the ``crm_resource`` command, which creates and modifies the extra constraints for you. If ``Email`` were running on ``sles-1`` and you wanted it moved to a specific location, the command would look something like: .. code-block:: none # crm_resource -M -r Email -H sles-2 Behind the scenes, the tool will create the following location constraint: .. code-block:: xml It is important to note that subsequent invocations of ``crm_resource -M`` are not cumulative. So, if you ran these commands: .. code-block:: none # crm_resource -M -r Email -H sles-2 # crm_resource -M -r Email -H sles-3 then it is as if you had never performed the first command. To allow the resource to move back again, use: .. code-block:: none # crm_resource -U -r Email Note the use of the word *allow*. The resource *can* move back to its original location, but depending on ``resource-stickiness``, location constraints, and so forth, it might stay where it is. To be absolutely certain that it moves back to ``sles-1``, move it there before issuing the call to ``crm_resource -U``: .. code-block:: none # crm_resource -M -r Email -H sles-1 # crm_resource -U -r Email Alternatively, if you only care that the resource should be moved from its current location, try: .. code-block:: none # crm_resource -B -r Email which will instead create a negative constraint, like: .. code-block:: xml This will achieve the desired effect, but will also have long-term consequences. As the tool will warn you, the creation of a ``-INFINITY`` constraint will prevent the resource from running on that node until ``crm_resource -U`` is used. This includes the situation where every other cluster node is no longer available! In some cases, such as when ``resource-stickiness`` is set to ``INFINITY``, it is possible that you will end up with nodes with the same score, forcing the cluster to choose one (which may not be the one you want). The tool can detect some of these cases and deals with them by creating both positive and negative constraints. For example: .. code-block:: xml which has the same long-term consequences as discussed earlier. Moving Resources Due to Connectivity Changes ############################################ You can configure the cluster to move resources when external connectivity is lost in two steps. .. index:: single: ocf:pacemaker:ping resource single: ping resource Tell Pacemaker to Monitor Connectivity ______________________________________ First, add an ``ocf:pacemaker:ping`` resource to the cluster. The ``ping`` resource uses the system utility of the same name to a test whether a list of machines (specified by DNS hostname or IP address) are reachable, and uses the results to maintain a node attribute. The node attribute is called ``pingd`` by default, but is customizable in order to allow multiple ping groups to be defined. Normally, the ping resource should run on all cluster nodes, which means that you'll need to create a clone. A template for this can be found below, along with a description of the most interesting parameters. -.. table:: **Commonly Used ocf:pacemaker:ping Resource Parameters** - :widths: 1 4 - - +--------------------+--------------------------------------------------------------+ - | Resource Parameter | Description | - +====================+==============================================================+ - | dampen | .. index:: | - | | single: ocf:pacemaker:ping resource; dampen parameter | - | | single: dampen; ocf:pacemaker:ping resource parameter | - | | | - | | The time to wait (dampening) for further changes to occur. | - | | Use this to prevent a resource from bouncing around the | - | | cluster when cluster nodes notice the loss of connectivity | - | | at slightly different times. | - +--------------------+--------------------------------------------------------------+ - | multiplier | .. index:: | - | | single: ocf:pacemaker:ping resource; multiplier parameter | - | | single: multiplier; ocf:pacemaker:ping resource parameter | - | | | - | | The number of connected ping nodes gets multiplied by this | - | | value to get a score. Useful when there are multiple ping | - | | nodes configured. | - +--------------------+--------------------------------------------------------------+ - | host_list | .. index:: | - | | single: ocf:pacemaker:ping resource; host_list parameter | - | | single: host_list; ocf:pacemaker:ping resource parameter | - | | | - | | The machines to contact in order to determine the current | - | | connectivity status. Allowed values include resolvable DNS | - | | connectivity host names, IPv4 addresses, and IPv6 addresses. | - +--------------------+--------------------------------------------------------------+ +.. list-table:: **Commonly Used ocf:pacemaker:ping Resource Parameters** + :widths: 20 80 + :header-rows: 1 + + * - Resource Parameter + - Description + * - dampen + - .. index:: + single: ocf:pacemaker:ping resource; dampen parameter + single: dampen; ocf:pacemaker:ping resource parameter + + The time to wait (dampening) for further changes to occur. Use this to + prevent a resource from bouncing around the cluster when cluster nodes + notice the loss of connectivity at slightly different times. + * - multiplier + - .. index:: + single: ocf:pacemaker:ping resource; multiplier parameter + single: multiplier; ocf:pacemaker:ping resource parameter + + The number of connected ping nodes gets multiplied by this value to get + a score. Useful when there are multiple ping nodes configured. + * - host_list + - .. index:: + single: ocf:pacemaker:ping resource; host_list parameter + single: host_list; ocf:pacemaker:ping resource parameter + + The machines to contact in order to determine the current connectivity + status. Allowed values include resolvable DNS connectivity host names, + IPv4 addresses, and IPv6 addresses. .. topic:: Example ping resource that checks node connectivity once every minute .. code-block:: xml .. important:: You're only half done. The next section deals with telling Pacemaker how to deal with the connectivity status that ``ocf:pacemaker:ping`` is recording. Tell Pacemaker How to Interpret the Connectivity Data _____________________________________________________ .. important:: Before attempting the following, make sure you understand rules. See the "Rules" chapter of the *Pacemaker Explained* document for details. There are a number of ways to use the connectivity data. The most common setup is for people to have a single ping target (for example, the service network's default gateway), to prevent the cluster from running a resource on any unconnected node. .. topic:: Don't run a resource on unconnected nodes .. code-block:: xml A more complex setup is to have a number of ping targets configured. You can require the cluster to only run resources on nodes that can connect to all (or a minimum subset) of them. .. topic:: Run only on nodes connected to three or more ping targets .. code-block:: xml ... ... ... Alternatively, you can tell the cluster only to *prefer* nodes with the best connectivity, by using ``score-attribute`` in the rule. Just be sure to set ``multiplier`` to a value higher than that of ``resource-stickiness`` (and don't set either of them to ``INFINITY``). .. topic:: Prefer node with most connected ping nodes .. code-block:: xml It is perhaps easier to think of this in terms of the simple constraints that the cluster translates it into. For example, if ``sles-1`` is connected to all five ping nodes but ``sles-2`` is only connected to two, then it would be as if you instead had the following constraints in your configuration: .. topic:: How the cluster translates the above location constraint .. code-block:: xml The advantage is that you don't have to manually update any constraints whenever your network connectivity changes. You can also combine the concepts above into something even more complex. The example below shows how you can prefer the node with the most connected ping nodes provided they have connectivity to at least three (again assuming that ``multiplier`` is set to 1000). .. topic:: More complex example of choosing location based on connectivity .. code-block:: xml diff --git a/doc/sphinx/Pacemaker_Administration/options.rst b/doc/sphinx/Pacemaker_Administration/options.rst index 776bb3606c..ea339dd8f1 100644 --- a/doc/sphinx/Pacemaker_Administration/options.rst +++ b/doc/sphinx/Pacemaker_Administration/options.rst @@ -1,232 +1,232 @@ .. index:: client options Client Options -------------- Pacemaker uses several environment variables set on the client side. .. note:: Directory and file paths below may differ on your system depending on your Pacemaker build settings. Check your Pacemaker configuration file to find the correct paths. .. list-table:: **Client-side Environment Variables** :class: longtable - :widths: 2 4 5 + :widths: 20 30 50 :header-rows: 1 * - Environment Variable - Default - Description * - .. _CIB_encrypted: .. index:: single: CIB_encrypted single: environment variable; CIB_encrypted CIB_encrypted - true - Whether to encrypt network traffic. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_file: .. index:: single: CIB_file single: environment variable; CIB_file CIB_file - - If set, CIB connections are created against the named XML file. Clients read an input CIB from, and write the result CIB to, the named file. Ignored if :ref:`CIB_shadow ` is set. * - .. _CIB_passwd: .. index:: single: CIB_passwd single: environment variable; CIB_passwd CIB_passwd - - :ref:`$CIB_user `'s password. Read from the command line if unset. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_port: .. index:: single: CIB_port single: environment variable; CIB_port CIB_port - - If set, CIB connections are created as clients to a remote CIB instance on :ref:`$CIB_server ` via this port. Ignored if :ref:`CIB_shadow ` or :ref:`CIB_file ` is set. * - .. _CIB_server: .. index:: single: CIB_server single: environment variable; CIB_server CIB_server - localhost - The host to connect to. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_ca_file: .. index:: single: CIB_ca_file single: environment variable; CIB_ca_file CIB_ca_file - - + - - If this, :ref:`CIB_cert_file `, and :ref:`CIB_key_file ` are set, remote CIB administration will be encrypted using X.509 (SSL/TLS) certificates, with this root certificate for the certificate authority. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_cert_file: .. index:: single: CIB_cert_file single: environment variable; CIB_cert_file CIB_cert_file - - + - - If this, :ref:`CIB_ca_file `, and :ref:`CIB_key_file ` are set, remote CIB administration will be encrypted using X.509 (SSL/TLS) certificates, with this certificate for the local host. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_key_file: .. index:: single: CIB_key_file single: environment variable; CIB_key_file CIB_key_file - - + - - If this, :ref:`CIB_ca_file `, and :ref:`CIB_cert_file ` are set, remote CIB administration will be encrypted using X.509 (SSL/TLS) certificates, with this private key for the local host. Used with :ref:`CIB_port ` for connecting to a remote CIB instance; ignored if :ref:`CIB_port ` is not set. * - .. _CIB_crl_file: .. index:: single: CIB_crl_file single: environment variable; CIB_crl_file CIB_crl_file - - + - - If this, :ref:`CIB_ca_file `, :ref:`CIB_cert_file `, and :ref:`CIB_key_file ` are all set, then certificates listed in this PEM-format Certificate Revocation List file will be rejected. * - .. _CIB_shadow: .. index:: single: CIB_shadow single: environment variable; CIB_shadow CIB_shadow - - If set, CIB connections are created against a temporary working ("shadow") CIB file called ``shadow.$CIB_shadow`` in :ref:`$CIB_shadow_dir `. Should be set only to the name of a shadow CIB created by :ref:`crm_shadow `. Otherwise, behavior is undefined. * - .. _CIB_shadow_dir: .. index:: single: CIB_shadow_dir single: environment variable; CIB_shadow_dir CIB_shadow_dir - |CRM_CONFIG_DIR| if the current user is ``root`` or |CRM_DAEMON_USER|; otherwise ``$HOME/.cib`` if :ref:`$HOME ` is set; otherwise ``$TMPDIR/.cib`` if :ref:`$TMPDIR ` is set to an absolute path; otherwise ``/tmp/.cib`` - If set, shadow files are created in this directory. Ignored if :ref:`CIB_shadow ` is not set. * - .. _CIB_user: .. index:: single: CIB_user single: environment variable; CIB_user CIB_user - |CRM_DAEMON_USER| if used with :ref:`CIB_port `, or the current effective user otherwise - If used with :ref:`CIB_port `, connect to :ref:`$CIB_server ` as this user. Must be part of the |CRM_DAEMON_GROUP| group on :ref:`$CIB_server `. Otherwise (without :ref:`CIB_port `), this is used only for ACL and display purposes. * - .. _EDITOR: .. index:: single: EDITOR single: environment variable; EDITOR EDITOR - - Text editor to use for editing shadow files. Required for the ``--edit`` command of :ref:`crm_shadow `. * - .. _HOME: .. index:: single: HOME single: environment variable; HOME HOME - Current user's home directory as configured in the passwd database, if an entry exists - Used to create a default :ref:`CIB_shadow_dir ` for non- privileged users. * - .. _PE_fail: .. index:: single: PE_fail single: environment variable; PE_fail PE_fail - 0 - Advanced use only: A dummy graph action with action ID matching this option will be marked as failed. Primarily for developer use with scheduler simulations. * - .. _PS1: .. index:: single: PS1 single: environment variable; PS1 PS1 - - The shell's primary prompt string. Used by :ref:`crm_shadow `: set to indicate that the user is in an interactive shadow CIB session, and checked to determine whether the user is already in an interactive session before creating a new one. * - .. _SHELL: .. index:: single: SHELL single: environment variable; SHELL SHELL - - Absolute path to a shell. Used by :ref:`crm_shadow ` when launching an interactive session. * - .. _TMPDIR: .. index:: single: TMPDIR single: environment variable; TMPDIR TMPDIR - /tmp - Directory for temporary files. If not an absolute path, the default is used instead. diff --git a/doc/sphinx/Pacemaker_Administration/pcs-crmsh.rst b/doc/sphinx/Pacemaker_Administration/pcs-crmsh.rst index 06fb24fb31..d0718dcfeb 100644 --- a/doc/sphinx/Pacemaker_Administration/pcs-crmsh.rst +++ b/doc/sphinx/Pacemaker_Administration/pcs-crmsh.rst @@ -1,444 +1,444 @@ Quick Comparison of pcs and crm shell ------------------------------------- ``pcs`` and ``crm shell`` are two popular higher-level command-line interfaces to Pacemaker. Each has its own syntax; this chapter gives a quick comparion of how to accomplish the same tasks using either one. Some examples also show the equivalent command using low-level Pacemaker command-line tools. These examples show the simplest syntax; see the respective man pages for all possible options. Show Cluster Configuration and Status ##################################### .. topic:: Show Configuration (Raw XML) .. code-block:: none crmsh # crm configure show xml pcs # pcs cluster cib pacemaker # cibadmin -Q .. topic:: Show Configuration (Human-friendly) .. code-block:: none crmsh # crm configure show pcs # pcs config - + .. topic:: Show Cluster Status .. code-block:: none crmsh # crm status pcs # pcs status pacemaker # crm_mon -1 Manage Nodes ############ .. topic:: Put node "pcmk-1" in standby mode .. code-block:: none crmsh # crm node standby pcmk-1 pcs-0.9 # pcs cluster standby pcmk-1 pcs-0.10 # pcs node standby pcmk-1 pacemaker # crm_standby -N pcmk-1 -v on .. topic:: Remove node "pcmk-1" from standby mode .. code-block:: none crmsh # crm node online pcmk-1 pcs-0.9 # pcs cluster unstandby pcmk-1 pcs-0.10 # pcs node unstandby pcmk-1 pacemaker # crm_standby -N pcmk-1 -v off Manage Cluster Properties ######################### .. topic:: Set the "stonith-enabled" cluster property to "false" .. code-block:: none crmsh # crm configure property stonith-enabled=false pcs # pcs property set stonith-enabled=false pacemaker # crm_attribute -n stonith-enabled -v false Show Resource Agent Information ############################### .. topic:: List Resource Agent (RA) Classes .. code-block:: none crmsh # crm ra classes pcs # pcs resource standards pacmaker # crm_resource --list-standards .. topic:: List Available Resource Agents (RAs) by Standard .. code-block:: none crmsh # crm ra list ocf pcs # pcs resource agents ocf pacemaker # crm_resource --list-agents ocf .. topic:: List Available Resource Agents (RAs) by OCF Provider .. code-block:: none crmsh # crm ra list ocf pacemaker pcs # pcs resource agents ocf:pacemaker pacemaker # crm_resource --list-agents ocf:pacemaker .. topic:: List Available Resource Agent Parameters .. code-block:: none crmsh # crm ra info IPaddr2 pcs # pcs resource describe IPaddr2 pacemaker # crm_resource --show-metadata ocf:heartbeat:IPaddr2 You can also use the full ``class:provider:type`` format with crmsh and pcs if multiple RAs with the same name are available. .. topic:: Show Available Fence Agent Parameters .. code-block:: none crmsh # crm ra info stonith:fence_ipmilan pcs # pcs stonith describe fence_ipmilan Manage Resources ################ .. topic:: Create a Resource .. code-block:: none crmsh # crm configure primitive ClusterIP IPaddr2 params ip=192.168.122.120 cidr_netmask=24 pcs # pcs resource create ClusterIP IPaddr2 ip=192.168.122.120 cidr_netmask=24 Both crmsh and pcs determine the standard and provider (``ocf:heartbeat``) automatically since ``IPaddr2`` is unique, and automatically create operations (including monitor) based on the agent's meta-data. .. topic:: Show Configuration of All Resources .. code-block:: none crmsh # crm configure show pcs-0.9 # pcs resource show --full pcs-0.10 # pcs resource config .. topic:: Show Configuration of One Resource .. code-block:: none crmsh # crm configure show ClusterIP pcs-0.9 # pcs resource show ClusterIP pcs-0.10 # pcs resource config ClusterIP .. topic:: Show Configuration of Fencing Resources .. code-block:: none crmsh # crm resource status pcs-0.9 # pcs stonith show --full pcs-0.10 # pcs stonith config .. topic:: Start a Resource .. code-block:: none crmsh # crm resource start ClusterIP pcs # pcs resource enable ClusterIP pacemaker # crm_resource -r ClusterIP --set-parameter target-role --meta -v Started .. topic:: Stop a Resource .. code-block:: none crmsh # crm resource stop ClusterIP pcs # pcs resource disable ClusterIP pacemaker # crm_resource -r ClusterIP --set-parameter target-role --meta -v Stopped .. topic:: Remove a Resource .. code-block:: none crmsh # crm configure delete ClusterIP pcs # pcs resource delete ClusterIP .. topic:: Modify a Resource's Instance Parameters .. code-block:: none crmsh # crm resource param ClusterIP set clusterip_hash=sourceip pcs # pcs resource update ClusterIP clusterip_hash=sourceip pacemaker # crm_resource -r ClusterIP --set-parameter clusterip_hash -v sourceip crmsh also has an `edit` command which edits the simplified CIB syntax (same commands as the command line) via a configurable text editor. .. topic:: Modify a Resource's Instance Parameters Interactively .. code-block:: none crmsh # crm configure edit ClusterIP Using the interactive shell mode of crmsh, multiple changes can be edited and verified before committing to the live configuration: .. topic:: Make Multiple Configuration Changes Interactively .. code-block:: none crmsh # crm configure crmsh # edit crmsh # verify crmsh # commit .. topic:: Delete a Resource's Instance Parameters .. code-block:: none crmsh # crm resource param ClusterIP delete nic pcs # pcs resource update ClusterIP nic= pacemaker # crm_resource -r ClusterIP --delete-parameter nic .. topic:: List Current Resource Defaults .. code-block:: none crmsh # crm configure show type:rsc_defaults pcs # pcs resource defaults pacemaker # cibadmin -Q --scope rsc_defaults .. topic:: Set Resource Defaults .. code-block:: none crmsh # crm configure rsc_defaults resource-stickiness=100 pcs # pcs resource defaults resource-stickiness=100 - + .. topic:: List Current Operation Defaults .. code-block:: none crmsh # crm configure show type:op_defaults pcs # pcs resource op defaults pacemaker # cibadmin -Q --scope op_defaults .. topic:: Set Operation Defaults .. code-block:: none crmsh # crm configure op_defaults timeout=240s pcs # pcs resource op defaults timeout=240s .. topic:: Enable Resource Agent Tracing for a Resource .. code-block:: none crmsh # crm resource trace Website .. topic:: Clear Fail Counts for a Resource .. code-block:: none crmsh # crm resource cleanup Website pcs # pcs resource cleanup Website pacemaker # crm_resource --cleanup -r Website .. topic:: Create a Clone Resource .. code-block:: none crmsh # crm configure clone WebIP ClusterIP meta globally-unique=true clone-max=2 clone-node-max=2 pcs # pcs resource clone ClusterIP globally-unique=true clone-max=2 clone-node-max=2 .. topic:: Create a Promotable Clone Resource .. code-block:: none crmsh # crm configure ms WebDataClone WebData \ meta master-max=1 master-node-max=1 \ clone-max=2 clone-node-max=1 notify=true crmsh # crm configure clone WebDataClone WebData \ meta promotable=true \ promoted-max=1 promoted-node-max=1 \ clone-max=2 clone-node-max=1 notify=true pcs-0.9 # pcs resource master WebDataClone WebData \ master-max=1 master-node-max=1 \ clone-max=2 clone-node-max=1 notify=true pcs-0.10 # pcs resource promotable WebData WebDataClone \ promoted-max=1 promoted-node-max=1 \ clone-max=2 clone-node-max=1 notify=true crmsh supports both ways ('configure ms' is deprecated) to configure promotable clone since crmsh 4.4.0. pcs will generate the clone name automatically if it is omitted from the command line. Manage Constraints ################## .. topic:: Create a Colocation Constraint .. code-block:: none crmsh # crm configure colocation website-with-ip INFINITY: WebSite ClusterIP pcs # pcs constraint colocation add ClusterIP with WebSite INFINITY .. topic:: Create a Colocation Constraint Based on Role .. code-block:: none crmsh # crm configure colocation another-ip-with-website inf: AnotherIP WebSite:Master pcs # pcs constraint colocation add Started AnotherIP with Promoted WebSite INFINITY .. topic:: Create an Ordering Constraint .. code-block:: none crmsh # crm configure order apache-after-ip mandatory: ClusterIP WebSite pcs # pcs constraint order ClusterIP then WebSite .. topic:: Create an Ordering Constraint Based on Role .. code-block:: none crmsh # crm configure order ip-after-website Mandatory: WebSite:Master AnotherIP pcs # pcs constraint order promote WebSite then start AnotherIP .. topic:: Create a Location Constraint .. code-block:: none crmsh # crm configure location prefer-pcmk-1 WebSite 50: pcmk-1 pcs # pcs constraint location WebSite prefers pcmk-1=50 - + .. topic:: Create a Location Constraint Based on Role .. code-block:: none crmsh # crm configure location prefer-pcmk-1 WebSite rule role=Master 50: \#uname eq pcmk-1 pcs # pcs constraint location WebSite rule role=Promoted 50 \#uname eq pcmk-1 .. topic:: Move a Resource to a Specific Node (by Creating a Location Constraint) .. code-block:: none crmsh # crm resource move WebSite pcmk-1 pcs # pcs resource move WebSite pcmk-1 pacemaker # crm_resource -r WebSite --move -N pcmk-1 - + .. topic:: Move a Resource Away from Its Current Node (by Creating a Location Constraint) .. code-block:: none crmsh # crm resource ban Website pcmk-2 pcs # pcs resource ban Website pcmk-2 pacemaker # crm_resource -r WebSite --move .. topic:: Remove any Constraints Created by Moving a Resource .. code-block:: none crmsh # crm resource unmove WebSite pcs # pcs resource clear WebSite pacemaker # crm_resource -r WebSite --clear Advanced Configuration ###################### Manipulate Configuration Elements by Type _________________________________________ .. topic:: List Constraints with IDs .. code-block:: none pcs # pcs constraint list --full .. topic:: Remove Constraint by ID .. code-block:: none pcs # pcs constraint remove cli-ban-Website-on-pcmk-1 crmsh # crm configure remove cli-ban-Website-on-pcmk-1 crmsh's `show` and `edit` commands can be used to manage resources and constraints by type: .. topic:: Show Configuration Elements .. code-block:: none crmsh # crm configure show type:primitive crmsh # crm configure edit type:colocation Batch Changes _____________ .. topic:: Make Multiple Changes and Apply Together .. code-block:: none crmsh # crm crmsh # cib new drbd_cfg crmsh # configure primitive WebData ocf:linbit:drbd params drbd_resource=wwwdata \ op monitor interval=60s crmsh # configure ms WebDataClone WebData meta master-max=1 master-node-max=1 \ clone-max=2 clone-node-max=1 notify=true crmsh # cib commit drbd_cfg crmsh # quit pcs # pcs cluster cib drbd_cfg pcs # pcs -f drbd_cfg resource create WebData ocf:linbit:drbd drbd_resource=wwwdata \ op monitor interval=60s pcs-0.9 # pcs -f drbd_cfg resource master WebDataClone WebData \ master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true pcs-0.10 # pcs -f drbd_cfg resource promotable WebData WebDataClone \ promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 notify=true pcs # pcs cluster cib-push drbd_cfg Template Creation _________________ .. topic:: Create Resource Template Based on Existing Primitives of Same Type .. code-block:: none crmsh # crm configure assist template ClusterIP AdminIP Log Analysis ____________ .. topic:: Show Information About Recent Cluster Events .. code-block:: none crmsh # crm history crmsh # peinputs crmsh # transition pe-input-10 crmsh # transition log pe-input-10 Configuration Scripts _____________________ .. topic:: Script Multiple-step Cluster Configurations .. code-block:: none crmsh # crm script show apache crmsh # crm script run apache \ id=WebSite \ install=true \ virtual-ip:ip=192.168.0.15 \ database:id=WebData \ database:install=true diff --git a/doc/sphinx/Pacemaker_Administration/tools.rst b/doc/sphinx/Pacemaker_Administration/tools.rst index de9ee85607..7911c335bf 100644 --- a/doc/sphinx/Pacemaker_Administration/tools.rst +++ b/doc/sphinx/Pacemaker_Administration/tools.rst @@ -1,561 +1,576 @@ .. index:: command-line tool Using Pacemaker Command-Line Tools ---------------------------------- .. index:: single: command-line tool; output format .. _cmdline_output: Controlling Command Line Output ############################### Some of the pacemaker command line utilities have been converted to a new output system. Among these tools are ``crm_mon`` and ``stonith_admin``. This is an ongoing project, and more tools will be converted over time. This system lets you control the formatting of output with ``--output-as=`` and the destination of output with ``--output-to=``. The available formats vary by tool, but at least plain text and XML are supported by all tools that use the new system. The default format is plain text. The default destination is stdout but can be redirected to any file. Some formats support command line options for changing the style of the output. For instance: .. code-block:: none # crm_mon --help-output Usage: crm_mon [OPTION?] Provides a summary of cluster's current state. Outputs varying levels of detail in a number of different formats. Output Options: --output-as=FORMAT Specify output format as one of: console (default), html, text, xml --output-to=DEST Specify file name for output (or "-" for stdout) --html-cgi Add text needed to use output in a CGI program --html-stylesheet=URI Link to an external CSS stylesheet --html-title=TITLE Page title .. index:: single: crm_mon single: command-line tool; crm_mon .. _crm_mon: Monitor a Cluster with crm_mon ############################## The ``crm_mon`` utility displays the current state of an active cluster. It can show the cluster status organized by node or by resource, and can be used in either single-shot or dynamically updating mode. It can also display operations performed and information about failures. Using this tool, you can examine the state of the cluster for irregularities, and see how it responds when you cause or simulate failures. See the manual page or the output of ``crm_mon --help`` for a full description of its many options. - + .. topic:: Sample output from crm_mon -1 .. code-block:: none Cluster Summary: * Stack: corosync * Current DC: node2 (version 2.0.0-1) - partition with quorum * Last updated: Mon Jan 29 12:18:42 2018 * Last change: Mon Jan 29 12:18:40 2018 by root via crm_attribute on node3 * 5 nodes configured * 2 resources configured Node List: * Online: [ node1 node2 node3 node4 node5 ] * Active resources: * Fencing (stonith:fence_xvm): Started node1 * IP (ocf:heartbeat:IPaddr2): Started node2 - + .. topic:: Sample output from crm_mon -n -1 .. code-block:: none Cluster Summary: * Stack: corosync * Current DC: node2 (version 2.0.0-1) - partition with quorum * Last updated: Mon Jan 29 12:21:48 2018 * Last change: Mon Jan 29 12:18:40 2018 by root via crm_attribute on node3 * 5 nodes configured * 2 resources configured * Node List: * Node node1: online * Fencing (stonith:fence_xvm): Started * Node node2: online * IP (ocf:heartbeat:IPaddr2): Started * Node node3: online * Node node4: online * Node node5: online As mentioned in an earlier chapter, the DC is the node is where decisions are made. The cluster elects a node to be DC as needed. The only significance of the choice of DC to an administrator is the fact that its logs will have the most information about why decisions were made. .. index:: pair: crm_mon; CSS .. _crm_mon_css: Styling crm_mon HTML output ___________________________ Various parts of ``crm_mon``'s HTML output have a CSS class associated with them. Not everything does, but some of the most interesting portions do. In the following example, the status of each node has an ``online`` class and the details of each resource have an ``rsc-ok`` class. .. code-block:: html

Node List

  • Node: cluster01 online
    • ping (ocf::pacemaker:ping): Started
  • Node: cluster02 online
    • ping (ocf::pacemaker:ping): Started
By default, a stylesheet for styling these classes is included in the head of the HTML output. The relevant portions of this stylesheet that would be used in the above example is: .. code-block:: css If you want to override some or all of the styling, simply create your own stylesheet, place it on a web server, and pass ``--html-stylesheet=`` to ``crm_mon``. The link is added after the default stylesheet, so your changes take precedence. You don't need to duplicate the entire default. Only include what you want to change. .. index:: single: cibadmin single: command-line tool; cibadmin .. _cibadmin: Edit the CIB XML with cibadmin ############################## The most flexible tool for modifying the configuration is Pacemaker's ``cibadmin`` command. With ``cibadmin``, you can query, add, remove, update or replace any part of the configuration. All changes take effect immediately, so there is no need to perform a reload-like operation. The simplest way of using ``cibadmin`` is to use it to save the current configuration to a temporary file, edit that file with your favorite text or XML editor, and then upload the revised configuration. .. topic:: Safely using an editor to modify the cluster configuration .. code-block:: none # cibadmin --query > tmp.xml # vi tmp.xml # cibadmin --replace --xml-file tmp.xml Some of the better XML editors can make use of a RELAX NG schema to help make sure any changes you make are valid. The schema describing the configuration can be found in ``pacemaker.rng``, which may be deployed in a location such as ``/usr/share/pacemaker`` depending on your operating system distribution and how you installed the software. If you want to modify just one section of the configuration, you can query and replace just that section to avoid modifying any others. - + .. topic:: Safely using an editor to modify only the resources section .. code-block:: none # cibadmin --query --scope resources > tmp.xml # vi tmp.xml # cibadmin --replace --scope resources --xml-file tmp.xml To quickly delete a part of the configuration, identify the object you wish to delete by XML tag and id. For example, you might search the CIB for all STONITH-related configuration: - + .. topic:: Searching for STONITH-related configuration items .. code-block:: none # cibadmin --query | grep stonith If you wanted to delete the ``primitive`` tag with id ``child_DoFencing``, you would run: .. code-block:: none # cibadmin --delete --xml-text '' See the cibadmin man page for more options. .. warning:: Never edit the live ``cib.xml`` file directly. Pacemaker will detect such changes and refuse to use the configuration. .. index:: single: crm_shadow single: command-line tool; crm_shadow .. _crm_shadow: Batch Configuration Changes with crm_shadow ########################################### Often, it is desirable to preview the effects of a series of configuration changes before updating the live configuration all at once. For this purpose, ``crm_shadow`` creates a "shadow" copy of the configuration and arranges for all the command-line tools to use it. To begin, simply invoke ``crm_shadow --create`` with a name of your choice, and follow the simple on-screen instructions. Shadow copies are identified with a name to make it possible to have more than one. .. warning:: Read this section and the on-screen instructions carefully; failure to do so could result in destroying the cluster's active configuration! - + .. topic:: Creating and displaying the active sandbox .. code-block:: none # crm_shadow --create test Setting up shadow instance Type Ctrl-D to exit the crm_shadow shell - shadow[test]: + shadow[test]: shadow[test] # crm_shadow --which test From this point on, all cluster commands will automatically use the shadow copy instead of talking to the cluster's active configuration. Once you have finished experimenting, you can either make the changes active via the ``--commit`` option, or discard them using the ``--delete`` option. Again, be sure to follow the on-screen instructions carefully! - + For a full list of ``crm_shadow`` options and commands, invoke it with the ``--help`` option. .. topic:: Use sandbox to make multiple changes all at once, discard them, and verify real configuration is untouched .. code-block:: none - + shadow[test] # crm_failcount -r rsc_c001n01 -G scope=status name=fail-count-rsc_c001n01 value=0 shadow[test] # crm_standby --node c001n02 -v on shadow[test] # crm_standby --node c001n02 -G scope=nodes name=standby value=on - + shadow[test] # cibadmin --erase --force shadow[test] # cibadmin --query shadow[test] # crm_shadow --delete test --force Now type Ctrl-D to exit the crm_shadow shell shadow[test] # exit # crm_shadow --which No active shadow configuration defined # cibadmin -Q See the next section, :ref:`crm_simulate`, for how to test your changes before committing them to the live cluster. .. index:: single: crm_simulate single: command-line tool; crm_simulate .. _crm_simulate: Simulate Cluster Activity with crm_simulate ########################################### The command-line tool `crm_simulate` shows the results of the same logic the cluster itself uses to respond to a particular cluster configuration and status. As always, the man page is the primary documentation, and should be consulted for further details. This section aims for a better conceptual explanation and practical examples. Replaying cluster decision-making logic _______________________________________ At any given time, one node in a Pacemaker cluster will be elected DC, and that node will run Pacemaker's scheduler to make decisions. Each time decisions need to be made (a "transition"), the DC will have log messages like "Calculated transition ... saving inputs in ..." with a file name. You can grab the named file and replay the cluster logic to see why particular decisions were made. The file contains the live cluster configuration at that moment, so you can also look at it directly to see the value of node attributes, etc., at that time. The simplest usage is (replacing $FILENAME with the actual file name): .. topic:: Simulate cluster response to a given CIB .. code-block:: none # crm_simulate --simulate --xml-file $FILENAME That will show the cluster state when the process started, the actions that need to be taken ("Transition Summary"), and the resulting cluster state if the actions succeed. Most actions will have a brief description of why they were required. The transition inputs may be compressed. ``crm_simulate`` can handle these compressed files directly, though if you want to edit the file, you'll need to uncompress it first. You can do the same simulation for the live cluster configuration at the current moment. This is useful mainly when using ``crm_shadow`` to create a sandbox version of the CIB; the ``--live-check`` option will use the shadow CIB if one is in effect. .. topic:: Simulate cluster response to current live CIB or shadow CIB .. code-block:: none # crm_simulate --simulate --live-check Why decisions were made _______________________ To get further insight into the "why", it gets user-unfriendly very quickly. If you add the ``--show-scores`` option, you will also see all the scores that went into the decision-making. The node with the highest cumulative score for a resource will run it. You can look for ``-INFINITY`` scores in particular to see where complete bans came into effect. You can also add ``-VVVV`` to get more detailed messages about what's happening under the hood. You can add up to two more V's even, but that's usually useful only if you're a masochist or tracing through the source code. Visualizing the action sequence _______________________________ Another handy feature is the ability to generate a visual graph of the actions needed, using the ``--save-dotfile`` option. This relies on the separate Graphviz [#]_ project. .. topic:: Generate a visual graph of cluster actions from a saved CIB .. code-block:: none # crm_simulate --simulate --xml-file $FILENAME --save-dotfile $FILENAME.dot # dot $FILENAME.dot -Tsvg > $FILENAME.svg ``$FILENAME.dot`` will contain a GraphViz representation of the cluster's response to your changes, including all actions with their ordering dependencies. ``$FILENAME.svg`` will be the same information in a standard graphical format that you can view in your browser or other app of choice. You could, of course, use other ``dot`` options to generate other formats. - + How to interpret the graphical output: * Bubbles indicate actions, and arrows indicate ordering dependencies * Resource actions have text of the form ``__ `` indicating that the specified action will be executed for the specified resource on the specified node, once if interval is 0 or at specified recurring interval otherwise * Actions with black text will be sent to the executor (that is, the appropriate agent will be invoked) * Actions with orange text are "pseudo" actions that the cluster uses internally for ordering but require no real activity * Actions with a solid green border are part of the transition (that is, the cluster will attempt to execute them in the given order -- though a transition can be interrupted by action failure or new events) * Dashed arrows indicate dependencies that are not present in the transition graph * Actions with a dashed border will not be executed. If the dashed border is blue, the cluster does not feel the action needs to be executed. If the dashed border is red, the cluster would like to execute the action but cannot. Any actions depending on an action with a dashed border will not be - able to execute. + able to execute. * Loops should not happen, and should be reported as a bug if found. .. topic:: Small Cluster Transition .. image:: ../shared/images/Policy-Engine-small.png :alt: An example transition graph as represented by Graphviz :align: center In the above example, it appears that a new node, ``pcmk-2``, has come online and that the cluster is checking to make sure ``rsc1``, ``rsc2`` and ``rsc3`` are not already running there (indicated by the ``rscN_monitor_0`` entries). Once it did that, and assuming the resources were not active there, it would have liked to stop ``rsc1`` and ``rsc2`` on ``pcmk-1`` and move them to ``pcmk-2``. However, there appears to be some problem and the cluster cannot or is not permitted to perform the stop actions which implies it also cannot perform the start actions. For some reason, the cluster does not want to start ``rsc3`` anywhere. .. topic:: Complex Cluster Transition .. image:: ../shared/images/Policy-Engine-big.png :alt: Complex transition graph that you're not expected to be able to read :align: center What-if scenarios _________________ You can make changes to the saved or shadow CIB and simulate it again, to see how Pacemaker would react differently. You can edit the XML by hand, use command-line tools such as ``cibadmin`` with either a shadow CIB or the ``CIB_file`` environment variable set to the filename, or use higher-level tool support (see the man pages of the specific tool you're using for how to perform actions on a saved CIB file rather than the live CIB). You can also inject node failures and/or action failures into the simulation; see the ``crm_simulate`` man page for more details. This capability is useful when using a shadow CIB to edit the configuration. Before committing the changes to the live cluster with ``crm_shadow --commit``, you can use ``crm_simulate`` to see how the cluster will react to the changes. .. _crm_attribute: .. index:: single: attrd_updater single: command-line tool; attrd_updater single: crm_attribute single: command-line tool; crm_attribute Manage Node Attributes, Cluster Options and Defaults with crm_attribute and attrd_updater ######################################################################################### ``crm_attribute`` and ``attrd_updater`` are confusingly similar tools with subtle differences. ``attrd_updater`` can query and update node attributes. ``crm_attribute`` can query and update not only node attributes, but also cluster options, resource defaults, and operation defaults. To understand the differences, it helps to understand the various types of node attribute. -.. table:: **Types of Node Attributes** - - +-----------+----------+-------------------+------------------+----------------+----------------+ - | Type | Recorded | Recorded in | Survive full | Manageable by | Manageable by | - | | in CIB? | attribute manager | cluster restart? | crm_attribute? | attrd_updater? | - | | | memory? | | | | - +===========+==========+===================+==================+================+================+ - | permanent | yes | no | yes | yes | no | - +-----------+----------+-------------------+------------------+----------------+----------------+ - | transient | yes | yes | no | yes | yes | - +-----------+----------+-------------------+------------------+----------------+----------------+ - | private | no | yes | no | no | yes | - +-----------+----------+-------------------+------------------+----------------+----------------+ +.. list-table:: **Types of Node Attributes** + :widths: 20 16 16 16 16 16 + :header-rows: 1 + + * - Type + - Recorded in CIB? + - Recorded in attribute manager memory? + - Survive full cluster restart? + - Manageable by by crm_attribute? + - Manageable by attrd_updater? + * - permanent + - yes + - no + - yes + - yes + - no + * - transient + - yes + - yes + - no + - yes + - yes + * - private + - no + - yes + - no + - no + - yes As you can see from the table above, ``crm_attribute`` can manage permanent and transient node attributes, while ``attrd_updater`` can manage transient and private node attributes. The difference between the two tools lies mainly in *how* they update node attributes: ``attrd_updater`` always contacts the Pacemaker attribute manager directly, while ``crm_attribute`` will contact the attribute manager only for transient node attributes, and will instead modify the CIB directly for permanent node attributes (and for transient node attributes when unable to contact the attribute manager). By contacting the attribute manager directly, ``attrd_updater`` can change an attribute's "dampening" (whether changes are immediately flushed to the CIB or after a specified amount of time, to minimize disk writes for frequent changes), set private node attributes (which are never written to the CIB), and set attributes for nodes that don't yet exist. By modifying the CIB directly, ``crm_attribute`` can set permanent node attributes (which are only in the CIB and not managed by the attribute manager), and can be used with saved CIB files and shadow CIBs. However a transient node attribute is set, it is synchronized between the CIB and the attribute manager, on all nodes. .. index:: single: crm_failcount single: command-line tool; crm_failcount single: crm_node single: command-line tool; crm_node single: crm_report single: command-line tool; crm_report single: crm_standby single: command-line tool; crm_standby single: crm_verify single: command-line tool; crm_verify single: stonith_admin single: command-line tool; stonith_admin Other Commonly Used Tools ######################### Other command-line tools include: * ``crm_failcount``: query or delete resource fail counts * ``crm_node``: manage cluster nodes * ``crm_report``: generate a detailed cluster report for bug submissions * ``crm_resource``: manage cluster resources * ``crm_standby``: manage standby status of nodes * ``crm_verify``: validate a CIB * ``stonith_admin``: manage fencing devices See the manual pages for details. .. rubric:: Footnotes .. [#] Graph visualization software. See http://www.graphviz.org/ for details. diff --git a/doc/sphinx/Pacemaker_Administration/troubleshooting.rst b/doc/sphinx/Pacemaker_Administration/troubleshooting.rst index 4f24725979..ac1b810611 100644 --- a/doc/sphinx/Pacemaker_Administration/troubleshooting.rst +++ b/doc/sphinx/Pacemaker_Administration/troubleshooting.rst @@ -1,128 +1,128 @@ .. index:: troubleshooting Troubleshooting Cluster Problems -------------------------------- .. index:: logging, pacemaker.log Logging ####### Pacemaker by default logs messages of ``notice`` severity and higher to the system log, and messages of ``info`` severity and higher to the detail log, which by default is ``/var/log/pacemaker/pacemaker.log``. Logging options can be controlled via environment variables at Pacemaker start-up. Where these are set varies by operating system (often ``/etc/sysconfig/pacemaker`` or ``/etc/default/pacemaker``). See the comments in that file for details. Because cluster problems are often highly complex, involving multiple machines, cluster daemons, and managed services, Pacemaker logs rather verbosely to provide as much context as possible. It is an ongoing priority to make these logs more user-friendly, but by necessity there is a lot of obscure, low-level information that can make them difficult to follow. The default log rotation configuration shipped with Pacemaker (typically installed in ``/etc/logrotate.d/pacemaker``) rotates the log when it reaches 100MB in size, or weekly, whichever comes first. If you configure debug or (Heaven forbid) trace-level logging, the logs can grow enormous quite quickly. Because rotated logs are by default named with the year, month, and day only, this can cause name collisions if your logs exceed 100MB in a single day. You can add ``dateformat -%Y%m%d-%H`` to the rotation configuration to avoid this. Reading the Logs ################ When troubleshooting, first check the system log or journal for errors or warnings from Pacemaker components (conveniently, they will all have "pacemaker" in their logged process name). For example: .. code-block:: none # grep 'pacemaker.*\(error\|warning\)' /var/log/messages Mar 29 14:04:19 node1 pacemaker-controld[86636]: error: Result of monitor operation for rn2 on node1: Timed Out after 45s (Remote executor did not respond) If that doesn't give sufficient information, next look at the ``notice`` level messages from ``pacemaker-controld``. These will show changes in the state of cluster nodes. On the DC, this will also show resource actions attempted. For example: .. code-block:: none # grep 'pacemaker-controld.*notice:' /var/log/messages ... output skipped for brevity ... Mar 29 14:05:36 node1 pacemaker-controld[86636]: notice: Node rn2 state is now lost ... more output skipped for brevity ... Mar 29 14:12:17 node1 pacemaker-controld[86636]: notice: Initiating stop operation rsc1_stop_0 on node4 ... more output skipped for brevity ... Of course, you can use other tools besides ``grep`` to search the logs. .. index:: transition Transitions ########### A key concept in understanding how a Pacemaker cluster functions is a *transition*. A transition is a set of actions that need to be taken to bring the cluster from its current state to the desired state (as expressed by the configuration). Whenever a relevant event happens (a node joining or leaving the cluster, a resource failing, etc.), the controller will ask the scheduler to recalculate the status of the cluster, which generates a new transition. The controller then performs the actions in the transition in the proper order. Each transition can be identified in the DC's logs by a line like: .. code-block:: none notice: Calculated transition 19, saving inputs in /var/lib/pacemaker/pengine/pe-input-1463.bz2 The file listed as the "inputs" is a snapshot of the cluster configuration and state at that moment (the CIB). This file can help determine why particular actions were scheduled. The ``crm_simulate`` command, described in :ref:`crm_simulate`, can be used to replay the file. The log messages immediately before the "saving inputs" message will include any actions that the scheduler thinks need to be done. .. important:: - + Any actions that have already been initiated must complete (or time out) before a new transition can be calculated. Node Failures ############# When a node fails, and looking at errors and warnings doesn't give an obvious explanation, try to answer questions like the following based on log messages: * When and what was the last successful message on the node itself, or about that node in the other nodes' logs? * Did pacemaker-controld on the other nodes notice the node leave? * Did pacemaker-controld on the DC invoke the scheduler and schedule a new transition? * Did the transition include fencing the failed node? * Was fencing attempted? * Did fencing succeed? Resource Failures ################# When a resource fails, and looking at errors and warnings doesn't give an obvious explanation, try to answer questions like the following based on log messages: * Did pacemaker-controld record the result of the failed resource action? * What was the failed action's execution status and exit status? * What code in the resource agent could result in those status codes? * Did pacemaker-controld on the DC invoke the scheduler and schedule a new transition? * Did the new transition include recovery of the resource? * Were the recovery actions initiated, and what were their results? diff --git a/doc/sphinx/Pacemaker_Administration/upgrading.rst b/doc/sphinx/Pacemaker_Administration/upgrading.rst index b23c65ea89..9d87bca571 100644 --- a/doc/sphinx/Pacemaker_Administration/upgrading.rst +++ b/doc/sphinx/Pacemaker_Administration/upgrading.rst @@ -1,565 +1,579 @@ .. index:: upgrade Upgrading a Pacemaker Cluster ----------------------------- .. index:: version Pacemaker Versioning #################### Pacemaker has an overall release version, plus separate version numbers for certain internal components. .. index:: single: version; release * **Pacemaker release version:** This version consists of three numbers (*x.y.z*). The major version number (the *x* in *x.y.z*) increases when at least some rolling upgrades are not possible from the previous major version. For example, a rolling upgrade from 1.0.8 to 1.1.15 should always be supported, but a rolling upgrade from 1.0.8 to 2.0.0 may not be possible. The minor version (the *y* in *x.y.z*) increases when there are significant changes in cluster default behavior, tool behavior, and/or the API interface (for software that utilizes Pacemaker libraries). The main benefit is to alert you to pay closer attention to the release notes, to see if you might be affected. The release counter (the *z* in *x.y.z*) is increased with all public releases of Pacemaker, which typically include both bug fixes and new features. .. index:: single: feature set single: version; feature set * **CRM feature set:** This version number applies to the communication between full cluster nodes, and is used to avoid problems in mixed-version clusters. The major version number increases when nodes with different versions would not work (rolling upgrades are not allowed). The minor version number increases when mixed-version clusters are allowed only during rolling upgrades. The minor-minor version number is ignored, but allows resource agents to detect cluster support for various features. [#]_ Pacemaker ensures that the longest-running node is the cluster's DC. This ensures new features are not enabled until all nodes are upgraded to support them. .. index:: single: version; Pacemaker Remote protocol * **Pacemaker Remote protocol version:** This version applies to communication between a Pacemaker Remote node and the cluster. It increases when an older cluster node would have problems hosting the connection to a newer Pacemaker Remote node. To avoid these problems, Pacemaker Remote nodes will accept connections only from cluster nodes with the same or newer Pacemaker Remote protocol version. Unlike with CRM feature set differences between full cluster nodes, mixed Pacemaker Remote protocol versions between Pacemaker Remote nodes and full cluster nodes are fine, as long as the Pacemaker Remote nodes have the older version. This can be useful, for example, to host a legacy application in an older operating system version used as a Pacemaker Remote node. .. index:: single: version; XML schema * **XML schema version:** Pacemaker’s configuration syntax — what's allowed in the Configuration Information Base (CIB) — has its own version. This allows the configuration syntax to evolve over time while still allowing clusters with older configurations to work without change. .. index:: single: upgrade; methods Upgrading Cluster Software ########################## There are three approaches to upgrading a cluster, each with advantages and disadvantages. -.. table:: **Upgrade Methods** - - +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ - | Method | Available| Can be | Service| Service | Exercises| Allows | - | | between | used with| outage | recovery| failover | change of| - | | all | Pacemaker| during | during | logic | messaging| - | | versions | Remote | upgrade| upgrade | | layer | - | | | nodes | | | | [#]_ | - +===================================================+==========+==========+========+=========+==========+==========+ - | Complete cluster shutdown | yes | yes | always | N/A | no | yes | - +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ - | Rolling (node by node) | no | yes | always | yes | yes | no | - | | | | [#]_ | | | | - +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ - | Detach and reattach | yes | no | only | no | no | yes | - | | | | due to | | | | - | | | | failure| | | | - +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ +.. list-table:: **Upgrade Methods** + :widths: 16 14 14 14 14 14 14 + :header-rows: 1 + + * - Method + - Available between all versions + - Can be used with Pacemaker Remote nodes + - Service outage during upgrade + - Service recovery during upgrade + - Exercises failover logic + - Allows change of messaging layer [#]_ + * - Complete cluster shutdown + - yes + - yes + - always + - N/A + - no + - yes + * - Rolling (node by node) + - no + - yes + - always [#]_ + - yes + - yes + - no + * - Detach and reattach + - yes + - no + - only due to failure + - no + - no + - yes .. index:: single: upgrade; shutdown Complete Cluster Shutdown _________________________ In this scenario, one shuts down all cluster nodes and resources, then upgrades all the nodes before restarting the cluster. #. On each node: a. Shutdown the cluster software (pacemaker and the messaging layer). #. Upgrade the Pacemaker software. This may also include upgrading the messaging layer and/or the underlying operating system. #. Check the configuration with the ``crm_verify`` tool. #. On each node: a. Start the cluster software. Currently, only Corosync version 2 and greater is supported as the cluster layer, but if another stack is supported in the future, the stack does not need to be the same one before the upgrade. One variation of this approach is to build a new cluster on new hosts. This allows the new version to be tested beforehand, and minimizes downtime by having the new nodes ready to be placed in production as soon as the old nodes are shut down. .. index:: single: upgrade; rolling upgrade Rolling (node by node) ______________________ In this scenario, each node is removed from the cluster, upgraded, and then brought back online, until all nodes are running the newest version. Special considerations when planning a rolling upgrade: * If you plan to upgrade other cluster software -- such as the messaging layer -- at the same time, consult that software's documentation for its compatibility with a rolling upgrade. * If the major version number is changing in the Pacemaker version you are upgrading to, a rolling upgrade may not be possible. Read the new version's release notes (as well the information here) for what limitations may exist. * If the CRM feature set is changing in the Pacemaker version you are upgrading to, you should run a mixed-version cluster only during a small rolling upgrade window. If one of the older nodes drops out of the cluster for any reason, it will not be able to rejoin until it is upgraded. * If the Pacemaker Remote protocol version is changing, all cluster nodes should be upgraded before upgrading any Pacemaker Remote nodes. See the `Pacemaker release calendar `_ on the ClusterLabs wiki to figure out whether the CRM feature set and/or Pacemaker Remote protocol version changed between the Pacemaker release versions in your rolling upgrade. To perform a rolling upgrade, on each node in turn: #. Put the node into standby mode, and wait for any active resources to be moved cleanly to another node. (This step is optional, but allows you to deal with any resource issues before the upgrade.) #. Shut down Pacemaker or ``pacemaker-remoted``. #. If a cluster node, shut down the messaging layer. #. Upgrade the Pacemaker software. This may also include upgrading the messaging layer and/or the underlying operating system. #. If this is the first node to be upgraded, check the configuration with the ``crm_verify`` tool. #. If a cluster node, start the messaging layer. This must be the same messaging layer (currently only Corosync version 2 and greater is supported) that the rest of the cluster is using. #. Start Pacemaker or ``pacemaker-remoted``. .. note:: Even if a rolling upgrade from the current version of the cluster to the newest version is not directly possible, it may be possible to perform a rolling upgrade in multiple steps, by upgrading to an intermediate version first. The following table lists compatible versions for all other nodes in the cluster when upgrading a cluster node. .. list-table:: **Version Compatibility for Cluster Nodes** :class: longtable - :widths: 1 1 + :widths: 50 50 :header-rows: 1 * - Version Being Installed - Minimum Compatible Version * - Pacemaker 3.y.z - Pacemaker 2.0.0 * - Pacemaker 2.y.z - Pacemaker 1.1.11 [#]_ * - Pacemaker 1.y.z - Pacemaker 1.0.0 * - Pacemaker 0.6.z to 0.7.z - Pacemaker 0.6.0 When upgrading a Pacemaker Remote node, all cluster nodes must be running at least the minimum version listed in the table below. .. list-table:: **Cluster Node Version Compatibility for Pacemaker Remote Nodes** :class: longtable - :widths: 1 1 + :widths: 50 50 :header-rows: 1 * - Pacemaker Remote Version - Minimum Cluster Node Version * - Pacemaker 3.y.z - Pacemaker 2.0.0 * - Pacemaker 1.1.9 to 2.1.z - Pacemaker 1.1.9 [#]_ .. index:: single: upgrade; detach and reattach Detach and Reattach ___________________ The reattach method is a variant of a complete cluster shutdown, where the resources are left active and get re-detected when the cluster is restarted. This method may not be used if the cluster contains any Pacemaker Remote nodes. #. Tell the cluster to stop managing services. This is required to allow the services to remain active after the cluster shuts down. .. code-block:: none # crm_attribute --name maintenance-mode --update true #. On each node, shutdown the cluster software (pacemaker and the messaging layer), and upgrade the Pacemaker software. This may also include upgrading the messaging layer. While the underlying operating system may be upgraded at the same time, that will be more likely to cause outages in the detached services (certainly, if a reboot is required). #. Check the configuration with the ``crm_verify`` tool. #. On each node, start the cluster software. Currently, only Corosync version 2 and greater is supported as the cluster layer, but if another stack is supported in the future, the stack does not need to be the same one before the upgrade. #. Verify that the cluster re-detected all resources correctly. #. Allow the cluster to resume managing resources again: .. code-block:: none # crm_attribute --name maintenance-mode --delete .. note:: While the goal of the detach-and-reattach method is to avoid disturbing running services, resources may still move after the upgrade if any resource's location is governed by a rule based on transient node attributes. Transient node attributes are erased when the node leaves the cluster. A common example is using the ``ocf:pacemaker:ping`` resource to set a node attribute used to locate other resources. .. index:: pair: upgrade; CIB Upgrading the Configuration ########################### The CIB schema version can change from one Pacemaker version to another. After cluster software is upgraded, the cluster will continue to use the older schema version that it was previously using. This can be useful, for example, when administrators have written tools that modify the configuration, and are based on the older syntax. [#]_ However, when using an older syntax, new features may be unavailable, and there is a performance impact, since the cluster must do a non-persistent configuration upgrade before each transition. So while using the old syntax is possible, it is not advisable to continue using it indefinitely. Even if you wish to continue using the old syntax, it is a good idea to follow the upgrade procedure outlined below, except for the last step, to ensure that the new software has no problems with your existing configuration (since it will perform much the same task internally). If you are brave, it is sufficient simply to run ``cibadmin --upgrade``. A more cautious approach would proceed like this: #. Create a shadow copy of the configuration. The later commands will automatically operate on this copy, rather than the live configuration. .. code-block:: none # crm_shadow --create shadow .. index:: single: configuration; verify #. Verify the configuration is valid with the new software (which may be stricter about syntax mistakes, or may have dropped support for deprecated features): .. code-block:: none # crm_verify --live-check #. Fix any errors or warnings. #. Perform the upgrade: .. code-block:: none # cibadmin --upgrade #. If this step fails, there are three main possibilities: a. The configuration was not valid to start with (did you do steps 2 and 3?). #. The transformation failed; `report a bug `_. #. The transformation was successful but produced an invalid result. If the result of the transformation is invalid, you may see a number of errors from the validation library. If these are not helpful, try the manual upgrade procedure described below. #. Check the changes: .. code-block:: none # crm_shadow --diff If at this point there is anything about the upgrade that you wish to fine-tune (for example, to change some of the automatic IDs), now is the time to do so: .. code-block:: none # crm_shadow --edit This will open the configuration in your favorite editor (whichever is specified by the standard ``$EDITOR`` environment variable). #. Preview how the cluster will react: .. code-block:: none # crm_simulate --live-check --save-dotfile shadow.dot -S # dot -Tsvg shadow.dot -o shadow.svg You can then view shadow.svg with any compatible image viewer or web browser. Verify that either no resource actions will occur or that you are happy with any that are scheduled. If the output contains actions you do not expect (possibly due to changes to the score calculations), you may need to make further manual changes. See :ref:`crm_simulate` for further details on how to interpret the output of ``crm_simulate`` and ``dot``. #. Upload the changes: .. code-block:: none # crm_shadow --commit shadow --force In the unlikely event this step fails, please report a bug. .. note:: It is also possible to perform the configuration upgrade steps manually: #. Locate the ``upgrade*.xsl`` conversion scripts provided with the source code. These will often be installed in a location such as ``/usr/share/pacemaker``, or may be obtained from the `source repository `_. - + #. Run the conversion scripts that apply to your older version, for example: .. code-block:: none # xsltproc /path/to/upgrade06.xsl config06.xml > config10.xml #. Locate the ``pacemaker.rng`` script (from the same location as the xsl files). #. Check the XML validity: .. code-block:: none # xmllint --relaxng /path/to/pacemaker.rng config10.xml The advantage of this method is that it can be performed without the cluster running, and any validation errors are often more informative. What Changed in 2.1 ################### The Pacemaker 2.1 release is fully backward-compatible in both the CIB XML and the C API. Highlights: * Pacemaker now supports the **OCF Resource Agent API version 1.1**. Most notably, the ``Master`` and ``Slave`` role names have been renamed to ``Promoted`` and ``Unpromoted``. * Pacemaker now supports colocations where the dependent resource does not affect the primary resource's placement (via a new ``influence`` colocation constraint option and ``critical`` resource meta-attribute). This is intended for cases where a less-important resource must be colocated with an essential resource, but it is preferred to leave the less-important resource stopped if it fails, rather than move both resources. * If Pacemaker is built with libqb 2.0 or later, the detail log will use **millisecond-resolution timestamps**. * In addition to crm_mon and stonith_admin, the crmadmin, crm_resource, crm_simulate, and crm_verify commands now support the ``--output-as`` and ``--output-to`` options, including **XML output** (which scripts and higher-level tools are strongly recommended to use instead of trying to parse the text output, which may change from release to release). For a detailed list of changes, see the release notes and `Pacemaker 2.1 Changes `_ on the ClusterLabs wiki. What Changed in 2.0 ################### The main goal of the 2.0 release was to remove support for deprecated syntax, along with some small changes in default configuration behavior and tool behavior. Highlights: * Only Corosync version 2 and greater is now supported as the underlying cluster layer. Support for Heartbeat and Corosync 1 (including CMAN) is removed. * The Pacemaker detail log file is now stored in ``/var/log/pacemaker/pacemaker.log`` by default. * The record-pending cluster property now defaults to true, which allows status tools such as crm_mon to show operations that are in progress. * Support for a number of deprecated build options, environment variables, and configuration settings has been removed. * The ``master`` tag has been deprecated in favor of using the ``clone`` tag with the new ``promotable`` meta-attribute set to ``true``. "Master/slave" clone resources are now referred to as "promotable" clone resources. * The public API for Pacemaker libraries that software applications can use has changed significantly. For a detailed list of changes, see the release notes and `Pacemaker 2.0 Changes `_ on the ClusterLabs wiki. What Changed in 1.0 ################### New ___ * Failure timeouts. * New section for resource and operation defaults. * Tool for making offline configuration changes. * ``Rules``, ``instance_attributes``, ``meta_attributes`` and sets of operations can be defined once and referenced in multiple places. * The CIB now accepts XPath-based create/modify/delete operations. See ``cibadmin --help``. * Multi-dimensional colocation and ordering constraints. * The ability to connect to the CIB from non-cluster machines. * Allow recurring actions to be triggered at known times. Changed _______ * Syntax * All resource and cluster options now use dashes (-) instead of underscores (_) * ``master_slave`` was renamed to ``master`` * The ``attributes`` container tag was removed * The operation field ``pre-req`` has been renamed ``requires`` * All operations must have an ``interval``, ``start``/``stop`` must have it set to zero * The ``stonith-enabled`` option now defaults to true. * The cluster will refuse to start resources if ``stonith-enabled`` is true (or unset) and no STONITH resources have been defined * The attributes of colocation and ordering constraints were renamed for clarity. * ``resource-failure-stickiness`` has been replaced by ``migration-threshold``. * The parameters for command-line tools have been made consistent * Switched to 'RelaxNG' schema validation and 'libxml2' parser * id fields are now XML IDs which have the following limitations: * id's cannot contain colons (:) * id's cannot begin with a number * id's must be globally unique (not just unique for that tag) * Some fields (such as those in constraints that refer to resources) are IDREFs. This means that they must reference existing resources or objects in order for the configuration to be valid. Removing an object which is referenced elsewhere will therefore fail. * The CIB representation, from which a MD5 digest is calculated to verify CIBs on the nodes, has changed. This means that every CIB update will require a full refresh on any upgraded nodes until the cluster is fully upgraded to 1.0. This will result in significant performance degradation and it is therefore highly inadvisable to run a mixed 1.0/0.6 cluster for any longer than absolutely necessary. * Ping node information no longer needs to be added to ``ha.cf``. Simply include the lists of hosts in your ping resource(s). Removed _______ * Syntax * It is no longer possible to set resource meta options as top-level attributes. Use meta-attributes instead. * Resource and operation defaults are no longer read from ``crm_config``. .. rubric:: Footnotes .. [#] Before CRM feature set 3.1.0 (Pacemaker 2.0.0), the minor-minor version number was treated the same as the minor version. .. [#] Currently, Corosync version 2 and greater is the only supported cluster stack, but other stacks have been supported by past versions, and may be supported by future versions. .. [#] Any active resources will be moved off the node being upgraded, so there will be at least a brief outage unless all resources can be migrated "live". .. [#] Rolling upgrades from Pacemaker 1.1.z to 2.y.z are possible only if the cluster uses corosync version 2 or greater as its messaging layer, and the Cluster Information Base (CIB) uses schema 1.0 or higher in its ``validate-with`` property. .. [#] Pacemaker Remote versions 1.1.15 through 1.1.17 require cluster nodes to be at least version 1.1.15. Version 1.1.15 introduced an accidental remote protocol version bump, breaking rolling upgrade compatibility with older versions. This was fixed in 1.1.18. .. [#] As of Pacemaker 2.0.0, only schema versions pacemaker-1.0 and higher are supported (excluding pacemaker-1.1, which was a special case). diff --git a/doc/sphinx/Pacemaker_Development/c.rst b/doc/sphinx/Pacemaker_Development/c.rst index 8d879617f1..1586c822a0 100644 --- a/doc/sphinx/Pacemaker_Development/c.rst +++ b/doc/sphinx/Pacemaker_Development/c.rst @@ -1,1151 +1,1187 @@ .. index:: single: C pair: C; guidelines C Coding Guidelines ------------------- Pacemaker is a large project accepting contributions from developers with a wide range of skill levels and organizational affiliations, and maintained by multiple people over long periods of time. Following consistent guidelines makes reading, writing, and reviewing code easier, and helps avoid common mistakes. Some existing Pacemaker code does not follow these guidelines, for historical reasons and API backward compatibility, but new code should. Code Organization ################# Pacemaker's C code is organized as follows: -+-----------------+-----------------------------------------------------------+ -| Directory | Contents | -+=================+===========================================================+ -| daemons | the Pacemaker daemons (pacemakerd, pacemaker-based, etc.) | -+-----------------+-----------------------------------------------------------+ -| include | header files for library APIs | -+-----------------+-----------------------------------------------------------+ -| lib | libraries | -+-----------------+-----------------------------------------------------------+ -| tools | command-line tools | -+-----------------+-----------------------------------------------------------+ +.. list-table:: **C Code Organization** + :widths: 25 75 + :header-rows: 1 + + * - Directory + - Contents + * - daemons + - the Pacemaker daemons (pacemakerd, pacemaker-based, etc.) + * - include + - header files for library APIs + * - lib + - libraries + * - tools + - command-line tools Source file names should be unique across the entire project, to allow for individual tracing via ``PCMK_trace_files``. .. index:: single: C; library single: C library Pacemaker Libraries ################### -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| Library | Symbol | Source | API Headers | Description | -| | prefix | location | | | -+===============+=========+===============+===========================+=====================================+ -| libcib | cib | lib/cib | | include/crm/cib.h | .. index:: | -| | | | | include/crm/cib/* | single: C library; libcib | -| | | | | single: libcib | -| | | | | | -| | | | | API for pacemaker-based IPC and | -| | | | | the CIB | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libcrmcluster | pcmk | lib/cluster | | include/crm/cluster.h | .. index:: | -| | | | | include/crm/cluster/* | single: C library; libcrmcluster | -| | | | | single: libcrmcluster | -| | | | | | -| | | | | Abstract interface to underlying | -| | | | | cluster layer | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libcrmcommon | pcmk | lib/common | | include/crm/common/* | .. index:: | -| | | | | some of include/crm/* | single: C library; libcrmcommon | -| | | | | single: libcrmcommon | -| | | | | | -| | | | | Everything else | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libcrmservice | svc | lib/services | | include/crm/services.h | .. index:: | -| | | | | single: C library; libcrmservice | -| | | | | single: libcrmservice | -| | | | | | -| | | | | Abstract interface to supported | -| | | | | resource types (OCF, LSB, etc.) | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| liblrmd | lrmd | lib/lrmd | | include/crm/lrmd*.h | .. index:: | -| | | | | single: C library; liblrmd | -| | | | | single: liblrmd | -| | | | | | -| | | | | API for pacemaker-execd IPC | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libpacemaker | pcmk | lib/pacemaker | | include/pacemaker*.h | .. index:: | -| | | | | include/pcmki/* | single: C library; libpacemaker | -| | | | | single: libpacemaker | -| | | | | | -| | | | | High-level APIs equivalent to | -| | | | | command-line tool capabilities | -| | | | | (and high-level internal APIs) | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libpe_rules | pe | lib/pengine | | include/crm/pengine/* | .. index:: | -| | | | | single: C library; libpe_rules | -| | | | | single: libpe_rules | -| | | | | | -| | | | | Deprecated APIs related to | -| | | | | evaluating rules | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libpe_status | pe | lib/pengine | | include/crm/pengine/* | .. index:: | -| | | | | single: C library; libpe_status | -| | | | | single: libpe_status | -| | | | | | -| | | | | Low-level scheduler functionality | -+---------------+---------+---------------+---------------------------+-------------------------------------+ -| libstonithd | stonith | lib/fencing | | include/crm/stonith-ng.h| .. index:: | -| | | | | include/crm/fencing/* | single: C library; libstonithd | -| | | | | single: libstonithd | -| | | | | | -| | | | | API for pacemaker-fenced IPC | -+---------------+---------+---------------+---------------------------+-------------------------------------+ +.. list-table:: **C Libraries** + :class: longtable + :widths: 15 10 15 25 35 + :header-rows: 1 + + * - Library + - Symbol Prefix + - Source Location + - API Headers + - Description + * - libcib + - cib + - lib/cib + - | include/crm/cib.h + | include/crm/cib/ + - .. index:: + single: C library; libcib + single: libcib + + API for pacemaker-based IPC and the CIB + * - libcrmcluster + - pcmk + - lib/cluster + - | include/crm/cluster.h + | include/crm/cluster/ + - .. index:: + single: C library; libcrmcluster + single: libcrmcluster + + Abstract interface to underlying cluster layer + * - libcrmcommon + - pcmk + - lib/common + - | include/crm/common/ + | some of include/crm/ + - .. index:: + single: C library; libcrmcommon + single: libcrmcommon + + Everything else + * - libcrmservice + - services, svc + - lib/services + - include/crm/services.h + - .. index:: + single: C library; libcrmservice + single: libcrmservice + + Abstract interface to supported resource types (OCF, LSB, etc.) + * - liblrmd + - lrmd + - lib/lrmd + - include/crm/lrmd*.h + - .. index:: + single: C library; liblrmd + single: liblrmd + + API for pacemaker-execd IPC + * - libpacemaker + - pcmk + - lib/pacemaker + - | include/pacemaker*.h + | include/pcmki/ + - .. index:: + single: C library; libpacemaker + single: libpacemaker + + High-level APIs equivalent to command-line tool capabilities + (and high-level internal APIs) + * - libpe_rules + - pe + - lib/pengine + - include/crm/pengine/ + - .. index:: + single: C library; libpe_rules + single: libpe_rules + + Deprecated APIs related to evaluating rules + * - libpe_status + - pe + - lib/pengine + - include/crm/pengine/ + - .. index:: + single: C library; libpe_status + single: libpe_status + + Low-level scheduler functionality + * - libstonithd + - stonith + - lib/fencing + - | include/crm/stonith-ng.h + | include/crm/fencing + - .. index:: + single: C library; libstonithd + single: libstonithd + + API for pacemaker-fenced IPC Public versus Internal APIs ___________________________ Pacemaker libraries have both internal and public APIs. Internal APIs are those used only within Pacemaker; public APIs are those offered (via header files and documentation) for external code to use. Generic functionality needed by Pacemaker itself, such as string processing or XML processing, should remain internal, while functions providing useful high-level access to Pacemaker capabilities should be public. When in doubt, keep APIs internal, because it's easier to expose a previously internal API than hide a previously public API. Internal APIs can be changed as needed. The public API/ABI should maintain a degree of stability so that external applications using it do not need to be rewritten or rebuilt frequently. Many OSes/distributions avoid breaking API/ABI compatibility within a major release, so if Pacemaker breaks compatibility, that significantly delays when OSes can package the new version. Therefore, changes to public APIs should be backward-compatible (as detailed throughout this chapter), unless we are doing a (rare) release where we specifically intend to break compatibility. External applications known to use Pacemaker's public C API include `sbd `_ and dlm_controld. .. index:: pair: C; naming API Symbol Naming _________________ Exposed API symbols (non-``static`` function names, ``struct`` and ``typedef`` names in header files, etc.) must begin with the prefix appropriate to the library (shown in the table at the beginning of this section). This reduces the chance of naming collisions when external software links against the library. The prefix is usually lowercase but may be all-caps for some defined constants and macros. Public API symbols should follow the library prefix with a single underbar (for example, ``pcmk_something``), and internal API symbols with a double underbar (for example, ``pcmk__other_thing``). File-local symbols (such as static functions) and non-library code do not require a prefix, though a unique prefix indicating an executable (controld, crm_mon, etc.) can be helpful when symbols are shared between multiple source files for the executable. API Header File Naming ______________________ * Internal API headers should be named ending in ``_internal.h``, in the same location as public headers, with the exception of libpacemaker, which for historical reasons keeps internal headers in ``include/pcmki/pcmki_*.h``). * If a library needs to share symbols just within the library, header files for these should be named ending in ``_private.h`` and located in the library source directory (not ``include``). Such functions should be declared as ``G_GNUC_INTERNAL``, to aid compiler efficiency (glib defines this symbol appropriately for the compiler). Header files that are not library API are kept in the same directory as the source code they're included from. The easiest way to tell what kind of API a symbol is, is to see where it's declared. If it's in a public header, it's public API; if it's in an internal header, it's internal API; if it's in a library-private header, it's library-private API; otherwise, it's not an API. .. index:: pair: C; API documentation single: Doxygen API Documentation _________________ Pacemaker uses `Doxygen `_ to automatically generate its `online API documentation `_, so all public API (header files, functions, structs, enums, etc.) should be documented with Doxygen comment blocks. Other code may be documented in the same way if desired, with an ``\internal`` tag in the Doxygen comment. Simple example of an internal function with a Doxygen comment block: .. code-block:: c /*! * \internal * \brief Return string length plus 1 * * Return the number of characters in a given string, plus one. * * \param[in] s A string (must not be NULL) * * \return The length of \p s plus 1. */ static int f(const char *s) { return strlen(s) + 1; } Function arguments are marked as ``[in]`` for input only, ``[out]`` for output only, or ``[in,out]`` for both input and output. ``[in,out]`` should be used for struct pointer arguments if the function can change any data accessed via the pointer. For example, if the struct contains a ``GHashTable *`` member, the argument should be marked as ``[in,out]`` if the function inserts data into the table, even if the struct members themselves are not changed. However, an argument is not ``[in,out]`` if something reachable via the argument is modified via a separate argument. For example, both ``pcmk_resource_t`` and ``pcmk_node_t`` contain pointers to their ``pcmk_scheduler_t`` and thus indirectly to each other, but if the function modifies the resource via the resource argument, the node argument does not have to be ``[in,out]``. Public API Deprecation ______________________ Public APIs may not be removed in most Pacemaker releases, but they may be deprecated. When a public API is deprecated, it is moved to a header whose name ends in ``compat.h``. The original header includes the compatibility header only if the ``PCMK_ALLOW_DEPRECATED`` symbol is undefined or defined to 1. This allows external code to continue using the deprecated APIs, but internal code is prevented from using them because the ``crm_internal.h`` header defines the symbol to 0. .. index:: pair: C; boilerplate pair: license; C pair: copyright; C C Boilerplate ############# Every C file should start with a short copyright and license notice: .. code-block:: c /* * Copyright the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under WITHOUT ANY WARRANTY. */ ** should follow the policy set forth in the `COPYING `_ file, generally one of "GNU General Public License version 2 or later (GPLv2+)" or "GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)". Header files should additionally protect against multiple inclusion by defining a unique symbol of the form ``PCMK____H``, and declare C compatibility for inclusion by C++. For example: .. code-block:: c #ifndef PCMK__MY_HEADER__H #define PCMK__MY_HEADER__H // put #include directives here #ifdef __cplusplus extern "C" { #endif // put header code here #ifdef __cplusplus } #endif #endif // PCMK__MY_HEADER__H Public API header files should give a Doxygen file description at the top of the header code. For example: .. code-block:: c /*! * \file * \brief My brief description here * \ingroup core */ .. index:: pair: C; whitespace Line Formatting ############### * Indentation must be 4 spaces, no tabs. * Do not leave trailing whitespace. * Lines should be no longer than 80 characters unless limiting line length hurts readability. .. index:: pair: C; comment Comments ######## .. code-block:: c /* Single-line comments may look like this */ // ... or this /* Multi-line comments should start immediately after the comment opening. * Subsequent lines should start with an aligned asterisk. The comment * closing should be aligned and on a line by itself. */ .. index:: pair: C; operator Operators ######### .. code-block:: c // Operators have spaces on both sides x = a; /* (1) Do not rely on operator precedence; use parentheses when mixing * operators with different priority, for readability. * (2) No space is used after an opening parenthesis or before a closing * parenthesis. */ x = a + b - (c * d); .. index:: single: C; if single: C; else single: C; while single: C; for single: C; switch Control Statements (if, else, while, for, switch) ################################################# .. code-block:: c /* * (1) The control keyword is followed by a space, a left parenthesis * without a space, the condition, a right parenthesis, a space, and the * opening bracket on the same line. * (2) Always use braces around control statement blocks, even if they only * contain one line. This makes code review diffs smaller if a line gets * added in the future, and avoids the chance of bad indenting making a * line incorrectly appear to be part of the block. * (3) The closing bracket is on a line by itself. */ if (v < 0) { return 0; } /* "else" and "else if" are on the same line with the previous ending brace * and next opening brace, separated by a space. Blank lines may be used * between blocks to help readability. */ if (v > 0) { return 0; } else if (a == 0) { return 1; } else { return 2; } /* Do not use assignments in conditions. This ensures that the developer's * intent is always clear, makes code reviews easier, and reduces the chance * of using assignment where comparison is intended. */ // Do this ... a = f(); if (a) { return 0; } // ... NOT this if (a = f()) { return 0; } /* It helps readability to use the "!" operator only in boolean * comparisons, and explicitly compare numeric values against 0, * pointers against NULL, etc. This helps remind the reader of the * type being compared. */ int i = 0; char *s = NULL; bool cond = false; if (!cond) { return 0; } if (i == 0) { return 0; } if (s == NULL) { return 0; } /* In a "switch" statement, indent "case" one level, and indent the body of * each "case" another level. */ switch (expression) { case 0: command1; break; case 1: command2; break; default: command3; break; } .. index:: pair: C; macro Macros ###### Macros are a powerful but easily misused feature of the C preprocessor, and Pacemaker uses a lot of obscure macro features. If you need to brush up, the `GCC documentation for macros `_ is excellent. Some common issues: * Beware of side effects in macro arguments that may be evaluated more than once * Always parenthesize macro arguments used in the macro body to avoid precedence issues if the argument is an expression * Multi-statement macro bodies should be enclosed in do...while(0) to make them behave more like a single statement and avoid control flow issues Often, a static inline function defined in a header is preferable to a macro, to avoid the numerous issues that plague macros and gain the benefit of argument and return value type checking. .. index:: pair: C; memory Memory Management ################# * Always use ``calloc()`` rather than ``malloc()``. It has no additional cost on modern operating systems, and reduces the severity and security risks of uninitialized memory usage bugs. * Ensure that all dynamically allocated memory is freed when no longer needed, and not used after it is freed. This can be challenging in the more event-driven, callback-oriented sections of code. * Free dynamically allocated memory using the free function corresponding to how it was allocated. For example, use ``free()`` with ``calloc()``, and ``g_free()`` with most glib functions that allocate objects. .. index:: single: C; struct Structures ########## Changes to structures defined in public API headers (adding or removing members, or changing member types) are generally not possible without breaking API compatibility. However, there are exceptions: * Public API structures can be designed such that they can be allocated only via API functions, not declared directly or allocated with standard memory functions using ``sizeof``. * This can be enforced simply by documentating the limitation, in which case new ``struct`` members can be added to the end of the structure without breaking compatibility. * Alternatively, the structure definition can be kept in an internal header, with only a pointer type definition kept in a public header, in which case the structure definition can be changed however needed. .. index:: single: C; variable Variables ######### .. index:: single: C; pointer Pointers ________ .. code-block:: c /* (1) The asterisk goes by the variable name, not the type; * (2) Avoid leaving pointers uninitialized, to lessen the impact of * use-before-assignment bugs */ char *my_string = NULL; // Use space before asterisk and after closing parenthesis in a cast char *foo = (char *) bar; .. index:: single: C; global variable Globals _______ Global variables should be avoided in libraries when possible. State information should instead be passed as function arguments (often as a structure). This is not for thread safety -- Pacemaker's use of forking ensures it will never be threaded -- but it does minimize overhead, improve readability, and avoid obscure side effects. Variable Naming _______________ Time intervals are sometimes represented in Pacemaker code as user-defined text specifications (for example, "10s"), other times as an integer number of seconds or milliseconds, and still other times as a string representation of an integer number. Variables for these should be named with an indication of which is being used (for example, use ``interval_spec``, ``interval_ms``, or ``interval_ms_s`` instead of ``interval``). .. index:: pair: C; booleans pair: C; bool pair: C; gboolean Booleans ________ Booleans in C can be represented by an integer type, ``bool``, or ``gboolean``. Integers are sometimes useful for storing booleans when they must be converted to and from a string, such as an XML attribute value (for which ``crm_element_value_int()`` can be used). Integer booleans use 0 for false and nonzero (usually 1) for true. ``gboolean`` should be used with glib APIs that specify it. ``gboolean`` should always be used with glib's ``TRUE`` and ``FALSE`` constants. Otherwise, ``bool`` should be preferred. ``bool`` should be used with the ``true`` and ``false`` constants from the ``stdbool.h`` header. Do not use equality operators when testing booleans. For example: .. code-block:: c // Do this if (bool1) { fn(); } if (!bool2) { fn2(); } // Not this if (bool1 == true) { fn(); } if (bool2 == false) { fn2(); } // Otherwise there's no logical end ... if ((bool1 == false) == true) { fn(); } .. index:: pair: C; strings String Handling ############### Define Constants for Magic Strings __________________________________ A "magic" string is one used for control purposes rather than human reading, and which must be exactly the same every time it is used. Examples would be configuration option names, XML attribute names, or environment variable names. These should always be defined constants, rather than using the string literal everywhere. If someone mistypes a defined constant, the code won't compile, but if they mistype a literal, it could go unnoticed until a user runs into a problem. String-Related Library Functions ________________________________ Pacemaker's libcrmcommon has a large number of functions to assist in string handling. The most commonly used ones are: * ``pcmk__str_eq()`` tests string equality (similar to ``strcmp()``), but can handle NULL, and takes options for case-insensitive, whether NULL should be considered a match, etc. * ``crm_strdup_printf()`` takes ``printf()``-style arguments and creates a string from them (dynamically allocated, so it must be freed with ``free()``). It asserts on memory failure, so the return value is always non-NULL. String handling functions should almost always be internal API, since Pacemaker isn't intended to be used as a general-purpose library. Most are declared in ``include/crm/common/strings_internal.h``. ``util.h`` has some older ones that are public API (for now, but will eventually be made internal). char*, gchar*, and GString __________________________ When using dynamically allocated strings, be careful to always use the appropriate free function. * ``char*`` strings allocated with something like ``calloc()`` must be freed with ``free()``. Most Pacemaker library functions that allocate strings use this implementation. * glib functions often use ``gchar*`` instead, which must be freed with ``g_free()``. * Occasionally, it's convenient to use glib's flexible ``GString*`` type, which must be freed with ``g_string_free()``. .. index:: pair: C; regular expression Regular Expressions ___________________ - Use ``REG_NOSUB`` with ``regcomp()`` whenever possible, for efficiency. - Be sure to use ``regfree()`` appropriately. .. index:: single: C; enum Enumerations ############ * Enumerations should not have a ``typedef``, and do not require any naming convention beyond what applies to all exposed symbols. * New values should usually be added to the end of public API enumerations, because the compiler will define the values to 0, 1, etc., in the order given, and inserting a value in the middle would change the numerical values of all later values, breaking code compiled with the old values. However, if enum numerical values are explicitly specified rather than left to the compiler, new values can be added anywhere. * When defining constant integer values, enum should be preferred over ``#define`` or ``const`` when possible. This allows type checking without consuming memory. Flag groups ___________ Pacemaker often uses flag groups (also called bit fields or bitmasks) for a collection of boolean options (flags/bits). This is more efficient for storage and manipulation than individual booleans, but its main advantage is when used in public APIs, because using another bit in a bitmask is backward compatible, whereas adding a new function argument (or sometimes even a structure member) is not. .. code-block:: c #include /* (1) Define an enumeration to name the individual flags, for readability. * An enumeration is preferred to a series of "#define" constants * because it is typed, and logically groups the related names. * (2) Define the values using left-shifting, which is more readable and * less error-prone than hexadecimal literals (0x0001, 0x0002, 0x0004, * etc.). * (3) Using a comma after the last entry makes diffs smaller for reviewing * if a new value needs to be added or removed later. */ enum pcmk__some_bitmask_type { pcmk__some_value = (1 << 0), pcmk__other_value = (1 << 1), pcmk__another_value = (1 << 2), }; /* The flag group itself should be an unsigned type from stdint.h (not * the enum type, since it will be a mask of the enum values and not just * one of them). uint32_t is the most common, since we rarely need more than * 32 flags, but a smaller or larger type could be appropriate in some * cases. */ uint32_t flags = pcmk__some_value|pcmk__other_value; /* If the values will be used only with uint64_t, define them accordingly, * to make compilers happier. */ enum pcmk__something_else { pcmk__whatever = (UINT64_C(1) << 0), }; We have convenience functions for checking flags (see ``pcmk_any_flags_set()``, ``pcmk_all_flags_set()``, and ``pcmk_is_set()``) as well as setting and clearing them (see ``pcmk__set_flags_as()`` and ``pcmk__clear_flags_as()``, usually used via wrapper macros defined for specific flag groups). These convenience functions should be preferred to direct bitwise arithmetic, for readability and logging consistency. .. index:: pair: C; function Functions ######### Function Naming _______________ Function names should be unique across the entire project, to allow for individual tracing via ``PCMK_trace_functions``, and make it easier to search code and follow detail logs. .. _sort_func: Sorting ^^^^^^^ A function that sorts an entire list should have ``sort`` in its name. It sorts elements using a :ref:`comparison ` function, which may be either hard-coded or passed as an argument. .. _compare_func: Comparison ^^^^^^^^^^ A comparison function for :ref:`sorting ` should have ``cmp`` in its name and should *not* have ``sort`` in its name. .. _constructor_func: Constructors ^^^^^^^^^^^^ A constructor creates a new dynamically allocated object. It may perform some initialization procedure on the new object. * If the constructor always creates an independent object instance, its name should include ``new``. * If the constructor may add the new object to some existing object, its name should include ``create``. Functions that take the caller's name as an argument ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sometimes, we define a function that uses the ``__FILE__``, ``__func__``, and/or ``__LINE__`` of the caller for logging purposes, often with a wrapper macro that automatically passes them. * The function should take those values as its first arguments. * The function name should end in ``_as()``. * If a wrapper macro is used, its name should be the same without ``_as()``. * See ``pcmk__assert_alloc()`` and ``pcmk__assert_alloc_as()`` as examples. Function Definitions ____________________ .. code-block:: c /* * (1) The return type goes on its own line * (2) The opening brace goes by itself on a line * (3) Use "const" with pointer arguments whenever appropriate, to allow the * function to be used by more callers. */ int my_func1(const char *s) { return 0; } /* Functions with no arguments must explicitly list them as void, * for compatibility with strict compilers */ int my_func2(void) { return 0; } /* * (1) For functions with enough arguments that they must break to the next * line, align arguments with the first argument. * (2) When a function argument is a function itself, use the pointer form. * (3) Declare functions and file-global variables as ``static`` whenever * appropriate. This gains a slight efficiency in shared libraries, and * helps the reader know that it is not used outside the one file. */ static int my_func3(int bar, const char *a, const char *b, const char *c, void (*callback)()) { return 0; } Return Values _____________ Functions that need to indicate success or failure should follow one of the following guidelines. More details, including functions for using them in user messages and converting from one to another, can be found in ``include/crm/common/results.h``. * A **standard Pacemaker return code** is one of the ``pcmk_rc_*`` enum values or a system errno code, as an ``int``. * ``crm_exit_t`` (the ``CRM_EX_*`` enum values) is a system-independent code suitable for the exit status of a process, or for interchange between nodes. These values need to be kept in sync with the ``ExitStatus`` enum in ``python/pacemaker/exitstatus.py``. * Other special-purpose status codes exist, such as ``enum ocf_exitcode`` for the possible exit statuses of OCF resource agents (along with some Pacemaker-specific extensions). It is usually obvious when the context calls for such. * Some older Pacemaker APIs use the now-deprecated "legacy" return values of ``pcmk_ok`` or the positive or negative value of one of the ``pcmk_err_*`` constants or system errno codes. * Functions registered with external libraries (as callbacks for example) should use the appropriate signature defined by those libraries, rather than follow Pacemaker guidelines. Of course, functions may have return values that aren't success/failure indicators, such as a pointer, integer count, or bool. :ref:`Comparison ` functions should return * a negative integer if the first argument should sort first * 0 if its arguments are equal for sorting purposes * a positive integer is the second argument should sort first Public API Functions ____________________ Unless we are doing a (rare) release where we break public API compatibility, new public API functions can be added, but existing function signatures (return type, name, and argument types) should not be changed. To work around this, an existing function can become a wrapper for a new function. .. index:: pair: C; logging pair: C; output Logging and Output ################## Logging Vs. Output __________________ Log messages and output messages are logically similar but distinct. Oversimplifying a bit, daemons log, and tools output. Log messages are intended to help with troubleshooting and debugging. They may have a high level of technical detail, and are usually filtered by severity -- for example, the system log by default gets messages of notice level and higher. Output is intended to let the user know what a tool is doing, and is generally terser and less technical, and may even be parsed by scripts. Output might have "verbose" and "quiet" modes, but it is not filtered by severity. Common Guidelines for All Messages __________________________________ * When format strings are used for derived data types whose implementation may vary across platforms (``pid_t``, ``time_t``, etc.), the safest approach is to use ``%lld`` in the format string, and cast the value to ``long long``. * Do not rely on ``%s`` handling ``NULL`` values properly. While the standard library functions might, not all functions using printf-style formatting does, and it's safest to get in the habit of always ensuring format values are non-NULL. If a value can be NULL, the ``pcmk__s()`` function is a convenient way to say "this string if not NULL otherwise this default". * The convenience macros ``pcmk__plural_s()`` and ``pcmk__plural_alt()`` are handy when logging a word that may be singular or plural. Log Levels __________ When to use each log level: * **critical:** fatal error (usually something that would make a daemon exit) * **error:** failure of something that affects the cluster (such as a resource action, fencing action, etc.) or daemon operation * **warning:** minor, potential, or recoverable failures (such as something only affecting a daemon client, or invalid configuration that can be left to default) * **notice:** important successful events (such as a node joining or leaving, resource action results, or configuration changes) * **info:** events that would be helpful with troubleshooting (such as status section updates or elections) * **debug:** information that would be helpful for debugging code or complex problems * **trace:** like debug but for very noisy or low-level stuff By default, critical through notice are logged to the system log and detail log, info is logged to the detail log only, and debug and trace are not logged (if enabled, they go to the detail log only). Logging _______ Pacemaker uses libqb for logging, but wraps it with a higher level of functionality (see ``include/crm/common/logging*h``). A few macros ``crm_err()``, ``crm_warn()``, etc. do most of the heavy lifting. By default, Pacemaker sends logs at notice level and higher to the system log, and logs at info level and higher to the detail log (typically ``/var/log/pacemaker/pacemaker.log``). The intent is that most users will only ever need the system log, but for deeper troubleshooting and developer debugging, the detail log may be helpful, at the cost of being more technical and difficult to follow. The same message can have more detail in the detail log than in the system log, using libqb's "extended logging" feature: .. code-block:: c /* The following will log a simple message in the system log, like: warning: Action failed: Node not found with extra detail in the detail log, like: warning: Action failed: Node not found | rc=-1005 id=hgjjg-51006 */ crm_warn("Action failed: %s " QB_XS " rc=%d id=%s", pcmk_rc_str(rc), rc, id); Assertion Logging _________________ ``pcmk__assert(expr)`` If ``expr`` is false, this will call ``crm_err()`` with a "Triggered fatal assertion" message (with details), then abort execution. This should be used for logic errors that should be impossible (such as a NULL function argument where not accepted) and environmental errors that can't be handled gracefully (for example, memory allocation failures, though returning ``ENOMEM`` is often better). ``CRM_LOG_ASSERT(expr)`` If ``expr`` is false, this will generally log a message without aborting. If the log level is below trace, it just calls ``crm_err()`` with a "Triggered assert" message (with details). If the log level is trace, and the caller is a daemon, then it will fork a child process in which to dump core, as well as logging the message. If the log level is trace, and the caller is not a daemon, then it will behave like ``pcmk__assert()`` (i.e. log and abort). This should be used for logic or protocol errors that require no special handling. ``CRM_CHECK(expr, failed_action)`` If ``expr`` is false, behave like ``CRM_LOG_ASSERT(expr)`` (that is, log a message and dump core if requested) then perform ``failed_action`` (which must not contain ``continue``, ``break``, or ``errno``). This should be used for logic or protocol errors that can be handled, usually by returning an error status. Output ______ Pacemaker has a somewhat complicated system for tool output. The main benefit is that the user can select the output format with the ``--output-as`` option (usually "text" for human-friendly output or "xml" for reliably script-parsable output, though ``crm_mon`` additionally supports "console" and "html"). A custom message can be defined with a unique string identifier, plus implementation functions for each supported format. The caller invokes the message using the identifier. The user selects the output format via ``--output-as``, and the output code automatically calls the appropriate -implementation function. Custom messages are useful when you want to output -messages that are more complex than a one-line error or informational message, -reproducible, and automatically handled by the output formatting system. +implementation function. Custom messages are useful when you want to output +messages that are more complex than a one-line error or informational message, +reproducible, and automatically handled by the output formatting system. Custom messages can contain other custom messages. -Custom message functions are implemented as follows: Start with the macro -``PCMK__OUTPUT_ARGS``, whose arguments are the message name, followed by the -arguments to the message. Then there is the function declaration, for which the -arguments are the pointer to the current output object, then a variable argument +Custom message functions are implemented as follows: Start with the macro +``PCMK__OUTPUT_ARGS``, whose arguments are the message name, followed by the +arguments to the message. Then there is the function declaration, for which the +arguments are the pointer to the current output object, then a variable argument list. -To output a custom message, you first need to create, i.e. register, the custom -message that you want to output. Either call ``register_message``, which -registers a custom message at runtime, or make use of the collection of -predefined custom messages in ``fmt_functions``, which is defined in -``lib/pacemaker/pcmk_output.c``. Once you have the message to be outputted, +To output a custom message, you first need to create, i.e. register, the custom +message that you want to output. Either call ``register_message``, which +registers a custom message at runtime, or make use of the collection of +predefined custom messages in ``fmt_functions``, which is defined in +``lib/pacemaker/pcmk_output.c``. Once you have the message to be outputted, output it by calling ``message``. -Note: The ``fmt_functions`` functions accommodate all of the output formats; -the default implementation accommodates any format that isn't explicitly -accommodated. The default output provides valid output for any output format, -but you may still want to implement a specific output, i.e. xml, text, or html. -The ``message`` function automatically knows which implementation to use, +Note: The ``fmt_functions`` functions accommodate all of the output formats; +the default implementation accommodates any format that isn't explicitly +accommodated. The default output provides valid output for any output format, +but you may still want to implement a specific output, i.e. xml, text, or html. +The ``message`` function automatically knows which implementation to use, because the ``pcmk__output_s`` contains this information. The interface (most importantly ``pcmk__output_t``) is declared in ``include/crm/common/output*h``. See the API comments and existing tools for examples. -Some of its important member functions are ``err``, which formats error messages -and ``info``, which formats informational messages. Also, ``list_item``, -which formats list items, ``begin_list``, which starts lists, and ``end_list``, -which ends lists, are important because lists can be useful, yet differently +Some of its important member functions are ``err``, which formats error messages +and ``info``, which formats informational messages. Also, ``list_item``, +which formats list items, ``begin_list``, which starts lists, and ``end_list``, +which ends lists, are important because lists can be useful, yet differently handled by the different output types. .. index:: pair: C; XML XML ### External Libraries __________________ Pacemaker uses `libxml2 `_ and `libxslt `_ to process XML. These libraries implement only version 1.0 of the XML, XPath, and XSLT specifications. Naming ______ Names of functions, constants, and enum values related to XML should contain substrings indicating the type of object they're used with, according to the following convention: * ``xml``: XML subtree, or XML generically * ``xe``: XML element node, including the attributes belonging to an element * ``xa``: XML attribute node * ``xc``: XML comment node Private Data ____________ Libxml2 data structures such as ``xmlNode`` and ``xmlDoc`` contain a ``void *_private`` member for application-specific data. Pacemaker uses this field to store internal bookkeeping data, such as changes relative to another XML tree, or ACLs. XML documents, elements, attributes, and comments have private data. The private data field must be allocated immediately after the node is created and freed immediately before the node is freed. Wrapper Functions _________________ Pacemaker provides wrappers for a variety of libxml2 and libxslt functions. They should be used whenever possible. Some are merely for convenience. However, many perform additional, Pacemaker-specific tasks, such as change tracking, ACL checking, and allocation/deallocation of XML documents and private data. Pacemaker assumes that every XML node is part of a document and has private data allocated. If libxml2 APIs are used directly instead of the wrapper functions, Pacemaker may crash with a segmentation fault, or change tracking and ACL checking may be incorrectly disabled. XPaths ______ Separting XPath element names with ``/`` (specifying each level in the hierarchy explicitly) is more efficient than ``//`` (allowing intermediate levels to be omitted), so it should be used whenever practical. .. index:: single: Makefile.am Makefiles ######### Pacemaker uses `automake `_ for building, so the Makefile.am in each directory should be edited rather than Makefile.in or Makefile, which are automatically generated. * Public API headers are installed (by adding them to a ``HEADERS`` variable in ``Makefile.am``), but internal API headers are not (by adding them to ``noinst_HEADERS``). .. index:: pair: C; vim settings vim Settings ############ Developers who use ``vim`` to edit source code can add the following settings to their ``~/.vimrc`` file to follow Pacemaker C coding guidelines: .. code-block:: none " follow Pacemaker coding guidelines when editing C source code files filetype plugin indent on au FileType c setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 autocmd BufNewFile,BufRead *.h set filetype=c let c_space_errors = 1 diff --git a/doc/sphinx/Pacemaker_Development/components.rst b/doc/sphinx/Pacemaker_Development/components.rst index bff62d49df..f886eb2568 100644 --- a/doc/sphinx/Pacemaker_Development/components.rst +++ b/doc/sphinx/Pacemaker_Development/components.rst @@ -1,514 +1,514 @@ Coding Particular Pacemaker Components -------------------------------------- The Pacemaker code can be intricate and difficult to follow. This chapter has some high-level descriptions of how individual components work. .. index:: single: controller single: pacemaker-controld Controller ########## ``pacemaker-controld`` is the Pacemaker daemon that utilizes the other daemons to orchestrate actions that need to be taken in the cluster. It receives CIB change notifications from the CIB manager, passes the new CIB to the scheduler to determine whether anything needs to be done, uses the executor and fencer to execute any actions required, and sets failure counts (among other things) via the attribute manager. As might be expected, it has the most code of any of the daemons. .. index:: single: join Join sequence _____________ Most daemons track their cluster peers using Corosync's membership and :term:`CPG` only. The controller additionally requires peers to `join`, which ensures they are ready to be assigned tasks. Joining proceeds through a series of phases referred to as the `join sequence` or `join process`. A node's current join phase is tracked by the ``user_data`` member of ``pcmk__node_status_t`` (used in the peer cache). It is an ``enum controld_join_phase`` that (ideally) progresses from the DC's point of view as follows: * The node initially starts at ``controld_join_none`` * The DC sends the node a `join offer` (``CRM_OP_JOIN_OFFER``), and the node proceeds to ``controld_join_welcomed``. This can happen in three ways: - + * The joining node will send a `join announce` (``CRM_OP_JOIN_ANNOUNCE``) at its controller startup, and the DC will reply to that with a join offer. * When the DC's peer status callback notices that the node has joined the messaging layer, it registers ``I_NODE_JOIN`` (which leads to ``A_DC_JOIN_OFFER_ONE`` -> ``do_dc_join_offer_one()`` -> ``join_make_offer()``). * After certain events (notably a new DC being elected), the DC will send all nodes join offers (via A_DC_JOIN_OFFER_ALL -> ``do_dc_join_offer_all()``). These can overlap. The DC can send a join offer and the node can send a join announce at nearly the same time, so the node responds to the original join offer while the DC responds to the join announce with a new join offer. The situation resolves itself after looping a bit. * The node responds to join offers with a `join request` (``CRM_OP_JOIN_REQUEST``, via ``do_cl_join_offer_respond()`` and ``join_query_callback()``). When the DC receives the request, the node proceeds to ``controld_join_integrated`` (via ``do_dc_join_filter_offer()``). * As each node is integrated, the current best CIB is sync'ed to each integrated node via ``do_dc_join_finalize()``. As each integrated node's CIB sync succeeds, the DC acks the node's join request (``CRM_OP_JOIN_ACKNAK``) and the node proceeds to ``controld_join_finalized`` (via ``finalize_sync_callback()`` + ``finalize_join_for()``). * Each node confirms the finalization ack (``CRM_OP_JOIN_CONFIRM`` via ``do_cl_join_finalize_respond()``), including its current resource operation history (via ``controld_query_executor_state()``). Once the DC receives this confirmation, the node proceeds to ``controld_join_confirmed`` via ``do_dc_join_ack()``. Once all nodes are confirmed, the DC calls ``do_dc_join_final()``, which checks for quorum and responds appropriately. When peers are lost, their join phase is reset to none (in various places). ``crm_update_peer_join()`` updates a node's join phase. The DC increments the global ``current_join_id`` for each joining round, and rejects any (older) replies that don't match. .. index:: single: fencer single: pacemaker-fenced Fencer ###### ``pacemaker-fenced`` is the Pacemaker daemon that handles fencing requests. In the broadest terms, fencing works like this: #. The initiator (an external program such as ``stonith_admin``, or the cluster itself via the controller) asks the local fencer, "Hey, could you please fence this node?" #. The local fencer asks all the fencers in the cluster (including itself), "Hey, what fencing devices do you have access to that can fence this node?" #. Each fencer in the cluster replies with a list of available devices that it knows about. #. Once the original fencer gets all the replies, it asks the most appropriate fencer peer to actually carry out the fencing. It may send out more than one such request if the target node must be fenced with multiple devices. #. The chosen fencer(s) call the appropriate fencing resource agent(s) to do the fencing, then reply to the original fencer with the result. #. The original fencer broadcasts the result to all fencers. #. Each fencer sends the result to each of its local clients (including, at some point, the initiator). A more detailed description follows. .. index:: single: libstonithd Initiating a fencing request ____________________________ A fencing request can be initiated by the cluster or externally, using the libstonithd API. * The cluster always initiates fencing via ``daemons/controld/controld_fencing.c:te_fence_node()`` (which calls the ``fence()`` API method). This occurs when a transition graph synapse contains a ``CRM_OP_FENCE`` XML operation. * The main external clients are ``stonith_admin`` and ``cts-fence-helper``. The ``DLM`` project also uses Pacemaker for fencing. Highlights of the fencing API: * ``stonith_api_new()`` creates and returns a new ``stonith_t`` object, whose ``cmds`` member has methods for connect, disconnect, fence, etc. * the ``fence()`` method creates and sends a ``STONITH_OP_FENCE XML`` request with the desired action and target node. Callers do not have to choose or even have any knowledge about particular fencing devices. Fencing queries _______________ The function calls for a fencing request go something like this: The local fencer receives the client's request via an :term:`IPC` or messaging layer callback, which calls * ``stonith_command()``, which (for requests) calls * ``handle_request()``, which (for ``STONITH_OP_FENCE`` from a client) calls * ``initiate_remote_stonith_op()``, which creates a ``STONITH_OP_QUERY`` XML request with the target, desired action, timeout, etc. then broadcasts the operation to the cluster group (i.e. all fencer instances) and starts a timer. The query is broadcast because (1) location constraints might prevent the local node from accessing the stonith device directly, and (2) even if the local node does have direct access, another node might be preferred to carry out the fencing. Each fencer receives the original fencer's ``STONITH_OP_QUERY`` broadcast request via IPC or messaging layer callback, which calls: * ``stonith_command()``, which (for requests) calls * ``handle_request()``, which (for ``STONITH_OP_QUERY`` from a peer) calls * ``stonith_query()``, which calls * ``get_capable_devices()`` with ``stonith_query_capable_device_cb()`` to add device information to an XML reply and send it. (A message is considered a reply if it contains ``T_STONITH_REPLY``, which is only set by fencer peers, not clients.) The original fencer receives all peers' ``STONITH_OP_QUERY`` replies via IPC or messaging layer callback, which calls: * ``stonith_command()``, which (for replies) calls * ``handle_reply()`` which (for ``STONITH_OP_QUERY``) calls * ``process_remote_stonith_query()``, which allocates a new query result structure, parses device information into it, and adds it to the operation object. It increments the number of replies received for this operation, and compares it against the expected number of replies (i.e. the number of active peers), and if this is the last expected reply, calls * ``request_peer_fencing()``, which calculates the timeout and sends ``STONITH_OP_FENCE`` request(s) to carry out the fencing. If the target node has a fencing "topology" (which allows specifications such as "this node can be fenced either with device A, or devices B and C in combination"), it will choose the device(s), and send out as many requests as needed. If it chooses a device, it will choose the peer; a peer is preferred if it has "verified" access to the desired device, meaning that it has the device "running" on it and thus has a monitor operation ensuring reachability. Fencing operations __________________ Each ``STONITH_OP_FENCE`` request goes something like this: The chosen peer fencer receives the ``STONITH_OP_FENCE`` request via :term:`IPC` or messaging layer callback, which calls: * ``stonith_command()``, which (for requests) calls * ``handle_request()``, which (for ``STONITH_OP_FENCE`` from a peer) calls * ``stonith_fence()``, which calls * ``schedule_stonith_command()`` (using supplied device if ``F_STONITH_DEVICE`` was set, otherwise the highest-priority capable device obtained via ``get_capable_devices()`` with ``stonith_fence_get_devices_cb()``), which adds the operation to the device's pending operations list and triggers processing. The chosen peer fencer's mainloop is triggered and calls * ``stonith_device_dispatch()``, which calls * ``stonith_device_execute()``, which pops off the next item from the device's pending operations list. If acting as the (internally implemented) watchdog agent, it panics the node, otherwise it calls * ``stonith_action_create()`` and ``stonith_action_execute_async()`` to call the fencing agent. The chosen peer fencer's mainloop is triggered again once the fencing agent returns, and calls * ``stonith_action_async_done()`` which adds the results to an action object then calls its * done callback (``st_child_done()``), which calls ``schedule_stonith_command()`` for a new device if there are further required actions to execute or if the original action failed, then builds and sends an XML reply to the original fencer (via ``send_async_reply()``), then checks whether any pending actions are the same as the one just executed and merges them if so. Fencing replies _______________ The original fencer receives the ``STONITH_OP_FENCE`` reply via :term:`IPC` or messaging layer callback, which calls: * ``stonith_command()``, which (for replies) calls * ``handle_reply()``, which calls * ``fenced_process_fencing_reply()``, which calls either ``request_peer_fencing()`` (to retry a failed operation, or try the next device in a topology if appropriate, which issues a new ``STONITH_OP_FENCE`` request, proceeding as before) or ``finalize_op()`` (if the operation is definitively failed or successful). * ``finalize_op()`` broadcasts the result to all peers. Finally, all peers receive the broadcast result and call * ``finalize_op()``, which sends the result to all local clients. .. index:: single: fence history Fencing History _______________ The fencer keeps a running history of all fencing operations. The bulk of the relevant code is in `fenced_history.c` and ensures the history is synchronized across all nodes even if a node leaves and rejoins the cluster. In libstonithd, this information is represented by `stonith_history_t` and is queryable by the `stonith_api_operations_t:history()` method. `crm_mon` and `stonith_admin` use this API to display the history. .. index:: single: scheduler single: pacemaker-schedulerd single: libcrmcommon single: libpe_status single: libpacemaker Scheduler ######### ``pacemaker-schedulerd`` is the Pacemaker daemon that runs the Pacemaker scheduler for the controller, but "the scheduler" in general refers to related library code in various files in ``libcrmcommon``, ``libpe_status``, and ``libpacemaker``. The purpose of the scheduler is to take a CIB as input and generate a transition graph (list of actions that need to be taken) as output. The controller invokes the scheduler by contacting the scheduler daemon via local :term:`IPC`. Tools such as ``crm_simulate``, ``crm_mon``, and ``crm_resource`` can also invoke the scheduler, but do so by calling the library functions directly. This allows them to run using a ``CIB_file`` without the cluster needing to be active. The main entry point for the scheduler code is ``lib/pacemaker/pcmk_scheduler.c:pcmk__schedule_actions()``. It sets defaults and calls a series of functions for the scheduling. Some key steps: * ``unpack_cib()`` parses most of the CIB XML into data structures, and determines the current cluster status. * ``apply_node_criteria()`` applies factors that make resources prefer certain nodes, such as shutdown locks, location constraints, and stickiness. * ``pcmk__create_internal_constraints()`` creates internal constraints, such as the implicit ordering for group members, or start actions being implicitly ordered before promote actions. * ``pcmk__handle_rsc_config_changes()`` processes resource history entries in the CIB status section. This is used to decide whether certain actions need to be done, such as deleting orphan resources, forcing a restart when a resource definition changes, etc. * ``assign_resources()`` :term:`assigns ` resources to nodes. * ``schedule_resource_actions()`` schedules resource-specific actions (which might or might not end up in the final graph). * ``pcmk__apply_orderings()`` processes ordering constraints in order to modify action attributes such as optional or required. * ``pcmk__create_graph()`` creates the transition graph. Challenges __________ Working with the scheduler is difficult. Challenges include: * It is far too much code to keep more than a small portion in your head at one time. * Small changes can have large (and unexpected) effects. This is why we have a large number of regression tests (``cts/cts-scheduler``), which should be run after making code changes. * It produces an insane amount of log messages at debug and trace levels. You can put resource ID(s) in the ``PCMK_trace_tags`` environment variable to enable trace-level messages only when related to specific resources. * Different parts of the main ``pcmk_scheduler_t`` structure are finalized at different points in the scheduling process, so you have to keep in mind whether information you're using at one point of the code can possibly change later. For example, data unpacked from the CIB can safely be used anytime after ``unpack_cib(),`` but actions may become optional or required anytime before ``pcmk__create_graph()``. There's no easy way to deal with this. .. index:: single: pcmk_scheduler_t The Scheduler Object ____________________ The main data object for the scheduler is ``pcmk_scheduler_t``, which contains all information needed about nodes, resources, constraints, etc., both as the raw CIB XML and parsed into more usable data structures, plus the resulting transition graph XML. The variable name is usually ``scheduler``. .. index:: single: pcmk_resource_t Resources _________ ``pcmk_resource_t`` is the data object representing cluster resources. It has a couple of public members for backward compatibility reasons, but most of the implementation is in the internal ``pcmk__resource_private_t`` type. A resource has a variant: :term:`primitive`, group, clone, or :term:`bundle`. The private resource object has members for two sets of methods, ``pcmk__rsc_methods_t`` from ``libcrmcommon``, and ``pcmk__assignment_methods_t`` whose implementation is internal to ``libpacemaker``. The actual functions vary by variant. The resource methods have basic capabilities such as unpacking the resource XML, and determining the current or planned location of the resource. The :term:`assignment ` methods have more obscure capabilities needed for scheduling, such as processing location and ordering constraints. For example, ``pcmk__create_internal_constraints()`` simply calls the ``internal_constraints()`` method for each top-level resource in the cluster. .. index:: single: pcmk_node_t Nodes _____ :term:`Assignment ` of resources to nodes is done by choosing the node with the highest :term:`score` for a given resource. The scheduler does a bunch of processing to generate the scores, then the actual assignment is straightforward. The scheduler node implementation is a little confusing. ``pcmk_node_t`` (``struct pcmk__scored_node``) is the primary object used. It contains two sub-structs, ``pcmk__node_private_t *priv`` (which is internal) and ``struct pcmk__node_details *details`` (which is public for backward compatibility reasons), that contain all node information that is independent of resource assignment (the node name, etc.). It contains one other (internal) sub-struct, ``struct pcmk__node_assignment *assign``, which contains information particular to a specific resource being assigned. Node lists are frequently used. For example, ``pcmk_scheduler_t`` has a ``nodes`` member which is a list of all nodes in the cluster, and the internal resource object has an ``active_nodes`` member which is a list of all nodes on which the resource is (or might be) active. Only the scheduler's ``nodes`` list has the full, original node instances. All other node lists have shallow copies created by ``pe__copy_node()``, which share ``details`` and ``priv`` from the main list (but can differ in their ``assign`` member). .. index:: single: pcmk_action_t single: pcmk__action_flags Actions _______ ``pcmk_action_t`` is the data object representing actions that might need to be taken. These could be resource actions, cluster-wide actions such as fencing a node, or "pseudo-actions" which are abstractions used as convenient points for ordering other actions against. Its (internal) implementation has a ``flags`` member which is a bitmask of ``enum pcmk__action_flags``. The most important of these are ``pcmk__action_runnable`` (if not set, the action is "blocked" and cannot be added to the transition graph) and ``pcmk__action_optional`` (actions with this set will not be added to the transition graph; actions often start out as optional, and may become required later). .. index:: single: pcmk__colocation_t Colocations ___________ ``pcmk__colocation_t`` is the data object representing colocations. Colocation constraints come into play in these parts of the scheduler code: * When sorting resources for :term:`assignment `, so resources with highest node :term:`score` are assigned first (see ``cmp_resources()``) * When updating node scores for resource assigment or promotion priority * When assigning resources, so any resources to be colocated with can be assigned first, and so colocations affect where the resource is assigned * When choosing roles for promotable clone instances, so colocations involving a specific role can affect which instances are promoted The resource assignment functions have several methods related to colocations: * ``apply_coloc_score():`` This applies a colocation's score to either the dependent's allowed node scores (if called while resources are being assigned) or the dependent's priority (if called while choosing promotable instance roles). It can behave differently depending on whether it is being called as the :term:`primary's ` method or as the :term:`dependent's ` method. * ``add_colocated_node_scores():`` This updates a table of nodes for a given colocation attribute and score. It goes through colocations involving a given resource, and updates the scores of the nodes in the table with the best scores of nodes that match up according to the colocation criteria. * ``colocated_resources():`` This generates a list of all resources involved in mandatory colocations (directly or indirectly via colocation chains) with a given resource. .. index:: single: pcmk__action_relation_t single: action; relation Action Relations ________________ Ordering constraints are simple in concept, but they are one of the most important, powerful, and difficult to follow aspects of the scheduler code. ``pcmk__action_relation_t`` is the data object representing an ordering, better thought of as a relationship between two actions, since the relation can be more complex than just "this one runs after that one". For a relation "A then B", the code generally refers to A as "first" or "before", and B as "then" or "after". Much of the power comes from ``enum pcmk__action_relation_flags``, which are flags that determine how a relation behaves. There are many obscure flags with big effects. A few examples: * ``pcmk__ar_none`` means the relation is disabled and will be ignored. The value is 0, meaning no flags set, so it must be compared with equality rather than ``pcmk_is_set()``. * ``pcmk__ar_ordered`` without any other flags set means the relation does not make either action required, so it applies only if they both become required for other reasons. * ``pcmk__ar_then_implies_first`` means that if action B becomes required for any reason, then action A will become required as well. Adding a New Scheduler Regression Test ______________________________________ #. Choose a test name. #. Copy the uncompressed input CIB to cts/scheduler/xml/TESTNAME.xml. It's helpful to add an XML comment at the top describing the essential features of the test (which configuration and status scenarios are being tested). #. Edit ``cts/cts-scheduler.in`` and add the test name and description to the ``TESTS`` array. #. Run ``cts/cts-scheduler --update --run TESTNAME`` to generate the expected transition graph, scores, etc. Look over the generated files to make sure they are as expected. #. Commit your changes. diff --git a/doc/sphinx/Pacemaker_Development/faq.rst b/doc/sphinx/Pacemaker_Development/faq.rst index b1b1e5ac90..94deb63734 100644 --- a/doc/sphinx/Pacemaker_Development/faq.rst +++ b/doc/sphinx/Pacemaker_Development/faq.rst @@ -1,166 +1,166 @@ Frequently Asked Questions -------------------------- :Q: Who is this document intended for? :A: Anyone who wishes to read and/or edit the Pacemaker source code. Casual contributors should feel free to read just this FAQ, and consult other chapters as needed. ---- .. index:: single: download single: source code single: git single: git; GitHub :Q: Where is the source code for Pacemaker? :A: The `source code for Pacemaker `_ is kept on `GitHub `_, as are all software projects under the `ClusterLabs `_ umbrella. Pacemaker uses `Git `_ for source code management. If you are a Git newbie, the `gittutorial(7) man page `_ is an excellent starting point. If you're familiar with using Git from the command line, you can create a local copy of the Pacemaker source code with: **git clone https://github.com/ClusterLabs/pacemaker.git** ---- .. index:: single: git; branch :Q: What are the different Git branches and repositories used for? :A: * The `main branch `_ is used for all new development. * The `3.0 `_ and `2.1 `_ branches are for the currently supported major and minor version release series. Normally, they do not receive any changes, but during the release cycle for a new release, they will contain release candidates. The main branch is pulled into 3.0 just before the first release candidate of a new release, but otherwise, separate pull requests must be submitted to backport changes from the main branch into a release branch. * The `2.0 branch `_, `1.1 branch `_, and separate `1.0 repository `_ are frozen snapshots of earlier release series, no longer being developed. ---- :Q: How do I build from the source code? :A: See `INSTALL.md `_ in the main checkout directory. ---- :Q: What coding style should I follow? :A: You'll be mostly fine if you simply follow the example of existing code. When unsure, see the relevant chapter of this document for language-specific recommendations. Pacemaker has grown and evolved organically over many years, so you will see much code that doesn't conform to the current guidelines. We discourage making changes solely to bring code into conformance, as any change requires developer time for review and opens the possibility of adding bugs. However, new code should follow the guidelines, and it is fine to bring lines of older code into conformance when modifying that code for other reasons. ---- .. index:: single: git; commit message :Q: How should I format my Git commit messages? :A: An example is "Feature: scheduler: wobble the frizzle better". - + * The first part is the type of change, used to automatically generate the change log for the next release. Commit messages with the following will be included in the change log: * **Feature** for new features * **Fix** for bug fixes (**Bug** or **High** also work) * **API** for changes to the public API Everything else will *not* automatically be in the change log, and so don't really matter, but types commonly used include: * **Log** for changes to log messages or handling * **Doc** for changes to documentation or comments * **Test** for changes in CTS and regression tests * **Low**, **Med**, or **Mid** for bug fixes not significant enough for a change log entry * **Refactor** for refactoring-only code changes * **Build** for build process changes - + * The next part is the name of the component(s) being changed, for example, **controller** or **libcrmcommon** (it's more free-form, so don't sweat getting it exact). - + * The rest briefly describes the change. The git project recommends the entire summary line stay under 50 characters, but more is fine if needed for clarity. - + * Except for the most simple and obvious of changes, the summary should be followed by a blank line and a longer explanation of *why* the change was made. * If the commit is associated with a task in the `ClusterLabs project manager `_, you can say "Fixes T\ *n*" in the commit message to automatically close task T\ *n* when the pull request is merged. ---- :Q: How can I test my changes? :A: The source repository has some unit tests for simple functions, though this is a recent effort without much coverage yet. Pacemaker's Cluster Test Suite (CTS) has regression tests for most major components; these will automatically be run for any pull requests submitted through GitHub, and are sufficient for most changes. Additionally, CTS has a lab component that can be used to set up a test cluster and run a wide variety of complex tests, for testing major changes. See cts/README.md in the source repository for details. ---- .. index:: license :Q: What is Pacemaker's license? :A: Except where noted otherwise in the file itself, the source code for all Pacemaker programs is licensed under version 2 or later of the GNU General Public License (`GPLv2+ `_), its headers, libraries, and native language translations under version 2.1 or later of the less restrictive GNU Lesser General Public License (`LGPLv2.1+ `_), its documentation under version 4.0 or later of the Creative Commons Attribution-ShareAlike International Public License (`CC-BY-SA-4.0 `_), and its init scripts under the `Revised BSD `_ license. If you find any deviations from this policy, or wish to inquire about alternate licensing arrangements, please e-mail the `developers@ClusterLabs.org `_ mailing list. Licensing issues are also discussed on the `ClusterLabs wiki `_. ---- :Q: How can I contribute my changes to the project? :A: Contributions of bug fixes or new features are very much appreciated! Patches can be submitted as `pull requests `_ via GitHub (the preferred method, due to its excellent `features `_), or e-mailed to the `developers@ClusterLabs.org `_ mailing list as an attachment in a format Git can import. Authors may only submit changes that they have the right to submit under the open source license indicated in the affected files. ---- .. index:: mailing list :Q: What if I still have questions? :A: Ask on the `ClusterLabs mailing lists `_. diff --git a/doc/sphinx/Pacemaker_Development/general.rst b/doc/sphinx/Pacemaker_Development/general.rst index 94015c9b8f..99b89a6ebe 100644 --- a/doc/sphinx/Pacemaker_Development/general.rst +++ b/doc/sphinx/Pacemaker_Development/general.rst @@ -1,50 +1,50 @@ .. index:: single: guidelines; all languages General Guidelines for All Languages ------------------------------------ .. index:: copyright Copyright ######### When copyright notices are added to a file, they should look like this: .. note:: **Copyright Notice Format** | Copyright *YYYY[-YYYY]* the Pacemaker project contributors - | + | | The version control history for this file may have further details. The first *YYYY* is the year the file was *originally* published. The original date is important for two reasons: when two entities claim copyright ownership of the same work, the earlier claim generally prevails; and copyright expiration is generally calculated from the original publication date. [1]_ If the file is modified in later years, add *-YYYY* with the most recent year of modification. Even though Pacemaker is an ongoing project, copyright notices are about the years of *publication* of specific content. Copyright notices are intended to indicate, but do not affect, copyright *ownership*, which is determined by applicable laws and regulations. Authors may put more specific copyright notices in their commit messages if desired. .. rubric:: Footnotes .. [1] See the U.S. Copyright Office's `"Compendium of U.S. Copyright Office Practices" `_, particularly "Chapter 2200: Notice of Copyright", sections 2205.1(A) and 2205.1(F), or `"Updating Copyright Notices" `_ for a more readable summary. Terminology ########### Pacemaker is extremely complex, and it helps to use terminology consistently throughout documentation, symbol names and comments in code, and so forth. It also helps to use natural language when practical instead of technical jargon and acronyms. For specific recommendations, see the :ref:`glossary`. diff --git a/doc/sphinx/Pacemaker_Development/index.rst b/doc/sphinx/Pacemaker_Development/index.rst index a3f624f65b..b74c9f8cf4 100644 --- a/doc/sphinx/Pacemaker_Development/index.rst +++ b/doc/sphinx/Pacemaker_Development/index.rst @@ -1,35 +1,26 @@ Pacemaker Development ===================== *Working with the Pacemaker Code Base* -Abstract --------- This document has guidelines and tips for developers interested in editing Pacemaker source code and submitting changes for inclusion in the project. Start with the FAQ; the rest is optional detail. -Table of Contents ------------------ - .. toctree:: :maxdepth: 3 :numbered: faq general documentation python c components helpers evolution glossary - -Index ------ - -* :ref:`genindex` -* :ref:`search` + :ref:`genindex` + :ref:`search` diff --git a/doc/sphinx/Pacemaker_Explained/acls.rst b/doc/sphinx/Pacemaker_Explained/acls.rst index 878f8f64b3..1ceff36d9e 100644 --- a/doc/sphinx/Pacemaker_Explained/acls.rst +++ b/doc/sphinx/Pacemaker_Explained/acls.rst @@ -1,476 +1,476 @@ .. index:: single: Access Control List (ACL) .. _acl: Access Control Lists (ACLs) --------------------------- By default, the ``root`` user or any user in the |CRM_DAEMON_GROUP| group can modify Pacemaker's CIB without restriction. Pacemaker offers *access control lists (ACLs)* to provide more fine-grained authorization. - + .. important:: Being able to modify the CIB's resource section allows a user to run any executable file as root, by configuring it as an LSB resource with a full path. ACL Prerequisites ################# - + In order to use ACLs: * The ``enable-acl`` :ref:`cluster option ` must be set to true. * Desired users must have user accounts in the |CRM_DAEMON_GROUP| group on all cluster nodes in the cluster. * If your CIB was created before Pacemaker 1.1.12, it might need to be updated to the current schema (using ``cibadmin --upgrade`` or a higher-level tool equivalent) in order to use the syntax documented here. * Prior to the 2.1.0 release, the Pacemaker software had to have been built with ACL support. If you are using an older release, your installation supports ACLs only if the output of the command ``pacemakerd --features`` contains ``acls``. In newer versions, ACLs are always enabled. - + .. important:: ``enable-acl`` should be set either by the root user, or as part of a batch of CIB changes including roles and users. Otherwise, the user setting it might lock themselves out from making any further changes. .. index:: single: Access Control List (ACL); acls pair: acls; XML element ACL Configuration ################# ACLs are specified within an ``acls`` element of the CIB. The ``acls`` element may contain any number of ``acl_role``, ``acl_target``, and ``acl_group`` elements. - + .. index:: single: Access Control List (ACL); acl_role pair: acl_role; XML element ACL Roles ######### An ACL *role* is a collection of permissions allowing or denying access to particular portions of the CIB. A role is configured with an ``acl_role`` element in the CIB ``acls`` section. - -.. table:: **Properties of an acl_role element** - :widths: 1 3 + +.. table:: **Properties of an acl_role Element** + :widths: 25 75 +------------------+-----------------------------------------------------------+ | Attribute | Description | +==================+===========================================================+ | id | .. index:: | | | single: acl_role; id (attribute) | | | single: id; acl_role attribute | | | single: attribute; id (acl_role) | | | | | | A unique name for the role *(required)* | +------------------+-----------------------------------------------------------+ | description | .. index:: | | | single: acl_role; description (attribute) | | | single: description; acl_role attribute | | | single: attribute; description (acl_role) | | | | | | Arbitrary text for user's use (ignored by Pacemaker) | +------------------+-----------------------------------------------------------+ An ``acl_role`` element may contain any number of ``acl_permission`` elements. - + .. index:: single: Access Control List (ACL); acl_permission pair: acl_permission; XML element -.. table:: **Properties of an acl_permission element** - :widths: 1 3 +.. table:: **Properties of an acl_permission Element** + :widths: 25 75 +------------------+-----------------------------------------------------------+ | Attribute | Description | +==================+===========================================================+ | id | .. index:: | | | single: acl_permission; id (attribute) | | | single: id; acl_permission attribute | | | single: attribute; id (acl_permission) | | | | | | A unique name for the permission *(required)* | +------------------+-----------------------------------------------------------+ | description | .. index:: | | | single: acl_permission; description (attribute) | | | single: description; acl_permission attribute | | | single: attribute; description (acl_permission) | | | | | | Arbitrary text for user's use (ignored by Pacemaker) | +------------------+-----------------------------------------------------------+ | kind | .. index:: | | | single: acl_permission; kind (attribute) | | | single: kind; acl_permission attribute | | | single: attribute; kind (acl_permission) | | | | | | The access being granted. Allowed values are ``read``, | | | ``write``, and ``deny``. A value of ``write`` grants both | | | read and write access. | +------------------+-----------------------------------------------------------+ | object-type | .. index:: | | | single: acl_permission; object-type (attribute) | | | single: object-type; acl_permission attribute | | | single: attribute; object-type (acl_permission) | | | | | | The name of an XML element in the CIB to which the | | | permission applies. (Exactly one of ``object-type``, | | | ``xpath``, and ``reference`` must be specified for a | | | permission.) | +------------------+-----------------------------------------------------------+ | attribute | .. index:: | | | single: acl_permission; attribute (attribute) | | | single: attribute; acl_permission attribute | | | single: attribute; attribute (acl_permission) | | | | | | If specified, the permission applies only to | | | ``object-type`` elements that have this attribute set (to | | | any value). If not specified, the permission applies to | | | all ``object-type`` elements. May only be used with | | | ``object-type``. | +------------------+-----------------------------------------------------------+ | reference | .. index:: | | | single: acl_permission; reference (attribute) | | | single: reference; acl_permission attribute | | | single: attribute; reference (acl_permission) | | | | | | The ID of an XML element in the CIB to which the | | | permission applies. (Exactly one of ``object-type``, | | | ``xpath``, and ``reference`` must be specified for a | | | permission.) | +------------------+-----------------------------------------------------------+ | xpath | .. index:: | | | single: acl_permission; xpath (attribute) | | | single: xpath; acl_permission attribute | | | single: attribute; xpath (acl_permission) | | | | | | An `XPath `_ | | | specification selecting an XML element in the CIB to | | | which the permission applies. Attributes may be specified | | | in the XPath to select particular elements, but the | | | permissions apply to the entire element. (Exactly one of | | | ``object-type``, ``xpath``, and ``reference`` must be | | | specified for a permission.) | +------------------+-----------------------------------------------------------+ .. important:: * Permissions are applied to the selected XML element's entire XML subtree (all elements enclosed within it). - + * Write permission grants the ability to create, modify, or remove the element and its subtree, and also the ability to create any "scaffolding" elements (enclosing elements that do not have attributes other than an ID). - + * Permissions for more specific matches (more deeply nested elements) take precedence over more general ones. - + * If multiple permissions are configured for the same match (for example, in different roles applied to the same user), any ``deny`` permission takes precedence, then ``write``, then lastly ``read``. - + ACL Targets and Groups ###################### - + ACL targets correspond to user accounts on the system. .. index:: single: Access Control List (ACL); acl_target pair: acl_target; XML element -.. table:: **Properties of an acl_target element** - :widths: 1 3 +.. table:: **Properties of an acl_target Element** + :widths: 25 75 +------------------+-----------------------------------------------------------+ | Attribute | Description | +==================+===========================================================+ | id | .. index:: | | | single: acl_target; id (attribute) | | | single: id; acl_target attribute | | | single: attribute; id (acl_target) | | | | | | A unique identifier for the target (if ``name`` is not | | | specified, this must be the name of the user account) | | | *(required)* | +------------------+-----------------------------------------------------------+ | name | .. index:: | | | single: acl_target; name (attribute) | | | single: name; acl_target attribute | | | single: attribute; name (acl_target) | | | | | | If specified, the user account name (this allows you to | | | specify a user name that is already used as the ``id`` | | | for some other configuration element) *(since 2.1.5)* | +------------------+-----------------------------------------------------------+ ACL groups correspond to groups on the system. Any role configured for these groups apply to all users in that group *(since 2.1.5)*. - + .. index:: single: Access Control List (ACL); acl_group pair: acl_group; XML element -.. table:: **Properties of an acl_group element** - :widths: 1 3 +.. table:: **Properties of an acl_group Element** + :widths: 25 75 +------------------+-----------------------------------------------------------+ | Attribute | Description | +==================+===========================================================+ | id | .. index:: | | | single: acl_group; id (attribute) | | | single: id; acl_group attribute | | | single: attribute; id (acl_group) | | | | | | A unique identifier for the group (if ``name`` is not | | | specified, this must be the group name) *(required)* | +------------------+-----------------------------------------------------------+ | name | .. index:: | | | single: acl_group; name (attribute) | | | single: name; acl_group attribute | | | single: attribute; name (acl_group) | | | | | | If specified, the group name (this allows you to specify | | | a group name that is already used as the ``id`` for some | | | other configuration element) | +------------------+-----------------------------------------------------------+ Each ``acl_target`` and ``acl_group`` element may contain any number of ``role`` elements. .. note:: If the system users and groups are defined by some network service (such as LDAP), the cluster itself will be unaffected by outages in the service, but affected users and groups will not be able to make changes to the CIB. .. index:: single: Access Control List (ACL); role pair: role; XML element -.. table:: **Properties of a role element** - :widths: 1 3 +.. table:: **Properties of a role Element** + :widths: 25 75 +------------------+-----------------------------------------------------------+ | Attribute | Description | +==================+===========================================================+ | id | .. index:: | | | single: role; id (attribute) | | | single: id; role attribute | | | single: attribute; id (role) | | | | | | The ``id`` of an ``acl_role`` element that specifies | | | permissions granted to the enclosing target or group. | +------------------+-----------------------------------------------------------+ .. important:: The ``root`` and |CRM_DAEMON_USER| user accounts always have full access to the CIB, regardless of ACLs. For all other user accounts, when ``enable-acl`` is true, permission to all parts of the CIB is denied by default (permissions must be explicitly granted). - + ACLs and Pacemaker Remote Nodes ############################### ACLs apply differently on Pacemaker Remote nodes, which are assumed to be special-purpose hosts without typical user accounts. Instead, CIB modifications coming from a Pacemaker Remote node use the node's name as the ACL user name, and ``pacemaker-remote`` as the role. ACL Examples ############ - + .. code-block:: xml - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + In the above example, the user ``alice`` has the minimal permissions necessary to run basic Pacemaker CLI tools, including using ``crm_mon`` to view the cluster status, without being able to modify anything. The user ``bob`` can view the entire configuration and status of the cluster, but not make any changes. The user ``carol`` can read everything, and change selected cluster properties as well as resource roles and location constraints. Finally, ``dave`` has full read and write access to the entire CIB. Looking at the ``minimal`` role in more depth, it is designed to allow read access to the ``cib`` tag itself, while denying access to particular portions of its subtree (which is the entire CIB). This is because the DC node is indicated in the ``cib`` tag, so ``crm_mon`` will not be able to report the DC otherwise. However, this does change the security model to allow by default, since any portions of the CIB not explicitly denied will be readable. The ``cib`` read access could be removed and replaced with read access to just the ``crm_config`` and ``status`` sections, for a safer approach at the cost of not seeing the DC in status output. For a simpler configuration, the ``minimal`` role allows read access to the entire ``crm_config`` section, which contains cluster properties. It would be possible to allow read access to specific properties instead (such as ``stonith-enabled``, ``dc-uuid``, ``have-quorum``, and ``cluster-name``) to restrict access further while still allowing status output, but cluster properties are unlikely to be considered sensitive. ACL Limitations ############### Actions performed via IPC rather than the CIB _____________________________________________ ACLs apply *only* to the CIB. That means ACLs apply to command-line tools that operate by reading or writing the CIB, such as ``crm_attribute`` when managing permanent node attributes, ``crm_mon``, and ``cibadmin``. However, command-line tools that communicate directly with Pacemaker daemons via IPC are not affected by ACLs. For example, users in the |CRM_DAEMON_GROUP| group may still do the following, regardless of ACLs: * Query transient node attribute values using ``crm_attribute`` and ``attrd_updater``. * Query basic node information using ``crm_node``. * Erase resource operation history using ``crm_resource``. * Query fencing configuration information, and execute fencing against nodes, using ``stonith_admin``. ACLs and Pacemaker Remote _________________________ ACLs apply to commands run on Pacemaker Remote nodes using the Pacemaker Remote node's name as the ACL user name. The idea is that Pacemaker Remote nodes (especially virtual machines and containers) are likely to be purpose-built and have different user accounts from full cluster nodes. diff --git a/doc/sphinx/Pacemaker_Explained/alerts.rst b/doc/sphinx/Pacemaker_Explained/alerts.rst index b573bcf2d4..b73d57e346 100644 --- a/doc/sphinx/Pacemaker_Explained/alerts.rst +++ b/doc/sphinx/Pacemaker_Explained/alerts.rst @@ -1,297 +1,297 @@ .. _alerts: .. index:: single: alert single: resource; alert single: node; alert single: fencing; alert pair: XML element; alert pair: XML element; alerts Alerts ------ *Alerts* may be configured to take some external action when a cluster event occurs (node failure, resource starting or stopping, etc.). .. index:: pair: alert; agent Alert Agents ############ As with resource agents, the cluster calls an external program (an *alert agent*) to handle alerts. The cluster passes information about the event to the agent via environment variables. Agents can do anything desired with this information (send an e-mail, log to a file, update a monitoring system, etc.). .. topic:: Simple alert configuration .. code-block:: xml In the example above, the cluster will call ``my-script.sh`` for each event. Multiple alert agents may be configured; the cluster will call all of them for each event. Alert agents will be called only on cluster nodes. They will be called for events involving Pacemaker Remote nodes, but they will never be called *on* those nodes. - + For more information about sample alert agents provided by Pacemaker and about developing custom alert agents, see the *Pacemaker Administration* document. .. index:: single: alert; recipient pair: XML element; recipient Alert Recipients ################ - + Usually, alerts are directed towards a recipient. Thus, each alert may be additionally configured with one or more recipients. The cluster will call the agent separately for each recipient. - + .. topic:: Alert configuration with recipient .. code-block:: xml - + In the above example, the cluster will call ``my-script.sh`` for each event, passing the recipient ``some-address`` as an environment variable. The recipient may be anything the alert agent can recognize -- an IP address, an e-mail address, a file name, whatever the particular agent supports. - - + + .. index:: single: alert; meta-attributes single: meta-attribute; alert meta-attributes Alert Meta-Attributes ##################### - + As with resources, meta-attributes can be configured for alerts to change whether and how Pacemaker calls them. - -.. table:: **Meta-Attributes of an Alert or Recipient** + +.. list-table:: **Meta-Attributes of an Alert or Recipient** :class: longtable - :widths: 1 1 3 - - +------------------+---------------+-----------------------------------------------------+ - | Meta-Attribute | Default | Description | - +==================+===============+=====================================================+ - | description | | .. index:: | - | | | single: acl_permission; description (attribute) | - | | | single: description; acl_permission attribute | - | | | single: attribute; description (acl_permission) | - | | | | - | | | Arbitrary text for user's use (ignored by Pacemaker)| - +------------------+---------------+-----------------------------------------------------+ - | enabled | true | .. index:: | - | | | single: alert; meta-attribute, enabled | - | | | single: meta-attribute; enabled (alert) | - | | | single: enabled; alert meta-attribute | - | | | | - | | | If false for an alert, the alert will not be used. | - | | | If true for an alert and false for a particular | - | | | recipient of that alert, that recipient will not be | - | | | used. *(since 2.1.6)* | - +------------------+---------------+-----------------------------------------------------+ - | timestamp-format | %H:%M:%S.%6N | .. index:: | - | | | single: alert; meta-attribute, timestamp-format | - | | | single: meta-attribute; timestamp-format (alert) | - | | | single: timestamp-format; alert meta-attribute | - | | | | - | | | Format the cluster will use when sending the | - | | | event's timestamp to the agent. This is a string as | - | | | used with the ``date(1)`` command, with the | - | | | following extension. ``"%xN"``, where ``x`` is a | - | | | number with ``1 <= x <= 6``, prints the fractional | - | | | seconds component of the timestamp at ``10^(-x)`` | - | | | resolution, without a decimal point (``'.'``). | - | | | Values are truncated toward zero, not rounded. | - | | | | - | | | Note: This is implemented using ``strftime()`` with | - | | | a 128-character buffer. If any format specifier's | - | | | expansion requires more than 128 characters, or if | - | | | any specifier expands to an empty string, then the | - | | | timestamp is discarded. (Expanding to an empty | - | | | string is not an error, but there is no way to | - | | | distinguish this from a too-small buffer.) | - +------------------+---------------+-----------------------------------------------------+ - | timeout | 30s | .. index:: | - | | | single: alert; meta-attribute, timeout | - | | | single: meta-attribute; timeout (alert) | - | | | single: timeout; alert meta-attribute | - | | | | - | | | If the alert agent does not complete within this | - | | | amount of time, it will be terminated. | - +------------------+---------------+-----------------------------------------------------+ - + :widths: 20 20 60 + :header-rows: 1 + + * - Meta-Attribute + - Default + - Description + * - description + - + - .. index:: + single: acl_permission; description (attribute) + single: description; acl_permission attribute + single: attribute; description (acl_permission) + + Arbitrary text for user's use (ignored by Pacemaker) + * - enabled + - true + - .. index:: + single: alert; meta-attribute, enabled + single: meta-attribute; enabled (alert) + single: enabled; alert meta-attribute + + If false for an alert, the alert will not be used. If true for an alert + and false for a particular recipient of that alert, that recipient will + not be used. *(since 2.1.6)* + * - timestamp-format + - %H:%M:%S.%6N + - .. index:: + single: alert; meta-attribute, timestamp-format + single: meta-attribute; timestamp-format (alert) + single: timestamp-format; alert meta-attribute + + Format the cluster will use when sending the event's timestamp to the + agent. This is a string as used with the ``date(1)`` command, with the + following extension. ``"%xN"``, where ``x`` is a number with + ``1 <= x <= 6``, prints the fractional seconds component of the timestamp + at ``10^(-x)`` resolution, without a decimal point (``'.'``). Values are + truncated toward zero, not rounded. + + Note: This is implemented using ``strftime()`` with a 128-character + buffer. If any format specifier's expansion requires more than 128 + characters, or if any specifier expands to an empty string, then the + timestamp is discarded. (Expanding to an empty string is not an error, + but there is no way to distinguish this from a too-small buffer.) + * - timeout + - 30s + - .. index:: + single: alert; meta-attribute, timeout + single: meta-attribute; timeout (alert) + single: timeout; alert meta-attribute + + If the alert agent does not complete within this amount of time, it + will be terminated. + Meta-attributes can be configured per alert and/or per recipient. - + .. topic:: Alert configuration with meta-attributes .. code-block:: xml - + In the above example, the ``my-script.sh`` will get called twice for each event, with each call using a 15-second timeout. One call will be passed the recipient ``someuser@example.com`` and a timestamp in the format ``%D %H:%M``, while the other call will be passed the recipient ``otheruser@example.com`` and a timestamp in the format ``%c``. - - + + .. index:: single: alert; instance attributes single: instance attribute; alert instance attributes Alert Instance Attributes ######################### - + As with resource agents, agent-specific configuration values may be configured as instance attributes. These will be passed to the agent as additional environment variables. The number, names and allowed values of these instance attributes are completely up to the particular agent. - + .. topic:: Alert configuration with instance attributes .. code-block:: xml - - + + .. index:: single: alert; filters pair: XML element; select pair: XML element; select_nodes pair: XML element; select_fencing pair: XML element; select_resources pair: XML element; select_attributes pair: XML element; attribute Alert Filters ############# - + By default, an alert agent will be called for node events, fencing events, and resource events. An agent may choose to ignore certain types of events, but there is still the overhead of calling it for those events. To eliminate that overhead, you may select which types of events the agent should receive. Alert filters are configured within a ``select`` element inside an ``alert`` element. -.. list-table:: **Possible alert filters** +.. list-table:: **Possible Alert Filters** :class: longtable - :widths: 1 3 + :widths: 25 75 :header-rows: 1 * - Name - Events alerted * - select_nodes - A node joins or leaves the cluster (whether at the cluster layer for cluster nodes, or via a remote connection for Pacemaker Remote nodes). * - select_fencing - Fencing or unfencing of a node completes (whether successfully or not). * - select_resources - A resource action other than meta-data completes (whether successfully or not). * - select_attributes - A transient attribute value update is sent to the CIB. .. topic:: Alert configuration to receive only node events and fencing events .. code-block:: xml - + With ```` (the only event type not enabled by default), the agent will receive alerts when a node attribute changes. If you wish the agent to be called only when certain attributes change, you can configure that as well. - + .. topic:: Alert configuration to be called when certain node attributes change .. code-block:: xml - + Node attribute alerts are currently considered experimental. Alerts may be limited to attributes set via ``attrd_updater``, and agents may be called multiple times with the same attribute value. diff --git a/doc/sphinx/Pacemaker_Explained/ap-samples.rst b/doc/sphinx/Pacemaker_Explained/ap-samples.rst index 35188a8750..e618ef9314 100644 --- a/doc/sphinx/Pacemaker_Explained/ap-samples.rst +++ b/doc/sphinx/Pacemaker_Explained/ap-samples.rst @@ -1,148 +1,148 @@ Sample Configurations --------------------- Empty ##### - + .. topic:: An Empty Configuration .. code-block:: xml - + Simple ###### - + .. topic:: A simple configuration with two nodes, some cluster options and a resource .. code-block:: xml - + In the above example, we have one resource (an IP address) that we check every five minutes and will run on host ``c001n01`` until either the resource fails 10 times or the host shuts down. - + Advanced Configuration ###################### - + .. topic:: An advanced configuration with groups, clones and STONITH .. code-block:: xml diff --git a/doc/sphinx/Pacemaker_Explained/cluster-options.rst b/doc/sphinx/Pacemaker_Explained/cluster-options.rst index 6ebe5f38eb..22329142e5 100644 --- a/doc/sphinx/Pacemaker_Explained/cluster-options.rst +++ b/doc/sphinx/Pacemaker_Explained/cluster-options.rst @@ -1,936 +1,936 @@ Cluster-Wide Configuration -------------------------- .. index:: pair: XML element; cib pair: XML element; configuration Configuration Layout #################### The cluster is defined by the Cluster Information Base (CIB), which uses XML notation. The simplest CIB, an empty one, looks like this: .. topic:: An empty configuration .. code-block:: xml The empty configuration above contains the major sections that make up a CIB: * ``cib``: The entire CIB is enclosed with a ``cib`` element. Certain fundamental settings are defined as attributes of this element. * ``configuration``: This section -- the primary focus of this document -- contains traditional configuration information such as what resources the cluster serves and the relationships among them. * ``crm_config``: cluster-wide configuration options * ``nodes``: the machines that host the cluster * ``resources``: the services run by the cluster * ``constraints``: indications of how resources should be placed * ``status``: This section contains the history of each resource on each node. Based on this data, the cluster can construct the complete current state of the cluster. The authoritative source for this section is the local executor (pacemaker-execd process) on each cluster node, and the cluster will occasionally repopulate the entire section. For this reason, it is never written to disk, and administrators are advised against modifying it in any way. In this document, configuration settings will be described as properties or options based on how they are defined in the CIB: * Properties are XML attributes of an XML element. * Options are name-value pairs expressed as ``nvpair`` child elements of an XML element. Normally, you will use command-line tools that abstract the XML, so the distinction will be unimportant; both properties and options are cluster settings you can tweak. Options can appear within four types of enclosing elements: * ``cluster_property_set`` * ``instance_attributes`` * ``meta_attributes`` * ``utilization`` We will refer to a set of options and its enclosing element as a *block*. .. list-table:: **Properties of an Option Block's Enclosing Element** :class: longtable - :widths: 2 2 3 5 + :widths: 15 15 15 55 :header-rows: 1 * - Name - Type - Default - Description * - .. _option_block_id: .. index:: pair: id; cluster_property_set pair: id; instance_attributes pair: id; meta_attributes pair: id; utilization single: attribute; id (cluster_property_set) single: attribute; id (instance_attributes) single: attribute; id (meta_attributes) single: attribute; id (utilization) id - :ref:`id ` - - A unique name for the block (required) * - .. _option_block_score: .. index:: pair: score; cluster_property_set pair: score; instance_attributes pair: score; meta_attributes pair: score; utilization single: attribute; score (cluster_property_set) single: attribute; score (instance_attributes) single: attribute; score (meta_attributes) single: attribute; score (utilization) score - :ref:`score ` - 0 - Priority with which to process the block Each block may optionally contain a :ref:`rule `. .. _option_precedence: Option Precedence ################# This subsection describes the precedence of options within a set of blocks and within a single block. Options are processed as follows: * All option blocks of a given type are processed in order of their ``score`` attribute, from highest to lowest. For ``cluster_property_set``, if there is a block whose enclosing element has ``id="cib-bootstrap-options"``, then that block is always processed first regardless of score. * If a block contains a rule that evaluates to false, that block is skipped. * Within a block, options are processed in order from first to last. * The first value found for a given option is applied, and the rest are ignored. Note that this means it is pointless to configure the same option twice in a single block, because occurrences after the first one would be ignored. For example, in the following configuration snippet, the ``no-quorum-policy`` value ``demote`` is applied. ``property-set2`` has a higher score than ``property-set1``, so it's processed first. There are no rules in this snippet, so both sets are processed. Within ``property-set2``, the value ``demote`` appears first, so the later value ``freeze`` is ignored. We've already found a value for ``no-quorum-policy`` before we begin processing ``property-set1``, so its value ``stop`` is ignored. .. code-block:: xml CIB Properties ############## Certain settings are defined by CIB properties (that is, attributes of the ``cib`` tag) rather than with the rest of the cluster configuration in the ``configuration`` section. The reason is simply a matter of parsing. These options are used by the configuration database which is, by design, mostly ignorant of the content it holds. So the decision was made to place them in an easy-to-find location. .. list-table:: **CIB Properties** :class: longtable - :widths: 2 2 2 5 + :widths: 20 15 10 55 :header-rows: 1 * - Name - Type - Default - Description * - .. _admin_epoch: - + .. index:: pair: admin_epoch; cib - + admin_epoch - :ref:`nonnegative integer ` - 0 - When a node joins the cluster, the cluster asks the node with the highest (``admin_epoch``, ``epoch``, ``num_updates``) tuple to replace the configuration on all the nodes -- which makes setting them correctly very important. ``admin_epoch`` is never modified by the cluster; you can use this to make the configurations on any inactive nodes obsolete. * - .. _epoch: - + .. index:: pair: epoch; cib - + epoch - :ref:`nonnegative integer ` - 0 - The cluster increments this every time the CIB's configuration section is updated. * - .. _num_updates: - + .. index:: pair: num_updates; cib - + num_updates - :ref:`nonnegative integer ` - 0 - The cluster increments this every time the CIB's configuration or status sections are updated, and resets it to 0 when epoch changes. * - .. _validate_with: - + .. index:: pair: validate-with; cib - + validate-with - :ref:`enumeration ` - - Determines the type of XML validation that will be done on the configuration. Allowed values are ``none`` (in which case the cluster will not require that updates conform to expected syntax) and the base names of schema files installed on the local machine (for example, "pacemaker-3.9") * - .. _remote_tls_port: - + .. index:: pair: remote-tls-port; cib - + remote-tls-port - :ref:`port ` - - If set, the CIB manager will listen for anonymously encrypted remote connections on this port, to allow CIB administration from hosts not in the cluster. No key is used, so this should be used only on a protected network where man-in-the-middle attacks can be avoided. * - .. _remote_clear_port: - + .. index:: pair: remote-clear-port; cib - + remote-clear-port - :ref:`port ` - - If set to a TCP port number, the CIB manager will listen for remote connections on this port, to allow for CIB administration from hosts not in the cluster. No encryption is used, so this should be used only on a protected network. * - .. _cib_last_written: - + .. index:: pair: cib-last-written; cib - + cib-last-written - :ref:`date/time ` - - Indicates when the configuration was last written to disk. Maintained by the cluster; for informational purposes only. * - .. _have_quorum: - + .. index:: pair: have-quorum; cib - + have-quorum - :ref:`boolean ` - - Indicates whether the cluster has quorum. If false, the cluster's response is determined by ``no-quorum-policy`` (see below). Maintained by the cluster. * - .. _dc_uuid: - + .. index:: pair: dc-uuid; cib - + dc-uuid - :ref:`text ` - - Node ID of the cluster's current designated controller (DC). Used and maintained by the cluster. * - .. _execution_date: - + .. index:: pair: execution-date; cib - + execution-date - :ref:`epoch time ` - - Time to use when evaluating rules. .. _cluster_options: Cluster Options ############### Cluster options, as you might expect, control how the cluster behaves when confronted with various situations. They are grouped into sets within the ``crm_config`` section. In advanced configurations, there may be more than one set. (This will be described later in the chapter on :ref:`rules` where we will show how to have the cluster use different sets of options during working hours than during weekends.) For now, we will describe the simple case where each option is present at most once. You can obtain an up-to-date list of cluster options, including their default values, by running the ``man pacemaker-schedulerd`` and ``man pacemaker-controld`` commands. .. list-table:: **Cluster Options** :class: longtable - :widths: 2 2 2 5 + :widths: 25 13 12 50 :header-rows: 1 * - Name - Type - Default - Description * - .. _cluster_name: - + .. index:: pair: cluster option; cluster-name - + cluster-name - :ref:`text ` - - An (optional) name for the cluster as a whole. This is mostly for users' convenience for use as desired in administration, but can be used in the Pacemaker configuration in :ref:`rules` (as the ``#cluster-name`` :ref:`node attribute `). It may also be used by higher-level tools when displaying cluster information, and by certain resource agents (for example, the ``ocf:heartbeat:GFS2`` agent stores the cluster name in filesystem meta-data). * - .. _dc_version: - + .. index:: pair: cluster option; dc-version - + dc-version - :ref:`version ` - *detected* - Version of Pacemaker on the cluster's designated controller (DC). Maintained by the cluster, and intended for diagnostic purposes. * - .. _cluster_infrastructure: - + .. index:: pair: cluster option; cluster-infrastructure - + cluster-infrastructure - :ref:`text ` - *detected* - The messaging layer with which Pacemaker is currently running. Maintained by the cluster, and intended for informational and diagnostic purposes. * - .. _no_quorum_policy: - + .. index:: pair: cluster option; no-quorum-policy - + no-quorum-policy - :ref:`enumeration ` - stop - What to do when the cluster does not have quorum. Allowed values: - + * ``ignore:`` continue all resource management * ``freeze:`` continue resource management, but don't recover resources from nodes not in the affected partition * ``stop:`` stop all resources in the affected cluster partition * ``demote:`` demote promotable resources and stop all other resources in the affected cluster partition *(since 2.0.5)* * ``fence:`` fence all nodes in the affected cluster partition *(since 2.1.9)* * ``suicide:`` same as ``fence`` *(deprecated since 2.1.9)* * - .. _batch_limit: - + .. index:: pair: cluster option; batch-limit - + batch-limit - :ref:`integer ` - 0 - The maximum number of actions that the cluster may execute in parallel across all nodes. The ideal value will depend on the speed and load of your network and cluster nodes. If zero, the cluster will impose a dynamically calculated limit only when any node has high load. If -1, the cluster will not impose any limit. * - .. _migration_limit: - + .. index:: pair: cluster option; migration-limit - + migration-limit - :ref:`integer ` - -1 - The number of :ref:`live migration ` actions that the cluster is allowed to execute in parallel on a node. A value of -1 means unlimited. * - .. _load_threshold: - + .. index:: pair: cluster option; load-threshold - + load-threshold - :ref:`percentage ` - 80% - Maximum amount of system load that should be used by cluster nodes. The cluster will slow down its recovery process when the amount of system resources used (currently CPU) approaches this limit. * - .. _node_action_limit: - + .. index:: pair: cluster option; node-action-limit - + node-action-limit - :ref:`integer ` - 0 - Maximum number of jobs that can be scheduled per node. If nonpositive or invalid, double the number of cores is used as the maximum number of jobs per node. :ref:`PCMK_node_action_limit ` overrides this option on a per-node basis. * - .. _symmetric_cluster: - + .. index:: pair: cluster option; symmetric-cluster - + symmetric-cluster - :ref:`boolean ` - true - If true, resources can run on any node by default. If false, a resource is allowed to run on a node only if a :ref:`location constraint ` enables it. * - .. _stop_all_resources: - + .. index:: pair: cluster option; stop-all-resources - + stop-all-resources - :ref:`boolean ` - false - Whether all resources should be disallowed from running (can be useful during maintenance or troubleshooting) * - .. _stop_orphan_resources: - + .. index:: pair: cluster option; stop-orphan-resources - + stop-orphan-resources - :ref:`boolean ` - true - Whether resources that have been deleted from the configuration should be stopped. This value takes precedence over :ref:`is-managed ` (that is, even unmanaged resources will be stopped when orphaned if this value is ``true``). * - .. _stop_orphan_actions: - + .. index:: pair: cluster option; stop-orphan-actions - + stop-orphan-actions - :ref:`boolean ` - true - Whether recurring :ref:`operations ` that have been deleted from the configuration should be cancelled * - .. _start_failure_is_fatal: - + .. index:: pair: cluster option; start-failure-is-fatal - + start-failure-is-fatal - :ref:`boolean ` - true - Whether a failure to start a resource on a particular node prevents further start attempts on that node. If ``false``, the cluster will decide whether the node is still eligible based on the resource's current failure count and ``migration-threshold``. * - .. _enable_startup_probes: - + .. index:: pair: cluster option; enable-startup-probes - + enable-startup-probes - :ref:`boolean ` - true - Whether the cluster should check the pre-existing state of resources when the cluster starts * - .. _maintenance_mode: - + .. index:: pair: cluster option; maintenance-mode - + maintenance-mode - :ref:`boolean ` - false - If true, the cluster will not start or stop any resource in the cluster, and any recurring operations (expect those specifying ``role`` as ``Stopped``) will be paused. If true, this overrides the :ref:`maintenance ` node attribute, :ref:`is-managed ` and :ref:`maintenance ` resource meta-attributes, and :ref:`enabled ` operation meta-attribute. * - .. _stonith_enabled: - + .. index:: pair: cluster option; stonith-enabled - + stonith-enabled - :ref:`boolean ` - true - Whether the cluster is allowed to fence nodes (for example, failed nodes and nodes with resources that can't be stopped). - + If true, at least one fence device must be configured before resources are allowed to run. - + If false, unresponsive nodes are immediately assumed to be running no resources, and resource recovery on online nodes starts without any further protection (which can mean *data loss* if the unresponsive node still accesses shared storage, for example). See also the :ref:`requires ` resource meta-attribute. This option applies only to fencing scheduled by the cluster, not to requests initiated externally (such as with the ``stonith_admin`` command-line tool). * - .. _stonith_action: - + .. index:: pair: cluster option; stonith-action - + stonith-action - :ref:`enumeration ` - reboot - Action the cluster should send to the fence agent when a node must be fenced. Allowed values are ``reboot`` and ``off``. * - .. _stonith_timeout: - + .. index:: pair: cluster option; stonith-timeout - + stonith-timeout - :ref:`duration ` - 60s - How long to wait for ``on``, ``off``, and ``reboot`` fence actions to complete by default. * - .. _stonith_max_attempts: - + .. index:: pair: cluster option; stonith-max-attempts - + stonith-max-attempts - :ref:`score ` - 10 - How many times fencing can fail for a target before the cluster will no longer immediately re-attempt it. Any value below 1 will be ignored, and the default will be used instead. * - .. _have_watchdog: .. index:: pair: cluster option; have-watchdog have-watchdog - :ref:`boolean ` - *detected* - Whether watchdog integration is enabled. This is set automatically by the cluster according to whether SBD is detected to be in use. User-configured values are ignored. The value `true` is meaningful if diskless SBD is used and :ref:`stonith-watchdog-timeout ` is nonzero. In that case, if fencing is required, watchdog-based self-fencing will be performed via SBD without requiring a fencing resource explicitly configured. * - .. _stonith_watchdog_timeout: - + .. index:: pair: cluster option; stonith-watchdog-timeout - + stonith-watchdog-timeout - :ref:`timeout ` - 0 - If nonzero, and the cluster detects ``have-watchdog`` as ``true``, then watchdog-based self-fencing will be performed via SBD when fencing is required. - + If this is set to a positive value, lost nodes are assumed to achieve self-fencing within this much time. This does not require a fencing resource to be explicitly configured, though a fence_watchdog resource can be configured, to limit use to specific nodes. If this is set to 0 (the default), the cluster will never assume watchdog-based self-fencing. If this is set to a negative value, the cluster will use twice the local value of the ``SBD_WATCHDOG_TIMEOUT`` environment variable if that is positive, or otherwise treat this as 0. - + **Warning:** When used, this timeout must be larger than ``SBD_WATCHDOG_TIMEOUT`` on all nodes that use watchdog-based SBD, and Pacemaker will refuse to start on any of those nodes where this is not true for the local value or SBD is not active. When this is set to a negative value, ``SBD_WATCHDOG_TIMEOUT`` must be set to the same value on all nodes that use SBD, otherwise data corruption or loss could occur. - + * - .. _concurrent-fencing: - + .. index:: pair: cluster option; concurrent-fencing - + concurrent-fencing - :ref:`boolean ` - false - Whether the cluster is allowed to initiate multiple fence actions concurrently. Fence actions initiated externally, such as via the ``stonith_admin`` tool or an application such as DLM, or by the fencer itself such as recurring device monitors and ``status`` and ``list`` commands, are not limited by this option. * - .. _fence_reaction: - + .. index:: pair: cluster option; fence-reaction - + fence-reaction - :ref:`enumeration ` - stop - How should a cluster node react if notified of its own fencing? A cluster node may receive notification of a "succeeded" fencing that targeted it if fencing is misconfigured, or if fabric fencing is in use that doesn't cut cluster communication. Allowed values are ``stop`` to attempt to immediately stop Pacemaker and stay stopped, or ``panic`` to attempt to immediately reboot the local node, falling back to stop on failure. The default is likely to be changed to ``panic`` in a future release. *(since 2.0.3)* * - .. _priority_fencing_delay: - + .. index:: pair: cluster option; priority-fencing-delay - + priority-fencing-delay - :ref:`duration ` - 0 - Apply this delay to any fencing targeting the lost nodes with the highest total resource priority in case we don't have the majority of the nodes in our cluster partition, so that the more significant nodes potentially win any fencing match (especially meaningful in a split-brain of a 2-node cluster). A promoted resource instance takes the resource's priority plus 1 if the resource's priority is not 0. Any static or random delays introduced by ``pcmk_delay_base`` and ``pcmk_delay_max`` configured for the corresponding fencing resources will be added to this delay. This delay should be significantly greater than (safely twice) the maximum delay from those parameters. *(since 2.0.4)* * - .. _node_pending_timeout: - + .. index:: pair: cluster option; node-pending-timeout - + node-pending-timeout - :ref:`duration ` - 0 - Fence nodes that do not join the controller process group within this much time after joining the cluster, to allow the cluster to continue managing resources. A value of 0 means never fence pending nodes. Setting the value to 2h means fence nodes after 2 hours. *(since 2.1.7)* * - .. _cluster_delay: - + .. index:: pair: cluster option; cluster-delay - + cluster-delay - :ref:`duration ` - 60s - If the DC requires an action to be executed on another node, it will consider the action failed if it does not get a response from the other node within this time (beyond the action's own timeout). The ideal value will depend on the speed and load of your network and cluster nodes. * - .. _dc_deadtime: - + .. index:: pair: cluster option; dc-deadtime - + dc-deadtime - :ref:`duration ` - 20s - How long to wait for a response from other nodes when electing a DC. The ideal value will depend on the speed and load of your network and cluster nodes. * - .. _cluster_ipc_limit: - + .. index:: pair: cluster option; cluster-ipc-limit - + cluster-ipc-limit - :ref:`nonnegative integer ` - 500 - The maximum IPC message backlog before one cluster daemon will disconnect another. This is of use in large clusters, for which a good value is the number of resources in the cluster multiplied by the number of nodes. The default of 500 is also the minimum. Raise this if you see "Evicting client" log messages for cluster daemon process IDs. * - .. _pe_error_series_max: - + .. index:: pair: cluster option; pe-error-series-max - + pe-error-series-max - :ref:`integer ` - -1 - The number of scheduler inputs resulting in errors to save. These inputs can be helpful during troubleshooting and when reporting issues. A negative value means save all inputs, and 0 means save none. * - .. _pe_warn_series_max: - + .. index:: pair: cluster option; pe-warn-series-max - + pe-warn-series-max - :ref:`integer ` - 5000 - The number of scheduler inputs resulting in warnings to save. These inputs can be helpful during troubleshooting and when reporting issues. A negative value means save all inputs, and 0 means save none. * - .. _pe_input_series_max: - + .. index:: pair: cluster option; pe-input-series-max - + pe-input-series-max - :ref:`integer ` - 4000 - The number of "normal" scheduler inputs to save. These inputs can be helpful during troubleshooting and when reporting issues. A negative value means save all inputs, and 0 means save none. * - .. _enable_acl: - + .. index:: pair: cluster option; enable-acl - + enable-acl - :ref:`boolean ` - false - Whether :ref:`access control lists ` should be used to authorize CIB modifications * - .. _placement_strategy: - + .. index:: pair: cluster option; placement-strategy - + placement-strategy - :ref:`enumeration ` - default - How the cluster should assign resources to nodes (see :ref:`utilization`). Allowed values are ``default``, ``utilization``, ``balanced``, and ``minimal``. * - .. _node_health_strategy: - + .. index:: pair: cluster option; node-health-strategy - + node-health-strategy - :ref:`enumeration ` - none - How the cluster should react to :ref:`node health ` attributes. Allowed values are ``none``, ``migrate-on-red``, ``only-green``, ``progressive``, and ``custom``. * - .. _node_health_base: - + .. index:: pair: cluster option; node-health-base - + node-health-base - :ref:`score ` - 0 - The base health score assigned to a node. Only used when ``node-health-strategy`` is ``progressive``. * - .. _node_health_green: - + .. index:: pair: cluster option; node-health-green - + node-health-green - :ref:`score ` - 0 - The score to use for a node health attribute whose value is ``green``. Only used when ``node-health-strategy`` is ``progressive`` or ``custom``. * - .. _node_health_yellow: - + .. index:: pair: cluster option; node-health-yellow - + node-health-yellow - :ref:`score ` - 0 - The score to use for a node health attribute whose value is ``yellow``. Only used when ``node-health-strategy`` is ``progressive`` or ``custom``. * - .. _node_health_red: - + .. index:: pair: cluster option; node-health-red - + node-health-red - :ref:`score ` - -INFINITY - The score to use for a node health attribute whose value is ``red``. Only used when ``node-health-strategy`` is ``progressive`` or ``custom``. * - .. _cluster_recheck_interval: - + .. index:: pair: cluster option; cluster-recheck-interval - + cluster-recheck-interval - :ref:`duration ` - 15min - Pacemaker is primarily event-driven, and looks ahead to know when to recheck the cluster for failure-timeout settings and most time-based rules *(since 2.0.3)*. However, it will also recheck the cluster after this amount of inactivity. This has three main effects: - + * :ref:`Rules ` using ``date_spec`` are guaranteed to be checked only this often. * If :ref:`fencing ` fails enough to reach :ref:`stonith-max-attempts `, attempts will begin again after at most this time. * It serves as a fail-safe in case of certain scheduler bugs. If the scheduler incorrectly determines only some of the actions needed to react to a particular event, it will often correctly determine the rest after at most this time. - + A value of 0 disables this polling. * - .. _shutdown_lock: - + .. index:: pair: cluster option; shutdown-lock - + shutdown-lock - :ref:`boolean ` - false - The default of false allows active resources to be recovered elsewhere when their node is cleanly shut down, which is what the vast majority of users will want. However, some users prefer to make resources highly available only for failures, with no recovery for clean shutdowns. If this option is true, resources active on a node when it is cleanly shut down are kept "locked" to that node (not allowed to run elsewhere) until they start again on that node after it rejoins (or for at most ``shutdown-lock-limit``, if set). Stonith resources and Pacemaker Remote connections are never locked. Clone and bundle instances and the promoted role of promotable clones are currently never locked, though support could be added in a future release. Locks may be manually cleared using the ``--refresh`` option of ``crm_resource`` (both the resource and node must be specified; this works with remote nodes if their connection resource's ``target-role`` is set to ``Stopped``, but not if Pacemaker Remote is stopped on the remote node without disabling the connection resource). *(since 2.0.4)* * - .. _shutdown_lock_limit: - + .. index:: pair: cluster option; shutdown-lock-limit - + shutdown-lock-limit - :ref:`duration ` - 0 - If ``shutdown-lock`` is true, and this is set to a nonzero time duration, locked resources will be allowed to start after this much time has passed since the node shutdown was initiated, even if the node has not rejoined. (This works with remote nodes only if their connection resource's ``target-role`` is set to ``Stopped``.) *(since 2.0.4)* * - .. _startup_fencing: - + .. index:: pair: cluster option; startup-fencing - + startup-fencing - :ref:`boolean ` - true - *Advanced Use Only:* Whether the cluster should fence unseen nodes at start-up. Setting this to false is unsafe, because the unseen nodes could be active and running resources but unreachable. ``dc-deadtime`` acts as a grace period before this fencing, since a DC must be elected to schedule fencing. * - .. _election_timeout: - + .. index:: pair: cluster option; election-timeout - + election-timeout - :ref:`duration ` - 2min - *Advanced Use Only:* If a winner is not declared within this much time of starting an election, the node that initiated the election will declare itself the winner. * - .. _shutdown_escalation: - + .. index:: pair: cluster option; shutdown-escalation - + shutdown-escalation - :ref:`duration ` - 20min - *Advanced Use Only:* The controller will exit immediately if a shutdown does not complete within this much time. * - .. _join_integration_timeout: - + .. index:: pair: cluster option; join-integration-timeout - + join-integration-timeout - :ref:`duration ` - 3min - *Advanced Use Only:* If you need to adjust this value, it probably indicates the presence of a bug. * - .. _join_finalization_timeout: - + .. index:: pair: cluster option; join-finalization-timeout - + join-finalization-timeout - :ref:`duration ` - 30min - *Advanced Use Only:* If you need to adjust this value, it probably indicates the presence of a bug. * - .. _transition_delay: - + .. index:: pair: cluster option; transition-delay - + transition-delay - :ref:`duration ` - 0s - *Advanced Use Only:* Delay cluster recovery for the configured interval to allow for additional or related events to occur. This can be useful if your configuration is sensitive to the order in which ping updates arrive. Enabling this option will slow down cluster recovery under all conditions. diff --git a/doc/sphinx/Pacemaker_Explained/collective.rst b/doc/sphinx/Pacemaker_Explained/collective.rst index 73fb7a7e4a..36142a7132 100644 --- a/doc/sphinx/Pacemaker_Explained/collective.rst +++ b/doc/sphinx/Pacemaker_Explained/collective.rst @@ -1,1193 +1,1203 @@ .. index: single: collective resource single: resource; collective Collective Resources -------------------- Pacemaker supports several types of *collective* resources, which consist of multiple, related resource instances. .. index: single: group resource single: resource; group .. _group-resources: Groups - A Syntactic Shortcut ############################# One of the most common elements of a cluster is a set of resources that need to be located together, start sequentially, and stop in the reverse order. To simplify this configuration, we support the concept of groups. - + .. topic:: A group of two primitive resources .. code-block:: xml - - + + Although the example above contains only two resources, there is no limit to the number of resources a group can contain. The example is also sufficient to explain the fundamental properties of a group: - + * Resources are started in the order they appear in (**Public-IP** first, then **Email**) * Resources are stopped in the reverse order to which they appear in (**Email** first, then **Public-IP**) - + If a resource in the group can't run anywhere, then nothing after that is allowed to run, too. - + * If **Public-IP** can't run anywhere, neither can **Email**; * but if **Email** can't run anywhere, this does not affect **Public-IP** in any way - + The group above is logically equivalent to writing: - + .. topic:: How the cluster sees a group resource .. code-block:: xml - + Obviously as the group grows bigger, the reduced configuration effort can become significant. Another (typical) example of a group is a DRBD volume, the filesystem mount, an IP address, and an application that uses them. .. index:: pair: XML element; group Group Properties ________________ -.. table:: **Properties of a Group Resource** - :widths: 1 4 - - +-------------+------------------------------------------------------------------+ - | Field | Description | - +=============+==================================================================+ - | id | .. index:: | - | | single: group; property, id | - | | single: property; id (group) | - | | single: id; group property | - | | | - | | A unique name for the group | - +-------------+------------------------------------------------------------------+ - | description | .. index:: | - | | single: group; attribute, description | - | | single: attribute; description (group) | - | | single: description; group attribute | - | | | - | | Arbitrary text for user's use (ignored by Pacemaker) | - +-------------+------------------------------------------------------------------+ +.. list-table:: **Properties of a Group Resource** + :widths: 25 75 + :header-rows: 1 + + * - Field + - Description + * - id + - .. index:: + single: group; property, id + single: property; id (group) + single: id; group property + + A unique name for the group + * - description + - .. index:: + single: group; attribute, description + single: attribute; description (group) + single: description; group attribute + + Arbitrary text for user's use (ignored by Pacemaker) Group Options _____________ Groups inherit the ``priority``, ``target-role``, and ``is-managed`` properties from primitive resources. See :ref:`resource_options` for information about those properties. - + Group Instance Attributes _________________________ Groups have no instance attributes. However, any that are set for the group object will be inherited by the group's children. - + Group Contents ______________ Groups may only contain a collection of cluster resources (see :ref:`primitive-resource`). To refer to a child of a group resource, just use the child's ``id`` instead of the group's. - + Group Constraints _________________ - + Although it is possible to reference a group's children in constraints, it is usually preferable to reference the group itself. - + .. topic:: Some constraints involving groups .. code-block:: xml - + .. index:: pair: resource-stickiness; group Group Stickiness ________________ - + Stickiness, the measure of how much a resource wants to stay where it is, is additive in groups. Every active resource of the group will contribute its stickiness value to the group's total. So if the default ``resource-stickiness`` is 100, and a group has seven members, five of which are active, then the group as a whole will prefer its current location with a score of 500. .. index:: single: clone single: resource; clone - + .. _s-resource-clone: Clones - Resources That Can Have Multiple Active Instances ########################################################## *Clone* resources are resources that can have more than one copy active at the same time. This allows you, for example, to run a copy of a daemon on every node. You can clone any primitive or group resource [#]_. - + Anonymous versus Unique Clones ______________________________ - + A clone resource is configured to be either *anonymous* or *globally unique*. - + Anonymous clones are the simplest. These behave completely identically everywhere they are running. Because of this, there can be only one instance of an anonymous clone active per node. - + The instances of globally unique clones are distinct entities. All instances are launched identically, but one instance of the clone is not identical to any other instance, whether running on the same node or a different node. As an example, a cloned IP address can use special kernel functionality such that each instance handles a subset of requests for the same IP address. .. index:: single: promotable clone single: resource; promotable .. _s-resource-promotable: Promotable clones _________________ If a clone is *promotable*, its instances can perform a special role that Pacemaker will manage via the ``promote`` and ``demote`` actions of the resource agent. Services that support such a special role have various terms for the special role and the default role: primary and secondary, master and replica, controller and worker, etc. Pacemaker uses the terms *promoted* and *unpromoted* to be agnostic to what the service calls them or what they do. - + All that Pacemaker cares about is that an instance comes up in the unpromoted role when started, and the resource agent supports the ``promote`` and ``demote`` actions to manage entering and exiting the promoted role. .. index:: pair: XML element; clone - + Clone Properties ________________ - -.. table:: **Properties of a Clone Resource** - :widths: 1 4 - - +-------------+------------------------------------------------------------------+ - | Field | Description | - +=============+==================================================================+ - | id | .. index:: | - | | single: clone; property, id | - | | single: property; id (clone) | - | | single: id; clone property | - | | | - | | A unique name for the clone | - +-------------+------------------------------------------------------------------+ - | description | .. index:: | - | | single: clone; attribute, description | - | | single: attribute; description (clone) | - | | single: description; clone attribute | - | | | - | | Arbitrary text for user's use (ignored by Pacemaker) | - +-------------+------------------------------------------------------------------+ + +.. list-table:: **Properties of a Clone Resource** + :widths: 25 75 + :header-rows: 1 + + * - Field + - Description + * - id + - .. index:: + single: clone; property, id + single: property; id (clone) + single: id; clone property + + A unique name for the clone + * - description + - .. index:: + single: clone; attribute, description + single: attribute; description (clone) + single: description; clone attribute + + Arbitrary text for user's use (ignored by Pacemaker) .. index:: pair: options; clone Clone Options _____________ :ref:`Options ` inherited from primitive resources: ``priority, target-role, is-managed`` - -.. table:: **Clone-specific configuration options** + +.. list-table:: **Clone-Specific Configuration Options** :class: longtable - :widths: 1 1 3 - - +-------------------+-----------------+-------------------------------------------------------+ - | Field | Default | Description | - +===================+=================+=======================================================+ - | globally-unique | **true** if | .. index:: | - | | clone-node-max | single: clone; option, globally-unique | - | | is greater than | single: option; globally-unique (clone) | - | | 1 *(since* | single: globally-unique; clone option | - | | *3.0.0)*, | | - | | otherwise | If **true**, each clone instance performs a | - | | **false** | distinct function, such that a single node can run | - | | | more than one instance at the same time | - +-------------------+-----------------+-------------------------------------------------------+ - | clone-max | 0 | .. index:: | - | | | single: clone; option, clone-max | - | | | single: option; clone-max (clone) | - | | | single: clone-max; clone option | - | | | | - | | | The maximum number of clone instances that can | - | | | be started across the entire cluster. If 0, the | - | | | number of nodes in the cluster will be used. | - +-------------------+-----------------+-------------------------------------------------------+ - | clone-node-max | 1 | .. index:: | - | | | single: clone; option, clone-node-max | - | | | single: option; clone-node-max (clone) | - | | | single: clone-node-max; clone option | - | | | | - | | | If the clone is globally unique, this is the maximum | - | | | number of clone instances that can be started | - | | | on a single node | - +-------------------+-----------------+-------------------------------------------------------+ - | clone-min | 0 | .. index:: | - | | | single: clone; option, clone-min | - | | | single: option; clone-min (clone) | - | | | single: clone-min; clone option | - | | | | - | | | Require at least this number of clone instances | - | | | to be runnable before allowing resources | - | | | depending on the clone to be runnable. A value | - | | | of 0 means require all clone instances to be | - | | | runnable. | - +-------------------+-----------------+-------------------------------------------------------+ - | notify | false | .. index:: | - | | | single: clone; option, notify | - | | | single: option; notify (clone) | - | | | single: notify; clone option | - | | | | - | | | Call the resource agent's **notify** action for | - | | | all active instances, before and after starting | - | | | or stopping any clone instance. The resource | - | | | agent must support this action. | - | | | Allowed values: **false**, **true** | - +-------------------+-----------------+-------------------------------------------------------+ - | ordered | false | .. index:: | - | | | single: clone; option, ordered | - | | | single: option; ordered (clone) | - | | | single: ordered; clone option | - | | | | - | | | If **true**, clone instances must be started | - | | | sequentially instead of in parallel. | - | | | Allowed values: **false**, **true** | - +-------------------+-----------------+-------------------------------------------------------+ - | interleave | false | .. index:: | - | | | single: clone; option, interleave | - | | | single: option; interleave (clone) | - | | | single: interleave; clone option | - | | | | - | | | When this clone is ordered relative to another | - | | | clone, if this option is **false** (the default), | - | | | the ordering is relative to *all* instances of | - | | | the other clone, whereas if this option is | - | | | **true**, the ordering is relative only to | - | | | instances on the same node. | - | | | Allowed values: **false**, **true** | - +-------------------+-----------------+-------------------------------------------------------+ - | promotable | false | .. index:: | - | | | single: clone; option, promotable | - | | | single: option; promotable (clone) | - | | | single: promotable; clone option | - | | | | - | | | If **true**, clone instances can perform a | - | | | special role that Pacemaker will manage via the | - | | | resource agent's **promote** and **demote** | - | | | actions. The resource agent must support these | - | | | actions. | - | | | Allowed values: **false**, **true** | - +-------------------+-----------------+-------------------------------------------------------+ - | promoted-max | 1 | .. index:: | - | | | single: clone; option, promoted-max | - | | | single: option; promoted-max (clone) | - | | | single: promoted-max; clone option | - | | | | - | | | If ``promotable`` is **true**, the number of | - | | | instances that can be promoted at one time | - | | | across the entire cluster | - +-------------------+-----------------+-------------------------------------------------------+ - | promoted-node-max | 1 | .. index:: | - | | | single: clone; option, promoted-node-max | - | | | single: option; promoted-node-max (clone) | - | | | single: promoted-node-max; clone option | - | | | | - | | | If the clone is promotable and globally unique, this | - | | | is the number of instances that can be promoted at | - | | | one time on a single node (up to ``clone-node-max``) | - +-------------------+-----------------+-------------------------------------------------------+ - + :widths: 20 20 60 + :header-rows: 1 + + * - Field + - Default + - Description + * - globally-unique + - **true** if clone-node-max is greater than 1 *(since 3.0.0)*, otherwise + **false** + - .. index:: + single: clone; option, globally-unique + single: option; globally-unique (clone) + single: globally-unique; clone option + + If **true**, each clone instance performs a distinct function, such that + a single node can run more than one instance at the same time + * - clone-max + - 0 + - .. index:: + single: clone; option, clone-max + single: option; clone-max (clone) + single: clone-max; clone option + + The maximum number of clone instances that can be started across the + entire cluster. If 0, the number of nodes in the cluster will be used. + * - clone-node-max + - 1 + - .. index:: + single: clone; option, clone-node-max + single: option; clone-node-max (clone) + single: clone-node-max; clone option + + If the clone is globally unique, this is the maximum number of clone + instances that can be started on a single node + * - clone-min + - 0 + - .. index:: + single: clone; option, clone-min + single: option; clone-min (clone) + single: clone-min; clone option + + Require at least this number of clone instances to be runnable before + allowing resources depending on the clone to be runnable. A value of + 0 means require all clone instances to be runnable. + * - notify + - false + - .. index:: + single: clone; option, notify + single: option; notify (clone) + single: notify; clone option + + Call the resource agent's **notify** action for all active instances, + before and after starting or stopping any clone instance. The + resource agent must support this action. Allowed values: **false**, + **true** + * - ordered + - false + - .. index:: + single: clone; option, ordered + single: option; ordered (clone) + single: ordered; clone option + + If **true**, clone instances must be started sequentially instead of + in parallel. Allowed values: **false**, **true** + * - interleave + - false + - .. index:: + single: clone; option, interleave + single: option; interleave (clone) + single: interleave; clone option + + When this clone is ordered relative to another clone, if this option is + **false** (the default), the ordering is relative to *all* instances of + the other clone, whereas if this option is **true**, the ordering is + relative only to instances on the same node. Allowed values: **false**, + **true** + * - promotable + - false + - .. index:: + single: clone; option, promotable + single: option; promotable (clone) + single: promotable; clone option + + If **true**, clone instances can perform a special role that Pacemaker + will manage via the resource agent's **promote** and **demote** actions. + The resource agent must support these actions. Allowed values: + **false**, **true** + * - promoted-max + - 1 + - .. index:: + single: clone; option, promoted-max + single: option; promoted-max (clone) + single: promoted-max; clone option + + If ``promotable`` is **true**, the number of instances that can be + promoted at one time across the entire cluster + * - promoted-node-max + - 1 + - .. index:: + single: clone; option, promoted-node-max + single: option; promoted-node-max (clone) + single: promoted-node-max; clone option + + If the clone is promotable and globally unique, this is the number of + instances that can be promoted at one time on a single node (up to + ``clone-node-max``) + .. note:: **Deprecated Terminology** In older documentation and online examples, you may see promotable clones referred to as *multi-state*, *stateful*, or *master/slave*; these mean the same thing as *promotable*. Certain syntax is supported for backward compatibility, but is deprecated and will be removed in a future version: * Using the ``master-max`` meta-attribute instead of ``promoted-max`` * Using the ``master-node-max`` meta-attribute instead of ``promoted-node-max`` * Using ``Master`` as a role name instead of ``Promoted`` * Using ``Slave`` as a role name instead of ``Unpromoted`` - + Clone Contents ______________ - + Clones must contain exactly one primitive or group resource. - + .. topic:: A clone that runs a web server on all nodes .. code-block:: xml - + .. warning:: You should never reference the name of a clone's child (the primitive or group resource being cloned). If you think you need to do this, you probably need to re-evaluate your design. - + Clone Instance Attribute ________________________ - + Clones have no instance attributes; however, any that are set here will be inherited by the clone's child. - + .. index:: single: clone; constraint Clone Constraints _________________ - + In most cases, a clone will have a single instance on each active cluster node. If this is not the case, you can indicate which nodes the cluster should preferentially assign copies to with resource location constraints. These constraints are written no differently from those for primitive resources except that the clone's **id** is used. - + .. topic:: Some constraints involving clones .. code-block:: xml - - + + Ordering constraints behave slightly differently for clones. In the example above, ``apache-stats`` will wait until all copies of ``apache-clone`` that need to be started have done so before being started itself. Only if *no* copies can be started will ``apache-stats`` be prevented from being active. Additionally, the clone will wait for ``apache-stats`` to be stopped before stopping itself. Colocation of a primitive or group resource with a clone means that the resource can run on any node with an active instance of the clone. The cluster will choose an instance based on where the clone is running and the resource's own location preferences. Colocation between clones is also possible. If one clone **A** is colocated with another clone **B**, the set of allowed locations for **A** is limited to nodes on which **B** is (or will be) active. Placement is then performed normally. - + .. index:: single: promotable clone; constraint .. _promotable-clone-constraints: Promotable Clone Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + For promotable clone resources, the ``first-action`` and/or ``then-action`` fields for ordering constraints may be set to ``promote`` or ``demote`` to constrain the promoted role, and colocation constraints may contain ``rsc-role`` and/or ``with-rsc-role`` fields. -.. topic:: Constraints involving promotable clone resources +.. topic:: Constraints involving promotable clone resources .. code-block:: xml - + In the example above, **myApp** will wait until one of the database copies has been started and promoted before being started itself on the same node. Only if no copies can be promoted will **myApp** be prevented from being active. Additionally, the cluster will wait for **myApp** to be stopped before demoting the database. Colocation of a primitive or group resource with a promotable clone resource means that it can run on any node with an active instance of the promotable clone resource that has the specified role (``Promoted`` or ``Unpromoted``). In the example above, the cluster will choose a location based on where database is running in the promoted role, and if there are multiple promoted instances it will also factor in **myApp**'s own location preferences when deciding which location to choose. Colocation with regular clones and other promotable clone resources is also possible. In such cases, the set of allowed locations for the **rsc** clone is (after role filtering) limited to nodes on which the ``with-rsc`` promotable clone resource is (or will be) in the specified role. Placement is then performed as normal. - + Using Promotable Clone Resources in Colocation Sets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When a promotable clone is used in a :ref:`resource set ` inside a colocation constraint, the resource set may take a ``role`` attribute. In the following example, an instance of **B** may be promoted only on a node where **A** is in the promoted role. Additionally, resources **C** and **D** must be located on a node where both **A** and **B** are promoted. - + .. topic:: Colocate C and D with A's and B's promoted instances .. code-block:: xml - + Using Promotable Clone Resources in Ordered Sets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When a promotable clone is used in a :ref:`resource set ` inside an ordering constraint, the resource set may take an ``action`` attribute. .. topic:: Start C and D after first promoting A and B .. code-block:: xml - + In the above example, **B** cannot be promoted until **A** has been promoted. Additionally, resources **C** and **D** must wait until **A** and **B** have been promoted before they can start. .. index:: pair: resource-stickiness; clone - + .. _s-clone-stickiness: Clone Stickiness ________________ - + To achieve stable assignments, clones are slightly sticky by default. If no value for ``resource-stickiness`` is provided, the clone will use a value of 1. Being a small value, it causes minimal disturbance to the score calculations of other resources but is enough to prevent Pacemaker from needlessly moving instances around the cluster. - + .. note:: For globally unique clones, this may result in multiple instances of the clone staying on a single node, even after another eligible node becomes active (for example, after being put into standby mode then made active again). If you do not want this behavior, specify a ``resource-stickiness`` of 0 for the clone temporarily and let the cluster adjust, then set it back to 1 if you want the default behavior to apply again. - + .. important:: If ``resource-stickiness`` is set in the ``rsc_defaults`` section, it will apply to clone instances as well. This means an explicit ``resource-stickiness`` of 0 in ``rsc_defaults`` works differently from the implicit default used when ``resource-stickiness`` is not specified. Monitoring Promotable Clone Resources _____________________________________ The usual monitor actions are insufficient to monitor a promotable clone resource, because Pacemaker needs to verify not only that the resource is active, but also that its actual role matches its intended one. Define two monitoring actions: the usual one will cover the unpromoted role, and an additional one with ``role="Promoted"`` will cover the promoted role. - + .. topic:: Monitoring both states of a promotable clone resource .. code-block:: xml - - + + .. important:: It is crucial that *every* monitor operation has a different interval! Pacemaker currently differentiates between operations only by resource and interval; so if (for example) a promotable clone resource had the same monitor interval for both roles, Pacemaker would ignore the role when checking the status -- which would cause unexpected return codes, and therefore unnecessary complications. - + .. _s-promotion-scores: Determining Which Instance is Promoted ______________________________________ Pacemaker can choose a promotable clone instance to be promoted in one of two ways: * Promotion scores: These are node attributes set via the ``crm_attribute`` command using the ``--promotion`` option, which generally would be called by the resource agent's start action if it supports promotable clones. This tool automatically detects both the resource and host, and should be used to set a preference for being promoted. Based on this, ``promoted-max``, and ``promoted-node-max``, the instance(s) with the highest preference will be promoted. * Constraints: Location constraints can indicate which nodes are most preferred to be promoted. - + .. topic:: Explicitly preferring node1 to be promoted .. code-block:: xml +
.. index: single: bundle single: resource; bundle pair: container; Docker pair: container; podman - + .. _s-resource-bundle: Bundles - Containerized Resources ################################# Pacemaker supports a special syntax for launching a service inside a `container `_ with any infrastructure it requires: the *bundle*. - + Pacemaker bundles support `Docker `_ and `podman `_ *(since 2.0.1)* container technologies. [#]_ - + .. topic:: A bundle for a containerized web server .. code-block:: xml Bundle Prerequisites ____________________ - + Before configuring a bundle in Pacemaker, the user must install the appropriate container launch technology (Docker or podman), and supply a fully configured container image, on every node allowed to run the bundle. Pacemaker will create an implicit resource of type **ocf:heartbeat:docker** or **ocf:heartbeat:podman** to manage a bundle's container. The user must ensure that the appropriate resource agent is installed on every node allowed to run the bundle. .. index:: pair: XML element; bundle - + Bundle Properties _________________ - -.. table:: **XML Attributes of a bundle Element** - :widths: 1 4 - - +-------------+------------------------------------------------------------------+ - | Field | Description | - +=============+==================================================================+ - | id | .. index:: | - | | single: bundle; attribute, id | - | | single: attribute; id (bundle) | - | | single: id; bundle attribute | - | | | - | | A unique name for the bundle (required) | - +-------------+------------------------------------------------------------------+ - | description | .. index:: | - | | single: bundle; attribute, description | - | | single: attribute; description (bundle) | - | | single: description; bundle attribute | - | | | - | | Arbitrary text for user's use (ignored by Pacemaker) | - +-------------+------------------------------------------------------------------+ + +.. list-table:: **XML Attributes of a bundle Element** + :widths: 25 75 + :header-rows: 1 + + * - Field + - Description + * - id + - .. index:: + single: bundle; attribute, id + single: attribute; id (bundle) + single: id; bundle attribute + + A unique name for the bundle (required) + * - description + - .. index:: + single: bundle; attribute, description + single: attribute; description (bundle) + single: description; bundle attribute + + Arbitrary text for user's use (ignored by Pacemaker) A bundle must contain exactly one ``docker`` or ``podman`` element. .. index:: pair: XML element; docker pair: XML element; podman - + Bundle Container Properties ___________________________ - -.. table:: **XML attributes of a docker or podman Element** + +.. list-table:: **XML Attributes of a docker or podman Element** :class: longtable - :widths: 2 3 4 - - +-------------------+------------------------------------+---------------------------------------------------+ - | Attribute | Default | Description | - +===================+====================================+===================================================+ - | image | | .. index:: | - | | | single: docker; attribute, image | - | | | single: attribute; image (docker) | - | | | single: image; docker attribute | - | | | single: podman; attribute, image | - | | | single: attribute; image (podman) | - | | | single: image; podman attribute | - | | | | - | | | Container image tag (required) | - +-------------------+------------------------------------+---------------------------------------------------+ - | replicas | Value of ``promoted-max`` | .. index:: | - | | if that is positive, else 1 | single: docker; attribute, replicas | - | | | single: attribute; replicas (docker) | - | | | single: replicas; docker attribute | - | | | single: podman; attribute, replicas | - | | | single: attribute; replicas (podman) | - | | | single: replicas; podman attribute | - | | | | - | | | A positive integer specifying the number of | - | | | container instances to launch | - +-------------------+------------------------------------+---------------------------------------------------+ - | replicas-per-host | 1 | .. index:: | - | | | single: docker; attribute, replicas-per-host | - | | | single: attribute; replicas-per-host (docker) | - | | | single: replicas-per-host; docker attribute | - | | | single: podman; attribute, replicas-per-host | - | | | single: attribute; replicas-per-host (podman) | - | | | single: replicas-per-host; podman attribute | - | | | | - | | | A positive integer specifying the number of | - | | | container instances allowed to run on a | - | | | single node | - +-------------------+------------------------------------+---------------------------------------------------+ - | promoted-max | 0 | .. index:: | - | | | single: docker; attribute, promoted-max | - | | | single: attribute; promoted-max (docker) | - | | | single: promoted-max; docker attribute | - | | | single: podman; attribute, promoted-max | - | | | single: attribute; promoted-max (podman) | - | | | single: promoted-max; podman attribute | - | | | | - | | | A non-negative integer that, if positive, | - | | | indicates that the containerized service | - | | | should be treated as a promotable service, | - | | | with this many replicas allowed to run the | - | | | service in the promoted role | - +-------------------+------------------------------------+---------------------------------------------------+ - | network | | .. index:: | - | | | single: docker; attribute, network | - | | | single: attribute; network (docker) | - | | | single: network; docker attribute | - | | | single: podman; attribute, network | - | | | single: attribute; network (podman) | - | | | single: network; podman attribute | - | | | | - | | | If specified, this will be passed to the | - | | | ``docker run`` or ``podman run`` command as the | - | | | network setting for the container. | - +-------------------+------------------------------------+---------------------------------------------------+ - | run-command | ``/usr/sbin/pacemaker-remoted`` if | .. index:: | - | | bundle contains a **primitive**, | single: docker; attribute, run-command | - | | otherwise none | single: attribute; run-command (docker) | - | | | single: run-command; docker attribute | - | | | single: podman; attribute, run-command | - | | | single: attribute; run-command (podman) | - | | | single: run-command; podman attribute | - | | | | - | | | This command will be run inside the container | - | | | when launching it ("PID 1"). If the bundle | - | | | contains a **primitive**, this command *must* | - | | | start ``pacemaker-remoted`` (but could, for | - | | | example, be a script that does other stuff, too). | - +-------------------+------------------------------------+---------------------------------------------------+ - | options | | .. index:: | - | | | single: docker; attribute, options | - | | | single: attribute; options (docker) | - | | | single: options; docker attribute | - | | | single: podman; attribute, options | - | | | single: attribute; options (podman) | - | | | single: options; podman attribute | - | | | | - | | | Extra command-line options to pass to the | - | | | ``docker run`` or ``podman run`` command | - +-------------------+------------------------------------+---------------------------------------------------+ - + :widths: 15 40 45 + :header-rows: 1 + + * - Attribute + - Default + - Description + * - image + - + - .. index:: + single: docker; attribute, image + single: attribute; image (docker) + single: image; docker attribute + single: podman; attribute, image + single: attribute; image (podman) + single: image; podman attribute + + Container image tag (required) + * - replicas + - Value of ``promoted-max`` if that is positive, else 1 + - .. index:: + single: docker; attribute, replicas + single: attribute; replicas (docker) + single: replicas; docker attribute + single: podman; attribute, replicas + single: attribute; replicas (podman) + single: replicas; podman attribute + + A positive integer specifying the number of container instances to launch + * - replicas-per-host + - 1 + - .. index:: + single: docker; attribute, replicas-per-host + single: attribute; replicas-per-host (docker) + single: replicas-per-host; docker attribute + single: podman; attribute, replicas-per-host + single: attribute; replicas-per-host (podman) + single: replicas-per-host; podman attribute + + A positive integer specifying the number of container instances allowed + to run on a single node + * - promoted-max + - 0 + - .. index:: + single: docker; attribute, promoted-max + single: attribute; promoted-max (docker) + single: promoted-max; docker attribute + single: podman; attribute, promoted-max + single: attribute; promoted-max (podman) + single: promoted-max; podman attribute + + A non-negative integer that, if positive, indicates that the containerized + service should be treated as a promotable service, with this many replicas + allowed to run the service in the promoted role + * - network + - + - .. index:: + single: docker; attribute, network + single: attribute; network (docker) + single: network; docker attribute + single: podman; attribute, network + single: attribute; network (podman) + single: network; podman attribute + + If specified, this will be passed to the ``docker run`` or ``podman run`` + command as the network setting for the container. + * - run-command + - ``/usr/sbin/pacemaker-remoted`` if bundle contains a **primitive**, + otherwise none + - .. index:: + single: docker; attribute, run-command + single: attribute; run-command (docker) + single: run-command; docker attribute + single: podman; attribute, run-command + single: attribute; run-command (podman) + single: run-command; podman attribute + + This command will be run inside the container when launching it ("PID 1"). + If the bundle contains a **primitive**, this command *must* start + ``pacemaker-remoted`` (but could, for example, be a script that does + other stuff, too). + * - options + - + - .. index:: + single: docker; attribute, options + single: attribute; options (docker) + single: options; docker attribute + single: podman; attribute, options + single: attribute; options (podman) + single: options; podman attribute + + Extra command-line options to pass to the ``docker run`` or + ``podman run`` command + .. note:: Considerations when using cluster configurations or container images from Pacemaker 1.1: - + * If the container image has a pre-2.0.0 version of Pacemaker, set ``run-command`` to ``/usr/sbin/pacemaker_remoted`` (note the underbar instead of dash). - + * ``masters`` is accepted as an alias for ``promoted-max``, but is deprecated since 2.0.0, and support for it will be removed in a future version. Bundle Network Properties _________________________ - + A bundle may optionally contain one ```` element. .. index:: pair: XML element; network single: bundle; network - -.. table:: **XML attributes of a network Element** - :widths: 2 1 5 - - +----------------+---------+------------------------------------------------------------+ - | Attribute | Default | Description | - +================+=========+============================================================+ - | add-host | TRUE | .. index:: | - | | | single: network; attribute, add-host | - | | | single: attribute; add-host (network) | - | | | single: add-host; network attribute | - | | | | - | | | If TRUE, and ``ip-range-start`` is used, Pacemaker will | - | | | automatically ensure that ``/etc/hosts`` inside the | - | | | containers has entries for each | - | | | :ref:`replica name ` | - | | | and its assigned IP. | - +----------------+---------+------------------------------------------------------------+ - | ip-range-start | | .. index:: | - | | | single: network; attribute, ip-range-start | - | | | single: attribute; ip-range-start (network) | - | | | single: ip-range-start; network attribute | - | | | | - | | | If specified, Pacemaker will create an implicit | - | | | ``ocf:heartbeat:IPaddr2`` resource for each container | - | | | instance, starting with this IP address, using up to | - | | | ``replicas`` sequential addresses. These addresses can be | - | | | used from the host's network to reach the service inside | - | | | the container, though it is not visible within the | - | | | container itself. Only IPv4 addresses are currently | - | | | supported. | - +----------------+---------+------------------------------------------------------------+ - | host-netmask | 32 | .. index:: | - | | | single: network; attribute; host-netmask | - | | | single: attribute; host-netmask (network) | - | | | single: host-netmask; network attribute | - | | | | - | | | If ``ip-range-start`` is specified, the IP addresses | - | | | are created with this CIDR netmask (as a number of bits). | - +----------------+---------+------------------------------------------------------------+ - | host-interface | | .. index:: | - | | | single: network; attribute; host-interface | - | | | single: attribute; host-interface (network) | - | | | single: host-interface; network attribute | - | | | | - | | | If ``ip-range-start`` is specified, the IP addresses are | - | | | created on this host interface (by default, it will be | - | | | determined from the IP address). | - +----------------+---------+------------------------------------------------------------+ - | control-port | 3121 | .. index:: | - | | | single: network; attribute; control-port | - | | | single: attribute; control-port (network) | - | | | single: control-port; network attribute | - | | | | - | | | If the bundle contains a ``primitive``, the cluster will | - | | | use this integer TCP port for communication with | - | | | Pacemaker Remote inside the container. Changing this is | - | | | useful when the container is unable to listen on the | - | | | default port, for example, when the container uses the | - | | | host's network rather than ``ip-range-start`` (in which | - | | | case ``replicas-per-host`` must be 1), or when the bundle | - | | | may run on a Pacemaker Remote node that is already | - | | | listening on the default port. Any ``PCMK_remote_port`` | - | | | environment variable set on the host or in the container | - | | | is ignored for bundle connections. | - +----------------+---------+------------------------------------------------------------+ - + +.. list-table:: **XML Attributes of a network Element** + :class: longtable + :widths: 20 20 60 + :header-rows: 1 + + * - Attribute + - Default + - Description + * - add-host + - TRUE + - .. index:: + single: network; attribute, add-host + single: attribute; add-host (network) + single: add-host; network attribute + + If TRUE, and ``ip-range-start`` is used, Pacemaker will automatically + ensure that ``/etc/hosts`` inside the containers has entries for each + :ref:`replica name ` and its + assigned IP. + * - ip-range-start + - + - .. index:: + single: network; attribute, ip-range-start + single: attribute; ip-range-start (network) + single: ip-range-start; network attribute + + If specified, Pacemaker will create an implicit ``ocf:heartbeat:IPaddr2`` + resource for each container instance, starting with this IP address, + using up to ``replicas`` sequential addresses. These addresses can be + used from the host's network to reach the service inside the container, + though it is not visible within the container itself. Only IPv4 + addresses are currently supported. + * - host-netmask + - 32 + - .. index:: + single: network; attribute; host-netmask + single: attribute; host-netmask (network) + single: host-netmask; network attribute + + If ``ip-range-start`` is specified, the IP addresses are created with + this CIDR netmask (as a number of bits). + * - host-interface + - + - .. index:: + single: network; attribute; host-interface + single: attribute; host-interface (network) + single: host-interface; network attribute + + If ``ip-range-start`` is specified, the IP addresses are created on this + host interface (by default, it will be determined from the IP address). + * - control-port + - 3121 + - .. index:: + single: network; attribute; control-port + single: attribute; control-port (network) + single: control-port; network attribute + + If the bundle contains a ``primitive``, the cluster will use this integer + TCP port for communication with Pacemaker Remote inside the container. + Changing this is useful when the container is unable to listen on the + default port, for example, when the container uses the host's network + rather than ``ip-range-start`` (in which case ``replicas-per-host`` must + be 1), or when the bundle may run on a Pacemaker Remote node that is + already listening on the default port. Any ``PCMK_remote_port`` + environment variable set on the host or in the container is ignored for + bundle connections. + .. _s-resource-bundle-note-replica-names: .. note:: Replicas are named by the bundle id plus a dash and an integer counter starting with zero. For example, if a bundle named **httpd-bundle** has **replicas=2**, its containers will be named **httpd-bundle-0** and **httpd-bundle-1**. .. index:: pair: XML element; port-mapping - + Additionally, a ``network`` element may optionally contain one or more ``port-mapping`` elements. - -.. table:: **Attributes of a port-mapping Element** - :widths: 2 1 5 - - +---------------+-------------------+------------------------------------------------------+ - | Attribute | Default | Description | - +===============+===================+======================================================+ - | id | | .. index:: | - | | | single: port-mapping; attribute, id | - | | | single: attribute; id (port-mapping) | - | | | single: id; port-mapping attribute | - | | | | - | | | A unique name for the port mapping (required) | - +---------------+-------------------+------------------------------------------------------+ - | port | | .. index:: | - | | | single: port-mapping; attribute, port | - | | | single: attribute; port (port-mapping) | - | | | single: port; port-mapping attribute | - | | | | - | | | If this is specified, connections to this TCP port | - | | | number on the host network (on the container's | - | | | assigned IP address, if ``ip-range-start`` is | - | | | specified) will be forwarded to the container | - | | | network. Exactly one of ``port`` or ``range`` | - | | | must be specified in a ``port-mapping``. | - +---------------+-------------------+------------------------------------------------------+ - | internal-port | value of ``port`` | .. index:: | - | | | single: port-mapping; attribute, internal-port | - | | | single: attribute; internal-port (port-mapping) | - | | | single: internal-port; port-mapping attribute | - | | | | - | | | If ``port`` and this are specified, connections | - | | | to ``port`` on the host's network will be | - | | | forwarded to this port on the container network. | - +---------------+-------------------+------------------------------------------------------+ - | range | | .. index:: | - | | | single: port-mapping; attribute, range | - | | | single: attribute; range (port-mapping) | - | | | single: range; port-mapping attribute | - | | | | - | | | If this is specified, connections to these TCP | - | | | port numbers (expressed as *first_port*-*last_port*) | - | | | on the host network (on the container's assigned IP | - | | | address, if ``ip-range-start`` is specified) will | - | | | be forwarded to the same ports in the container | - | | | network. Exactly one of ``port`` or ``range`` | - | | | must be specified in a ``port-mapping``. | - +---------------+-------------------+------------------------------------------------------+ + +.. list-table:: **Attributes of a port-mapping Element** + :class: longtable + :widths: 20 20 60 + :header-rows: 1 + + * - Attribute + - Default + - Description + * - id + - + - .. index:: + single: port-mapping; attribute, id + single: attribute; id (port-mapping) + single: id; port-mapping attribute + + A unique name for the port mapping (required) + * - port + - + - .. index:: + single: port-mapping; attribute, port + single: attribute; port (port-mapping) + single: port; port-mapping attribute + + If this is specified, connections to this TCP port number on the host + network (on the container's assigned IP address, if ``ip-range-start`` + is specified) will be forwarded to the container network. Exactly one + of ``port`` or ``range`` must be specified in a ``port-mapping``. + * - internal-port + - value of ``port`` + - .. index:: + single: port-mapping; attribute, internal-port + single: attribute; internal-port (port-mapping) + single: internal-port; port-mapping attribute + + If ``port`` and this are specified, connections to ``port`` on the host's + network will be forwarded to this port on the container network. + * - range + - + - .. index:: + single: port-mapping; attribute, range + single: attribute; range (port-mapping) + single: range; port-mapping attribute + + If this is specified, connections to these TCP port numbers (expressed as + *first_port*-*last_port*) on the host network (on the container's + assigned IP address, if ``ip-range-start`` is specified) will be forwarded + to the same ports in the container network. Exactly one of ``port`` or + ``range`` must be specified in a ``port-mapping``. .. note:: If the bundle contains a ``primitive``, Pacemaker will automatically map the ``control-port``, so it is not necessary to specify that port in a ``port-mapping``. .. index: pair: XML element; storage pair: XML element; storage-mapping single: bundle; storage - + .. _s-bundle-storage: Bundle Storage Properties _________________________ - + A bundle may optionally contain one ``storage`` element. A ``storage`` element has no properties of its own, but may contain one or more ``storage-mapping`` elements. - -.. table:: **Attributes of a storage-mapping Element** - :widths: 2 1 5 - - +-----------------+---------+-------------------------------------------------------------+ - | Attribute | Default | Description | - +=================+=========+=============================================================+ - | id | | .. index:: | - | | | single: storage-mapping; attribute, id | - | | | single: attribute; id (storage-mapping) | - | | | single: id; storage-mapping attribute | - | | | | - | | | A unique name for the storage mapping (required) | - +-----------------+---------+-------------------------------------------------------------+ - | source-dir | | .. index:: | - | | | single: storage-mapping; attribute, source-dir | - | | | single: attribute; source-dir (storage-mapping) | - | | | single: source-dir; storage-mapping attribute | - | | | | - | | | The absolute path on the host's filesystem that will be | - | | | mapped into the container. Exactly one of ``source-dir`` | - | | | and ``source-dir-root`` must be specified in a | - | | | ``storage-mapping``. | - +-----------------+---------+-------------------------------------------------------------+ - | source-dir-root | | .. index:: | - | | | single: storage-mapping; attribute, source-dir-root | - | | | single: attribute; source-dir-root (storage-mapping) | - | | | single: source-dir-root; storage-mapping attribute | - | | | | - | | | The start of a path on the host's filesystem that will | - | | | be mapped into the container, using a different | - | | | subdirectory on the host for each container instance. | - | | | The subdirectory will be named the same as the | - | | | :ref:`replica name `. | - | | | Exactly one of ``source-dir`` and ``source-dir-root`` | - | | | must be specified in a ``storage-mapping``. | - +-----------------+---------+-------------------------------------------------------------+ - | target-dir | | .. index:: | - | | | single: storage-mapping; attribute, target-dir | - | | | single: attribute; target-dir (storage-mapping) | - | | | single: target-dir; storage-mapping attribute | - | | | | - | | | The path name within the container where the host | - | | | storage will be mapped (required) | - +-----------------+---------+-------------------------------------------------------------+ - | options | | .. index:: | - | | | single: storage-mapping; attribute, options | - | | | single: attribute; options (storage-mapping) | - | | | single: options; storage-mapping attribute | - | | | | - | | | A comma-separated list of file system mount | - | | | options to use when mapping the storage | - +-----------------+---------+-------------------------------------------------------------+ - + +.. list-table:: **Attributes of a storage-mapping Element** + :class: longtable + :widths: 20 20 60 + :header-rows: 1 + + * - Attribute + - Default + - Description + * - id + - + - .. index:: + single: storage-mapping; attribute, id + single: attribute; id (storage-mapping) + single: id; storage-mapping attribute + + A unique name for the storage mapping (required) + * - source-dir + - + - .. index:: + single: storage-mapping; attribute, source-dir + single: attribute; source-dir (storage-mapping) + single: source-dir; storage-mapping attribute + + The absolute path on the host's filesystem that will be mapped into the + container. Exactly one of ``source-dir`` and ``source-dir-root`` must be + specified in a ``storage-mapping``. + * - source-dir-root + - + - .. index:: + single: storage-mapping; attribute, source-dir-root + single: attribute; source-dir-root (storage-mapping) + single: source-dir-root; storage-mapping attribute + + The start of a path on the host's filesystem that will be mapped into the + container, using a different subdirectory on the host for each container + instance. The subdirectory will be named the same as the + :ref:`replica name `. Exactly one + of ``source-dir`` and ``source-dir-root`` must be specified in a + ``storage-mapping``. + * - target-dir + - + - .. index:: + single: storage-mapping; attribute, target-dir + single: attribute; target-dir (storage-mapping) + single: target-dir; storage-mapping attribute + + The path name within the container where the host storage will be mapped + (required) + * - options + - + - .. index:: + single: storage-mapping; attribute, options + single: attribute; options (storage-mapping) + single: options; storage-mapping attribute + + A comma-separated list of file system mount options to use when mapping + the storage + .. note:: Pacemaker does not define the behavior if the source directory does not already exist on the host. However, it is expected that the container technology and/or its resource agent will create the source directory in that case. - + .. note:: If the bundle contains a ``primitive``, Pacemaker will automatically map the equivalent of ``source-dir=/etc/pacemaker/authkey target-dir=/etc/pacemaker/authkey`` and ``source-dir-root=/var/log/pacemaker/bundles target-dir=/var/log`` into the container, so it is not necessary to specify those paths in a ``storage-mapping``. - + .. important:: The ``PCMK_authkey_location`` environment variable must not be set to anything other than the default of ``/etc/pacemaker/authkey`` on any node in the cluster. - + .. important:: If SELinux is used in enforcing mode on the host, you must ensure the container is allowed to use any storage you mount into it. For Docker and podman bundles, adding "Z" to the mount options will create a container-specific label for the mount that allows the container access. .. index:: single: bundle; primitive - + Bundle Primitive ________________ - + A bundle may optionally contain one :ref:`primitive ` resource. The primitive may have operations, instance attributes, and meta-attributes defined, as usual. If a bundle contains a primitive resource, the container image must include the Pacemaker Remote daemon, and at least one of ``ip-range-start`` or ``control-port`` must be configured in the bundle. Pacemaker will create an implicit **ocf:pacemaker:remote** resource for the connection, launch Pacemaker Remote within the container, and monitor and manage the primitive resource via Pacemaker Remote. If the bundle has more than one container instance (replica), the primitive resource will function as an implicit :ref:`clone ` -- a :ref:`promotable clone ` if the bundle has ``promoted-max`` greater than zero. - + .. note:: If you want to pass environment variables to a bundle's Pacemaker Remote connection or primitive, you have two options: - + * Environment variables whose value is the same regardless of the underlying host may be set using the container element's ``options`` attribute. * If you want variables to have host-specific values, you can use the :ref:`storage-mapping ` element to map a file on the host as ``/etc/pacemaker/pcmk-init.env`` in the container *(since 2.0.3)*. Pacemaker Remote will parse this file as a shell-like format, with variables set as NAME=VALUE, ignoring blank lines and comments starting with "#". - + .. important:: When a bundle has a ``primitive``, Pacemaker on all cluster nodes must be able to contact Pacemaker Remote inside the bundle's containers. - + * The containers must have an accessible network (for example, ``network`` should not be set to "none" with a ``primitive``). * The default, using a distinct network space inside the container, works in combination with ``ip-range-start``. Any firewall must allow access from all cluster nodes to the ``control-port`` on the container IPs. * If the container shares the host's network space (for example, by setting ``network`` to "host"), a unique ``control-port`` should be specified for each bundle. Any firewall must allow access from all cluster nodes to the ``control-port`` on all cluster and remote node IPs. - + .. index:: single: bundle; node attributes .. _s-bundle-attributes: Bundle Node Attributes ______________________ - + If the bundle has a ``primitive``, the primitive's resource agent may want to set node attributes such as :ref:`promotion scores `. However, with containers, it is not apparent which node should get the attribute. If the container uses shared storage that is the same no matter which node the container is hosted on, then it is appropriate to use the promotion score on the bundle node itself. On the other hand, if the container uses storage exported from the underlying host, then it may be more appropriate to use the promotion score on the underlying host. Since this depends on the particular situation, the ``container-attribute-target`` resource meta-attribute allows the user to specify which approach to use. If it is set to ``host``, then user-defined node attributes will be checked on the underlying host. If it is anything else, the local node (in this case the bundle node) is used as usual. This only applies to user-defined attributes; the cluster will always check the local node for cluster-defined attributes such as ``#uname``. If ``container-attribute-target`` is ``host``, the cluster will pass additional environment variables to the primitive's resource agent that allow it to set node attributes appropriately: ``CRM_meta_container_attribute_target`` (identical to the meta-attribute value) and ``CRM_meta_physical_host`` (the name of the underlying host). - + .. note:: When called by a resource agent, the ``attrd_updater`` and ``crm_attribute`` commands will automatically check those environment variables and set attributes appropriately. - + .. index:: single: bundle; meta-attributes Bundle Meta-Attributes ______________________ - + Any meta-attribute set on a bundle will be inherited by the bundle's primitive and any resources implicitly created by Pacemaker for the bundle. This includes options such as ``priority``, ``target-role``, and ``is-managed``. See :ref:`resource_options` for more information. - + Bundles support clone meta-attributes including ``notify``, ``ordered``, and ``interleave``. Limitations of Bundles ______________________ - + Restarting pacemaker while a bundle is unmanaged or the cluster is in maintenance mode may cause the bundle to fail. Bundles may not be explicitly cloned or included in groups. This includes the bundle's primitive and any resources implicitly created by Pacemaker for the bundle. (If ``replicas`` is greater than 1, the bundle will behave like a clone implicitly.) Bundles do not have instance attributes, utilization attributes, or operations, though a bundle's primitive may have them. A bundle with a primitive can run on a Pacemaker Remote node only if the bundle uses a distinct ``control-port``. .. [#] Of course, the service must support running multiple instances. .. [#] Docker is a trademark of Docker, Inc. No endorsement by or association with Docker, Inc. is implied. diff --git a/doc/sphinx/Pacemaker_Explained/constraints.rst b/doc/sphinx/Pacemaker_Explained/constraints.rst index 7d2f39c58e..e177ab76cd 100644 --- a/doc/sphinx/Pacemaker_Explained/constraints.rst +++ b/doc/sphinx/Pacemaker_Explained/constraints.rst @@ -1,1142 +1,1147 @@ .. index:: single: constraint single: resource; constraint .. _constraints: Resource Constraints -------------------- .. _location-constraint: .. index:: single: location constraint single: constraint; location Deciding Which Nodes a Resource Can Run On ########################################## *Location constraints* tell the cluster which nodes a resource can run on. There are two alternative strategies. One way is to say that, by default, resources can run anywhere, and then the location constraints specify nodes that are not allowed (an *opt-out* cluster). The other way is to start with nothing able to run anywhere, and use location constraints to selectively enable allowed nodes (an *opt-in* cluster). Whether you should choose opt-in or opt-out depends on your personal preference and the make-up of your cluster. If most of your resources can run on most of the nodes, then an opt-out arrangement is likely to result in a simpler configuration. On the other-hand, if most resources can only run on a small subset of nodes, an opt-in configuration might be simpler. .. index:: pair: XML element; rsc_location single: constraint; rsc_location Location Properties ___________________ .. list-table:: **Attributes of a rsc_location Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 10 60 :header-rows: 1 * - Name - Type - Default - Description * - .. rsc_location_id: - + .. index:: single: rsc_location; attribute, id single: attribute; id (rsc_location) single: id; rsc_location attribute - + id - :ref:`id ` - - A unique name for the constraint (required) * - .. rsc_location_rsc: - + .. index:: single: rsc_location; attribute, rsc single: attribute; rsc (rsc_location) single: rsc; rsc_location attribute - + rsc - :ref:`id ` - - The name of the resource to which this constraint applies. A location constraint must either have a ``rsc``, have a ``rsc-pattern``, or contain at least one resource set. * - .. rsc_pattern: - + .. index:: single: rsc_location; attribute, rsc-pattern single: attribute; rsc-pattern (rsc_location) single: rsc-pattern; rsc_location attribute - + rsc-pattern - :ref:`text ` - - A pattern matching the names of resources to which this constraint applies. The syntax is the same as `POSIX `_ extended regular expressions, with the addition of an initial ``!`` indicating that resources *not* matching the pattern are selected. If the regular expression contains submatches, and the constraint contains a :ref:`rule `, the submatches can be referenced as ``%1`` through ``%9`` in the rule's ``score-attribute`` or a rule expression's ``attribute`` (see :ref:`s-rsc-pattern-rules`). A location constraint must either have a ``rsc``, have a ``rsc-pattern``, or contain at least one resource set. * - .. rsc_location_node: - + .. index:: single: rsc_location; attribute, node single: attribute; node (rsc_location) single: node; rsc_location attribute - + node - :ref:`text ` - - The name of the node to which this constraint applies. A location constraint must either have a ``node`` and ``score``, or contain at least one rule. * - .. rsc_location_score: - + .. index:: single: rsc_location; attribute, score single: attribute; score (rsc_location) single: score; rsc_location attribute - + score - :ref:`score ` - - Positive values indicate a preference for running the affected resource(s) on ``node`` -- the higher the value, the stronger the preference. Negative values indicate the resource(s) should avoid this node (a value of **-INFINITY** changes "should" to "must"). A location constraint must either have a ``node`` and ``score``, or contain at least one rule. * - .. rsc_location_role: - + .. index:: single: rsc_location; attribute, role single: attribute; role (rsc_location) single: role; rsc_location attribute - + role - :ref:`enumeration ` - ``Started`` - This is significant only for :ref:`promotable clones `, is allowed only if ``rsc`` or ``rsc-pattern`` is set, and is ignored if the constraint contains a rule. Allowed values: - + * ``Started`` or ``Unpromoted``: The constraint affects the location of all instances of the resource. (A promoted instance must start in the unpromoted role before being promoted, so any location requirement for unpromoted instances also affects promoted instances.) * ``Promoted``: The constraint does not affect the location of instances, but instead affects which of the instances will be promoted. * - .. resource_discovery: - + .. index:: single: rsc_location; attribute, resource-discovery single: attribute; resource-discovery (rsc_location) single: resource-discovery; rsc_location attribute - + resource-discovery - :ref:`enumeration ` - always - Whether Pacemaker should perform resource discovery (that is, check whether the resource is already running) for this resource on this node. This should normally be left as the default, so that rogue instances of a service can be stopped when they are running where they are not supposed to be. However, there are two situations where disabling resource discovery is a good idea: when a service is not installed on a node, discovery might return an error (properly written OCF agents will not, so this is usually only seen with other agent types); and when Pacemaker Remote is used to scale a cluster to hundreds of nodes, limiting resource discovery to allowed nodes can significantly boost performance. Allowed values: - + * ``always:`` Always perform resource discovery for the specified resource on this node. * ``never:`` Never perform resource discovery for the specified resource on this node. This option should generally be used with a -INFINITY score, although that is not strictly required. * ``exclusive:`` Perform resource discovery for the specified resource only on this node (and other nodes similarly marked as ``exclusive``). Multiple location constraints using ``exclusive`` discovery for the same resource across different nodes creates a subset of nodes resource-discovery is exclusive to. If a resource is marked for ``exclusive`` discovery on one or more nodes, that resource is only allowed to be placed within that subset of nodes. .. warning:: Setting ``resource-discovery`` to ``never`` or ``exclusive`` removes Pacemaker's ability to detect and stop unwanted instances of a service running where it's not supposed to be. It is up to the system administrator (you!) to make sure that the service can *never* be active on nodes without ``resource-discovery`` (such as by leaving the relevant software uninstalled). .. index:: single: Asymmetrical Clusters single: Opt-In Clusters Asymmetrical "Opt-In" Clusters ______________________________ To create an opt-in cluster, start by preventing resources from running anywhere by default: .. code-block:: none # crm_attribute --name symmetric-cluster --update false Then start enabling nodes. The following fragment says that the web server prefers **sles-1**, the database prefers **sles-2** and both can fail over to **sles-3** if their most preferred node fails. .. topic:: Opt-in location constraints for two resources .. code-block:: xml .. index:: single: Symmetrical Clusters single: Opt-Out Clusters Symmetrical "Opt-Out" Clusters ______________________________ To create an opt-out cluster, start by allowing resources to run anywhere by default: .. code-block:: none # crm_attribute --name symmetric-cluster --update true Then start disabling nodes. The following fragment is the equivalent of the above opt-in configuration. .. topic:: Opt-out location constraints for two resources .. code-block:: xml .. _node-score-equal: What if Two Nodes Have the Same Score _____________________________________ If two nodes have the same score, then the cluster will choose one. This choice may seem random and may not be what was intended, however the cluster was not given enough information to know any better. .. topic:: Constraints where a resource prefers two nodes equally .. code-block:: xml In the example above, assuming no other constraints and an inactive cluster, **Webserver** would probably be placed on **sles-1** and **Database** on **sles-2**. It would likely have placed **Webserver** based on the node's uname and **Database** based on the desire to spread the resource load evenly across the cluster. However other factors can also be involved in more complex configurations. .. _s-rsc-pattern: Specifying locations using pattern matching ___________________________________________ A location constraint can affect all resources whose IDs match a given pattern. The following example bans resources named **ip-httpd**, **ip-asterisk**, **ip-gateway**, etc., from **node1**. .. topic:: Location constraint banning all resources matching a pattern from one node .. code-block:: xml .. index:: single: constraint; ordering single: resource; start order .. _s-resource-ordering: Specifying the Order in which Resources Should Start/Stop ######################################################### *Ordering constraints* tell the cluster the order in which certain resource actions should occur. .. important:: Ordering constraints affect *only* the ordering of resource actions; they do *not* require that the resources be placed on the same node. If you want resources to be started on the same node *and* in a specific order, you need both an ordering constraint *and* a colocation constraint (see :ref:`s-resource-colocation`), or alternatively, a group (see :ref:`group-resources`). .. index:: pair: XML element; rsc_order pair: constraint; rsc_order Ordering Properties ___________________ -.. table:: **Attributes of a rsc_order Element** +.. list-table:: **Attributes of a rsc_order Element** :class: longtable - :widths: 1 2 4 - - +--------------+----------------------------+-------------------------------------------------------------------+ - | Field | Default | Description | - +==============+============================+===================================================================+ - | id | | .. index:: | - | | | single: rsc_order; attribute, id | - | | | single: attribute; id (rsc_order) | - | | | single: id; rsc_order attribute | - | | | | - | | | A unique name for the constraint | - +--------------+----------------------------+-------------------------------------------------------------------+ - | first | | .. index:: | - | | | single: rsc_order; attribute, first | - | | | single: attribute; first (rsc_order) | - | | | single: first; rsc_order attribute | - | | | | - | | | Name of the resource that the ``then`` resource | - | | | depends on | - +--------------+----------------------------+-------------------------------------------------------------------+ - | then | | .. index:: | - | | | single: rsc_order; attribute, then | - | | | single: attribute; then (rsc_order) | - | | | single: then; rsc_order attribute | - | | | | - | | | Name of the dependent resource | - +--------------+----------------------------+-------------------------------------------------------------------+ - | first-action | start | .. index:: | - | | | single: rsc_order; attribute, first-action | - | | | single: attribute; first-action (rsc_order) | - | | | single: first-action; rsc_order attribute | - | | | | - | | | The action that the ``first`` resource must complete | - | | | before ``then-action`` can be initiated for the ``then`` | - | | | resource. Allowed values: ``start``, ``stop``, | - | | | ``promote``, ``demote``. | - +--------------+----------------------------+-------------------------------------------------------------------+ - | then-action | value of ``first-action`` | .. index:: | - | | | single: rsc_order; attribute, then-action | - | | | single: attribute; then-action (rsc_order) | - | | | single: first-action; rsc_order attribute | - | | | | - | | | The action that the ``then`` resource can execute only | - | | | after the ``first-action`` on the ``first`` resource has | - | | | completed. Allowed values: ``start``, ``stop``, | - | | | ``promote``, ``demote``. | - +--------------+----------------------------+-------------------------------------------------------------------+ - | kind | Mandatory | .. index:: | - | | | single: rsc_order; attribute, kind | - | | | single: attribute; kind (rsc_order) | - | | | single: kind; rsc_order attribute | - | | | | - | | | How to enforce the constraint. Allowed values: | - | | | | - | | | * ``Mandatory:`` ``then-action`` will never be initiated | - | | | for the ``then`` resource unless and until ``first-action`` | - | | | successfully completes for the ``first`` resource. | - | | | | - | | | * ``Optional:`` The constraint applies only if both specified | - | | | resource actions are scheduled in the same transition | - | | | (that is, in response to the same cluster state). This | - | | | means that ``then-action`` is allowed on the ``then`` | - | | | resource regardless of the state of the ``first`` resource, | - | | | but if both actions happen to be scheduled at the same time, | - | | | they will be ordered. | - | | | | - | | | * ``Serialize:`` Ensure that the specified actions are never | - | | | performed concurrently for the specified resources. | - | | | ``First-action`` and ``then-action`` can be executed in either | - | | | order, but one must complete before the other can be initiated. | - | | | An example use case is when resource start-up puts a high load | - | | | on the host. | - +--------------+----------------------------+-------------------------------------------------------------------+ - | symmetrical | TRUE for ``Mandatory`` and | .. index:: | - | | ``Optional`` kinds. FALSE | single: rsc_order; attribute, symmetrical | - | | for ``Serialize`` kind. | single: attribute; symmetrical (rsc)order) | - | | | single: symmetrical; rsc_order attribute | - | | | | - | | | If true, the reverse of the constraint applies for the | - | | | opposite action (for example, if B starts after A starts, | - | | | then B stops before A stops). ``Serialize`` orders cannot | - | | | be symmetrical. | - +--------------+----------------------------+-------------------------------------------------------------------+ + :widths: 15 30 55 + :header-rows: 1 + + * - Field + - Default + - Description + * - id + - + - .. index:: + single: rsc_order; attribute, id + single: attribute; id (rsc_order) + single: id; rsc_order attribute + + A unique name for the constraint + * - first + - + - .. index:: + single: rsc_order; attribute, first + single: attribute; first (rsc_order) + single: first; rsc_order attribute + + Name of the resource that the ``then`` resource depends on + * - then + - + - .. index:: + single: rsc_order; attribute, then + single: attribute; then (rsc_order) + single: then; rsc_order attribute + + Name of the dependent resource + * - first-action + - start + - .. index:: + single: rsc_order; attribute, first-action + single: attribute; first-action (rsc_order) + single: first-action; rsc_order attribute + + The action that the ``first`` resource must complete before + ``then-action`` can be initiated for the ``then`` resource. Allowed + values: ``start``, ``stop``, ``promote``, ``demote``. + * - then-action + - value of ``first-action`` + - .. index:: + single: rsc_order; attribute, then-action + single: attribute; then-action (rsc_order) + single: then-action; rsc_order attribute + + The action that the ``then`` resource can execute only after the + ``first-action`` on the ``first`` resource has completed. Allowed + values: ``start``, ``stop``, ``promote``, ``demote``. + * - kind + - Mandatory + - .. index:: + single: rsc_order; attribute, kind + single: attribute; kind (rsc_order) + single: kind; rsc_order attribute + + How to enforce the constraint. Allowed values: + + * ``Mandatory``: ``then-action`` will never be initiated for the + ``then`` resource unless and until ``first-action`` successfully + completes for the ``first`` resource. + + * ``Optional``: The constraint applies only if both specified resource + actions are scheduled in the same transition (that is, in response to + the same cluster state). This means that ``then-action`` is allowed + on the ``then`` resource regardless of the state of the ``first`` + resource, but if both actions happen to be scheduled at the same time, + they will be ordered. + + * ``Serialize``: Ensure that the specified actions are never performed + concurrently for the specified resources. ``first-action`` and + ``then-action`` can be executed in either order, but one must complete + before the other can be initiated. An example use case is when resource + start-up puts a high load on the host. + * - symmetrical + - TRUE for ``Mandatory`` and ``Optional`` kinds. FALSE for ``Serialize`` + kind. + - .. index:: + single: rsc_order; attribute, symmetrical + single: attribute; symmetrical (rsc_order) + single: symmetrical; rsc_order attribute + + If true, the reverse of the constraint applies for the opposite action (for + example, if B starts after A starts, then B stops before A stops). + ``Serialize`` orders cannot be symmetrical. ``Promote`` and ``demote`` apply to :ref:`promotable ` clone resources. Optional and mandatory ordering _______________________________ Here is an example of ordering constraints where **Database** *must* start before **Webserver**, and **IP** *should* start before **Webserver** if they both need to be started: .. topic:: Optional and mandatory ordering constraints .. code-block:: xml Because the above example lets ``symmetrical`` default to TRUE, **Webserver** must be stopped before **Database** can be stopped, and **Webserver** should be stopped before **IP** if they both need to be stopped. Symmetric and asymmetric ordering _________________________________ A mandatory symmetric ordering of "start A then start B" implies not only that the start actions must be ordered, but that B is not allowed to be active unless A is active. For example, if the ordering is added to the configuration when A is stopped (due to target-role, failure, etc.) and B is already active, then B will be stopped. By contrast, asymmetric ordering of "start A then start B" means the stops can occur in either order, which implies that B *can* remain active in the same situation. .. index:: single: colocation single: constraint; colocation single: resource; location relative to other resources .. _s-resource-colocation: Placing Resources Relative to other Resources ############################################# *Colocation constraints* tell the cluster that the location of one resource depends on the location of another one. Colocation has an important side-effect: it affects the order in which resources are assigned to a node. Think about it: You can't place A relative to B unless you know where B is [#]_. So when you are creating colocation constraints, it is important to consider whether you should colocate A with B, or B with A. .. important:: Colocation constraints affect *only* the placement of resources; they do *not* require that the resources be started in a particular order. If you want resources to be started on the same node *and* in a specific order, you need both an ordering constraint (see :ref:`s-resource-ordering`) *and* a colocation constraint, or alternatively, a group (see :ref:`group-resources`). .. index:: pair: XML element; rsc_colocation single: constraint; rsc_colocation Colocation Properties _____________________ -.. table:: **Attributes of a rsc_colocation Constraint** +.. list-table:: **Attributes of a rsc_colocation Constraint** :class: longtable - :widths: 2 2 5 - - +----------------+----------------+--------------------------------------------------------+ - | Field | Default | Description | - +================+================+========================================================+ - | id | | .. index:: | - | | | single: rsc_colocation; attribute, id | - | | | single: attribute; id (rsc_colocation) | - | | | single: id; rsc_colocation attribute | - | | | | - | | | A unique name for the constraint (required). | - +----------------+----------------+--------------------------------------------------------+ - | rsc | | .. index:: | - | | | single: rsc_colocation; attribute, rsc | - | | | single: attribute; rsc (rsc_colocation) | - | | | single: rsc; rsc_colocation attribute | - | | | | - | | | The name of a resource that should be located | - | | | relative to ``with-rsc``. A colocation constraint must | - | | | either contain at least one | - | | | :ref:`resource set `, or specify both | - | | | ``rsc`` and ``with-rsc``. | - +----------------+----------------+--------------------------------------------------------+ - | with-rsc | | .. index:: | - | | | single: rsc_colocation; attribute, with-rsc | - | | | single: attribute; with-rsc (rsc_colocation) | - | | | single: with-rsc; rsc_colocation attribute | - | | | | - | | | The name of the resource used as the colocation | - | | | target. The cluster will decide where to put this | - | | | resource first and then decide where to put ``rsc``. | - | | | A colocation constraint must either contain at least | - | | | one :ref:`resource set `, or specify | - | | | both ``rsc`` and ``with-rsc``. | - +----------------+----------------+--------------------------------------------------------+ - | node-attribute | #uname | .. index:: | - | | | single: rsc_colocation; attribute, node-attribute | - | | | single: attribute; node-attribute (rsc_colocation) | - | | | single: node-attribute; rsc_colocation attribute | - | | | | - | | | If ``rsc`` and ``with-rsc`` are specified, this node | - | | | attribute must be the same on the node running ``rsc`` | - | | | and the node running ``with-rsc`` for the constraint | - | | | to be satisfied. (For details, see | - | | | :ref:`s-coloc-attribute`.) | - +----------------+----------------+--------------------------------------------------------+ - | score | 0 | .. index:: | - | | | single: rsc_colocation; attribute, score | - | | | single: attribute; score (rsc_colocation) | - | | | single: score; rsc_colocation attribute | - | | | | - | | | Positive values indicate the resources should run on | - | | | the same node. Negative values indicate the resources | - | | | should run on different nodes. Values of | - | | | +/- ``INFINITY`` change "should" to "must". | - +----------------+----------------+--------------------------------------------------------+ - | rsc-role | Started | .. index:: | - | | | single: clone; ordering constraint, rsc-role | - | | | single: ordering constraint; rsc-role (clone) | - | | | single: rsc-role; clone ordering constraint | - | | | | - | | | If ``rsc`` and ``with-rsc`` are specified, and ``rsc`` | - | | | is a :ref:`promotable clone `, | - | | | the constraint applies only to ``rsc`` instances in | - | | | this role. Allowed values: ``Started``, ``Stopped``, | - | | | ``Promoted``, ``Unpromoted``. For details, see | - | | | :ref:`promotable-clone-constraints`. | - +----------------+----------------+--------------------------------------------------------+ - | with-rsc-role | Started | .. index:: | - | | | single: clone; ordering constraint, with-rsc-role | - | | | single: ordering constraint; with-rsc-role (clone) | - | | | single: with-rsc-role; clone ordering constraint | - | | | | - | | | If ``rsc`` and ``with-rsc`` are specified, and | - | | | ``with-rsc`` is a | - | | | :ref:`promotable clone `, the | - | | | constraint applies only to ``with-rsc`` instances in | - | | | this role. Allowed values: ``Started``, ``Stopped``, | - | | | ``Promoted``, ``Unpromoted``. For details, see | - | | | :ref:`promotable-clone-constraints`. | - +----------------+----------------+--------------------------------------------------------+ - | influence | value of | .. index:: | - | | ``critical`` | single: rsc_colocation; attribute, influence | - | | meta-attribute | single: attribute; influence (rsc_colocation) | - | | for ``rsc`` | single: influence; rsc_colocation attribute | - | | | | - | | | Whether to consider the location preferences of | - | | | ``rsc`` when ``with-rsc`` is already active. Allowed | - | | | values: ``true``, ``false``. For details, see | - | | | :ref:`s-coloc-influence`. *(since 2.1.0)* | - +----------------+----------------+--------------------------------------------------------+ + :widths: 15 30 55 + :header-rows: 1 + + * - Field + - Default + - Description + * - id + - + - .. index:: + single: rsc_colocation; attribute, id + single: attribute; id (rsc_colocation) + single: id; rsc_colocation attribute + + A unique name for the constraint (required). + * - rsc + - + - .. index:: + single: rsc_colocation; attribute, rsc + single: attribute; rsc (rsc_colocation) + single: rsc; rsc_colocation attribute + + The name of a resource that should be located relative to ``with-rsc``. + A colocation constraint must either contain at least one :ref:`resource + set `, or specify both ``rsc`` and ``with-rsc``. + * - with-rsc + - + - .. index:: + single: rsc_colocation; attribute, with-rsc + single: attribute; with-rsc (rsc_colocation) + single: with-rsc; rsc_colocation attribute + + The name of the resource used as the colocation target. The cluster will + decide where to put this resource first and then decide where to put + ``rsc``. A colocation constraint must either contain at least one + :ref:`resource set `, or specify both ``rsc`` and + ``with-rsc``. + * - node-attribute + - #uname + - .. index:: + single: rsc_colocation; attribute, node-attribute + single: attribute; node-attribute (rsc_colocation) + single: node-attribute; rsc_colocation attribute + + If ``rsc`` and ``with-rsc`` are specified, this node attribute must be + the same on the node running ``rsc`` and the node running ``with-rsc`` + for the constraint to be satisfied. (For details, see + :ref:`s-coloc-attribute`.) + * - score + - 0 + - .. index:: + single: rsc_colocation; attribute, score + single: attribute; score (rsc_colocation) + single: score; rsc_colocation attribute + + Positive values indicate the resources should run on the same node. + Negative values indicate the resources should run on different nodes. + Values of +/- ``INFINITY`` change "should" to "must". + * - rsc-role + - Started + - .. index:: + single: rsc_colocation; attribute, rsc-role + single: attribute; rsc-role (rsc_colocation) + single: rsc-role; clone colocation constraint + + If ``rsc`` and ``with-rsc`` are specified, and ``rsc`` is a + :ref:`promotable clone `, the constraint applies + only to ``rsc`` instances in this role. Allowed values: ``Started``, + ``Stopped``, ``Promoted``, ``Unpromoted``. For details, see + :ref:`promotable-clone-constraints`. + * - with-rsc-role + - Started + - .. index:: + single: rsc_colocation; attribute, with-rsc-role + single: attribute; with-rsc-role (rsc_colocation) + single: with-rsc-role; clone colocation constraint + + If ``rsc`` and ``with-rsc`` are specified, and ``with-rsc`` is a + :ref:`promotable clone `, the constraint applies + only to ``with-rsc`` instances in this role. Allowed values: ``Started``, + ``Stopped``, ``Promoted``, ``Unpromoted``. For details, see + :ref:`promotable-clone-constraints`. + * - influence + - value of ``critical`` meta-attribute for ``rsc`` + - .. index:: + single: rsc_colocation; attribute, influence + single: attribute; influence (rsc_colocation) + single: influence; rsc_colocation attribute + + Whether to consider the location preferences of ``rsc`` when ``with-rsc`` + is already active. Allowed values: ``true``, ``false``. For details, + see :ref:`s-coloc-influence`. *(since 2.1.0)* Mandatory Placement ___________________ Mandatory placement occurs when the constraint's score is **+INFINITY** or **-INFINITY**. In such cases, if the constraint can't be satisfied, then the **rsc** resource is not permitted to run. For ``score=INFINITY``, this includes cases where the ``with-rsc`` resource is not active. If you need resource **A** to always run on the same machine as resource **B**, you would add the following constraint: .. topic:: Mandatory colocation constraint for two resources .. code-block:: xml Remember, because **INFINITY** was used, if **B** can't run on any of the cluster nodes (for whatever reason) then **A** will not be allowed to run. Whether **A** is running or not has no effect on **B**. Alternatively, you may want the opposite -- that **A** *cannot* run on the same machine as **B**. In this case, use ``score="-INFINITY"``. .. topic:: Mandatory anti-colocation constraint for two resources .. code-block:: xml Again, by specifying **-INFINITY**, the constraint is binding. So if the only place left to run is where **B** already is, then **A** may not run anywhere. As with **INFINITY**, **B** can run even if **A** is stopped. However, in this case **A** also can run if **B** is stopped, because it still meets the constraint of **A** and **B** not running on the same node. Advisory Placement __________________ If mandatory placement is about "must" and "must not", then advisory placement is the "I'd prefer if" alternative. For colocation constraints with scores greater than **-INFINITY** and less than **INFINITY**, the cluster will try to accommodate your wishes, but may ignore them if other factors outweigh the colocation score. Those factors might include other constraints, resource stickiness, failure thresholds, whether other resources would be prevented from being active, etc. .. topic:: Advisory colocation constraint for two resources .. code-block:: xml .. _s-coloc-attribute: Colocation by Node Attribute ____________________________ The ``node-attribute`` property of a colocation constraints allows you to express the requirement, "these resources must be on similar nodes". As an example, imagine that you have two Storage Area Networks (SANs) that are not controlled by the cluster, and each node is connected to one or the other. You may have two resources **r1** and **r2** such that **r2** needs to use the same SAN as **r1**, but doesn't necessarily have to be on the same exact node. In such a case, you could define a :ref:`node attribute ` named **san**, with the value **san1** or **san2** on each node as appropriate. Then, you could colocate **r2** with **r1** using ``node-attribute`` set to **san**. .. _s-coloc-influence: Colocation Influence ____________________ By default, if A is colocated with B, the cluster will take into account A's preferences when deciding where to place B, to maximize the chance that both resources can run. For a detailed look at exactly how this occurs, see `Colocation Explained `_. However, if ``influence`` is set to ``false`` in the colocation constraint, this will happen only if B is inactive and needing to be started. If B is already active, A's preferences will have no effect on placing B. An example of what effect this would have and when it would be desirable would be a nonessential reporting tool colocated with a resource-intensive service that takes a long time to start. If the reporting tool fails enough times to reach its migration threshold, by default the cluster will want to move both resources to another node if possible. Setting ``influence`` to ``false`` on the colocation constraint would mean that the reporting tool would be stopped in this situation instead, to avoid forcing the service to move. The ``critical`` resource meta-attribute is a convenient way to specify the default for all colocation constraints and groups involving a particular resource. .. note:: If a noncritical resource is a member of a group, all later members of the group will be treated as noncritical, even if they are marked as (or left to default to) critical. .. _s-resource-sets: Resource Sets ############# .. index:: single: constraint; resource set single: resource; resource set *Resource sets* allow multiple resources to be affected by a single constraint. .. topic:: A set of 3 resources .. code-block:: xml Resource sets are valid inside ``rsc_location``, ``rsc_order`` (see :ref:`s-resource-sets-ordering`), ``rsc_colocation`` (see :ref:`s-resource-sets-colocation`), and ``rsc_ticket`` (see :ref:`ticket-constraints`) constraints. A resource set has a number of properties that can be set, though not all have an effect in all contexts. .. index:: pair: XML element; resource_set -.. table:: **Attributes of a resource_set Element** +.. list-table:: **Attributes of a resource_set Element** :class: longtable - :widths: 2 2 5 - - +-------------+------------------+--------------------------------------------------------+ - | Field | Default | Description | - +=============+==================+========================================================+ - | id | | .. index:: | - | | | single: resource_set; attribute, id | - | | | single: attribute; id (resource_set) | - | | | single: id; resource_set attribute | - | | | | - | | | A unique name for the set (required) | - +-------------+------------------+--------------------------------------------------------+ - | sequential | true | .. index:: | - | | | single: resource_set; attribute, sequential | - | | | single: attribute; sequential (resource_set) | - | | | single: sequential; resource_set attribute | - | | | | - | | | Whether the members of the set must be acted on in | - | | | order. Meaningful within ``rsc_order`` and | - | | | ``rsc_colocation``. | - +-------------+------------------+--------------------------------------------------------+ - | require-all | true | .. index:: | - | | | single: resource_set; attribute, require-all | - | | | single: attribute; require-all (resource_set) | - | | | single: require-all; resource_set attribute | - | | | | - | | | Whether all members of the set must be active before | - | | | continuing. With the current implementation, the | - | | | cluster may continue even if only one member of the | - | | | set is started, but if more than one member of the set | - | | | is starting at the same time, the cluster will still | - | | | wait until all of those have started before continuing | - | | | (this may change in future versions). Meaningful | - | | | within ``rsc_order``. | - +-------------+------------------+--------------------------------------------------------+ - | role | | .. index:: | - | | | single: resource_set; attribute, role | - | | | single: attribute; role (resource_set) | - | | | single: role; resource_set attribute | - | | | | - | | | The constraint applies only to resource set members | - | | | that are :ref:`s-resource-promotable` in this | - | | | role. Meaningful within ``rsc_location``, | - | | | ``rsc_colocation`` and ``rsc_ticket``. | - | | | Allowed values: ``Started``, ``Promoted``, | - | | | ``Unpromoted``. For details, see | - | | | :ref:`promotable-clone-constraints`. | - +-------------+------------------+--------------------------------------------------------+ - | action | start | .. index:: | - | | | single: resource_set; attribute, action | - | | | single: attribute; action (resource_set) | - | | | single: action; resource_set attribute | - | | | | - | | | The action that applies to *all members* of the set. | - | | | Meaningful within ``rsc_order``. Allowed values: | - | | | ``start``, ``stop``, ``promote``, ``demote``. | - +-------------+------------------+--------------------------------------------------------+ - | score | | .. index:: | - | | | single: resource_set; attribute, score | - | | | single: attribute; score (resource_set) | - | | | single: score; resource_set attribute | - | | | | - | | | *Advanced use only.* Use a specific score for this | - | | | set. Meaningful within ``rsc_location`` or | - | | | ``rsc_colocation``. | - +-------------+------------------+--------------------------------------------------------+ - | kind | | .. index:: | - | | | single: resource_set; attribute, kind | - | | | single: attribute; kind (resource_set) | - | | | single: kind; resource_set attribute | - | | | | - | | | *Advanced use only.* Use a specific kind for this | - | | | set. Meaningful within ``rsc_order``. | - +-------------+------------------+--------------------------------------------------------+ + :widths: 15 15 70 + :header-rows: 1 + + * - Field + - Default + - Description + * - id + - + - .. index:: + single: resource_set; attribute, id + single: attribute; id (resource_set) + single: id; resource_set attribute + + A unique name for the set (required) + * - sequential + - true + - .. index:: + single: resource_set; attribute, sequential + single: attribute; sequential (resource_set) + single: sequential; resource_set attribute + + Whether the members of the set must be acted on in order. Meaningful + within ``rsc_order`` and ``rsc_colocation``. + * - require-all + - true + - .. index:: + single: resource_set; attribute, require-all + single: attribute; require-all (resource_set) + single: require-all; resource_set attribute + + Whether all members of the set must be active before continuing. With + the current implementation, the cluster may continue even if only one + member of the set is started, but if more than one member of the set is + starting at the same time, the cluster will still wait until all of + those have started before continuing (this may change in future + versions). Meaningful within ``rsc_order``. + * - role + - + - .. index:: + single: resource_set; attribute, role + single: attribute; role (resource_set) + single: role; resource_set attribute + + The constraint applies only to resource set members that are + :ref:`s-resource-promotable` in this role. Meaningful within + ``rsc_location``, ``rsc_colocation`` and ``rsc_ticket``. Allowed + values: ``Started``, ``Promoted``, ``Unpromoted``. For details, see + :ref:`promotable-clone-constraints`. + * - action + - start + - .. index:: + single: resource_set; attribute, action + single: attribute; action (resource_set) + single: action; resource_set attribute + + The action that applies to *all members* of the set. Meaningful within + ``rsc_order``. Allowed values: ``start``, ``stop``, ``promote``, + ``demote``. + * - score + - + - .. index:: + single: resource_set; attribute, score + single: attribute; score (resource_set) + single: score; resource_set attribute + + *Advanced use only.* Use a specific score for this set. Meaningful + within ``rsc_location`` or ``rsc_colocation``. + * - kind + - + - .. index:: + single: resource_set; attribute, kind + single: attribute; kind (resource_set) + single: kind; resource_set attribute + + *Advanced use only.* Use a specific kind for this set. Meaningful within + ``rsc_order``. Anti-colocation Chains ______________________ Sometimes, you would like a set of resources to be anti-colocated with each other. For example, ``resource1``, ``resource2``, and ``resource3`` must all run on different nodes. A straightforward approach would be to configure either separate colocations or a resource set, with ``-INFINITY`` scores between all the resources. However, this will not work as expected. Resource sets may in the future gain new syntax for this specific situation, but for now, a workaround is to use :ref:`utilization ` instead of colocations to keep the resources apart. Create a utilization attribute for the anti-colocation, assign the same value to each resource, and give each node the capacity to run one resource. .. _s-resource-sets-ordering: Ordering Sets of Resources ########################## A common situation is for an administrator to create a chain of ordered resources, such as: .. topic:: A chain of ordered resources .. code-block:: xml .. topic:: Visual representation of the four resources' start order for the above constraints .. image:: images/resource-set.png :alt: Ordered set Ordered Set ___________ To simplify this situation, :ref:`s-resource-sets` can be used within ordering constraints: .. topic:: A chain of ordered resources expressed as a set .. code-block:: xml While the set-based format is not less verbose, it is significantly easier to get right and maintain. .. important:: If you use a higher-level tool, pay attention to how it exposes this functionality. Depending on the tool, creating a set **A B** may be equivalent to **A then B**, or **B then A**. Ordering Multiple Sets ______________________ The syntax can be expanded to allow sets of resources to be ordered relative to each other, where the members of each individual set may be ordered or unordered (controlled by the ``sequential`` property). In the example below, **A** and **B** can both start in parallel, as can **C** and **D**, however **C** and **D** can only start once *both* **A** *and* **B** are active. .. topic:: Ordered sets of unordered resources .. code-block:: xml .. topic:: Visual representation of the start order for two ordered sets of unordered resources .. image:: images/two-sets.png :alt: Two ordered sets Of course either set -- or both sets -- of resources can also be internally ordered (by setting ``sequential="true"``) and there is no limit to the number of sets that can be specified. .. topic:: Advanced use of set ordering - Three ordered sets, two of which are internally unordered .. code-block:: xml .. topic:: Visual representation of the start order for the three sets defined above .. image:: images/three-sets.png :alt: Three ordered sets .. important:: An ordered set with ``sequential=false`` makes sense only if there is another set in the constraint. Otherwise, the constraint has no effect. Resource Set OR Logic _____________________ The unordered set logic discussed so far has all been "AND" logic. To illustrate this take the 3 resource set figure in the previous section. Those sets can be expressed, **(A and B) then (C) then (D) then (E and F)**. Say for example we want to change the first set, **(A and B)**, to use "OR" logic so the sets look like this: **(A or B) then (C) then (D) then (E and F)**. This functionality can be achieved through the use of the ``require-all`` option. This option defaults to TRUE which is why the "AND" logic is used by default. Setting ``require-all=false`` means only one resource in the set needs to be started before continuing on to the next set. .. topic:: Resource Set "OR" logic: Three ordered sets, where the first set is internally unordered with "OR" logic .. code-block:: xml .. important:: An ordered set with ``require-all=false`` makes sense only in conjunction with ``sequential=false``. Think of it like this: ``sequential=false`` modifies the set to be an unordered set using "AND" logic by default, and adding ``require-all=false`` flips the unordered set's "AND" logic to "OR" logic. .. _s-resource-sets-colocation: Colocating Sets of Resources ############################ Another common situation is for an administrator to create a set of colocated resources. The simplest way to do this is to define a resource group (see :ref:`group-resources`), but that cannot always accurately express the desired relationships. For example, maybe the resources do not need to be ordered. Another way would be to define each relationship as an individual constraint, but that causes a difficult-to-follow constraint explosion as the number of resources and combinations grow. .. topic:: Colocation chain as individual constraints, where A is placed first, then B, then C, then D .. code-block:: xml To express complicated relationships with a simplified syntax [#]_, :ref:`resource sets ` can be used within colocation constraints. .. topic:: Equivalent colocation chain expressed using **resource_set** .. code-block:: xml .. note:: Within a ``resource_set``, the resources are listed in the order they are *placed*, which is the reverse of the order in which they are *colocated*. In the above example, resource **A** is placed before resource **B**, which is the same as saying resource **B** is colocated with resource **A**. As with individual constraints, a resource that can't be active prevents any resource that must be colocated with it from being active. In both of the two previous examples, if **B** is unable to run, then both **C** and by inference **D** must remain stopped. .. important:: If you use a higher-level tool, pay attention to how it exposes this functionality. Depending on the tool, creating a set **A B** may be equivalent to **A with B**, or **B with A**. Resource sets can also be used to tell the cluster that entire *sets* of resources must be colocated relative to each other, while the individual members within any one set may or may not be colocated relative to each other (determined by the set's ``sequential`` property). In the following example, resources **B**, **C**, and **D** will each be colocated with **A** (which will be placed first). **A** must be able to run in order for any of the resources to run, but any of **B**, **C**, or **D** may be stopped without affecting any of the others. .. topic:: Using colocated sets to specify a shared dependency .. code-block:: xml .. note:: Pay close attention to the order in which resources and sets are listed. While the members of any one sequential set are placed first to last (i.e., the colocation dependency is last with first), multiple sets are placed last to first (i.e. the colocation dependency is first with last). .. important:: A colocated set with ``sequential="false"`` makes sense only if there is another set in the constraint. Otherwise, the constraint has no effect. There is no inherent limit to the number and size of the sets used. The only thing that matters is that in order for any member of one set in the constraint to be active, all members of sets listed after it must also be active (and naturally on the same node); and if a set has ``sequential="true"``, then in order for one member of that set to be active, all members listed before it must also be active. If desired, you can restrict the dependency to instances of promotable clone resources that are in a specific role, using the set's ``role`` property. .. topic:: Colocation in which the members of the middle set have no interdependencies, and the last set listed applies only to promoted instances .. code-block:: xml .. topic:: Visual representation of the above example (resources are placed from left to right) .. image:: ../shared/images/pcmk-colocated-sets.png :alt: Colocation chain .. note:: Unlike ordered sets, colocated sets do not use the ``require-all`` option. External Resource Dependencies ############################## Sometimes, a resource will depend on services that are not managed by the cluster. An example might be a resource that requires a file system that is not managed by the cluster but mounted by systemd at boot time. To accommodate this, the pacemaker systemd service depends on a normally empty target called ``resource-agents-deps.target``. The system administrator may create a unit drop-in for that target specifying the dependencies, to ensure that the services are started before Pacemaker starts and stopped after Pacemaker stops. Typically, this is accomplished by placing a unit file in the ``/etc/systemd/system/resource-agents-deps.target.d`` directory, with directives such as ``Requires`` and ``After`` specifying the dependencies as needed. .. [#] While the human brain is sophisticated enough to read the constraint in any order and choose the correct one depending on the situation, the cluster is not quite so smart. Yet. .. [#] which is not the same as saying easy to follow diff --git a/doc/sphinx/Pacemaker_Explained/fencing.rst b/doc/sphinx/Pacemaker_Explained/fencing.rst index dce479e3c6..6ae836c258 100644 --- a/doc/sphinx/Pacemaker_Explained/fencing.rst +++ b/doc/sphinx/Pacemaker_Explained/fencing.rst @@ -1,1281 +1,1283 @@ .. index:: single: fencing single: STONITH .. _fencing: Fencing ------- What Is Fencing? ################ *Fencing* is the ability to make a node unable to run resources, even when that node is unresponsive to cluster commands. Fencing is also known as *STONITH*, an acronym for "Shoot The Other Node In The Head", since the most common fencing method is cutting power to the node. Another method is "fabric fencing", cutting the node's access to some capability required to run resources (such as network access or a shared disk). .. index:: single: fencing; why necessary Why Is Fencing Necessary? ######################### Fencing protects your data from being corrupted by malfunctioning nodes or unintentional concurrent access to shared resources. Fencing protects against the "split brain" failure scenario, where cluster nodes have lost the ability to reliably communicate with each other but are still able to run resources. If the cluster just assumed that uncommunicative nodes were down, then multiple instances of a resource could be started on different nodes. The effect of split brain depends on the resource type. For example, an IP address brought up on two hosts on a network will cause packets to randomly be sent to one or the other host, rendering the IP useless. For a database or clustered file system, the effect could be much more severe, causing data corruption or divergence. Fencing is also used when a resource cannot otherwise be stopped. If a resource fails to stop on a node, it cannot be started on a different node without risking the same type of conflict as split-brain. Fencing the original node ensures the resource can be safely started elsewhere. Users may also configure the ``on-fail`` property of :ref:`operation` or the ``loss-policy`` property of :ref:`ticket constraints ` to ``fence``, in which case the cluster will fence the resource's node if the operation fails or the ticket is lost. .. index:: single: fencing; device Fence Devices ############# A *fence device* or *fencing device* is a special type of resource that provides the means to fence a node. Examples of fencing devices include intelligent power switches and IPMI devices that accept SNMP commands to cut power to a node, and iSCSI controllers that allow SCSI reservations to be used to cut a node's access to a shared disk. Since fencing devices will be used to recover from loss of networking connectivity to other nodes, it is essential that they do not rely on the same network as the cluster itself, otherwise that network becomes a single point of failure. Since loss of a node due to power outage is indistinguishable from loss of network connectivity to that node, it is also essential that at least one fence device for a node does not share power with that node. For example, an on-board IPMI controller that shares power with its host should not be used as the sole fencing device for that host. Since fencing is used to isolate malfunctioning nodes, no fence device should rely on its target functioning properly. This includes, for example, devices that ssh into a node and issue a shutdown command (such devices might be suitable for testing, but never for production). .. index:: single: fencing; agent Fence Agents ############ A *fence agent* or *fencing agent* is a ``stonith``-class resource agent. The fence agent standard provides commands (such as ``off`` and ``reboot``) that the cluster can use to fence nodes. As with other resource agent classes, this allows a layer of abstraction so that Pacemaker doesn't need any knowledge about specific fencing technologies -- that knowledge is isolated in the agent. Pacemaker supports two fence agent standards, both inherited from no-longer-active projects: * Red Hat Cluster Suite (RHCS) style: These are typically installed in ``/usr/sbin`` with names starting with ``fence_``. * Linux-HA style: These typically have names starting with ``external/``. Pacemaker can support these agents using the **fence_legacy** RHCS-style agent as a wrapper, *if* support was enabled when Pacemaker was built, which requires the ``cluster-glue`` library. When a Fence Device Can Be Used ############################### Fencing devices do not actually "run" like most services. Typically, they just provide an interface for sending commands to an external device. Additionally, fencing may be initiated by Pacemaker, by other cluster-aware software such as DRBD or DLM, or manually by an administrator, at any point in the cluster life cycle, including before any resources have been started. To accommodate this, Pacemaker does not require the fence device resource to be "started" in order to be used. Whether a fence device is started or not determines whether a node runs any recurring monitor for the device, and gives the node a slight preference for being chosen to execute fencing using that device. By default, any node can execute any fencing device. If a fence device is disabled by setting its ``target-role`` to ``Stopped``, then no node can use that device. If a location constraint with a negative score prevents a specific node from "running" a fence device, then that node will never be chosen to execute fencing using the device. A node may fence itself, but the cluster will choose that only if no other nodes can do the fencing. A common configuration scenario is to have one fence device per target node. In such a case, users often configure anti-location constraints so that the target node does not monitor its own device. Limitations of Fencing Resources ################################ Fencing resources have certain limitations that other resource classes don't: * They may have only one set of meta-attributes and one set of instance attributes. * If :ref:`rules` are used to determine fencing resource options, these might be evaluated only when first read, meaning that later changes to the rules will have no effect. Therefore, it is better to avoid confusion and not use rules at all with fencing resources. These limitations could be revisited if there is sufficient user demand. .. index:: single: fencing; special instance attributes Special Meta-Attributes for Fencing Resources ############################################# The table below lists special resource meta-attributes that may be set for any fencing resource. -.. table:: **Additional Properties of Fencing Resources** - :widths: 2 1 2 4 - - - +----------------------+---------+--------------------+----------------------------------------+ - | Field | Type | Default | Description | - +======================+=========+====================+========================================+ - | provides | string | | .. index:: | - | | | | single: provides | - | | | | | - | | | | Any special capability provided by the | - | | | | fence device. Currently, only one such | - | | | | capability is meaningful: | - | | | | :ref:`unfencing `. | - +----------------------+---------+--------------------+----------------------------------------+ +.. list-table:: **Additional Properties of Fencing Resources** + :widths: 10 10 10 70 + :header-rows: 1 + + * - Field + - Type + - Default + - Description + * - provides + - string + - + - .. index:: + single: provides + + Any special capability provided by the fence device. Currently, only one + such capability is meaningful: :ref:`unfencing `. .. _fencing-attributes: Special Instance Attributes for Fencing Resources ################################################# The table below lists special instance attributes that may be set for any fencing resource (*not* meta-attributes, even though they are interpreted by Pacemaker rather than the fence agent). These are also listed in the man page for ``pacemaker-fenced``. .. list-table:: **Additional Properties of Fencing Resources** :class: longtable - :widths: 2 1 2 4 + :widths: 22 10 20 48 :header-rows: 1 * - Name - Type - Default - Description * - .. _primitive_stonith_timeout: .. index:: single: stonith-timeout (primitive instance attribute) stonith-timeout - :ref:`timeout ` - - + - - This is not used by Pacemaker (see the ``pcmk_reboot_timeout``, ``pcmk_off_timeout``, etc., properties instead), but it may be used by Linux-HA fence agents. * - .. _pcmk_host_map: .. index:: single: pcmk_host_map pcmk_host_map - :ref:`text ` - - + - - A mapping of node names to ports for devices that do not understand the node names. For example, ``node1:1;node2:2,3`` tells the cluster to use port 1 for ``node1`` and ports 2 and 3 for ``node2``. If ``pcmk_host_check`` is explicitly set to ``static-list``, either this or ``pcmk_host_list`` must be set. The port portion of the map may contain special characters such as spaces if preceded by a backslash *(since 2.1.2)*. * - .. _pcmk_host_list: .. index:: single: pcmk_host_list pcmk_host_list - :ref:`text ` - - + - - Comma-separated list of nodes that can be targeted by this device (for example, ``node1,node2,node3``). If pcmk_host_check is ``static-list``, either this or ``pcmk_host_map`` must be set. * - .. _pcmk_host_check: .. index:: single: pcmk_host_check pcmk_host_check - :ref:`text ` - See :ref:`pcmk_host_check_default` - The method Pacemaker should use to determine which nodes can be targeted by this device. Allowed values: - * ``static-list:`` targets are listed in the ``pcmk_host_list`` or ``pcmk_host_map`` attribute + * ``static-list:`` targets are listed in the ``pcmk_host_list`` or + ``pcmk_host_map`` attribute * ``dynamic-list:`` query the device via the agent's ``list`` action * ``status:`` query the device via the agent's ``status`` action * ``none:`` assume the device can fence any node * - .. _pcmk_delay_max: .. index:: single: pcmk_delay_max pcmk_delay_max - :ref:`duration ` - 0s - Enable a delay of no more than the time specified before executing fencing actions. Pacemaker derives the overall delay by taking the value of pcmk_delay_base and adding a random delay value such that the sum is kept below this maximum. This is sometimes used in two-node clusters to ensure that the nodes don't fence each other at the same time. * - .. _pcmk_delay_base: .. index:: single: pcmk_delay_base pcmk_delay_base - :ref:`text ` - 0s - Enable a static delay before executing fencing actions. This can be used, for example, in two-node clusters to ensure that the nodes don't fence each other, by having separate fencing resources with different values. The node that is fenced with the shorter delay will lose a fencing race. The overall delay introduced by pacemaker is derived from this value plus a random delay such that the sum is kept below the maximum delay. A single device can have different delays per node using a host map *(since 2.1.2)*, for example ``node1:0s;node2:5s.`` * - .. _pcmk_action_limit: .. index:: single: pcmk_action_limit pcmk_action_limit - :ref:`integer ` - 1 - The maximum number of actions that can be performed in parallel on this device. A value of -1 means unlimited. Node fencing actions initiated by the cluster (as opposed to an administrator running the ``stonith_admin`` tool or the fencer running recurring device monitors and ``status`` and ``list`` commands) are additionally subject to the ``concurrent-fencing`` cluster property. * - .. _pcmk_host_argument: .. index:: single: pcmk_host_argument pcmk_host_argument - :ref:`text ` - ``port`` if the fence agent metadata advertises support for it, otherwise ``plug`` if supported, otherwise ``none`` - *Advanced use only.* Which parameter should be supplied to the fence agent to identify the node to be fenced. A value of ``none`` tells the cluster not to supply any additional parameters. * - .. _pcmk_reboot_action: .. index:: single: pcmk_reboot_action pcmk_reboot_action - :ref:`text ` - ``reboot`` - *Advanced use only.* The command to send to the resource agent in order to reboot a node. Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific command. * - .. _pcmk_reboot_timeout: .. index:: single: pcmk_reboot_timeout pcmk_reboot_timeout - :ref:`timeout ` - 60s - *Advanced use only.* Specify an alternate timeout (in seconds) to use for ``reboot`` actions instead of the value of ``stonith-timeout``. Some devices need much more or less time to complete than normal. Use this to specify an alternate, device-specific timeout. * - .. _pcmk_reboot_retries: .. index:: single: pcmk_reboot_retries pcmk_reboot_retries - :ref:`integer ` - 2 - *Advanced use only.* The maximum number of times to retry the ``reboot`` command within the timeout period. Some devices do not support multiple connections, and operations may fail if the device is busy with another task, so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries before giving up. * - .. _pcmk_off_action: .. index:: single: pcmk_off_action pcmk_off_action - :ref:`text ` - ``off`` - *Advanced use only.* The command to send to the resource agent in order to shut down a node. Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific command. * - .. _pcmk_off_timeout: .. index:: single: pcmk_off_timeout pcmk_off_timeout - :ref:`timeout ` - 60s - *Advanced use only.* Specify an alternate timeout (in seconds) to use for ``off`` actions instead of the value of ``stonith-timeout``. Some devices need much more or less time to complete than normal. Use this to specify an alternate, device-specific timeout. * - .. _pcmk_off_retries: .. index:: single: pcmk_off_retries pcmk_off_retries - :ref:`integer ` - 2 - *Advanced use only.* The maximum number of times to retry the ``off`` command within the timeout period. Some devices do not support multiple connections, and operations may fail if the device is busy with another task, so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries before giving up. * - .. _pcmk_list_action: .. index:: single: pcmk_list_action pcmk_list_action - :ref:`text ` - ``list`` - *Advanced use only.* The command to send to the resource agent in order to list nodes. Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific command. * - .. _pcmk_list_timeout: .. index:: single: pcmk_list_timeout pcmk_list_timeout - :ref:`timeout ` - 60s - *Advanced use only.* Specify an alternate timeout (in seconds) to use for ``list`` actions instead of the value of ``stonith-timeout``. Some devices need much more or less time to complete than normal. Use this to specify an alternate, device-specific timeout. * - .. _pcmk_list_retries: .. index:: single: pcmk_list_retries pcmk_list_retries - :ref:`integer ` - 2 - *Advanced use only.* The maximum number of times to retry the ``list`` command within the timeout period. Some devices do not support multiple connections, and operations may fail if the device is busy with another task, so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries before giving up. * - .. _pcmk_monitor_action: .. index:: single: pcmk_monitor_action pcmk_monitor_action - :ref:`text ` - ``monitor`` - *Advanced use only.* The command to send to the resource agent in order to report extended status. Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific command. * - .. _pcmk_monitor_timeout: .. index:: single: pcmk_monitor_timeout pcmk_monitor_timeout - :ref:`timeout ` - 60s - *Advanced use only.* Specify an alternate timeout (in seconds) to use for ``monitor`` actions instead of the value of ``stonith-timeout``. Some devices need much more or less time to complete than normal. Use this to specify an alternate, device-specific timeout. * - .. _pcmk_monitor_retries: .. index:: single: pcmk_monitor_retries pcmk_monitor_retries - :ref:`integer ` - 2 - *Advanced use only.* The maximum number of times to retry the ``monitor`` command within the timeout period. Some devices do not support multiple connections, and operations may fail if the device is busy with another task, so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries before giving up. * - .. _pcmk_status_action: .. index:: single: pcmk_status_action pcmk_status_action - :ref:`text ` - ``status`` - *Advanced use only.* The command to send to the resource agent in order to report status. Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific command. * - .. _pcmk_status_timeout: .. index:: single: pcmk_status_timeout pcmk_status_timeout - :ref:`timeout ` - 60s - *Advanced use only.* Specify an alternate timeout (in seconds) to use for ``status`` actions instead of the value of ``stonith-timeout``. Some devices need much more or less time to complete than normal. Use this to specify an alternate, device-specific timeout. * - .. _pcmk_status_retries: .. index:: single: pcmk_status_retries pcmk_status_retries - :ref:`integer ` - 2 - *Advanced use only.* The maximum number of times to retry the ``status`` command within the timeout period. Some devices do not support multiple connections, and operations may fail if the device is busy with another task, so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries before giving up. .. _pcmk_host_check_default: Default Check Type ################## If the user does not explicitly configure ``pcmk_host_check`` for a fence device, a default value appropriate to other configured parameters will be used: * If either ``pcmk_host_list`` or ``pcmk_host_map`` is configured, ``static-list`` will be used; * otherwise, if the fence device supports the ``list`` action, and the first attempt at using ``list`` succeeds, ``dynamic-list`` will be used; * otherwise, if the fence device supports the ``status`` action, ``status`` will be used; * otherwise, ``none`` will be used. .. index:: single: unfencing single: fencing; unfencing .. _unfencing: Unfencing ######### With fabric fencing (such as cutting network or shared disk access rather than power), it is expected that the cluster will fence the node, and then a system administrator must manually investigate what went wrong, correct any issues found, then reboot (or restart the cluster services on) the node. Once the node reboots and rejoins the cluster, some fabric fencing devices require an explicit command to restore the node's access. This capability is called *unfencing* and is typically implemented as the fence agent's ``on`` command. If any cluster resource has ``requires`` set to ``unfencing``, then that resource will not be probed or started on a node until that node has been unfenced. Fencing and Quorum ################## In general, a cluster partition may execute fencing only if the partition has quorum, and the ``stonith-enabled`` cluster property is set to true. However, there are exceptions: * The requirements apply only to fencing initiated by Pacemaker. If an administrator initiates fencing using the ``stonith_admin`` command, or an external application such as DLM initiates fencing using Pacemaker's C API, the requirements do not apply. * A cluster partition without quorum is allowed to fence any active member of that partition. As a corollary, this allows a ``no-quorum-policy`` of ``suicide`` to work. * If the ``no-quorum-policy`` cluster property is set to ``ignore``, then quorum is not required to execute fencing of any node. Fencing Timeouts ################ Fencing timeouts are complicated, since a single fencing operation can involve many steps, each of which may have a separate timeout. Fencing may be initiated in one of several ways: * An administrator may initiate fencing using the ``stonith_admin`` tool, which has a ``--timeout`` option (defaulting to 2 minutes) that will be used as the fence operation timeout. * An external application such as DLM may initiate fencing using the Pacemaker C API. The application will specify the fence operation timeout in this case, which might or might not be configurable by the user. * The cluster may initiate fencing itself. In this case, the ``stonith-timeout`` cluster property (defaulting to 1 minute) will be used as the fence operation timeout. However fencing is initiated, the initiator contacts Pacemaker's fencer (``pacemaker-fenced``) to request fencing. This connection and request has its own timeout, separate from the fencing operation timeout, but usually happens very quickly. The fencer will contact all fencers in the cluster to ask what devices they have available to fence the target node. The fence operation timeout will be used as the timeout for each of these queries. Once a fencing device has been selected, the fencer will check whether any action-specific timeout has been configured for the device, to use instead of the fence operation timeout. For example, if ``stonith-timeout`` is 60 seconds, but the fencing device has ``pcmk_reboot_timeout`` configured as 90 seconds, then a timeout of 90 seconds will be used for reboot actions using that device. A device may have retries configured, in which case the timeout applies across all attempts. For example, if a device has ``pcmk_reboot_retries`` configured as 2, and the first reboot attempt fails, the second attempt will only have whatever time is remaining in the action timeout after subtracting how much time the first attempt used. This means that if the first attempt fails due to using the entire timeout, no further attempts will be made. There is currently no way to configure a per-attempt timeout. If more than one device is required to fence a target, whether due to failure of the first device or a fencing topology with multiple devices configured for the target, each device will have its own separate action timeout. For all of the above timeouts, the fencer will generally multiply the configured value by 1.2 to get an actual value to use, to account for time needed by the fencer's own processing. Separate from the fencer's timeouts, some fence agents have internal timeouts for individual steps of their fencing process. These agents often have parameters to configure these timeouts, such as ``login-timeout``, ``shell-timeout``, or ``power-timeout``. Many such agents also have a ``disable-timeout`` parameter to ignore their internal timeouts and just let Pacemaker handle the timeout. This causes a difference in retry behavior. If ``disable-timeout`` is not set, and the agent hits one of its internal timeouts, it will report that as a failure to Pacemaker, which can then retry. If ``disable-timeout`` is set, and Pacemaker hits a timeout for the agent, then there will be no time remaining, and no retry will be done. Fence Devices Dependent on Other Resources ########################################## In some cases, a fence device may require some other cluster resource (such as an IP address) to be active in order to function properly. This is obviously undesirable in general: fencing may be required when the depended-on resource is not active, or fencing may be required because the node running the depended-on resource is no longer responding. However, this may be acceptable under certain conditions: * The dependent fence device should not be able to target any node that is allowed to run the depended-on resource. * The depended-on resource should not be disabled during production operation. * The ``concurrent-fencing`` cluster property should be set to ``true``. Otherwise, if both the node running the depended-on resource and some node targeted by the dependent fence device need to be fenced, the fencing of the node running the depended-on resource might be ordered first, making the second fencing impossible and blocking further recovery. With concurrent fencing, the dependent fence device might fail at first due to the depended-on resource being unavailable, but it will be retried and eventually succeed once the resource is brought back up. Even under those conditions, there is one unlikely problem scenario. The DC always schedules fencing of itself after any other fencing needed, to avoid unnecessary repeated DC elections. If the dependent fence device targets the DC, and both the DC and a different node running the depended-on resource need to be fenced, the DC fencing will always fail and block further recovery. Note, however, that losing a DC node entirely causes some other node to become DC and schedule the fencing, so this is only a risk when a stop or other operation with ``on-fail`` set to ``fencing`` fails on the DC. .. index:: single: fencing; configuration Configuring Fencing ################### Higher-level tools can provide simpler interfaces to this process, but using Pacemaker command-line tools, this is how you could configure a fence device. #. Find the correct driver: .. code-block:: none # stonith_admin --list-installed .. note:: You may have to install packages to make fence agents available on your host. Searching your available packages for ``fence-`` is usually helpful. Ensure the packages providing the fence agents you require are installed on every cluster node. #. Find the required parameters associated with the device (replacing ``$AGENT_NAME`` with the name obtained from the previous step): .. code-block:: none # stonith_admin --metadata --agent $AGENT_NAME #. Create a file called ``stonith.xml`` containing a primitive resource with a class of ``stonith``, a type equal to the agent name obtained earlier, and a parameter for each of the values returned in the previous step. #. If the device does not know how to fence nodes based on their uname, you may also need to set the special ``pcmk_host_map`` parameter. See :ref:`fencing-attributes` for details. #. If the device does not support the ``list`` command, you may also need to set the special ``pcmk_host_list`` and/or ``pcmk_host_check`` parameters. See :ref:`fencing-attributes` for details. #. If the device does not expect the target to be specified with the ``port`` parameter, you may also need to set the special ``pcmk_host_argument`` parameter. See :ref:`fencing-attributes` for details. #. Upload it into the CIB using cibadmin: .. code-block:: none # cibadmin --create --scope resources --xml-file stonith.xml #. Set ``stonith-enabled`` to true: .. code-block:: none # crm_attribute --type crm_config --name stonith-enabled --update true #. Once the stonith resource is running, you can test it by executing the following, replacing ``$NODE_NAME`` with the name of the node to fence (although you might want to stop the cluster on that machine first): .. code-block:: none # stonith_admin --reboot $NODE_NAME Example Fencing Configuration _____________________________ For this example, we assume we have a cluster node, ``pcmk-1``, whose IPMI controller is reachable at the IP address 192.0.2.1. The IPMI controller uses the username ``testuser`` and the password ``abc123``. #. Looking at what's installed, we may see a variety of available agents: .. code-block:: none # stonith_admin --list-installed .. code-block:: none (... some output omitted ...) fence_idrac fence_ilo3 fence_ilo4 fence_ilo5 fence_imm fence_ipmilan (... some output omitted ...) Perhaps after some reading some man pages and doing some Internet searches, we might decide ``fence_ipmilan`` is our best choice. #. Next, we would check what parameters ``fence_ipmilan`` provides: .. code-block:: none # stonith_admin --metadata -a fence_ipmilan .. code-block:: xml fence_ipmilan is an I/O Fencing agentwhich can be used with machines controlled by IPMI.This agent calls support software ipmitool (http://ipmitool.sf.net/). WARNING! This fence agent might report success before the node is powered off. You should use -m/method onoff if your fence device works correctly with that option. Fencing action IPMI Lan Auth type. Ciphersuite to use (same as ipmitool -C parameter) Hexadecimal-encoded Kg key for IPMIv2 authentication IP address or hostname of fencing device IP address or hostname of fencing device TCP/UDP port to use for connection with device Use Lanplus to improve security of connection Login name Method to fence Login password or passphrase Script to run to retrieve password Login password or passphrase Script to run to retrieve password IP address or hostname of fencing device (together with --port-as-ip) IP address or hostname of fencing device (together with --port-as-ip) Privilege level on IPMI device Bridge IPMI requests to the remote target address Login name Disable logging to stderr. Does not affect --verbose or --debug-file or logging to syslog. Verbose mode Write debug information to given file Write debug information to given file Display version information and exit Display help and exit Wait X seconds before fencing is started Path to ipmitool binary Wait X seconds for cmd prompt after login Make "port/plug" to be an alias to IP address Test X seconds for status change after ON/OFF Wait X seconds after issuing ON/OFF Wait X seconds for cmd prompt after issuing command Count of attempts to retry power on Use sudo (without password) when calling 3rd party software Use sudo (without password) when calling 3rd party software Path to sudo binary Once we've decided what parameter values we think we need, it is a good idea to run the fence agent's status action manually, to verify that our values work correctly: .. code-block:: none # fence_ipmilan --lanplus -a 192.0.2.1 -l testuser -p abc123 -o status Chassis Power is on #. Based on that, we might create a fencing resource configuration like this in ``stonith.xml`` (or any file name, just use the same name with ``cibadmin`` later): .. code-block:: xml .. note:: Even though the man page shows that the ``action`` parameter is supported, we do not provide that in the resource configuration. Pacemaker will supply an appropriate action whenever the fence device must be used. #. In this case, we don't need to configure ``pcmk_host_map`` because ``fence_ipmilan`` ignores the target node name and instead uses its ``ip`` parameter to know how to contact the IPMI controller. #. We do need to let Pacemaker know which cluster node can be fenced by this device, since ``fence_ipmilan`` doesn't support the ``list`` action. Add a line like this to the agent's instance attributes: .. code-block:: xml #. We don't need to configure ``pcmk_host_argument`` since ``ip`` is all the fence agent needs (it ignores the target name). #. Make the configuration active: .. code-block:: none # cibadmin --create --scope resources --xml-file stonith.xml #. Set ``stonith-enabled`` to true (this only has to be done once): .. code-block:: none # crm_attribute --type crm_config --name stonith-enabled --update true #. Since our cluster is still in testing, we can reboot ``pcmk-1`` without bothering anyone, so we'll test our fencing configuration by running this from one of the other cluster nodes: .. code-block:: none # stonith_admin --reboot pcmk-1 Then we will verify that the node did, in fact, reboot. We can repeat that process to create a separate fencing resource for each node. With some other fence device types, a single fencing resource is able to be used for all nodes. In fact, we could do that with ``fence_ipmilan``, using the ``port-as-ip`` parameter along with ``pcmk_host_map``. Either approach is fine. .. index:: single: fencing; topology single: fencing-topology single: fencing-level Fencing Topologies ################## Pacemaker supports fencing nodes with multiple devices through a feature called *fencing topologies*. Fencing topologies may be used to provide alternative devices in case one fails, or to require multiple devices to all be executed successfully in order to consider the node successfully fenced, or even a combination of the two. Create the individual devices as you normally would, then define one or more ``fencing-level`` entries in the ``fencing-topology`` section of the configuration. * Each fencing level is attempted in order of ascending ``index``. Allowed values are 1 through 9. * If a device fails, processing terminates for the current level. No further devices in that level are exercised, and the next level is attempted instead. * If the operation succeeds for all the listed devices in a level, the level is deemed to have passed. * The operation is finished when a level has passed (success), or all levels have been attempted (failed). * If the operation failed, the next step is determined by the scheduler and/or the controller. Some possible uses of topologies include: * Try on-board IPMI, then an intelligent power switch if that fails * Try fabric fencing of both disk and network, then fall back to power fencing if either fails * Wait up to a certain time for a kernel dump to complete, then cut power to the node -.. table:: **Attributes of a fencing-level Element** +.. list-table:: **Attributes of a fencing-level Element** :class: longtable - :widths: 1 4 - - +------------------+-----------------------------------------------------------------------------------------+ - | Attribute | Description | - +==================+=========================================================================================+ - | id | .. index:: | - | | pair: fencing-level; id | - | | | - | | A unique name for this element (required) | - +------------------+-----------------------------------------------------------------------------------------+ - | target | .. index:: | - | | pair: fencing-level; target | - | | | - | | The name of a single node to which this level applies | - +------------------+-----------------------------------------------------------------------------------------+ - | target-pattern | .. index:: | - | | pair: fencing-level; target-pattern | - | | | - | | An extended regular expression (as defined in `POSIX | - | | `_) | - | | matching the names of nodes to which this level applies | - +------------------+-----------------------------------------------------------------------------------------+ - | target-attribute | .. index:: | - | | pair: fencing-level; target-attribute | - | | | - | | The name of a node attribute that is set (to ``target-value``) for nodes to which this | - | | level applies | - +------------------+-----------------------------------------------------------------------------------------+ - | target-value | .. index:: | - | | pair: fencing-level; target-value | - | | | - | | The node attribute value (of ``target-attribute``) that is set for nodes to which this | - | | level applies | - +------------------+-----------------------------------------------------------------------------------------+ - | index | .. index:: | - | | pair: fencing-level; index | - | | | - | | The order in which to attempt the levels. Levels are attempted in ascending order | - | | *until one succeeds*. Valid values are 1 through 9. | - +------------------+-----------------------------------------------------------------------------------------+ - | devices | .. index:: | - | | pair: fencing-level; devices | - | | | - | | A comma-separated list of devices that must all be tried for this level | - +------------------+-----------------------------------------------------------------------------------------+ + :widths: 25 75 + :header-rows: 1 + + * - Attribute + - Description + * - id + - .. index:: + pair: fencing-level; id + + A unique name for this element (required) + * - target + - .. index:: + pair: fencing-level; target + + The name of a single node to which this level applies + * - target-pattern + - .. index:: + pair: fencing-level; target-pattern + + An extended regular expression (as defined in `POSIX + `_) + matching the names of nodes to which this level applies + * - target-attribute + - .. index:: + pair: fencing-level; target-attribute + + The name of a node attribute that is set (to ``target-value``) for nodes to which this + level applies + * - target-value + - .. index:: + pair: fencing-level; target-value + + The node attribute value (of ``target-attribute``) that is set for nodes to which this + level applies + * - index + - .. index:: + pair: fencing-level; index + + The order in which to attempt the levels. Levels are attempted in ascending order + *until one succeeds*. Valid values are 1 through 9. + * - devices + - .. index:: + pair: fencing-level; devices + + A comma-separated list of devices that must all be tried for this level .. note:: **Fencing topology with different devices for different nodes** .. code-block:: xml ... - + ... Example Dual-Layer, Dual-Device Fencing Topologies __________________________________________________ The following example illustrates an advanced use of ``fencing-topology`` in a cluster with the following properties: * 2 nodes (prod-mysql1 and prod-mysql2) * the nodes have IPMI controllers reachable at 192.0.2.1 and 192.0.2.2 * the nodes each have two independent Power Supply Units (PSUs) connected to two independent Power Distribution Units (PDUs) reachable at 198.51.100.1 (port 10 and port 11) and 203.0.113.1 (port 10 and port 11) * fencing via the IPMI controller uses the ``fence_ipmilan`` agent (1 fence device per controller, with each device targeting a separate node) * fencing via the PDUs uses the ``fence_apc_snmp`` agent (1 fence device per PDU, with both devices targeting both nodes) * a random delay is used to lessen the chance of a "death match" * fencing topology is set to try IPMI fencing first then dual PDU fencing if that fails In a node failure scenario, Pacemaker will first select ``fence_ipmilan`` to try to kill the faulty node. Using the fencing topology, if that method fails, it will then move on to selecting ``fence_apc_snmp`` twice (once for the first PDU, then again for the second PDU). The fence action is considered successful only if both PDUs report the required status. If any of them fails, fencing loops back to the first fencing method, ``fence_ipmilan``, and so on, until the node is fenced or the fencing action is cancelled. .. note:: **First fencing method: single IPMI device per target** Each cluster node has it own dedicated IPMI controller that can be contacted for fencing using the following primitives: .. code-block:: xml .. note:: **Second fencing method: dual PDU devices** Each cluster node also has 2 distinct power supplies controlled by 2 distinct PDUs: * Node 1: PDU 1 port 10 and PDU 2 port 10 * Node 2: PDU 1 port 11 and PDU 2 port 11 The matching fencing agents are configured as follows: .. code-block:: xml .. note:: **Fencing topology** Now that all the fencing resources are defined, it's time to create the right topology. We want to first fence using IPMI and if that does not work, fence both PDUs to effectively and surely kill the node. .. code-block:: xml In ``fencing-topology``, the lowest ``index`` value for a target determines its first fencing method. Remapping Reboots ################# When the cluster needs to reboot a node, whether because ``stonith-action`` is ``reboot`` or because a reboot was requested externally (such as by ``stonith_admin --reboot``), it will remap that to other commands in two cases: * If the chosen fencing device does not support the ``reboot`` command, the cluster will ask it to perform ``off`` instead. * If a fencing topology level with multiple devices must be executed, the cluster will ask all the devices to perform ``off``, then ask the devices to perform ``on``. To understand the second case, consider the example of a node with redundant power supplies connected to intelligent power switches. Rebooting one switch and then the other would have no effect on the node. Turning both switches off, and then on, actually reboots the node. In such a case, the fencing operation will be treated as successful as long as the ``off`` commands succeed, because then it is safe for the cluster to recover any resources that were on the node. Timeouts and errors in the ``on`` phase will be logged but ignored. When a reboot operation is remapped, any action-specific timeout for the remapped action will be used (for example, ``pcmk_off_timeout`` will be used when executing the ``off`` command, not ``pcmk_reboot_timeout``). diff --git a/doc/sphinx/Pacemaker_Explained/index.rst b/doc/sphinx/Pacemaker_Explained/index.rst index 68139809c0..2361737b47 100644 --- a/doc/sphinx/Pacemaker_Explained/index.rst +++ b/doc/sphinx/Pacemaker_Explained/index.rst @@ -1,42 +1,33 @@ Pacemaker Explained =================== *Configuring Pacemaker Clusters* -Abstract --------- This document definitively explains Pacemaker's features and capabilities, particularly the XML syntax used in Pacemaker's Cluster Information Base (CIB). -Table of Contents ------------------ - .. toctree:: :maxdepth: 3 :numbered: intro local-options cluster-options nodes resources operations constraints fencing collective utilization rules acls alerts reusing-configuration status multi-site-clusters ap-samples - -Index ------ - -* :ref:`genindex` -* :ref:`search` + :ref:`genindex` + :ref:`search` diff --git a/doc/sphinx/Pacemaker_Explained/intro.rst b/doc/sphinx/Pacemaker_Explained/intro.rst index a1240c308c..7ba18fde57 100644 --- a/doc/sphinx/Pacemaker_Explained/intro.rst +++ b/doc/sphinx/Pacemaker_Explained/intro.rst @@ -1,22 +1,22 @@ Introduction ------------ The Scope of this Document ########################## This document is intended to be an exhaustive reference for configuring Pacemaker. To achieve this, it focuses on the XML syntax used to configure the CIB. For those that are allergic to XML, multiple higher-level front-ends (both command-line and GUI) are available. These tools will not be covered in this document, though the concepts explained here should make the functionality of these tools more easily understood. - + Users may be interested in other parts of the `Pacemaker documentation set `_, such as *Clusters from Scratch*, a step-by-step guide to setting up an example cluster, and *Pacemaker Administration*, a guide to maintaining a cluster. .. include:: ../shared/pacemaker-intro.rst diff --git a/doc/sphinx/Pacemaker_Explained/local-options.rst b/doc/sphinx/Pacemaker_Explained/local-options.rst index 64e45d0a02..ea754be539 100644 --- a/doc/sphinx/Pacemaker_Explained/local-options.rst +++ b/doc/sphinx/Pacemaker_Explained/local-options.rst @@ -1,780 +1,780 @@ Host-Local Configuration ------------------------ .. index:: pair: XML element; configuration .. note:: Directory and file paths below may differ on your system depending on your Pacemaker build settings. Check your Pacemaker configuration file to find the correct paths. Configuration Value Types ######################### Throughout this document, configuration values will be designated as having one of the following types: .. list-table:: **Configuration Value Types** :class: longtable - :widths: 1 3 + :widths: 25 75 :header-rows: 1 * - Type - Description * - .. _boolean: .. index:: pair: type; boolean boolean - Case-insensitive text value where ``1``, ``yes``, ``y``, ``on``, and ``true`` evaluate as true and ``0``, ``no``, ``n``, ``off``, ``false``, and unset evaluate as false * - .. _date_time: .. index:: pair: type; date/time date/time - Textual timestamp like ``Sat Dec 21 11:47:45 2013`` * - .. _duration: .. index:: pair: type; duration duration - A nonnegative time duration, specified either like a :ref:`timeout ` or an `ISO 8601 duration `_. A duration may be up to approximately 49 days but is intended for much smaller time periods. * - .. _enumeration: .. index:: pair: type; enumeration enumeration - Text that must be one of a set of defined values (which will be listed in the description) * - .. _epoch_time: .. index:: pair: type; epoch_time epoch_time - Time as the integer number of seconds since the Unix epoch, ``1970-01-01 00:00:00 +0000 (UTC)``. * - .. _id: .. index:: pair: type; id id - A text string starting with a letter or underbar, followed by any combination of letters, numbers, dashes, dots, and/or underbars; when used for a property named ``id``, the string must be unique across all ``id`` properties in the CIB * - .. _integer: .. index:: pair: type; integer integer - 32-bit signed integer value (-2,147,483,648 to 2,147,483,647) * - .. _iso8601: .. index:: pair: type; iso8601 ISO 8601 - An `ISO 8601 `_ date/time. * - .. _nonnegative_integer: .. index:: pair: type; nonnegative integer nonnegative integer - 32-bit nonnegative integer value (0 to 2,147,483,647) * - .. _percentage: .. index:: pair: type; percentage percentage - Floating-point number followed by an optional percent sign ('%') * - .. _port: .. index:: pair: type; port port - Integer TCP port number (0 to 65535) * - .. _range: .. index:: pair: type; range range - A range may be a single nonnegative integer or a dash-separated range of nonnegative integers. Either the first or last value may be omitted to leave the range open-ended. Examples: ``0``, ``3-``, ``-5``, ``4-6``. * - .. _score: .. index:: pair: type; score score - A Pacemaker score can be an integer between -1,000,000 and 1,000,000, or a string alias: ``INFINITY`` or ``+INFINITY`` is equivalent to 1,000,000, ``-INFINITY`` is equivalent to -1,000,000, and ``red``, ``yellow``, and ``green`` are equivalent to integers as described in :ref:`node-health`. * - .. _text: .. index:: pair: type; text text - A text string * - .. _timeout: .. index:: pair: type; timeout timeout - A time duration, specified as a bare number (in which case it is considered to be in seconds) or a number with a unit (``ms`` or ``msec`` for milliseconds, ``us`` or ``usec`` for microseconds, ``s`` or ``sec`` for seconds, ``m`` or ``min`` for minutes, ``h`` or ``hr`` for hours) optionally with whitespace before and/or after the number. * - .. _version: .. index:: pair: type; version version - Version number (any combination of alphanumeric characters, dots, and dashes, starting with a number). Scores ______ Scores are integral to how Pacemaker works. Practically everything from moving a resource to deciding which resource to stop in a degraded cluster is achieved by manipulating scores in some way. Scores are calculated per resource and node. Any node with a negative score for a resource can't run that resource. The cluster places a resource on the node with the highest score for it. Score addition and subtraction follow these rules: * Any value (including ``INFINITY``) - ``INFINITY`` = ``-INFINITY`` * ``INFINITY`` + any value other than ``-INFINITY`` = ``INFINITY`` .. note:: What if you want to use a score higher than 1,000,000? Typically this possibility arises when someone wants to base the score on some external metric that might go above 1,000,000. The short answer is you can't. The long answer is it is sometimes possible work around this limitation creatively. You may be able to set the score to some computed value based on the external metric rather than use the metric directly. For nodes, you can store the metric as a node attribute, and query the attribute when computing the score (possibly as part of a custom resource agent). Local Options ############# Most Pacemaker configuration is in the cluster-wide CIB, but some host-local configuration options either are needed at startup (before the CIB is read) or provide per-host overrides of cluster-wide options. These options are configured as environment variables set when Pacemaker is started, in the format ``=""``. These are typically set in a file whose location varies by OS (most commonly ``/etc/sysconfig/pacemaker`` or ``/etc/default/pacemaker``; this documentation was generated on a system using |PCMK_CONFIG_FILE|). .. list-table:: **Local Options** :class: longtable - :widths: 2 2 2 5 + :widths: 25 15 10 50 :header-rows: 1 * - Name - Type - Default - Description * - .. _cib_pam_service: .. index:: pair: node option; CIB_pam_service CIB_pam_service - :ref:`text ` - login - PAM service to use for remote CIB client authentication (passed to ``pam_start``). * - .. _pcmk_logfacility: - + .. index:: pair: node option; PCMK_logfacility - + PCMK_logfacility - :ref:`enumeration ` - daemon - Enable logging via the system log or journal, using the specified log facility. Messages sent here are of value to all Pacemaker administrators. This can be disabled using ``none``, but that is not recommended. Allowed values: * ``none`` * ``daemon`` * ``user`` * ``local0`` * ``local1`` * ``local2`` * ``local3`` * ``local4`` * ``local5`` * ``local6`` * ``local7`` * - .. _pcmk_logpriority: .. index:: pair: node option; PCMK_logpriority PCMK_logpriority - :ref:`enumeration ` - notice - Unless system logging is disabled using ``PCMK_logfacility=none``, messages of the specified log severity and higher will be sent to the system log. The default is appropriate for most installations. Allowed values: * ``emerg`` * ``alert`` * ``crit`` * ``error`` * ``warning`` * ``notice`` * ``info`` * ``debug`` * - .. _pcmk_logfile: .. index:: pair: node option; PCMK_logfile PCMK_logfile - :ref:`text ` - |PCMK_LOG_FILE| - Unless set to ``none``, more detailed log messages will be sent to the specified file (in addition to the system log, if enabled). These messages may have extended information, and will include messages of info severity. This log is of more use to developers and advanced system administrators, and when reporting problems. Note: The default is |PCMK_CONTAINER_LOG_FILE| (inside the container) for bundled container nodes; this would typically be mapped to a different path on the host running the container. * - .. _pcmk_logfile_mode: .. index:: pair: node option; PCMK_logfile_mode PCMK_logfile_mode - :ref:`text ` - 0660 - Pacemaker will set the permissions on the detail log to this value (see ``chmod(1)``). * - .. _pcmk_debug: .. index:: pair: node option; PCMK_debug PCMK_debug - :ref:`enumeration ` - no - Whether to send debug severity messages to the detail log. This may be set for all subsystems (``yes`` or ``no``) or for specific (comma- separated) subsystems. Allowed subsystems are: * ``pacemakerd`` * ``pacemaker-attrd`` * ``pacemaker-based`` * ``pacemaker-controld`` * ``pacemaker-execd`` * ``pacemaker-fenced`` * ``pacemaker-schedulerd`` Example: ``PCMK_debug="pacemakerd,pacemaker-execd"`` * - .. _pcmk_stderr: .. index:: pair: node option; PCMK_stderr PCMK_stderr - :ref:`boolean ` - no - *Advanced Use Only:* Whether to send daemon log messages to stderr. This would be useful only during troubleshooting, when starting Pacemaker manually on the command line. Setting this option in the configuration file is pointless, since the file is not read when starting Pacemaker manually. However, it can be set directly as an environment variable on the command line. * - .. _pcmk_trace_functions: .. index:: pair: node option; PCMK_trace_functions PCMK_trace_functions - :ref:`text ` - - *Advanced Use Only:* Send debug and trace severity messages from these (comma-separated) source code functions to the detail log. Example: ``PCMK_trace_functions="func1,func2"`` * - .. _pcmk_trace_files: .. index:: pair: node option; PCMK_trace_files PCMK_trace_files - :ref:`text ` - - *Advanced Use Only:* Send debug and trace severity messages from all functions in these (comma-separated) source file names to the detail log. Example: ``PCMK_trace_files="file1.c,file2.c"`` * - .. _pcmk_trace_formats: .. index:: pair: node option; PCMK_trace_formats PCMK_trace_formats - :ref:`text ` - - *Advanced Use Only:* Send trace severity messages that are generated by these (comma-separated) format strings in the source code to the detail log. Example: ``PCMK_trace_formats="Error: %s (%d)"`` * - .. _pcmk_trace_tags: .. index:: pair: node option; PCMK_trace_tags PCMK_trace_tags - :ref:`text ` - - *Advanced Use Only:* Send debug and trace severity messages related to these (comma-separated) resource IDs to the detail log. Example: ``PCMK_trace_tags="client-ip,dbfs"`` * - .. _pcmk_blackbox: .. index:: pair: node option; PCMK_blackbox PCMK_blackbox - :ref:`enumeration ` - no - *Advanced Use Only:* Enable blackbox logging globally (``yes`` or ``no``) or by subsystem. A blackbox contains a rolling buffer of all logs (of all severities). Blackboxes are stored under |CRM_BLACKBOX_DIR| by default, by default, and their contents can be viewed using the ``qb-blackbox(8)`` command. The blackbox recorder can be enabled at start using this variable, or at runtime by sending a Pacemaker subsystem daemon process a ``SIGUSR1`` or ``SIGTRAP`` signal, and disabled by sending ``SIGUSR2`` (see ``kill(1)``). The blackbox will be written after a crash, assertion failure, or ``SIGTRAP`` signal. See :ref:`PCMK_debug ` for allowed subsystems. Example: ``PCMK_blackbox="pacemakerd,pacemaker-execd"`` * - .. _pcmk_trace_blackbox: .. index:: pair: node option; PCMK_trace_blackbox PCMK_trace_blackbox - :ref:`enumeration ` - - *Advanced Use Only:* Write a blackbox whenever the message at the specified function and line is logged. Multiple entries may be comma- separated. Example: ``PCMK_trace_blackbox="remote.c:144,remote.c:149"`` * - .. _pcmk_node_start_state: .. index:: pair: node option; PCMK_node_start_state PCMK_node_start_state - :ref:`enumeration ` - default - By default, the local host will join the cluster in an online or standby state when Pacemaker first starts depending on whether it was previously put into standby mode. If this variable is set to ``standby`` or ``online``, it will force the local host to join in the specified state. * - .. _pcmk_node_action_limit: .. index:: pair: node option; PCMK_node_action_limit PCMK_node_action_limit - :ref:`nonnegative integer ` - - If set, this overrides the :ref:`node-action-limit ` cluster option on this node to specify the maximum number of jobs that can be scheduled on this node (or 0 to use twice the number of CPU cores). * - .. _pcmk_fail_fast: .. index:: pair: node option; PCMK_fail_fast PCMK_fail_fast - :ref:`boolean ` - no - By default, if a Pacemaker subsystem crashes, the main ``pacemakerd`` process will attempt to restart it. If this variable is set to ``yes``, ``pacemakerd`` will panic the local host instead. * - .. _pcmk_panic_action: .. index:: pair: node option; PCMK_panic_action PCMK_panic_action - :ref:`enumeration ` - reboot - Pacemaker will panic the local host under certain conditions. By default, this means rebooting the host. This variable can change that behavior: if ``crash``, trigger a kernel crash (useful if you want a kernel dump to investigate); if ``sync-reboot`` or ``sync-crash``, synchronize filesystems before rebooting the host or triggering a kernel crash. The sync values are more likely to preserve log messages, but with the risk that the host may be left active if the synchronization hangs. * - .. _pcmk_remote_address: .. index:: pair: node option; PCMK_remote_address PCMK_remote_address - :ref:`text ` - - By default, if the :ref:`Pacemaker Remote ` service is run on the local node, it will listen for connections on all IP addresses. This may be set to one address to listen on instead, as a resolvable hostname or as a numeric IPv4 or IPv6 address. When resolving names or listening on all addresses, IPv6 will be preferred if available. When listening on an IPv6 address, IPv4 clients will be supported via IPv4-mapped IPv6 addresses. Example: ``PCMK_remote_address="192.0.2.1"`` * - .. _pcmk_remote_port: .. index:: pair: node option; PCMK_remote_port PCMK_remote_port - :ref:`port ` - 3121 - Use this TCP port number for :ref:`Pacemaker Remote ` node connections. This value must be the same on all nodes. * - .. _pcmk_ca_file: .. index:: pair: node option; PCMK_ca_file PCMK_ca_file - :ref:`text ` - - The location of a file containing trusted Certificate Authorities, used to verify client or server certificates. This file must be in PEM format and must be readable by Pacemaker daemons (that is, it must allow read permissions to either the |CRM_DAEMON_USER| user or the |CRM_DAEMON_GROUP| group). If set, along with :ref:`PCMK_key_file ` and :ref:`PCMK_cert_file `, X509 authentication will be enabled for :ref:`Pacemaker Remote ` and remote CIB connections. Example: ``PCMK_ca_file="/etc/pacemaker/ca.cert.pem"`` * - .. _pcmk_cert_file: .. index:: pair: node option; PCMK_cert_file PCMK_cert_file - :ref:`text ` - - The location of a file containing the signed certificate for the server side of the connection. This file must be in PEM format and must be readable by Pacemaker daemons (that is, it must allow read permissions to either the |CRM_DAEMON_USER| user or the |CRM_DAEMON_GROUP| group). If set, along with :ref:`PCMK_ca_file ` and :ref:`PCMK_key_file `, X509 authentication will be enabled for :ref:`Pacemaker Remote ` and remote CIB connections. Example: ``PCMK_cert_file="/etc/pacemaker/server.cert.pem"`` * - .. _pcmk_crl_file: .. index:: pair: node option; PCMK_crl_file PCMK_crl_file - :ref:`text ` - - The location of a Certificate Revocation List file, in PEM format. This setting is optional for X509 authentication. Example: ``PCMK_cr1_file="/etc/pacemaker/crl.pem"`` * - .. _pcmk_key_file: .. index:: pair: node option; PCMK_key_file PCMK_key_file - :ref:`text ` - - The location of a file containing the private key for the matching :ref:`PCMK_cert_file `, in PEM format. This file must be readble by Pacemaker daemons (that is, it must allow read permissions to either the |CRM_DAEMON_USER| user or the |CRM_DAEMON_GROUP| group). If set, along with :ref:`PCMK_ca_file ` and :ref:`PCMK_cert_file `, X509 authentication will be enabled for :ref:`Pacemaker Remote ` and remote CIB connections. Example: ``PCMK_key_file="/etc/pacemaker/server.key.pem"`` * - .. _pcmk_authkey_location: .. index:: pair: node option; PCMK_authkey_location PCMK_authkey_location - :ref:`text ` - |PCMK_AUTHKEY_FILE| - As an alternative to using X509 authentication for :ref:`Pacemaker Remote ` connections, use the contents of this file as the authorization key. This file must be readable by Pacemaker daemons (that is, it must allow read permissions to either the |CRM_DAEMON_USER| user or the |CRM_DAEMON_GROUP| group), and its contents must be identical on all nodes. This is an alternative to using X509 certificates. * - .. _pcmk_remote_pid1: .. index:: pair: node option; PCMK_remote_pid1 PCMK_remote_pid1 - :ref:`enumeration ` - default - *Advanced Use Only:* When a bundle resource's ``run-command`` option is left to default, :ref:`Pacemaker Remote ` runs as PID 1 in the bundle's containers. When it does so, it loads environment variables from the container's |PCMK_INIT_ENV_FILE| and performs the PID 1 responsibility of reaping dead subprocesses. This option controls whether those actions are performed when Pacemaker Remote is not running as PID 1. It is intended primarily for developer testing but can be useful when ``run-command`` is set to a separate, custom PID 1 process that launches Pacemaker Remote. * ``full``: Pacemaker Remote loads environment variables from |PCMK_INIT_ENV_FILE| and reaps dead subprocesses. * ``vars``: Pacemaker Remote loads environment variables from |PCMK_INIT_ENV_FILE| but does not reap dead subprocesses. * ``default``: Pacemaker Remote performs neither action. If Pacemaker Remote is running as PID 1, this option is ignored, and the behavior is the same as for ``full``. * - .. _pcmk_tls_priorities: .. index:: pair: node option; PCMK_tls_priorities PCMK_tls_priorities - :ref:`text ` - |PCMK__GNUTLS_PRIORITIES| - *Advanced Use Only:* These `GnuTLS cipher priorities `_ will be used for TLS connections (whether for :ref:`Pacemaker Remote ` connections or remote CIB access, when enabled). Pacemaker will append ``":+ANON-DH"`` for remote CIB access and ``":+DHE-PSK:+PSK"`` for Pacemaker Remote connections, as they are required for the respective functionality. Example: ``PCMK_tls_priorities="SECURE128:+SECURE192"`` * - .. _pcmk_dh_max_bits: .. index:: pair: node option; PCMK_dh_max_bits PCMK_dh_max_bits - :ref:`nonnegative integer ` - 0 (no maximum) - *Advanced Use Only:* Set an upper bound on the bit length of the prime number generated for Diffie-Hellman parameters needed by TLS connections. The default is no maximum. The server (:ref:`Pacemaker Remote ` daemon, or CIB manager configured to accept remote clients) will use this value to provide a ceiling for the value recommended by the GnuTLS library. The library will only accept a limited number of specific values, which vary by library version, so setting these is recommended only when required for compatibility with specific client versions. Clients do not use ``PCMK_dh_max_bits``. * - .. _pcmk_ipc_type: .. index:: pair: node option; PCMK_ipc_type PCMK_ipc_type - :ref:`enumeration ` - shared-mem - *Advanced Use Only:* Force use of a particular IPC method. Allowed values: * ``shared-mem`` * ``socket`` * ``posix`` * ``sysv`` * - .. _pcmk_cluster_type: .. index:: pair: node option; PCMK_cluster_type PCMK_cluster_type - :ref:`enumeration ` - corosync - *Advanced Use Only:* Specify the cluster layer to be used. If unset, Pacemaker will detect and use a supported cluster layer, if available. Currently, ``"corosync"`` is the only supported cluster layer. If multiple layers are supported in the future, this will allow overriding Pacemaker's automatic detection to select a specific one. * - .. _pcmk_schema_directory: .. index:: pair: node option; PCMK_schema_directory PCMK_schema_directory - :ref:`text ` - |PCMK_SCHEMA_DIR| - *Advanced Use Only:* Specify an alternate location for RNG schemas and XSL transforms. * - .. _pcmk_remote_schema_directory: .. index:: pair: node option; PCMK_remote_schema_directory PCMK_remote_schema_directory - :ref:`text ` - |PCMK__REMOTE_SCHEMA_DIR| - *Advanced Use Only:* Specify an alternate location on :ref:`Pacemaker Remote ` nodes for storing newer RNG schemas and XSL transforms fetched from the cluster. * - .. _pcmk_valgrind_enabled: .. index:: pair: node option; PCMK_valgrind_enabled PCMK_valgrind_enabled - :ref:`enumeration ` - no - *Advanced Use Only:* Whether subsystem daemons should be run under ``valgrind``. Allowed values are the same as for ``PCMK_debug``. * - .. _pcmk_callgrind_enabled: .. index:: pair: node option; PCMK_callgrind_enabled PCMK_callgrind_enabled - :ref:`enumeration ` - no - *Advanced Use Only:* Whether subsystem daemons should be run under ``valgrind`` with the ``callgrind`` tool enabled. Allowed values are the same as for ``PCMK_debug``. * - .. _sbd_sync_resource_startup: .. index:: pair: node option; SBD_SYNC_RESOURCE_STARTUP SBD_SYNC_RESOURCE_STARTUP - :ref:`boolean ` - - If true, ``pacemakerd`` waits for a ping from ``sbd`` during startup before starting other Pacemaker daemons, and during shutdown after stopping other Pacemaker daemons but before exiting. Default value is set based on the ``--with-sbd-sync-default`` configure script option. * - .. _sbd_watchdog_timeout: .. index:: pair: node option; SBD_WATCHDOG_TIMEOUT SBD_WATCHDOG_TIMEOUT - :ref:`duration ` - - If the ``stonith-watchdog-timeout`` cluster property is set to a negative or invalid value, use double this value as the default if positive, or use 0 as the default otherwise. This value must be greater than the value of ``stonith-watchdog-timeout`` if both are set. * - .. _valgrind_opts: .. index:: pair: node option; VALGRIND_OPTS VALGRIND_OPTS - :ref:`text ` - - *Advanced Use Only:* Pass these options to valgrind, when enabled (see ``valgrind(1)``). ``"--vgdb=no"`` should usually be specified because ``pacemaker-execd`` can lower privileges when executing commands, which would otherwise leave a bunch of unremovable files in ``/tmp``. diff --git a/doc/sphinx/Pacemaker_Explained/multi-site-clusters.rst b/doc/sphinx/Pacemaker_Explained/multi-site-clusters.rst index 59d3f9345c..e5fd0de388 100644 --- a/doc/sphinx/Pacemaker_Explained/multi-site-clusters.rst +++ b/doc/sphinx/Pacemaker_Explained/multi-site-clusters.rst @@ -1,341 +1,341 @@ Multi-Site Clusters and Tickets ------------------------------- Apart from local clusters, Pacemaker also supports multi-site clusters. That means you can have multiple, geographically dispersed sites, each with a local cluster. Failover between these clusters can be coordinated manually by the administrator, or automatically by a higher-level entity called a *Cluster Ticket Registry (CTR)*. Challenges for Multi-Site Clusters ################################## Typically, multi-site environments are too far apart to support synchronous communication and data replication between the sites. That leads to significant challenges: - How do we make sure that a cluster site is up and running? - How do we make sure that resources are only started once? - How do we make sure that quorum can be reached between the different sites and a split-brain scenario avoided? - How do we manage failover between sites? - How do we deal with high latency in case of resources that need to be - stopped? + stopped? In the following sections, learn how to meet these challenges. Conceptual Overview ################### Multi-site clusters can be considered as “overlay” clusters where each cluster site corresponds to a cluster node in a traditional cluster. The overlay cluster can be managed by a CTR in order to guarantee that any cluster resource will be active on no more than one cluster site. This is achieved by using *tickets* that are treated as failover domain between cluster sites, in case a site should be down. The following sections explain the individual components and mechanisms that were introduced for multi-site clusters in more detail. Ticket ______ Tickets are, essentially, cluster-wide attributes. A ticket grants the right to run certain resources on a specific cluster site. Resources can be bound to a certain ticket by ``rsc_ticket`` constraints. Only if the ticket is available at a site can the respective resources be started there. Vice versa, if the ticket is revoked, the resources depending on that ticket must be stopped. The ticket thus is similar to a *site quorum*, i.e. the permission to manage/own resources associated with that site. (One can also think of the current ``have-quorum`` flag as a special, cluster-wide ticket that is granted in case of node majority.) Tickets can be granted and revoked either manually by administrators (which could be the default for classic enterprise clusters), or via the automated CTR mechanism described below. A ticket can only be owned by one site at a time. Initially, none of the sites has a ticket. Each ticket must be granted once by the cluster -administrator. +administrator. The presence or absence of tickets for a site is stored in the CIB as a cluster status. With regards to a certain ticket, there are only two states for a site: ``true`` (the site has the ticket) or ``false`` (the site does not have the ticket). The absence of a certain ticket (during the initial state of the multi-site cluster) is the same as the value ``false``. Dead Man Dependency ___________________ A site can only activate resources safely if it can be sure that the other site has deactivated them. However after a ticket is revoked, it can take a long time until all resources depending on that ticket are stopped "cleanly", especially in case of cascaded resources. To cut that process short, the concept of a *Dead Man Dependency* was introduced. If a dead man dependency is in force, if a ticket is revoked from a site, the nodes that are hosting dependent resources are fenced. This considerably speeds up the recovery process of the cluster and makes sure that resources can be migrated more quickly. This can be configured by specifying a ``loss-policy="fence"`` in ``rsc_ticket`` constraints. Cluster Ticket Registry _______________________ A CTR is a coordinated group of network daemons that automatically handles granting, revoking, and timing out tickets (instead of the administrator revoking the ticket somewhere, waiting for everything to stop, and then granting it on the desired site). Pacemaker does not implement its own CTR, but interoperates with external software designed for that purpose (similar to how resource and fencing agents are not directly part of pacemaker). Participating clusters run the CTR daemons, which connect to each other, exchange information about their connectivity, and vote on which sites gets which tickets. A ticket is granted to a site only once the CTR is sure that the ticket has been relinquished by the previous owner, implemented via a timer in most scenarios. If a site loses connection to its peers, its tickets time out and recovery occurs. After the connection timeout plus the recovery timeout has passed, the other sites are allowed to re-acquire the ticket and start the resources again. This can also be thought of as a "quorum server", except that it is not a single quorum ticket, but several. Configuration Replication _________________________ As usual, the CIB is synchronized within each cluster, but it is *not* synchronized across cluster sites of a multi-site cluster. You have to configure the resources that will be highly available across the multi-site cluster for every site accordingly. .. _ticket-constraints: Configuring Ticket Dependencies ############################### The **rsc_ticket** constraint lets you specify the resources depending on a certain ticket. Together with the constraint, you can set a **loss-policy** that defines -what should happen to the respective resources if the ticket is revoked. +what should happen to the respective resources if the ticket is revoked. The attribute **loss-policy** can have the following values: * ``fence:`` Fence the nodes that are running the relevant resources. * ``stop:`` Stop the relevant resources. * ``freeze:`` Do nothing to the relevant resources. * ``demote:`` Demote relevant resources that are running in the promoted role. .. topic:: Constraint that fences node if ``ticketA`` is revoked .. code-block:: xml The example above creates a constraint with the ID ``rsc1-req-ticketA``. It defines that the resource ``rsc1`` depends on ``ticketA`` and that the node running the resource should be fenced if ``ticketA`` is revoked. If resource ``rsc1`` were a promotable resource, you might want to configure that only being in the promoted role depends on ``ticketA``. With the following configuration, ``rsc1`` will be demoted if ``ticketA`` is revoked: .. topic:: Constraint that demotes ``rsc1`` if ``ticketA`` is revoked .. code-block:: xml You can create multiple **rsc_ticket** constraints to let multiple resources depend on the same ticket. However, **rsc_ticket** also supports resource sets (see :ref:`s-resource-sets`), so one can easily list all the resources in one **rsc_ticket** constraint instead. .. topic:: Ticket constraint for multiple resources .. code-block:: xml In the example above, there are two resource sets, so we can list resources with different roles in a single ``rsc_ticket`` constraint. There's no dependency between the two resource sets, and there's no dependency among the resources within a resource set. Each of the resources just depends on ``ticketA``. Referencing resource templates in ``rsc_ticket`` constraints, and even -referencing them within resource sets, is also supported. +referencing them within resource sets, is also supported. If you want other resources to depend on further tickets, create as many constraints as necessary with ``rsc_ticket``. Managing Multi-Site Clusters ############################ Granting and Revoking Tickets Manually ______________________________________ You can grant tickets to sites or revoke them from sites manually. If you want to re-distribute a ticket, you should wait for the dependent resources to stop cleanly at the previous site before you grant the ticket to the new site. -Use the **crm_ticket** command line tool to grant and revoke tickets. +Use the **crm_ticket** command line tool to grant and revoke tickets. To grant a ticket to this site: .. code-block:: none # crm_ticket --ticket ticketA --grant To revoke a ticket from this site: .. code-block:: none # crm_ticket --ticket ticketA --revoke .. important:: If you are managing tickets manually, use the **crm_ticket** command with great care, because it cannot check whether the same ticket is already - granted elsewhere. + granted elsewhere. Granting and Revoking Tickets via a Cluster Ticket Registry ___________________________________________________________ We will use `Booth `_ here as an example of software that can be used with pacemaker as a Cluster Ticket Registry. Booth implements the `Raft `_ algorithm to guarantee the distributed consensus among different cluster sites, and manages the ticket distribution (and thus the failover process between sites). Each of the participating clusters and *arbitrators* runs the Booth daemon **boothd**. An *arbitrator* is the multi-site equivalent of a quorum-only node in a local cluster. If you have a setup with an even number of sites, you need an additional instance to reach consensus about decisions such as failover of resources across sites. In this case, add one or more arbitrators running at additional sites. Arbitrators are single machines that run a booth instance in a special mode. An arbitrator is especially important for a two-site scenario, otherwise there is no way for one site to distinguish between a network failure between it and the other site, and a failure of the other site. The most common multi-site scenario is probably a multi-site cluster with two sites and a single arbitrator on a third site. However, technically, there are no limitations with regards to the number of sites and the number of arbitrators involved. **Boothd** at each site connects to its peers running at the other sites and exchanges connectivity details. Once a ticket is granted to a site, the booth mechanism will manage the ticket automatically: If the site which holds the ticket is out of service, the booth daemons will vote which of the other sites will get the ticket. To protect against brief connection failures, sites that lose the vote (either explicitly or implicitly by being disconnected from the voting body) need to relinquish the ticket after a time-out. Thus, it is made sure that a ticket will only be re-distributed after it has been relinquished by the previous site. The resources that depend on that ticket will fail over -to the new site holding the ticket. The nodes that have run the +to the new site holding the ticket. The nodes that have run the resources before will be treated according to the **loss-policy** you set within the **rsc_ticket** constraint. Before the booth can manage a certain ticket within the multi-site cluster, you initially need to grant it to a site manually via the **booth** command-line tool. After you have initially granted a ticket to a site, **boothd** -will take over and manage the ticket automatically. +will take over and manage the ticket automatically. .. important:: The **booth** command-line tool can be used to grant, list, or - revoke tickets and can be run on any machine where **boothd** is running. + revoke tickets and can be run on any machine where **boothd** is running. If you are managing tickets via Booth, use only **booth** for manual intervention, not **crm_ticket**. That ensures the same ticket will only be owned by one cluster site at a time. Booth Requirements ~~~~~~~~~~~~~~~~~~ * All clusters that will be part of the multi-site cluster must be based on Pacemaker. * Booth must be installed on all cluster nodes and on all arbitrators that will - be part of the multi-site cluster. + be part of the multi-site cluster. * Nodes belonging to the same cluster site should be synchronized via NTP. However, time synchronization is not required between the individual cluster sites. General Management of Tickets _____________________________ Display the information of tickets: .. code-block:: none # crm_ticket --info Or you can monitor them with: .. code-block:: none # crm_mon --tickets Display the ``rsc_ticket`` constraints that apply to a ticket: .. code-block:: none # crm_ticket --ticket ticketA --constraints When you want to do maintenance or manual switch-over of a ticket, revoking the ticket would trigger the loss policies. If ``loss-policy="fence"``, the dependent resources could not be gracefully stopped/demoted, and other unrelated resources could even be affected. The proper way is making the ticket *standby* first with: .. code-block:: none # crm_ticket --ticket ticketA --standby Then the dependent resources will be stopped or demoted gracefully without triggering the loss policies. If you have finished the maintenance and want to activate the ticket again, you can run: .. code-block:: none # crm_ticket --ticket ticketA --activate For more information #################### * `SUSE's Geo Clustering quick start `_ * `Booth `_ diff --git a/doc/sphinx/Pacemaker_Explained/nodes.rst b/doc/sphinx/Pacemaker_Explained/nodes.rst index e88e63a10e..576ce7d391 100644 --- a/doc/sphinx/Pacemaker_Explained/nodes.rst +++ b/doc/sphinx/Pacemaker_Explained/nodes.rst @@ -1,613 +1,587 @@ .. index:: single: node Nodes ----- Pacemaker supports two basic types of nodes: *cluster nodes* and *Pacemaker Remote nodes*. .. index:: single: node; cluster node Cluster nodes _____________ Cluster nodes run Corosync and all Pacemaker components. They may run cluster resources, run all Pacemaker command-line tools, execute fencing actions, count toward cluster quorum, and serve as the cluster's Designated Controller (DC). Every cluster must have at least one cluster node. Scalability is limited by the cluster layer to around 32 cluster nodes. Host Clock Considerations ######################### In general, Pacemaker does not rely on time or time zones being synchronized across nodes. However, if the configuration uses date/time-based :ref:`rules `, synchronization is a good idea, otherwise the rules will evaluate differently depending on which node is the Designated Controller (DC). Also, synchronization is greatly helpful when comparing logs across multiple nodes for problem investigation. If a node's clock jumps forward, you may see relatively minor issues such as various timeouts suddenly being considered expired. If a node's clock jumps backward, more serious problems may occur, so this should be avoided. If the host clock is adjusted at boot, and Pacemaker is enabled at boot, Pacemaker's start should be ordered after the clock adjustment. When run under systemd, Pacemaker will automatically order itself after ``time-sync.target``. However, depending on the local setup, you may need to enable an additional service (for example, ``chronyd-wait.service``) for that to be effective, or write your own workaround (for example, see the discussion on `systemd issue#5097 `_. .. _pacemaker_remote: .. index:: pair: node; Pacemaker Remote Pacemaker Remote nodes ______________________ Pacemaker Remote nodes do not run Corosync or the usual Pacemaker components. Instead, they run only the *remote executor* (``pacemaker-remoted``), which waits for Pacemaker on a cluster node to give it instructions. They may run cluster resources and most command-line tools, but cannot perform other functions of full cluster nodes such as fencing execution, quorum voting, or DC eligibility. There is no hard limit on the number of Pacemaker Remote nodes. .. NOTE:: *Remote* in this document has nothing to do with physical proximity and instead refers to the node not being a member of the underlying Corosync cluster. Pacemaker Remote nodes are subject to the same latency requirements as cluster nodes, which means they are typically in the same data center. There are three types of Pacemaker Remote nodes: * A *remote node* boots outside Pacemaker control, and is typically a physical host. The connection to the remote node is managed as a :ref:`special type of resource ` configured by the user. * A *guest node* is a virtual machine or container configured to run Pacemaker's remote executor when launched, and is launched and managed by the cluster as a standard resource configured by the user with :ref:`special options `. * A *bundle node* is a guest node created for a container that is launched and managed by the cluster as part of a :ref:`bundle ` resource configured by the user. .. NOTE:: It is important to distinguish the various roles a virtual machine can serve in Pacemaker clusters: * A virtual machine can run the full cluster stack, in which case it is a cluster node and is not itself managed by the cluster. * A virtual machine can be managed by the cluster as a simple resource, without the cluster having any awareness of the services running within it. The virtual machine is *opaque* to the cluster. * A virtual machine can be a guest node, allowing the cluster to manage both the virtual machine and resources running within it. The virtual machine is *transparent* to the cluster. Defining a Node _______________ Each cluster node will have an entry in the ``nodes`` section containing at least an ID and a name. A cluster node's ID is defined by the cluster layer (Corosync). .. topic:: **Example Corosync cluster node entry** .. code-block:: xml Pacemaker Remote nodes are defined by a resource in the ``resources`` section. Remote nodes and guest nodes may optionally have an entry in the ``nodes`` section, primarily for permanent :ref:`node attributes `. Normally, the user should let the cluster populate the ``nodes`` section automatically. .. index:: single: node; name .. _node_name: Where Pacemaker Gets the Node Name ################################## The name that Pacemaker uses for a node in the configuration does not have to be the same as its local hostname. Pacemaker uses the following for a cluster node's name, in order of most preferred first: * The value of ``name`` in the ``nodelist`` section of ``corosync.conf`` (``nodeid`` must also be explicitly set there in order for Pacemaker to associate the name with the node) * The value of ``ring0_addr`` in the ``nodelist`` section of ``corosync.conf`` * The local hostname (value of ``uname -n``) A Pacemaker Remote node's name is defined in its resource configuration. If the cluster is running, the ``crm_node -n`` command will display the local node's name as used by the cluster. If a Corosync ``nodelist`` is used, ``crm_node --name-for-id`` with a Corosync node ID will display the name used by the node with the given Corosync ``nodeid``, for example: .. code-block:: none crm_node --name-for-id 2 .. index:: single: node; quorum-only single: quorum-only node Quorum-only Nodes _________________ One popular cluster design uses an even number of cluster nodes (often 2), with an additional lightweight host that contributes to providing quorum but cannot run resources. With Pacemaker, this can be achieved in either of two ways: * When Corosync is used as the underlying cluster layer, the lightweight host can run `qdevice `_ instead of Corosync and Pacemaker. * The lightweight host can be configured as a Pacemaker cluster node, and a :ref:`location constraint ` can be configured for the node with ``score`` set to ``-INFINITY``, ``rsc-pattern`` set to ``.*``, and ``resource-discovey`` set to ``never``. .. index:: single: node; attribute single: node attribute .. _node_attributes: Node Attributes _______________ Pacemaker allows node-specific values to be specified using *node attributes*. A node attribute has a name, and may have a distinct value for each node. Node attributes come in two types, *permanent* and *transient*. Permanent node attributes are kept within the ``node`` entry, and keep their values even if the cluster restarts on a node. Transient node attributes are kept in the CIB's ``status`` section, and go away when the cluster stops on the node. While certain node attributes have specific meanings to the cluster, they are mainly intended to allow administrators and resource agents to track any information desired. For example, an administrator might choose to define node attributes for how much RAM and disk space each node has, which OS each uses, or which server room rack each node is in. Users can configure :ref:`rules` that use node attributes to affect where resources are placed. Setting and querying node attributes #################################### Node attributes can be set and queried using the ``crm_attribute`` and ``attrd_updater`` commands, so that the user does not have to deal with XML configuration directly. Here is an example command to set a permanent node attribute, and the XML configuration that would be generated: .. topic:: **Result of using crm_attribute to specify which kernel pcmk-1 is running** .. code-block:: none # crm_attribute --type nodes --node pcmk-1 --name kernel --update $(uname -r) .. code-block:: xml To read back the value that was just set: .. code-block:: none # crm_attribute --type nodes --node pcmk-1 --name kernel --query scope=nodes name=kernel value=3.10.0-862.14.4.el7.x86_64 The ``--type nodes`` indicates that this is a permanent node attribute; ``--type status`` would indicate a transient node attribute. .. warning:: Attribute values with newline or tab characters are currently displayed with newlines as ``"\n"`` and tabs as ``"\t"``, when ``crm_attribute`` or ``attrd_updater`` query commands use ``--output-as=text`` or leave ``--output-as`` unspecified: .. code-block:: none # crm_attribute -N node1 -n test_attr -v "$(echo -e "a\nb\tc")" -t status # crm_attribute -N node1 -n test_attr --query -t status scope=status name=test_attr value=a\nb\tc This format is deprecated. In a future release, the values will be displayed with literal whitespace characters: .. code-block:: none # crm_attribute -N node1 -n test_attr --query -t status scope=status name=test_attr value=a b c Users should either avoid attribute values with newlines and tabs, or ensure that they can handle both formats. However, it's best to use ``--output-as=xml`` when parsing attribute values from output. Newlines, tabs, and special characters are replaced with XML character references that a conforming XML processor can recognize and convert to literals *(since 2.1.8)*: .. code-block:: none # crm_attribute -N node1 -n test_attr --query -t status --output-as=xml Special node attributes ####################### Certain node attributes have special meaning to the cluster. Node attribute names beginning with ``#`` are considered reserved for these special attributes. Some special attributes do not start with ``#``, for historical reasons. Certain special attributes are set automatically by the cluster, should never be modified directly, and can be used only within :ref:`rules`; these are listed under :ref:`built-in node attributes `. For true/false values, the cluster considers a value of "1", "y", "yes", "on", or "true" (case-insensitively) to be true, "0", "n", "no", "off", "false", or unset to be false, and anything else to be an error. -.. table:: **Node attributes with special significance** +.. list-table:: **Node Attributes With Special Significance** :class: longtable - :widths: 1 2 - - +----------------------------+-----------------------------------------------------+ - | Name | Description | - +============================+=====================================================+ - | fail-count-* | .. index:: | - | | pair: node attribute; fail-count | - | | | - | | Attributes whose names start with | - | | ``fail-count-`` are managed by the cluster | - | | to track how many times particular resource | - | | operations have failed on this node. These | - | | should be queried and cleared via the | - | | ``crm_failcount`` or | - | | ``crm_resource --cleanup`` commands rather | - | | than directly. | - +----------------------------+-----------------------------------------------------+ - | last-failure-* | .. index:: | - | | pair: node attribute; last-failure | - | | | - | | Attributes whose names start with | - | | ``last-failure-`` are managed by the cluster | - | | to track when particular resource operations | - | | have most recently failed on this node. | - | | These should be cleared via the | - | | ``crm_failcount`` or | - | | ``crm_resource --cleanup`` commands rather | - | | than directly. | - +----------------------------+-----------------------------------------------------+ - | maintenance | .. _node_maintenance: | - | | | - | | .. index:: | - | | pair: node attribute; maintenance | - | | | - | | If true, the cluster will not start or stop any | - | | resources on this node. Any resources active on the | - | | node become unmanaged, and any recurring operations | - | | for those resources (except those specifying | - | | ``role`` as ``Stopped``) will be paused. The | - | | :ref:`maintenance-mode ` cluster | - | | option, if true, overrides this. If this attribute | - | | is true, it overrides the | - | | :ref:`is-managed ` and | - | | :ref:`maintenance ` | - | | meta-attributes of affected resources and | - | | :ref:`enabled ` meta-attribute for | - | | affected recurring actions. Pacemaker should not be | - | | restarted on a node that is in single-node | - | | maintenance mode. | - +----------------------------+-----------------------------------------------------+ - | probe_complete | .. index:: | - | | pair: node attribute; probe_complete | - | | | - | | This is managed by the cluster to detect | - | | when nodes need to be reprobed, and should | - | | never be used directly. | - +----------------------------+-----------------------------------------------------+ - | resource-discovery-enabled | .. index:: | - | | pair: node attribute; resource-discovery-enabled | - | | | - | | If the node is a remote node, fencing is enabled, | - | | and this attribute is explicitly set to false | - | | (unset means true in this case), resource discovery | - | | (probes) will not be done on this node. This is | - | | highly discouraged; the ``resource-discovery`` | - | | location constraint property is preferred for this | - | | purpose. | - +----------------------------+-----------------------------------------------------+ - | shutdown | .. index:: | - | | pair: node attribute; shutdown | - | | | - | | This is managed by the cluster to orchestrate the | - | | shutdown of a node, and should never be used | - | | directly. | - +----------------------------+-----------------------------------------------------+ - | site-name | .. index:: | - | | pair: node attribute; site-name | - | | | - | | If set, this will be used as the value of the | - | | ``#site-name`` node attribute used in rules. (If | - | | not set, the value of the ``cluster-name`` cluster | - | | option will be used as ``#site-name`` instead.) | - +----------------------------+-----------------------------------------------------+ - | standby | .. index:: | - | | pair: node attribute; standby | - | | | - | | If true, the node is in standby mode. This is | - | | typically set and queried via the ``crm_standby`` | - | | command rather than directly. | - +----------------------------+-----------------------------------------------------+ - | terminate | .. index:: | - | | pair: node attribute; terminate | - | | | - | | If the value is true or begins with any nonzero | - | | number, the node will be fenced. This is typically | - | | set by tools rather than directly. | - +----------------------------+-----------------------------------------------------+ - | #digests-* | .. index:: | - | | pair: node attribute; #digests | - | | | - | | Attributes whose names start with ``#digests-`` are | - | | managed by the cluster to detect when | - | | :ref:`unfencing` needs to be redone, and should | - | | never be used directly. | - +----------------------------+-----------------------------------------------------+ - | #node-unfenced | .. index:: | - | | pair: node attribute; #node-unfenced | - | | | - | | When the node was last unfenced (as seconds since | - | | the epoch). This is managed by the cluster and | - | | should never be used directly. | - +----------------------------+-----------------------------------------------------+ + :widths: 30 70 + :header-rows: 1 + + * - Name + - Description + * - fail-count-* + - .. index:: + pair: node attribute; fail-count + + Attributes whose names start with ``fail-count-`` are managed by the + cluster to track how many times particular resource operations have + failed on this node. These should be queried and cleared via the + ``crm_failcount`` or ``crm_resource --cleanup`` commands rather than + directly. + * - last-failure-* + - .. index:: + pair: node attribute; last-failure + + Attributes whose names start with ``last-failure-`` are managed by the + cluster to track when particular resource operations have most recently + failed on this node. These should be cleared via the ``crm_failcount`` + or ``crm_resource --cleanup`` commands rather than directly. + * - maintenance + - .. _node_maintenance: + + .. index:: + pair: node attribute; maintenance + + If true, the cluster will not start or stop any resources on this node. + Any resources active on the node become unmanaged, and any recurring + operations for those resources (except those specifying ``role`` as + ``Stopped``) will be paused. The :ref:`maintenance-mode ` + cluster option, if true, overrides this. If this attribute is true, it + overrides the :ref:`is-managed ` and + :ref:`maintenance ` meta-attributes of affected resources + and :ref:`enabled ` meta-attribute for affected recurring + actions. Pacemaker should not be restarted on a node that is in + single-node maintenance mode. + * - probe_complete + - .. index:: + pair: node attribute; probe_complete + + This is managed by the cluster to detect when nodes need to be reprobed, + and should never be used directly. + * - resource-discovery-enabled + - .. index:: + pair: node attribute; resource-discovery-enabled + + If the node is a remote node, fencing is enabled, and this attribute is + explicitly set to false (unset means true in this case), resource + discovery (probes) will not be done on this node. This is highly + discouraged; the ``resource-discovery`` location constraint property is + preferred for this purpose. + * - shutdown + - .. index:: + pair: node attribute; shutdown + + This is managed by the cluster to orchestrate the shutdown of a node, and + should never be used directly. + * - site-name + - .. index:: + pair: node attribute; site-name + + If set, this will be used as the value of the ``#site-name`` node + attribute used in rules. (If not set, the value of the ``cluster-name`` + cluster option will be used as ``#site-name`` instead.) + * - standby + - .. index:: + pair: node attribute; standby + + If true, the node is in standby mode. This is typically set and queried + via the ``crm_standby`` command rather than directly. + * - terminate + - .. index:: + pair: node attribute; terminate + + If the value is true or begins with any nonzero number, the node will be + fenced. This is typically set by tools rather than directly. + * - #digests-* + - .. index:: + pair: node attribute; #digests + + Attributes whose names start with ``#digests-`` are managed by the cluster + to detect when :ref:`unfencing` needs to be redone, and should never be + used directly. + * - #node-unfenced + - .. index:: + pair: node attribute; #node-unfenced + + When the node was last unfenced (as seconds since the epoch). This is + managed by the cluster and should never be used directly. .. index:: single: node; health .. _node-health: Tracking Node Health ____________________ A node may be functioning adequately as far as cluster membership is concerned, and yet be "unhealthy" in some respect that makes it an undesirable location for resources. For example, a disk drive may be reporting SMART errors, or the CPU may be highly loaded. Pacemaker offers a way to automatically move resources off unhealthy nodes. .. index:: single: node attribute; health Node Health Attributes ###################### Pacemaker will treat any node attribute whose name starts with ``#health`` as an indicator of node health. Node health attributes may have one of the following values: -.. table:: **Allowed Values for Node Health Attributes** - :widths: 1 4 - - +------------+--------------------------------------------------------------+ - | Value | Intended significance | - +============+==============================================================+ - | ``red`` | .. index:: | - | | single: red; node health attribute value | - | | single: node attribute; health (red) | - | | | - | | This indicator is unhealthy | - +------------+--------------------------------------------------------------+ - | ``yellow`` | .. index:: | - | | single: yellow; node health attribute value | - | | single: node attribute; health (yellow) | - | | | - | | This indicator is close to unhealthy (whether worsening or | - | | recovering) | - +------------+--------------------------------------------------------------+ - | ``green`` | .. index:: | - | | single: green; node health attribute value | - | | single: node attribute; health (green) | - | | | - | | This indicator is healthy | - +------------+--------------------------------------------------------------+ - | *integer* | .. index:: | - | | single: score; node health attribute value | - | | single: node attribute; health (score) | - | | | - | | A numeric score to apply to all resources on this node (0 or | - | | positive is healthy, negative is unhealthy) | - +------------+--------------------------------------------------------------+ +.. list-table:: **Allowed Values for Node Health Attributes** + :widths: 25 75 + :header-rows: 1 + + * - Value + - Intended significance + * - ``red`` + - .. index:: + single: red; node health attribute value + single: node attribute; health (red) + + This indicator is unhealthy + * - ``yellow`` + - .. index:: + single: yellow; node health attribute value + single: node attribute; health (yellow) + + This indicator is close to unhealthy (whether worsening or recovering) + * - ``green`` + - .. index:: + single: green; node health attribute value + single: node attribute; health (green) + + This indicator is healthy + * - *integer* + - .. index:: + single: score; node health attribute value + single: node attribute; health (score) + + A numeric score to apply to all resources on this node (0 or positive is + healthy, negative is unhealthy) .. note:: A health attribute may technically be transient or permanent, but generally only transient makes sense. .. note:: ``red``, ``yellow``, and ``green`` function as aliases for particular numeric scores as described later. .. index:: pair: cluster option; node-health-strategy Node Health Strategy #################### Pacemaker assigns a node health score to each node, as the sum of the values of all its node health attributes. This score will be used as a location constraint applied to this node for all resources. The ``node-health-strategy`` cluster option controls how Pacemaker responds to changes in node health attributes, and how it translates ``red``, ``yellow``, and ``green`` to scores. Allowed values are: -.. table:: **Node Health Strategies** - :widths: 1 4 - - +----------------+----------------------------------------------------------+ - | Value | Effect | - +================+==========================================================+ - | none | .. index:: | - | | single: node-health-strategy; none | - | | single: none; node-health-strategy value | - | | | - | | Do not track node health attributes at all. | - +----------------+----------------------------------------------------------+ - | migrate-on-red | .. index:: | - | | single: node-health-strategy; migrate-on-red | - | | single: migrate-on-red; node-health-strategy value | - | | | - | | Assign the value of ``-INFINITY`` to ``red``, and 0 to | - | | ``yellow`` and ``green``. This will cause all resources | - | | to move off the node if any attribute is ``red``. | - +----------------+----------------------------------------------------------+ - | only-green | .. index:: | - | | single: node-health-strategy; only-green | - | | single: only-green; node-health-strategy value | - | | | - | | Assign the value of ``-INFINITY`` to ``red`` and | - | | ``yellow``, and 0 to ``green``. This will cause all | - | | resources to move off the node if any attribute is | - | | ``red`` or ``yellow``. | - +----------------+----------------------------------------------------------+ - | progressive | .. index:: | - | | single: node-health-strategy; progressive | - | | single: progressive; node-health-strategy value | - | | | - | | Assign the value of the ``node-health-red`` cluster | - | | option to ``red``, the value of ``node-health-yellow`` | - | | to ``yellow``, and the value of ``node-health-green`` to | - | | ``green``. Each node is additionally assigned a score of | - | | ``node-health-base`` (this allows resources to start | - | | even if some attributes are ``yellow``). This strategy | - | | gives the administrator finer control over how important | - | | each value is. | - +----------------+----------------------------------------------------------+ - | custom | .. index:: | - | | single: node-health-strategy; custom | - | | single: custom; node-health-strategy value | - | | | - | | Track node health attributes using the same values as | - | | ``progressive`` for ``red``, ``yellow``, and ``green``, | - | | but do not take them into account. The administrator is | - | | expected to implement a policy by defining :ref:`rules` | - | | referencing node health attributes. | - +----------------+----------------------------------------------------------+ +.. list-table:: **Node Health Strategies** + :widths: 25 75 + :header-rows: 1 + + * - Value + - Effect + * - none + - .. index:: + single: node-health-strategy; none + single: none; node-health-strategy value + + Do not track node health attributes at all. + * - migrate-on-red + - .. index:: + single: node-health-strategy; migrate-on-red + single: migrate-on-red; node-health-strategy value + + Assign the value of ``-INFINITY`` to ``red``, and 0 to ``yellow`` and + ``green``. This will cause all resources to move off the node if any + attribute is ``red``. + * - only-green + - .. index:: + single: node-health-strategy; only-green + single: only-green; node-health-strategy value + + Assign the value of ``-INFINITY`` to ``red`` and ``yellow``, and 0 to + ``green``. This will cause all resources to move off the node if any + attribute is ``red`` or ``yellow``. + * - progressive + - .. index:: + single: node-health-strategy; progressive + single: progressive; node-health-strategy value + + Assign the value of the ``node-health-red`` cluster option to ``red``, + the value of ``node-health-yellow`` to ``yellow``, and the value of + ``node-health-green`` to ``green``. Each node is additionally assigned a + score of ``node-health-base`` (this allows resources to start even if + some attributes are ``yellow``). This strategy gives the administrator + finer control over how important each value is. + * - custom + - .. index:: + single: node-health-strategy; custom + single: custom; node-health-strategy value + + Track node health attributes using the same values as ``progressive`` for + ``red``, ``yellow``, and ``green``, but do not take them into account. + The administrator is expected to implement a policy by defining :ref:`rules` + referencing node health attributes. Exempting a Resource from Health Restrictions ############################################# If you want a resource to be able to run on a node even if its health score would otherwise prevent it, set the resource's ``allow-unhealthy-nodes`` meta-attribute to ``true`` *(available since 2.1.3)*. This is particularly useful for node health agents, to allow them to detect when the node becomes healthy again. If you configure a health agent without this setting, then the health agent will be banned from an unhealthy node, and you will have to investigate and clear the health attribute manually once it is healthy to allow resources on the node again. If you want the meta-attribute to apply to a clone, it must be set on the clone itself, not on the resource being cloned. Configuring Node Health Agents ############################## Since Pacemaker calculates node health based on node attributes, any method that sets node attributes may be used to measure node health. The most common are resource agents and custom daemons. Pacemaker provides examples that can be used directly or as a basis for custom code. The ``ocf:pacemaker:HealthCPU``, ``ocf:pacemaker:HealthIOWait``, and ``ocf:pacemaker:HealthSMART`` resource agents set node health attributes based on CPU and disk status. To take advantage of this feature, add the resource to your cluster (generally as a cloned resource with a recurring monitor action, to continually check the health of all nodes). For example: .. topic:: Example HealthIOWait resource configuration .. code-block:: xml The resource agents use ``attrd_updater`` to set proper status for each node running this resource, as a node attribute whose name starts with ``#health`` (for ``HealthIOWait``, the node attribute is named ``#health-iowait``). When a node is no longer faulty, you can force the cluster to make it available to take resources without waiting for the next monitor, by setting the node health attribute to green. For example: .. topic:: **Force node1 to be marked as healthy** .. code-block:: none # attrd_updater --name "#health-iowait" --update "green" --node "node1" diff --git a/doc/sphinx/Pacemaker_Explained/operations.rst b/doc/sphinx/Pacemaker_Explained/operations.rst index b5488268e8..8a3c1a1955 100644 --- a/doc/sphinx/Pacemaker_Explained/operations.rst +++ b/doc/sphinx/Pacemaker_Explained/operations.rst @@ -1,701 +1,701 @@ .. index:: single: resource; action single: resource; operation .. _operation: Resource Operations ------------------- *Operations* are actions the cluster can perform on a resource by calling the resource agent. Resource agents must support certain common operations such as start, stop, and monitor, and may implement any others. Operations may be explicitly configured for two purposes: to override defaults for options (such as timeout) that the cluster will use whenever it initiates the operation, and to run an operation on a recurring basis (for example, to monitor the resource for failure). .. topic:: An OCF resource with a non-default start timeout .. code-block:: xml Pacemaker identifies operations by a combination of name and interval, so this combination must be unique for each resource. That is, you should not configure two operations for the same resource with the same name and interval. .. _operation_properties: Operation Properties #################### The ``id``, ``name``, ``interval``, and ``role`` operation properties may be specified only as XML attributes of the ``op`` element. Other operation properties may be specified in any of the following ways, from highest precedence to lowest: * directly in the ``op`` element as an XML attribute * in an ``nvpair`` element within a ``meta_attributes`` element within the ``op`` element * in an ``nvpair`` element within a ``meta_attributes`` element within :ref:`operation defaults ` If not specified, the default from the table below is used. .. list-table:: **Operation Properties** :class: longtable - :widths: 2 2 3 4 + :widths: 17 13 30 40 :header-rows: 1 * - Name - Type - Default - Description * - .. _op_id: - + .. index:: pair: op; id single: id; action property single: action; property, id - + id - :ref:`id ` - - + - - A unique identifier for the XML element *(required)* * - .. _op_name: - + .. index:: pair: op; name single: name; action property single: action; property, name - + name - :ref:`text ` - - + - - An action name supported by the resource agent *(required)* * - .. _op_interval: - + .. index:: pair: op; interval single: interval; action property single: action; property, interval - + interval - :ref:`duration ` - 0 - If this is a positive value, Pacemaker will schedule recurring instances of this operation at the given interval (which makes sense only with :ref:`name ` set to :ref:`monitor `). If this is 0, Pacemaker will apply other properties configured for this operation to instances that are scheduled as needed during normal cluster operation. *(required)* * - .. _op_description: - + .. index:: pair: op; description single: description; action property single: action; property, description - + description - :ref:`text ` - - + - - Arbitrary text for user's use (ignored by Pacemaker) * - .. _op_role: - + .. index:: pair: op; role single: role; action property single: action; property, role - + role - :ref:`enumeration ` - - + - - If this is set, the operation configuration applies only on nodes where the cluster expects the resource to be in the specified role. This makes sense only for recurring monitors. Allowed values: ``Started``, ``Stopped``, and in the case of :ref:`promotable clone resources `, ``Unpromoted`` and ``Promoted``. * - .. _op_timeout: - + .. index:: pair: op; timeout single: timeout; action property single: action; property, timeout - + timeout - :ref:`timeout ` - 20s - If resource agent execution does not complete within this amount of time, the action will be considered failed. **Note:** timeouts for fencing agents are handled specially (see the :ref:`fencing` chapter). * - .. _op_on_fail: - + .. index:: pair: op; on-fail single: on-fail; action property single: action; property, on-fail - + on-fail - :ref:`enumeration ` - * If ``name`` is ``stop``: ``fence`` if :ref:`stonith-enabled ` is true, otherwise ``block`` * If ``name`` is ``demote``: ``on-fail`` of the ``monitor`` action with ``role`` set to ``Promoted``, if present, enabled, and configured to a value other than ``demote``, or ``restart`` otherwise * Otherwise: ``restart`` - How the cluster should respond to a failure of this action. Allowed values: - + * ``ignore:`` Pretend the resource did not fail * ``block:`` Do not perform any further operations on the resource * ``stop:`` Stop the resource and leave it stopped * ``demote:`` Demote the resource, without a full restart. This is valid only for ``promote`` actions, and for ``monitor`` actions with both a nonzero ``interval`` and ``role`` set to ``Promoted``; for any other action, a configuration error will be logged, and the default behavior will be used. *(since 2.0.5)* * ``restart:`` Stop the resource, and start it again if allowed (possibly on a different node) * ``fence:`` Fence the node on which the resource failed * ``standby:`` Put the node on which the resource failed in standby mode (forcing *all* resources away) * - .. _op_enabled: - + .. index:: pair: op; enabled single: enabled; action property single: action; property, enabled - + enabled - :ref:`boolean ` - true - If ``false``, ignore this operation definition. This does not suppress all actions of this type, but is typically used to pause a recurring monitor. This can complement the resource being unmanaged (:ref:`is-managed ` set to ``false``), which does not stop recurring operations. Maintenance mode, which does stop configured monitors, overrides this setting. * - .. _op_interval_origin: - + .. index:: pair: op; interval-origin single: interval-origin; action property single: action; property, interval-origin - + interval-origin - :ref:`ISO 8601 ` - - If set for a recurring action, the action will be scheduled for this time plus a multiple of the action's interval, rather than immediately after the resource gains the monitored role. For example, you might schedule an in-depth monitor to run once per day outside business hours, by setting this to the desired time (on any date) and setting ``interval`` to ``24h``. At most one of ``interval-origin`` and ``start-delay`` may be set. * - .. _op_start_delay: - + .. index:: pair: op; start-delay single: start-delay; action property single: action; property, start-delay - + start-delay - :ref:`duration ` - - If set, the cluster will wait this long before running the action (for the first time, if recurring). This is an advanced option that should generally be avoided. It can be useful for a recurring monitor if a resource agent incorrectly returns success from start before the service is actually ready, and the agent can't be corrected, or for a start action if a service takes a very long time to start, and you don't want to block the cluster from responding to other events during that time. If this delay is longer than 5 minutes, the cluster will pretend that the action succeeded when it is first scheduled for the purpose of other actions needed, then act on the result when it actually runs. At most one of ``interval-origin`` and ``start-delay`` may be set. * - .. _op_record_pending: - + .. index:: pair: op; record-pending single: record-pending; action property single: action; property, record-pending - + record-pending - :ref:`boolean ` - true - Operation results are always recorded when the operation completes (successful or not). If this is ``true``, operations will also be recorded when initiated, so that status output can indicate that the operation is in progress. *(deprecated since 3.0.0)* .. note:: Only one action can be configured for any given combination of ``name`` and ``interval``. .. note:: When ``on-fail`` is set to ``demote``, recovery from failure by a successful demote causes the cluster to recalculate whether and where a new instance should be promoted. The node with the failure is eligible, so if promotion scores have not changed, it will be promoted again. There is no direct equivalent of ``migration-threshold`` for the promoted role, but the same effect can be achieved with a location constraint using a :ref:`rule ` with a node attribute expression for the resource's fail count. For example, to immediately ban the promoted role from a node with any failed promote or promoted instance monitor: .. code-block:: xml This example assumes that there is a promotable clone of the ``my_primitive`` resource (note that the primitive name, not the clone name, is used in the rule), and that there is a recurring 10-second-interval monitor configured for the promoted role (fail count attributes specify the interval in milliseconds). .. _s-resource-monitoring: Monitoring Resources for Failure ################################ When Pacemaker first starts a resource, it runs one-time ``monitor`` operations (referred to as *probes*) to ensure the resource is running where it's supposed to be, and not running where it's not supposed to be. (This behavior can be affected by the ``resource-discovery`` location constraint property.) Other than those initial probes, Pacemaker will *not* (by default) check that the resource continues to stay healthy [#]_. You must configure ``monitor`` operations explicitly to perform these checks. .. topic:: An OCF resource with a recurring health check .. code-block:: xml By default, a ``monitor`` operation will ensure that the resource is running where it is supposed to. The ``target-role`` property can be used for further checking. For example, if a resource has one ``monitor`` operation with ``interval=10 role=Started`` and a second ``monitor`` operation with ``interval=11 role=Stopped``, the cluster will run the first monitor on any nodes it thinks *should* be running the resource, and the second monitor on any nodes that it thinks *should not* be running the resource (for the truly paranoid, who want to know when an administrator manually starts a service by mistake). .. note:: Currently, monitors with ``role=Stopped`` are not implemented for :ref:`clone ` resources. Custom Recurring Operations ########################### Typically, only ``monitor`` operations should be configured as recurring. However, it is possible to implement a custom action name in an OCF agent and then configure that as a recurring operation. This could be useful, for example, to run a report, rotate a log, or clean temporary files related to a particular service. Failures of custom recurring operations will be ignored by the cluster and will not be reported in cluster status *(since 3.0.0; previously, they would be treated like failed monitors)*. A fail count and last failure timestamp will be recorded as transient node attributes, and those node attributes will be erased by the ``crm_resource --cleanup`` command. .. _s-operation-defaults: Setting Global Defaults for Operations ###################################### You can change the global default values for operation properties -in a given cluster. These are defined in an ``op_defaults`` section +in a given cluster. These are defined in an ``op_defaults`` section of the CIB's ``configuration`` section, and can be set with ``crm_attribute``. For example, .. code-block:: none # crm_attribute --type op_defaults --name timeout --update 20s would default each operation's ``timeout`` to 20 seconds. If an operation's definition also includes a value for ``timeout``, then that value would be used for that operation instead. When Implicit Operations Take a Long Time ######################################### The cluster will always perform a number of implicit operations: ``start``, ``stop`` and a non-recurring ``monitor`` operation used at startup to check whether the resource is already active. If one of these is taking too long, then you can create an entry for them and specify a longer timeout. .. topic:: An OCF resource with custom timeouts for its implicit actions .. code-block:: xml Multiple Monitor Operations ########################### Provided no two operations (for a single resource) have the same name and interval, you can have as many ``monitor`` operations as you like. In this way, you can do a superficial health check every minute and progressively more intense ones at higher intervals. To tell the resource agent what kind of check to perform, you need to provide each monitor with a different value for a common parameter. The OCF standard creates a special parameter called ``OCF_CHECK_LEVEL`` for this purpose and dictates that it is "made available to the resource agent without the normal ``OCF_RESKEY`` prefix". Whatever name you choose, you can specify it by adding an ``instance_attributes`` block to the ``op`` tag. It is up to each resource agent to look for the parameter and decide how to use it. .. topic:: An OCF resource with two recurring health checks, performing different levels of checks specified via ``OCF_CHECK_LEVEL``. .. code-block:: xml Disabling a Monitor Operation ############################# The easiest way to stop a recurring monitor is to just delete it. However, there can be times when you only want to disable it temporarily. In such cases, simply add ``enabled=false`` to the operation's definition. .. topic:: Example of an OCF resource with a disabled health check .. code-block:: xml This can be achieved from the command line by executing: .. code-block:: none # cibadmin --modify --xml-text '' Once you've done whatever you needed to do, you can then re-enable it with .. code-block:: none # cibadmin --modify --xml-text '' .. index:: single: resource; failure recovery single: operation; failure recovery .. _failure-handling: Handling Resource Failure ######################### By default, Pacemaker will attempt to recover failed resources by restarting them. However, failure recovery is highly configurable. .. index:: single: resource; failure count single: operation; failure count Failure Counts ______________ Pacemaker tracks resource failures for each combination of node, resource, and operation (start, stop, monitor, etc.). You can query the fail count for a particular node, resource, and/or operation using the ``crm_failcount`` command. For example, to see how many times the 10-second monitor for ``myrsc`` has failed on ``node1``, run: .. code-block:: none # crm_failcount --query -r myrsc -N node1 -n monitor -I 10s If you omit the node, ``crm_failcount`` will use the local node. If you omit the operation and interval, ``crm_failcount`` will display the sum of the fail counts for all operations on the resource. You can use ``crm_resource --cleanup`` or ``crm_failcount --delete`` to clear fail counts. For example, to clear the above monitor failures, run: .. code-block:: none # crm_resource --cleanup -r myrsc -N node1 -n monitor -I 10s If you omit the resource, ``crm_resource --cleanup`` will clear failures for all resources. If you omit the node, it will clear failures on all nodes. If you omit the operation and interval, it will clear the failures for all operations on the resource. .. note:: Even when cleaning up only a single operation, all failed operations will disappear from the status display. This allows us to trigger a re-check of the resource's current status. Higher-level tools may provide other commands for querying and clearing fail counts. The ``crm_mon`` tool shows the current cluster status, including any failed operations. To see the current fail counts for any failed resources, call ``crm_mon`` with the ``--failcounts`` option. This shows the fail counts per resource (that is, the sum of any operation fail counts for the resource). .. index:: single: migration-threshold; resource meta-attribute single: resource; migration-threshold Failure Response ________________ Normally, if a running resource fails, pacemaker will try to stop it and start it again. Pacemaker will choose the best location to start it each time, which may be the same node that it failed on. However, if a resource fails repeatedly, it is possible that there is an underlying problem on that node, and you might desire trying a different node in such a case. Pacemaker allows you to set your preference via the ``migration-threshold`` resource meta-attribute. [#]_ If you define ``migration-threshold`` to *N* for a resource, it will be banned from the original node after *N* failures there. .. note:: The ``migration-threshold`` is per *resource*, even though fail counts are tracked per *operation*. The operation fail counts are added together to compare against the ``migration-threshold``. By default, fail counts remain until manually cleared by an administrator using ``crm_resource --cleanup`` or ``crm_failcount --delete`` (hopefully after first fixing the failure's cause). It is possible to have fail counts expire automatically by setting the ``failure-timeout`` resource meta-attribute. .. important:: A successful operation does not clear past failures. If a recurring monitor operation fails once, succeeds many times, then fails again days later, its fail count is 2. Fail counts are cleared only by manual intervention or failure timeout. For example, setting ``migration-threshold`` to 2 and ``failure-timeout`` to ``60s`` would cause the resource to move to a new node after 2 failures, and allow it to move back (depending on stickiness and constraint scores) after one minute. .. note:: ``failure-timeout`` is measured since the most recent failure. That is, older failures do not individually time out and lower the fail count. Instead, all failures are timed out simultaneously (and the fail count is reset to 0) if there is no new failure for the timeout period. There are two exceptions to the migration threshold: when a resource either fails to start or fails to stop. If the cluster property ``start-failure-is-fatal`` is set to ``true`` (which is the default), start failures cause the fail count to be set to ``INFINITY`` and thus always cause the resource to move immediately. Stop failures are slightly different and crucial. If a resource fails to stop and fencing is enabled, then the cluster will fence the node in order to be able to start the resource elsewhere. If fencing is disabled, then the cluster has no way to continue and will not try to start the resource elsewhere, but will try to stop it again after any failure timeout or clearing. .. index:: single: reload single: reload-agent Reloading an Agent After a Definition Change ############################################ The cluster automatically detects changes to the configuration of active resources. The cluster's normal response is to stop the service (using the old definition) and start it again (with the new definition). This works, but some resource agents are smarter and can be told to use a new set of options without restarting. To take advantage of this capability, the resource agent must: * Implement the ``reload-agent`` action. What it should do depends completely on your application! .. note:: Resource agents may also implement a ``reload`` action to make the managed service reload its own *native* configuration. This is different from ``reload-agent``, which makes effective changes in the resource's *Pacemaker* configuration (specifically, the values of the agent's reloadable parameters). * Advertise the ``reload-agent`` operation in the ``actions`` section of its meta-data. * Set the ``reloadable`` attribute to 1 in the ``parameters`` section of its meta-data for any parameters eligible to be reloaded after a change. Once these requirements are satisfied, the cluster will automatically know to reload the resource (instead of restarting) when a reloadable parameter changes. .. note:: Metadata will not be re-read unless the resource needs to be started. If you edit the agent of an already active resource to set a parameter reloadable, the resource may restart the first time the parameter value changes. .. note:: If both a reloadable and non-reloadable parameter are changed simultaneously, the resource will be restarted. .. _live-migration: Migrating Resources ################### Normally, when the cluster needs to move a resource, it fully restarts the resource (that is, it stops the resource on the current node and starts it on the new node). However, some types of resources, such as many virtual machines, are able to move to another location without loss of state (often referred to as live migration or hot migration). In pacemaker, this is called live migration. Pacemaker can be configured to migrate a resource when moving it, rather than restarting it. Not all resources are able to migrate; see the :ref:`migration checklist ` below. Even those that can, won't do so in all situations. Conceptually, there are two requirements from which the other prerequisites follow: * The resource must be active and healthy at the old location; and * everything required for the resource to run must be available on both the old and new locations. The cluster is able to accommodate both *push* and *pull* migration models by requiring the resource agent to support two special actions: ``migrate_to`` (performed on the current location) and ``migrate_from`` (performed on the destination). In push migration, the process on the current location transfers the resource to the new location where is it later activated. In this scenario, most of the work would be done in the ``migrate_to`` action and, if anything, the activation would occur during ``migrate_from``. Conversely for pull, the ``migrate_to`` action is practically empty and ``migrate_from`` does most of the work, extracting the relevant resource state from the old location and activating it. There is no wrong or right way for a resource agent to implement migration, as long as it works. .. _migration_checklist: .. topic:: Migration Checklist * The resource may not be a clone. * The resource agent standard must be OCF. * The resource must not be in a failed or degraded state. * The resource agent must support ``migrate_to`` and ``migrate_from`` actions, and advertise them in its meta-data. * The resource must have the ``allow-migrate`` meta-attribute set to ``true`` (which is not the default). If an otherwise migratable resource depends on another resource via an ordering constraint, there are special situations in which it will be restarted rather than migrated. For example, if the resource depends on a clone, and at the time the resource needs to be moved, the clone has instances that are stopping and instances that are starting, then the resource will be restarted. The scheduler is not yet able to model this situation correctly and so takes the safer (if less optimal) path. Also, if a migratable resource depends on a non-migratable resource, and both need to be moved, the migratable resource will be restarted. .. rubric:: Footnotes .. [#] Currently, anyway. Automatic monitoring operations may be added in a future version of Pacemaker. .. [#] The naming of this option was perhaps unfortunate as it is easily confused with live migration, the process of moving a resource from one node to another without stopping it. Xen virtual guests are the most common example of resources that can be migrated in this manner. diff --git a/doc/sphinx/Pacemaker_Explained/resources.rst b/doc/sphinx/Pacemaker_Explained/resources.rst index 16d437f71a..6d812fe6a6 100644 --- a/doc/sphinx/Pacemaker_Explained/resources.rst +++ b/doc/sphinx/Pacemaker_Explained/resources.rst @@ -1,832 +1,832 @@ .. _resource: Resources --------- .. _s-resource-primitive: .. index:: single: resource A *resource* is a service managed by Pacemaker. The simplest type of resource, a *primitive*, is described in this chapter. More complex forms, such as groups and clones, are described in later chapters. Every primitive has a *resource agent* that provides Pacemaker a standardized interface for managing the service. This allows Pacemaker to be agnostic about the services it manages. Pacemaker doesn't need to understand how the service works because it relies on the resource agent to do the right thing when asked. Every resource has a *standard* (also called *class*) specifying the interface that its resource agent follows, and a *type* identifying the specific service being managed. .. _s-resource-supported: .. index:: single: resource; standard - + Resource Standards ################## Pacemaker can use resource agents complying with these standards, described in more detail below: * ocf * lsb * systemd * service * stonith Support for some standards is controlled by build options and so might not be available in any particular build of Pacemaker. The command ``crm_resource --list-standards`` will show which standards are supported by the local build. .. index:: single: resource; OCF single: OCF; resources single: Open Cluster Framework; resources Open Cluster Framework ______________________ The Open Cluster Framework (OCF) Resource Agent API is a ClusterLabs standard for managing services. It is the most preferred since it is specifically designed for use in a Pacemaker cluster. OCF agents are scripts that support a variety of actions including ``start``, ``stop``, and ``monitor``. They may accept parameters, making them more flexible than other standards. The number and purpose of parameters is left to the agent, which advertises them via the ``meta-data`` action. Unlike other standards, OCF agents have a *provider* as well as a standard and type. For more information, see the "Resource Agents" chapter of *Pacemaker Administration* and the `OCF standard `_. .. _s-resource-supported-systemd: .. index:: single: Resource; Systemd single: Systemd; resources Systemd _______ Most Linux distributions use `Systemd `_ for system initialization and service management. *Unit files* specify how to manage services and are usually provided by the distribution. Pacemaker can manage systemd units of type service, socket, mount, timer, or path. Simply create a resource with ``systemd`` as the resource standard and the unit file name as the resource type. Do *not* run ``systemctl enable`` on the unit. .. important:: Make sure that any systemd services to be controlled by the cluster are *not* enabled to start at boot. .. index:: single: resource; LSB single: LSB; resources single: Linux Standard Base; resources Linux Standard Base ___________________ *LSB* resource agents, also known as `SysV-style `_, are scripts that provide start, stop, and status actions for a service. They are provided by some operating system distributions. If a full path is not given, they are assumed to be located in a directory specified when your Pacemaker software was built (usually ``/etc/init.d``). In order to be used with Pacemaker, they must conform to the `LSB specification `_ as it relates to init scripts. .. warning:: Some LSB scripts do not fully comply with the standard. For details on how to check whether your script is LSB-compatible, see the "Resource Agents" chapter of `Pacemaker Administration`. Common problems include: * Not implementing the ``status`` action * Not observing the correct exit status codes * Starting a started resource returns an error * Stopping a stopped resource returns an error .. important:: Make sure the host is *not* configured to start any LSB services at boot that will be controlled by the cluster. .. index:: single: Resource; System Services single: System Service; resources System Services _______________ Since there is more than one type of system service (``systemd`` and ``lsb``), Pacemaker supports a special ``service`` alias which intelligently figures out which one applies to a given cluster node. This is particularly useful when the cluster contains a mix of ``systemd`` and ``lsb``. If the ``service`` standard is specified, Pacemaker will try to find the named service as an LSB init script, and if none exists, a systemd unit file. .. index:: single: Resource; STONITH single: STONITH; resources STONITH _______ The ``stonith`` standard is used for managing fencing devices, discussed later in :ref:`fencing`. .. _primitive-resource: Resource Properties ################### These values tell the cluster which resource agent to use for the resource, where to find that resource agent and what standards it conforms to. -.. table:: **Properties of a Primitive Resource** - :widths: 1 4 - - +-------------+------------------------------------------------------------------+ - | Field | Description | - +=============+==================================================================+ - | id | .. index:: | - | | single: id; resource | - | | single: resource; property, id | - | | | - | | Your name for the resource | - +-------------+------------------------------------------------------------------+ - | class | .. index:: | - | | single: class; resource | - | | single: resource; property, class | - | | | - | | The standard the resource agent conforms to. Allowed values: | - | | ``lsb``, ``ocf``, ``service``, ``stonith``, and ``systemd`` | - +-------------+------------------------------------------------------------------+ - | description | .. index:: | - | | single: description; resource | - | | single: resource; property, description | - | | | - | | Arbitrary text for user's use (ignored by Pacemaker) | - +-------------+------------------------------------------------------------------+ - | type | .. index:: | - | | single: type; resource | - | | single: resource; property, type | - | | | - | | The name of the Resource Agent you wish to use. E.g. | - | | ``IPaddr`` or ``Filesystem`` | - +-------------+------------------------------------------------------------------+ - | provider | .. index:: | - | | single: provider; resource | - | | single: resource; property, provider | - | | | - | | The OCF spec allows multiple vendors to supply the same resource | - | | agent. To use the OCF resource agents supplied by the Heartbeat | - | | project, you would specify ``heartbeat`` here. | - +-------------+------------------------------------------------------------------+ +.. list-table:: **Properties of a Primitive Resource** + :widths: 25 75 + :header-rows: 1 + + * - Field + - Description + * - id + - .. index:: + single: id; resource + single: resource; property, id + + Your name for the resource + * - class + - .. index:: + single: class; resource + single: resource; property, class + + The standard the resource agent conforms to. Allowed values: ``lsb``, + ``ocf``, ``service``, ``stonith``, and ``systemd`` + * - description + - .. index:: + single: description; resource + single: resource; property, description + + Arbitrary text for user's use (ignored by Pacemaker) + * - type + - .. index:: + single: type; resource + single: resource; property, type + + The name of the Resource Agent you wish to use. E.g. ``IPaddr`` or + ``Filesystem`` + * - provider + - .. index:: + single: provider; resource + single: resource; property, provider + + The OCF spec allows multiple vendors to supply the same resource agent. + To use the OCF resource agents supplied by the Heartbeat project, you + would specify ``heartbeat`` here. The XML definition of a resource can be queried with the **crm_resource** tool. For example: .. code-block:: none # crm_resource --resource Email --query-xml might produce: .. topic:: A system resource definition .. code-block:: xml .. note:: One of the main drawbacks to system services (lsb and systemd) is that they do not allow parameters .. topic:: An OCF resource definition .. code-block:: xml .. _resource_options: Resource Options ################ Resources have two types of options: *meta-attributes* and *instance attributes*. Meta-attributes apply to any type of resource, while instance attributes are specific to each resource agent. Resource Meta-Attributes ________________________ Meta-attributes are used by the cluster to decide how a resource should behave and can be easily set using the ``--meta`` option of the **crm_resource** command. -.. list-table:: **Meta-attributes of a Primitive Resource** +.. list-table:: **Meta-Attributes of a Primitive Resource** :class: longtable - :widths: 2 2 3 5 + :widths: 20 15 20 45 :header-rows: 1 * - Name - Type - Default - Description * - .. _meta_priority: - + .. index:: single: priority; resource option single: resource; option, priority priority - :ref:`score ` - 0 - If not all resources can be active, the cluster will stop lower-priority resources in order to keep higher-priority ones active. * - .. _meta_critical: - + .. index:: single: critical; resource option single: resource; option, critical critical - :ref:`boolean ` - true - Use this value as the default for ``influence`` in all :ref:`colocation constraints ` involving this resource, as well as in the implicit colocation constraints created if this resource is in a :ref:`group `. For details, see :ref:`s-coloc-influence`. *(since 2.1.0)* * - .. _meta_target_role: - + .. index:: single: target-role; resource option single: resource; option, target-role target-role - :ref:`enumeration ` - Started - What state should the cluster attempt to keep this resource in? Allowed values: * ``Stopped:`` Force the resource to be stopped * ``Started:`` Allow the resource to be started (and in the case of :ref:`promotable ` clone resources, promoted if appropriate) * ``Unpromoted:`` Allow the resource to be started, but only in the unpromoted role if the resource is :ref:`promotable ` * ``Promoted:`` Equivalent to ``Started`` * - .. _meta_is_managed: .. _is_managed: - + .. index:: single: is-managed; resource option single: resource; option, is-managed is-managed - :ref:`boolean ` - true - If false, the cluster will not start, stop, promote, or demote the resource on any node. Recurring actions for the resource are unaffected. Maintenance mode overrides this setting. * - .. _meta_maintenance: .. _rsc_maintenance: - + .. index:: single: maintenance; resource option single: resource; option, maintenance maintenance - :ref:`boolean ` - false - If true, the cluster will not start, stop, promote, or demote the resource on any node, and will pause any recurring monitors (except those specifying ``role`` as ``Stopped``). If true, the :ref:`maintenance-mode ` cluster option or :ref:`maintenance ` node attribute overrides this. * - .. _meta_resource_stickiness: .. _resource-stickiness: - + .. index:: single: resource-stickiness; resource option single: resource; option, resource-stickiness resource-stickiness - :ref:`score ` - 1 for individual clone instances, 0 for all other resources - A score that will be added to the current node when a resource is already active. This allows running resources to stay where they are, even if they would be placed elsewhere if they were being started from a stopped state. * - .. _meta_requires: .. _requires: - + .. index:: single: requires; resource option single: resource; option, requires requires - :ref:`enumeration ` - ``quorum`` for resources with a ``class`` of ``stonith``, otherwise ``unfencing`` if unfencing is active in the cluster, otherwise ``fencing`` if ``stonith-enabled`` is true, otherwise ``quorum`` - Conditions under which the resource can be started. Allowed values: * ``nothing:`` The cluster can always start this resource. * ``quorum:`` The cluster can start this resource only if a majority of the configured nodes are active. * ``fencing:`` The cluster can start this resource only if a majority of the configured nodes are active *and* any failed or unknown nodes have been :ref:`fenced `. * ``unfencing:`` The cluster can only start this resource if a majority of the configured nodes are active *and* any failed or unknown nodes have been fenced *and* only on nodes that have been :ref:`unfenced `. * - .. _meta_migration_threshold: - + .. index:: single: migration-threshold; resource option single: resource; option, migration-threshold migration-threshold - :ref:`score ` - INFINITY - How many failures may occur for this resource on a node, before this node is marked ineligible to host this resource. A value of 0 indicates that this feature is disabled (the node will never be marked ineligible); by contrast, the cluster treats ``INFINITY`` (the default) as a very large but finite number. This option has an effect only if the failed operation specifies ``on-fail`` as ``restart`` (the default), and additionally for failed ``start`` operations, if the cluster property ``start-failure-is-fatal`` is ``false``. * - .. _meta_failure_timeout: - + .. index:: single: failure-timeout; resource option single: resource; option, failure-timeout failure-timeout - :ref:`duration ` - 0 - Ignore previously failed resource actions after this much time has passed without new failures (potentially allowing the resource back to the node on which it failed, if it previously reached its ``migration-threshold`` there). A value of 0 indicates that failures do not expire. **WARNING:** If this value is low, and pending cluster activity prevents the cluster from responding to a failure within that time, then the failure will be ignored completely and will not cause recovery of the resource, even if a recurring action continues to report failure. It should be at least greater than the longest :ref:`action timeout ` for all resources in the cluster. A value in hours or days is reasonable. * - .. _meta_multiple_active: - + .. index:: single: multiple-active; resource option single: resource; option, multiple-active multiple-active - :ref:`enumeration ` - stop_start - What should the cluster do if it ever finds the resource active on more than one node? Allowed values: * ``block``: mark the resource as unmanaged * ``stop_only``: stop all active instances and leave them that way * ``stop_start``: stop all active instances and start the resource in one location only * ``stop_unexpected``: stop all active instances except where the resource should be active (this should be used only when extra instances are not expected to disrupt existing instances, and the resource agent's monitor of an existing instance is capable of detecting any problems that could be caused; note that any resources ordered after this will still need to be restarted) *(since 2.1.3)* * - .. _meta_allow_migrate: - + .. index:: single: allow-migrate; resource option single: resource; option, allow-migrate allow-migrate - :ref:`boolean ` - true for ``ocf:pacemaker:remote`` resources, false otherwise - Whether the cluster should try to "live migrate" this resource when it needs to be moved (see :ref:`live-migration`) * - .. _meta_allow_unhealthy_nodes: - + .. index:: single: allow-unhealthy-nodes; resource option single: resource; option, allow-unhealthy-nodes allow-unhealthy-nodes - :ref:`boolean ` - false - Whether the resource should be able to run on a node even if the node's health score would otherwise prevent it (see :ref:`node-health`) *(since 2.1.3)* * - .. _meta_container_attribute_target: - + .. index:: single: container-attribute-target; resource option single: resource; option, container-attribute-target container-attribute-target - :ref:`enumeration ` - - Specific to bundle resources; see :ref:`s-bundle-attributes` As an example of setting resource options, if you performed the following commands on an LSB Email resource: .. code-block:: none # crm_resource --meta --resource Email --set-parameter priority --parameter-value 100 # crm_resource -m -r Email -p multiple-active -v block the resulting resource definition might be: .. topic:: An LSB resource with cluster options .. code-block:: xml In addition to the cluster-defined meta-attributes described above, you may also configure arbitrary meta-attributes of your own choosing. Most commonly, this would be done for use in :ref:`rules `. For example, an IT department might define a custom meta-attribute to indicate which company department each resource is intended for. To reduce the chance of name collisions with cluster-defined meta-attributes added in the future, it is recommended to use a unique, organization-specific prefix for such attributes. .. _s-resource-defaults: Setting Global Defaults for Resource Meta-Attributes ____________________________________________________ To set a default value for a resource option, add it to the ``rsc_defaults`` section with ``crm_attribute``. For example, .. code-block:: none # crm_attribute --type rsc_defaults --name is-managed --update false would prevent the cluster from starting or stopping any of the resources in the configuration (unless of course the individual resources were specifically enabled by having their ``is-managed`` set to ``true``). Resource Instance Attributes ____________________________ The resource agents of some resource standards (lsb and systemd *not* among them) can be given parameters which determine how they behave and which instance of a service they control. If your resource agent supports parameters, you can add them with the ``crm_resource`` command. For example, .. code-block:: none # crm_resource --resource Public-IP --set-parameter ip --parameter-value 192.0.2.2 would create an entry in the resource like this: .. topic:: An example OCF resource with instance attributes .. code-block:: xml For an OCF resource, the result would be an environment variable called ``OCF_RESKEY_ip`` with a value of ``192.0.2.2``. The list of instance attributes supported by an OCF resource agent can be found by calling the resource agent with the ``meta-data`` command. The output contains an XML description of all the supported attributes, their purpose and default values. .. topic:: Displaying the metadata for the Dummy resource agent template .. code-block:: none # export OCF_ROOT=/usr/lib/ocf # $OCF_ROOT/resource.d/pacemaker/Dummy meta-data .. code-block:: xml 1.1 This is a dummy OCF resource agent. It does absolutely nothing except keep track of whether it is running or not, and can be configured so that actions fail or take a long time. Its purpose is primarily for testing, and to serve as a template for resource agent writers. Example stateless resource agent Location to store the resource state in. State file Fake password field Password Fake attribute that can be changed to cause a reload Fake attribute that can be changed to cause a reload Number of seconds to sleep during operations. This can be used to test how the cluster reacts to operation timeouts. Operation sleep duration in seconds. Start, migrate_from, and reload-agent actions will return failure if running on the host specified here, but the resource will run successfully anyway (future monitor calls will find it running). This can be used to test on-fail=ignore. Report bogus start failure on specified host If this is set, the environment will be dumped to this file for every call. Environment dump file Pacemaker Remote Resources ########################## :ref:`Pacemaker Remote ` nodes are defined by resources. .. _remote_nodes: .. index:: single: node; remote single: Pacemaker Remote; remote node single: remote node Remote nodes ____________ A remote node is defined by a connection resource using the special, built-in **ocf:pacemaker:remote** resource agent. .. list-table:: **ocf:pacemaker:remote Instance Attributes** :class: longtable - :widths: 2 2 3 5 + :widths: 25 10 15 50 :header-rows: 1 * - Name - Type - Default - Description * - .. _remote_server: - + .. index:: pair: remote node; server server - :ref:`text ` - resource ID - Hostname or IP address used to connect to the remote node. The remote executor on the remote node must be configured to accept connections on this address. * - .. _remote_port: - + .. index:: pair: remote node; port port - :ref:`port ` - 3121 - TCP port on the remote node used for its Pacemaker Remote connection. The remote executor on the remote node must be configured to listen on this port. * - .. _remote_reconnect_interval: - + .. index:: pair: remote node; reconnect_interval reconnect_interval - :ref:`duration ` - 0 - If positive, the cluster will attempt to reconnect to a remote node at this interval after an active connection has been lost. Otherwise, the cluster will attempt to reconnect immediately (after any fencing, if needed). .. _guest_nodes: .. index:: single: node; guest single: Pacemaker Remote; guest node single: guest node Guest Nodes ___________ When configuring a virtual machine as a guest node, the virtual machine is created using one of the usual resource agents for that purpose (for example, **ocf:heartbeat:VirtualDomain** or **ocf:heartbeat:Xen**), with additional meta-attributes. No restrictions are enforced on what agents may be used to create a guest node, but obviously the agent must create a distinct environment capable of running the remote executor and cluster resources. An additional requirement is that fencing the node hosting the guest node resource must be sufficient for ensuring the guest node is stopped. This means that not all hypervisors supported by **VirtualDomain** may be used to create guest nodes; if the guest can survive the hypervisor being fenced, it is unsuitable for use as a guest node. -.. list-table:: **Guest node meta-attributes** +.. list-table:: **Guest Node Meta-Attributes** :class: longtable - :widths: 2 2 3 5 + :widths: 25 10 20 45 :header-rows: 1 * - Name - Type - Default - Description * - .. _meta_remote_node: - + .. index:: single: remote-node; resource option single: resource; option, remote-node remote-node - :ref:`text ` - - If specified, this resource defines a guest node using this node name. The guest must be configured to run the remote executor when it is started. This value *must not* be the same as any resource or node ID. * - .. _meta_remote_addr: - + .. index:: single: remote-addr; resource option single: resource; option, remote-addr remote-addr - :ref:`text ` - value of ``remote-node`` - If ``remote-node`` is specified, the hostname or IP address used to connect to the guest. The remote executor on the guest must be configured to accept connections on this address. * - .. _meta_remote_port: - + .. index:: single: remote-port; resource option single: resource; option, remote-port remote-port - :ref:`port ` - 3121 - If ``remote-node`` is specified, the port on the guest used for its Pacemaker Remote connection. The remote executor on the guest must be configured to listen on this port. * - .. _meta_remote_connect_timeout: - + .. index:: single: remote-connect-timeout; resource option single: resource; option, remote-connect-timeout remote-connect-timeout - :ref:`timeout ` - 60s - If ``remote-node`` is specified, how long before a pending guest connection will time out. * - .. _meta_remote_allow_migrate: .. index:: single: remote-allow-migrate; resource option single: resource; option, remote-allow-migrate remote-allow-migrate - :ref:`boolean ` - true - If ``remote-node`` is specified, this acts as the ``allow-migrate`` meta-attribute for its implicitly created remote connection resource (``ocf:pacemaker:remote``). Removing Pacemaker Remote Nodes _______________________________ If the resource creating a remote node connection or guest node is removed from the configuration, status output may continue to show the affected node (as offline). If you want to get rid of that output, run the following command, replacing ``$NODE_NAME`` appropriately: .. code-block:: none # crm_node --force --remove $NODE_NAME .. WARNING:: Be absolutely sure that there are no references to the node's resource in the configuration before running the above command. diff --git a/doc/sphinx/Pacemaker_Explained/reusing-configuration.rst b/doc/sphinx/Pacemaker_Explained/reusing-configuration.rst index 01c7a974ae..3a60b3b3b2 100644 --- a/doc/sphinx/Pacemaker_Explained/reusing-configuration.rst +++ b/doc/sphinx/Pacemaker_Explained/reusing-configuration.rst @@ -1,426 +1,426 @@ Reusing Parts of the Configuration ---------------------------------- Pacemaker provides multiple ways to simplify the configuration XML by reusing parts of it in multiple places. Besides simplifying the XML, this also allows you to manipulate multiple configuration elements with a single reference. Reusing Resource Definitions ############################ If you want to create lots of resources with similar configurations, defining a *resource template* simplifies the task. Once defined, it can be referenced in primitives or in certain types of constraints. Configuring Resources with Templates ____________________________________ The primitives referencing the template will inherit all meta-attributes, instance attributes, utilization attributes and operations defined in the template. And you can define specific attributes and operations for any of the primitives. If any of these are defined in both the template and the primitive, the values defined in the primitive will take precedence over the ones defined in the template. Hence, resource templates help to reduce the amount of configuration work. If any changes are needed, they can be done to the template definition and will take effect globally in all resource definitions referencing that template. Resource templates have a syntax similar to that of primitives. .. topic:: Resource template for a migratable Xen virtual machine .. code-block:: xml Once you define a resource template, you can use it in primitives by specifying the ``template`` property. .. topic:: Xen primitive resource using a resource template .. code-block:: xml In the example above, the new primitive ``vm1`` will inherit everything from ``vm-template``. For example, the equivalent of the above two examples would be: .. topic:: Equivalent Xen primitive resource not using a resource template .. code-block:: xml If you want to overwrite some attributes or operations, add them to the particular primitive's definition. .. topic:: Xen resource overriding template values .. code-block:: xml In the example above, the new primitive ``vm2`` has special attribute values. Its ``monitor`` operation has a longer ``timeout`` and ``interval``, and the primitive has an additional ``stop`` operation. To see the resulting definition of a resource, run: .. code-block:: none # crm_resource --query-xml --resource vm2 To see the raw definition of a resource in the CIB, run: .. code-block:: none # crm_resource --query-xml-raw --resource vm2 Using Templates in Constraints ______________________________ A resource template can be referenced in the following types of constraints: - ``order`` constraints (see :ref:`s-resource-ordering`) - ``colocation`` constraints (see :ref:`s-resource-colocation`) - ``rsc_ticket`` constraints (for multi-site clusters as described in :ref:`ticket-constraints`) Resource templates referenced in constraints stand for all primitives which are derived from that template. This means, the constraint applies to all primitive resources referencing the resource template. Referencing resource templates in constraints is an alternative to resource sets and can simplify the cluster configuration considerably. For example, given the example templates earlier in this chapter: .. code-block:: xml would colocate all VMs with ``base-rsc`` and is the equivalent of the following constraint configuration: .. code-block:: xml .. note:: In a colocation constraint, only one template may be referenced from either ``rsc`` or ``with-rsc``; the other reference must be a regular resource. Using Templates in Resource Sets ________________________________ Resource templates can also be referenced in resource sets. For example, given the example templates earlier in this section, then: .. code-block:: xml is the equivalent of the following constraint using a sequential resource set: .. code-block:: xml Or, if the resources referencing the template can run in parallel, then: .. code-block:: xml is the equivalent of the following constraint configuration: .. code-block:: xml .. _s-reusing-config-elements: Reusing Rules, Options and Sets of Operations ############################################# Sometimes a number of constraints need to use the same set of rules, and resources need to set the same options and parameters. To simplify this situation, you can refer to an existing object using an ``id-ref`` instead of an ``id``. So if for one resource you have .. code-block:: xml Then instead of duplicating the rule for all your other resources, you can instead specify: .. topic:: **Referencing rules from other constraints** .. code-block:: xml - + - + .. important:: The cluster will insist that the ``rule`` exists somewhere. Attempting to add a reference to a nonexistent ``id`` will cause a validation failure, as will attempting to remove a ``rule`` with an ``id`` that is referenced elsewhere. Some rule syntax is allowed only in :ref:`certain contexts `. Validation cannot ensure that the referenced rule is allowed in the context of the rule containing ``id-ref``, so such errors will be caught (and logged) only after the new configuration is accepted. It is the administrator's reponsibility to check for these. The same principle applies for ``meta_attributes`` and ``instance_attributes`` as illustrated in the example below: .. topic:: Referencing attributes, options, and operations from other resources .. code-block:: xml ``id-ref`` can similarly be used with ``resource_set`` (in any constraint type), ``nvpair``, and ``operations``. Tagging Configuration Elements ############################## Pacemaker allows you to *tag* any configuration element that has an XML ID. The main purpose of tagging is to support higher-level user interface tools; Pacemaker itself only uses tags within constraints. Therefore, what you can do with tags mostly depends on the tools you use. Configuring Tags ________________ A tag is simply a named list of XML IDs. .. topic:: Tag referencing three resources .. code-block:: xml What you can do with this new tag depends on what your higher-level tools support. For example, a tool might allow you to enable or disable all of the tagged resources at once, or show the status of just the tagged resources. A single configuration element can be listed in any number of tags. .. important:: If listing nodes in a tag, you must list the node's ``id``, not name. Using Tags in Constraints and Resource Sets ___________________________________________ Pacemaker itself only uses tags in constraints. If you supply a tag name instead of a resource name in any constraint, the constraint will apply to all resources listed in that tag. .. topic:: Constraint using a tag .. code-block:: xml In the example above, assuming the ``all-vms`` tag is defined as in the previous example, the constraint will behave the same as: .. topic:: Equivalent constraints without tags .. code-block:: xml A tag may be used directly in the constraint, or indirectly by being listed in a :ref:`resource set ` used in the constraint. When used in a resource set, an expanded tag will honor the set's ``sequential`` property. Filtering With Tags ___________________ The ``crm_mon`` tool can be used to display lots of information about the state of the cluster. On large or complicated clusters, this can include a lot of information, which makes it difficult to find the one thing you are interested in. The ``--resource=`` and ``--node=`` command line options can be used to filter results. In their most basic usage, these options take a single resource or node name. However, they can also be supplied with a tag name to display several objects at once. For instance, given the following CIB section: .. code-block:: xml The following would be output for ``crm_mon --resource=inactive-rscs -r``: .. code-block:: none Cluster Summary: * Stack: corosync * Current DC: cluster02 (version 2.0.4-1.e97f9675f.git.el7-e97f9675f) - partition with quorum * Last updated: Tue Oct 20 16:09:01 2020 * Last change: Tue May 5 12:04:36 2020 by hacluster via crmd on cluster01 * 5 nodes configured * 27 resource instances configured (4 DISABLED) Node List: * Online: [ cluster01 cluster02 ] Full List of Resources: * Clone Set: inactive-clone [inactive-dhcpd] (disabled): * Stopped (disabled): [ cluster01 cluster02 ] * Resource Group: inactive-group (disabled): * inactive-dummy-1 (ocf::pacemaker:Dummy): Stopped (disabled) * inactive-dummy-2 (ocf::pacemaker:Dummy): Stopped (disabled) diff --git a/doc/sphinx/Pacemaker_Explained/rules.rst b/doc/sphinx/Pacemaker_Explained/rules.rst index 13134daafa..35587d3066 100644 --- a/doc/sphinx/Pacemaker_Explained/rules.rst +++ b/doc/sphinx/Pacemaker_Explained/rules.rst @@ -1,1218 +1,1218 @@ .. index:: single: rule .. _rules: Rules ----- Rules make a configuration more dynamic, allowing values to depend on conditions such as time of day or the value of a node attribute. For example, rules can: * Set a higher value for :ref:`resource-stickiness ` during working hours to minimize downtime, and a lower value on weekends to allow resources to move to their most preferred locations when people aren't around * Automatically place the cluster into maintenance mode during a scheduled maintenance window * Restrict a particular department's resources to run on certain nodes, as determined by custom resource meta-attributes and node attributes .. index:: pair: rule; XML element pair: rule; options Rule Options ############ Each context that supports rules may contain a single ``rule`` element. .. list-table:: **Attributes of a rule Element** :class: longtable - :widths: 2 2 2 5 + :widths: 15 15 10 60 :header-rows: 1 - + * - Name - Type - Default - Description - + * - .. _rule_id: - + .. index:: pair: rule; id - + id - :ref:`id ` - - A unique name for this element (required) * - .. _boolean_op: - + .. index:: pair: rule; boolean-op - + boolean-op - :ref:`enumeration ` - ``and`` - How to combine conditions if this rule contains more than one. Allowed values: - + * ``and``: the rule is satisfied only if all conditions are satisfied * ``or``: the rule is satisfied if any condition is satisfied .. _rule_conditions: .. index:: single: rule; conditions single: rule; contexts Rule Conditions and Contexts ############################ A ``rule`` element must contain one or more conditions. A condition is any of the following, which will be described in more detail later: * a :ref:`date/time expression ` * a :ref:`node attribute expression ` * a :ref:`resource type expression ` * an :ref:`operation type expression ` * another ``rule`` (allowing for complex combinations of conditions) Each type of condition is allowed only in certain contexts. Although any given context may contain only one ``rule`` element, that element may contain any number of conditions, including other ``rule`` elements. Rules may be used in the following contexts, which also will be described in more detail later: * a :ref:`location constraint ` * a :ref:`cluster_property_set ` element (within the ``crm_config`` element) * an :ref:`instance_attributes ` element (within an ``alert``, ``bundle``, ``clone``, ``group``, ``node``, ``op``, ``primitive``, ``recipient``, or ``template`` element) * a :ref:`meta_attributes ` element (within an ``alert``, ``bundle``, ``clone``, ``group``, ``op``, ``op_defaults``, ``primitive``, ``recipient``, ``rsc_defaults``, or ``template`` element) * a :ref:`utilization ` element (within a ``node``, ``primitive``, or ``template`` element) .. _date_expression: .. index:: single: rule; date/time expression pair: XML element; date_expression Date/Time Expressions ##################### The ``date_expression`` element configures a rule condition based on the current date and time. It is allowed in rules in any context. It may contain a ``date_spec`` or ``duration`` element depending on the ``operation`` as described below. .. list-table:: **Attributes of a date_expression Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 20 50 :header-rows: 1 * - Name - Type - Default - Description * - .. _date_expression_id: .. index:: pair: date_expression; id id - :ref:`id ` - - + - - A unique name for this element (required) * - .. _date_expression_start: .. index:: pair: date_expression; start start - :ref:`ISO 8601 ` - - + - - The beginning of the desired time range. Meaningful with an ``operation`` of ``in_range`` or ``gt``. * - .. _date_expression_end: .. index:: pair: date_expression; end end - :ref:`ISO 8601 ` - - + - - The end of the desired time range. Meaningful with an ``operation`` of ``in_range`` or ``lt``. * - .. _date_expression_operation: .. index:: pair: date_expression; operation operation - :ref:`enumeration ` - ``in_range`` - Specifies how to compare the current date/time against a desired time range. Allowed values: * ``gt:`` The expression is satisfied if the current date/time is after ``start`` (which is required) * ``lt:`` The expression is satisfied if the current date/time is before ``end`` (which is required) * ``in_range:`` The expression is satisfied if the current date/time is greater than or equal to ``start`` (if specified) and less than or equal to either ``end`` (if specified) or ``start`` plus the value of the :ref:`duration ` element (if one is contained in the ``date_expression``). At least one of ``start`` or ``end`` must be specified. If both ``end`` and ``duration`` are specified, ``duration`` is ignored. * ``date_spec:`` The expression is satisfied if the current date/time matches the specification given in the contained :ref:`date_spec ` element (which is required) .. _date_spec: .. index:: single: date specification pair: XML element; date_spec Date Specifications ___________________ A ``date_spec`` element is used within a ``date_expression`` to specify a combination of dates and times that satisfy the expression. .. list-table:: **Attributes of a date_spec Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 10 60 :header-rows: 1 * - Name - Type - Default - Description * - .. _date_spec_id: .. index:: pair: date_spec; id id - :ref:`id ` - - + - - A unique name for this element (required) * - .. _date_spec_seconds: .. index:: pair: date_spec; seconds seconds - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current time's second is within this range. Allowed integers: 0 to 59. * - .. _date_spec_minutes: .. index:: pair: date_spec; minutes minutes - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current time's minute is within this range. Allowed integers: 0 to 59. * - .. _date_spec_hours: .. index:: pair: date_spec; hours hours - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current time's hour is within this range. Allowed integers: 0 to 23 where 0 is midnight and 23 is 11 p.m. * - .. _date_spec_monthdays: .. index:: pair: date_spec; monthdays monthdays - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's day of the month is in this range. Allowed integers: 1 to 31. * - .. _date_spec_weekdays: .. index:: pair: date_spec; weekdays weekdays - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's ordinal day of the week is in this range. Allowed integers: 1-7 (where 1 is Monday and 7 is Sunday). * - .. _date_spec_yeardays: .. index:: pair: date_spec; yeardays yeardays - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's ordinal day of the year is in this range. Allowed integers: 1-366. * - .. _date_spec_months: .. index:: pair: date_spec; months months - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's month is in this range. Allowed integers: 1-12 where 1 is January and 12 is December. * - .. _date_spec_weeks: .. index:: pair: date_spec; weeks weeks - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's ordinal week of the year is in this range. Allowed integers: 1-53. * - .. _date_spec_years: .. index:: pair: date_spec; years years - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's year according to the Gregorian calendar is in this range. * - .. _date_spec_weekyears: .. index:: pair: date_spec; weekyears weekyears - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's year in which the week started (according to the ISO 8601 standard) is in this range. * - .. _date_spec_moon: .. index:: pair: date_spec; moon moon - :ref:`range ` - - + - - If this is set, the expression is satisfied only if the current date's phase of the moon is in this range. Allowed values are 0 to 7 where 0 is the new moon and 4 is the full moon. *(deprecated since 2.1.6)* .. note:: Pacemaker can calculate when evaluation of a ``date_expression`` with an ``operation`` of ``gt``, ``lt``, or ``in_range`` will next change, and schedule a cluster re-check for that time. However, it does not do this for ``date_spec``. Instead, it evaluates the ``date_spec`` whenever a cluster re-check naturally happens via a cluster event or the ``cluster-recheck-interval`` cluster option. For example, if you have a ``date_spec`` enabling a resource from 9 a.m. to 5 p.m., and ``cluster-recheck-interval`` has been set to 5 minutes, then sometime between 9 a.m. and 9:05 a.m. the cluster would notice that it needs to start the resource, and sometime between 5 p.m. and 5:05 p.m. it would realize that it needs to stop the resource. The timing of the actual start and stop actions will further depend on factors such as any other actions the cluster may need to perform first, and the load of the machine. .. _duration_element: .. index:: single: duration pair: XML element; duration Durations _________ A ``duration`` element is used within a ``date_expression`` to calculate an ending value for ``in_range`` operations when ``end`` is not supplied. .. list-table:: **Attributes of a duration Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 10 60 :header-rows: 1 * - Name - Type - Default - Description * - .. _duration_id: .. index:: pair: duration; id id - :ref:`id ` - - + - - A unique name for this element (required) * - .. _duration_seconds: .. index:: pair: duration; seconds seconds - :ref:`integer ` - 0 - Number of seconds to add to the total duration * - .. _duration_minutes: .. index:: pair: duration; minutes minutes - :ref:`integer ` - 0 - Number of minutes to add to the total duration * - .. _duration_hours: .. index:: pair: duration; hours hours - :ref:`integer ` - 0 - Number of hours to add to the total duration * - .. _duration_days: .. index:: pair: duration; days days - :ref:`integer ` - 0 - Number of days to add to the total duration * - .. _duration_weeks: .. index:: pair: duration; weeks weeks - :ref:`integer ` - 0 - Number of weeks to add to the total duration * - .. _duration_months: .. index:: pair: duration; months months - :ref:`integer ` - 0 - Number of months to add to the total duration * - .. _duration_years: .. index:: pair: duration; years years - :ref:`integer ` - 0 - Number of years to add to the total duration Example Date/Time Expressions _____________________________ .. topic:: Satisfied if the current year is 2005 .. code-block:: xml or equivalently: .. code-block:: xml .. topic:: 9 a.m. to 5 p.m. Monday through Friday .. code-block:: xml Note that the ``16`` matches all the way through ``16:59:59``, because the numeric value of the hour still matches. .. topic:: 9 a.m. to 6 p.m. Monday through Friday, or anytime Saturday .. code-block:: xml .. topic:: 9 a.m. to 5 p.m. or 9 p.m. to 12 a.m. Monday through Friday .. code-block:: xml .. topic:: Mondays in March 2005 .. code-block:: xml .. note:: Because no time is specified with the above dates, 00:00:00 is implied. This means that the range includes all of 2005-03-01 but only the first second of 2005-04-01. You may wish to write ``end`` as ``"2005-03-31T23:59:59"`` to avoid confusion. .. index:: single: rule; node attribute expression single: node attribute; rule expression pair: XML element; expression .. _node_attribute_expressions: Node Attribute Expressions ########################## The ``expression`` element configures a rule condition based on the value of a node attribute. It is allowed in rules in location constraints and in ``instance_attributes`` elements within ``bundle``, ``clone``, ``group``, ``op``, ``primitive``, and ``template`` elements. .. list-table:: **Attributes of an expression Element** :class: longtable - :widths: 1 1 3 5 + :widths: 15 15 30 40 :header-rows: 1 - + * - Name - Type - Default - Description - + * - .. _expression_id: - + .. index:: pair: expression; id - + id - :ref:`id ` - - A unique name for this element (required) * - .. _expression_attribute: - + .. index:: pair: expression; attribute - + attribute - :ref:`text ` - - Name of the node attribute to test (required) * - .. _expression_operation: - + .. index:: pair: expression; operation - + operation - :ref:`enumeration ` - - + - - The comparison to perform (required). Allowed values: - + * ``defined:`` The expression is satisfied if the node has the named attribute * ``not_defined:`` The expression is satisfied if the node does not have the named attribute * ``lt:`` The expression is satisfied if the node attribute value is less than the reference value * ``gt:`` The expression is satisfied if the node attribute value is greater than the reference value * ``lte:`` The expression is satisfied if the node attribute value is less than or equal to the reference value * ``gte:`` The expression is satisfied if the node attribute value is greater than or equal to the reference value * ``eq:`` The expression is satisfied if the node attribute value is equal to the reference value * ``ne:`` The expression is satisfied if the node attribute value is not equal to the reference value * - .. _expression_type: - + .. index:: pair: expression; type - + type - :ref:`enumeration ` - The default type for ``lt``, ``gt``, ``lte``, and ``gte`` operations is ``number`` if either value contains a decimal point character, or ``integer`` otherwise. The default type for all other operations is ``string``. If a numeric parse fails for either value, then the values are compared as type ``string``. - How to interpret values. Allowed values are ``string``, ``integer`` *(since 2.0.5)*, ``number``, and ``version``. ``integer`` truncates floating-point values if necessary before performing a 64-bit integer comparison. ``number`` performs a double-precision floating-point comparison *(32-bit integer before 2.0.5)*. * - .. _expression_value: - + .. index:: pair: expression; value - + value - :ref:`text ` - - Reference value to compare node attribute against (used only with, and required for, operations other than ``defined`` and ``not_defined``) * - .. _expression_value_source: - + .. index:: pair: expression; value-source - + value-source - :ref:`enumeration ` - ``literal`` - How the reference value is obtained. Allowed values: - + * ``literal``: ``value`` contains the literal reference value to compare * ``param``: ``value`` contains the name of a resource parameter to compare (valid only in the context of a location constraint) * ``meta``: ``value`` is the name of a resource meta-attribute to compare (valid only in the context of a location constraint) .. _node-attribute-expressions-special: In addition to custom node attributes defined by the administrator, the cluster defines special, built-in node attributes for each node that can also be used in rule expressions. .. list-table:: **Built-in Node Attributes** :class: longtable - :widths: 1 4 + :widths: 25 75 :header-rows: 1 * - Name - Description * - #uname - :ref:`Node name ` * - #id - Node ID * - #kind - Node type (``cluster`` for cluster nodes, ``remote`` for Pacemaker Remote nodes created with the ``ocf:pacemaker:remote`` resource, and ``container`` for Pacemaker Remote guest nodes and bundle nodes) * - #is_dc - ``true`` if this node is the cluster's Designated Controller (DC), ``false`` otherwise * - #cluster-name - The value of the ``cluster-name`` cluster property, if set * - #site-name - The value of the ``site-name`` node attribute, if set, otherwise identical to ``#cluster-name`` .. _rsc_expression: .. index:: single: rule; resource expression single: resource; rule expression pair: XML element; rsc_expression Resource Type Expressions ######################### The ``rsc_expression`` element *(since 2.0.5)* configures a rule condition based on the agent used for a resource. It is allowed in rules in a ``meta_attributes`` element within a ``rsc_defaults`` or ``op_defaults`` element. .. list-table:: **Attributes of a rsc_expression Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 10 60 :header-rows: 1 * - Name - Type - Default - Description * - .. _rsc_expression_id: .. index:: pair: rsc_expression; id id - :ref:`id ` - - + - - A unique name for this element (required) * - .. _rsc_expression_class: .. index:: pair: rsc_expression; class class - :ref:`text ` - - + - - If this is set, the expression is satisfied only if the resource's agent standard matches this value * - .. _rsc_expression_provider: .. index:: pair: rsc_expression; provider provider - :ref:`text ` - - + - - If this is set, the expression is satisfied only if the resource's agent provider matches this value * - .. _rsc_expression_type: .. index:: pair: rsc_expression; type type - :ref:`text ` - - + - - If this is set, the expression is satisfied only if the resource's agent type matches this value Example Resource Type Expressions _________________________________ .. topic:: Satisfied for ``ocf:heartbeat:IPaddr2`` resources .. code-block:: xml .. topic:: Satisfied for ``stonith:fence_xvm`` resources .. code-block:: xml .. _op_expression: .. index:: single: rule; operation expression single: operation; rule expression pair: XML element; op_expression Operation Type Expressions ########################## The ``op_expression`` element *(since 2.0.5)* configures a rule condition based on a resource operation name and interval. It is allowed in rules in a ``meta_attributes`` element within an ``op_defaults`` element. .. list-table:: **Attributes of an op_expression Element** :class: longtable - :widths: 1 1 1 4 + :widths: 15 15 10 60 :header-rows: 1 * - Name - Type - Default - Description * - .. _op_expression_id: .. index:: pair: op_expression; id id - :ref:`id ` - - + - - A unique name for this element (required) * - .. _op_expression_name: .. index:: pair: op_expression; name name - :ref:`text ` - - + - - The expression is satisfied only if the operation's name matches this value (required) * - .. _op_expression_interval: .. index:: pair: op_expression; interval interval - :ref:`duration ` - - + - - If this is set, the expression is satisfied only if the operation's interval matches this value Example Operation Type Expressions __________________________________ .. topic:: Expression is satisfied for all monitor actions .. code-block:: xml .. topic:: Expression is satisfied for all monitor actions with a 10-second interval .. code-block:: xml .. _location_rule: .. index:: pair: location constraint; rule Using Rules to Determine Resource Location ########################################## If a :ref:`location constraint ` contains a rule, the cluster will apply the constraint to all nodes where the rule is satisfied. This acts as if identical location constraints without rules were defined for each of the nodes. In the context of a location constraint, ``rule`` elements may take additional attributes. These have an effect only when set for the constraint's top-level ``rule``; they are ignored if set on a subrule. .. list-table:: **Extra Attributes of a rule Element in a Location Constraint** :class: longtable - :widths: 2 2 1 5 + :widths: 20 15 10 55 :header-rows: 1 - + * - Name - Type - Default - Description - + * - .. _rule_role: - + .. index:: pair: rule; role - + role - :ref:`enumeration ` - ``Started`` - If this is set in the constraint's top-level rule, the constraint acts as if ``role`` were set to this in the ``rsc_location`` element. * - .. _rule_score: - + .. index:: pair: rule; score - + score - :ref:`score ` - - + - - If this is set in the constraint's top-level rule, the constraint acts as if ``score`` were set to this in the ``rsc_location`` element. Only one of ``score`` and ``score-attribute`` may be set. * - .. _rule_score_attribute: - + .. index:: pair: rule; score-attribute - + score-attribute - :ref:`text ` - - + - - If this is set in the constraint's top-level rule, the constraint acts as if ``score`` were set to the value of this node attribute on each node where the rule is satisfied. Only one of ``score`` and ``score-attribute`` may be set. Consider the following simple location constraint: .. topic:: Prevent resource ``webserver`` from running on node ``node3`` .. code-block:: xml The same constraint can be written more verbosely using a rule: .. topic:: Prevent resource ``webserver`` from running on node ``node3`` using a rule .. code-block:: xml The advantage of using the expanded form is that one could add more expressions (for example, limiting the constraint to certain days of the week). Location Rules Based on Other Node Properties _____________________________________________ The expanded form allows us to match node attributes other than its name. As an example, consider this configuration of custom node attributes specifying each node's CPU capacity: .. topic:: Sample node section with node attributes .. code-block:: xml We can use a rule to prevent a resource from running on underpowered machines: .. topic:: Rule using a node attribute (to be used inside a location constraint) .. code-block:: xml Using ``score-attribute`` Instead of ``score`` ______________________________________________ When using ``score-attribute`` instead of ``score``, each node matched by the rule has its score adjusted according to its value for the named node attribute. In the previous example, if the location constraint rule used ``score-attribute="cpu_mips"`` instead of ``score="-INFINITY"``, node ``c001n01`` would have its preference to run the resource increased by 1234 whereas node ``c001n02`` would have its preference increased by 5678. .. _s-rsc-pattern-rules: Specifying location scores using pattern submatches ___________________________________________________ Location constraints may use :ref:`rsc-pattern ` to apply the constraint to all resources whose IDs match the given pattern. The pattern may contain up to 9 submatches in parentheses, whose values may be used as ``%1`` through ``%9`` in a ``rule`` element's ``score-attribute`` or an ``expression`` element's ``attribute``. For example, the following configuration excerpt gives the resources **server-httpd** and **ip-httpd** a preference of 100 on node1 and 50 on node2, and **ip-gateway** a preference of -100 on node1 and 200 on node2. .. topic:: Location constraint using submatches .. code-block:: xml .. _option_rule: .. index:: pair: cluster option; rule pair: instance attribute; rule pair: meta-attribute; rule pair: resource defaults; rule pair: operation defaults; rule pair: node attribute; rule Using Rules to Define Options ############################# Rules may be used to control a variety of options: * :ref:`Cluster options ` (as ``cluster_property_set`` elements) * :ref:`Node attributes ` (as ``instance_attributes`` or ``utilization`` elements inside a ``node`` element) * :ref:`Resource options ` (as ``utilization``, ``meta_attributes``, or ``instance_attributes`` elements inside a resource definition element or ``op`` , ``rsc_defaults``, ``op_defaults``, or ``template`` element) * :ref:`Operation options ` (as ``meta_attributes`` elements inside an ``op`` or ``op_defaults`` element) * :ref:`Alert options ` (as ``instance_attributes`` or ``meta_attributes`` elements inside an ``alert`` or ``recipient`` element) Using Rules to Control Resource Options _______________________________________ Often some cluster nodes will be different from their peers. Sometimes, these differences (for example, the location of a binary, or the names of network interfaces) require resources to be configured differently depending on the machine they're hosted on. By defining multiple ``instance_attributes`` elements for the resource and adding a rule to each, we can easily handle these special cases. In the example below, ``mySpecialRsc`` will use eth1 and port 9999 when run on node1, eth2 and port 8888 on node2 and default to eth0 and port 9999 for all other nodes. .. topic:: Defining different resource options based on the node name .. code-block:: xml Multiple ``instance_attributes`` elements are evaluated from highest score to lowest. If not supplied, the score defaults to zero. Objects with equal scores are processed in their listed order. If an ``instance_attributes`` object has no rule or a satisfied ``rule``, then for any parameter the resource does not yet have a value for, the resource will use the value defined by the ``instance_attributes``. For example, given the configuration above, if the resource is placed on ``node1``: * ``special-node1`` has the highest score (3) and so is evaluated first; its rule is satisfied, so ``interface`` is set to ``eth1``. * ``special-node2`` is evaluated next with score 2, but its rule is not satisfied, so it is ignored. * ``defaults`` is evaluated last with score 1, and has no rule, so its values are examined; ``interface`` is already defined, so the value here is not used, but ``port`` is not yet defined, so ``port`` is set to ``9999``. Using Rules to Control Resource Defaults ________________________________________ Rules can be used for resource and operation defaults. The following example illustrates how to set a different ``resource-stickiness`` value during and outside work hours. This allows resources to automatically move back to their most preferred hosts, but at a time that (in theory) does not interfere with business activities. .. topic:: Change ``resource-stickiness`` during working hours .. code-block:: xml ``rsc_expression`` is valid within both ``rsc_defaults`` and ``op_defaults``; ``op_expression`` is valid only within ``op_defaults``. .. topic:: Default all IPaddr2 resources to stopped .. code-block:: xml .. topic:: Default all monitor action timeouts to 7 seconds .. code-block:: xml .. topic:: Default the timeout on all 10-second-interval monitor actions on ``IPaddr2`` resources to 8 seconds .. code-block:: xml .. index:: pair: rule; cluster option Using Rules to Control Cluster Options ______________________________________ Controlling cluster options is achieved in much the same manner as specifying different resource options on different nodes. The following example illustrates how to set ``maintenance_mode`` during a scheduled maintenance window. This will keep the cluster running but not monitor, start, or stop resources during this time. .. topic:: Schedule a maintenance window for 9 to 11 p.m. CDT Sept. 20, 2019 .. code-block:: xml .. important:: The ``cluster_property_set`` with an ``id`` set to "cib-bootstrap-options" will *always* have the highest priority, regardless of any scores. Therefore, rules in another ``cluster_property_set`` can never take effect for any properties listed in the bootstrap set. diff --git a/doc/sphinx/Pacemaker_Explained/status.rst b/doc/sphinx/Pacemaker_Explained/status.rst index 2cdf20c7e8..82d846b00c 100644 --- a/doc/sphinx/Pacemaker_Explained/status.rst +++ b/doc/sphinx/Pacemaker_Explained/status.rst @@ -1,459 +1,459 @@ .. index:: pair: XML element; status Status ------ Pacemaker automatically generates a ``status`` section in the CIB (inside the ``cib`` element, at the same level as ``configuration``). The status is transient, and is not stored to disk with the rest of the CIB. The section's structure and contents are internal to Pacemaker and subject to change from release to release. Its often obscure element and attribute names are kept for historical reasons, to maintain compatibility with older versions during rolling upgrades. Users should not modify the section directly, though various command-line tool options affect it indirectly. .. index:: pair: XML element; node_state single: node; state Node State ########## The ``status`` element contains ``node_state`` elements for each node in the cluster (and potentially nodes that have been removed from the configuration since the cluster started). The ``node_state`` element has attributes that allow the cluster to determine whether the node is healthy. .. topic:: Example minimal node state entry .. code-block:: xml .. list-table:: **Attributes of a node_state Element** :class: longtable - :widths: 1 1 3 + :widths: 20 20 60 :header-rows: 1 * - Name - Type - Description * - .. _node_state_id: .. index:: pair: node_state; id id - :ref:`text ` - Node ID (identical to ``id`` of corresponding ``node`` element in the ``configuration`` section) * - .. node_state_uname: .. index:: pair: node_state; uname uname - :ref:`text ` - Node name (identical to ``uname`` of corresponding ``node`` element in the ``configuration`` section) * - .. node_state_in_ccm: .. index:: pair: node_state; in_ccm in_ccm - :ref:`epoch time ` *(since 2.1.7; previously boolean)* - If the node's controller is currently in the cluster layer's membership, this is the epoch time at which it joined (or 1 if the node is in the process of leaving the cluster), otherwise 0 *(since 2.1.7; previously, it was "true" or "false")* * - .. node_state_crmd: .. index:: pair: node_state; crmd crmd - :ref:`epoch time ` *(since 2.1.7; previously an enumeration)* - If the node's controller is currently in the cluster layer's controller messaging group, this is the epoch time at which it joined, otherwise 0 *(since 2.1.7; previously, the value was either "online" or "offline")* * - .. node_state_crm_debug_origin: .. index:: pair: node_state; crm-debug-origin crm-debug-origin - :ref:`text ` - Name of the source code function that recorded this ``node_state`` element (for debugging) * - .. node_state_join: .. index:: pair: node_state; join join - :ref:`enumeration ` - Current status of node's controller join sequence (and thus whether it is eligible to run resources). Allowed values: * ``down``: Not yet joined * ``pending``: In the process of joining or leaving * ``member``: Fully joined * ``banned``: Rejected by DC * - .. node_state_expected: .. index:: pair: node_state; expected expected - :ref:`enumeration ` - What cluster expects ``join`` to be in the immediate future. Allowed values are same as for ``join``. .. _transient_attributes: .. index:: pair: XML element; transient_attributes single: node; transient attribute single: node attribute; transient Transient Node Attributes ######################### The ``transient_attributes`` section specifies transient :ref:`node_attributes`. In addition to any values set by the administrator or resource agents using the ``attrd_updater`` or ``crm_attribute`` tools, the cluster stores various state information here. .. topic:: Example transient node attributes for a node .. code-block:: xml .. index:: pair: XML element; lrm pair: XML element; lrm_resources pair: node; history Node History ############ Each ``node_state`` element contains an ``lrm`` element with a history of certain resource actions performed on the node. The ``lrm`` element contains an ``lrm_resources`` element. .. index:: pair: XML element; lrm_resource pair: resource; history Resource History ________________ The ``lrm_resources`` element contains an ``lrm_resource`` element for each resource that has had an action performed on the node. An ``lrm_resource`` entry has attributes allowing the cluster to stop the resource safely even if it is removed from the configuration. Specifically, the resource's ``id``, ``class``, ``type`` and ``provider`` are recorded. .. index:: pair: XML element; lrm_rsc_op pair: action; history Action History ______________ Each ``lrm_resource`` element contains an ``lrm_rsc_op`` element for each recorded action performed for that resource on that node. (Not all actions are recorded, just enough to determine the resource's state.) -.. list-table:: **Attributes of an lrm_rsc_op element** +.. list-table:: **Attributes of an lrm_rsc_op Element** :class: longtable - :widths: 1 1 3 + :widths: 20 20 60 :header-rows: 1 * - Name - Type - Description * - .. _lrm_rsc_op_id: .. index:: pair: lrm_rsc_op; id id - :ref:`text ` - Identifier for the history entry constructed from the resource ID, action name or history entry type, and action interval. * - .. _lrm_rsc_op_operation_key: .. index:: pair: lrm_rsc_op; operation_key operation_key - :ref:`text ` - Identifier for the action that was executed, constructed from the resource ID, action name, and action interval. * - .. _lrm_rsc_op_operation: .. index:: pair: lrm_rsc_op; operation operation - :ref:`text ` - The name of the action the history entry is for * - .. _lrm_rsc_op_crm_debug_origin: .. index:: pair: lrm_rsc_op; crm-debug-origin crm-debug-origin - :ref:`text ` - Name of the source code function that recorded this entry (for debugging) * - .. _lrm_rsc_op_crm_feature_set: .. index:: pair: lrm_rsc_op; crm_feature_set crm_feature_set - :ref:`version ` - The Pacemaker feature set used to record this entry. * - .. _lrm_rsc_op_transition_key: .. index:: pair: lrm_rsc_op; transition-key transition-key - :ref:`text ` - A concatenation of the action's transition graph action number, the transition graph number, the action's expected result, and the UUID of the controller instance that scheduled it. * - .. _lrm_rsc_op_transition_magic: .. index:: pair: lrm_rsc_op; transition-magic transition-magic - :ref:`text ` - A concatenation of ``op-status``, ``rc-code``, and ``transition-key``. * - .. _lrm_rsc_op_exit_reason: .. index:: pair: lrm_rsc_op; exit-reason exit-reason - :ref:`text ` - An error message (if available) from the resource agent or Pacemaker if the action did not return success. * - .. _lrm_rsc_op_on_node: .. index:: pair: lrm_rsc_op; on_node on_node - :ref:`text ` - The name of the node that executed the action (identical to the ``uname`` of the enclosing ``node_state`` element) * - .. _lrm_rsc_op_call_id: .. index:: pair: lrm_rsc_op; call-id call-id - :ref:`integer ` - A node-specific counter used to determine the order in which actions were executed. * - .. _lrm_rsc_op_rc_code: .. index:: pair: lrm_rsc_op; rc-code rc-code - :ref:`integer ` - The resource agent's exit status for this action. Refer to the *Resource Agents* chapter of *Pacemaker Administration* for how these values are interpreted. * - .. _lrm_rsc_op_op_status: .. index:: pair: lrm_rsc_op; op-status op-status - :ref:`integer ` - The execution status of this action. The meanings of these codes are internal to Pacemaker. * - .. _lrm_rsc_op_interval: .. index:: pair: lrm_rsc_op; interval interval - :ref:`nonnegative integer ` - If the action is recurring, its frequency (in milliseconds), otherwise 0. * - .. _lrm_rsc_op_last_rc_change: .. index:: pair: lrm_rsc_op; last-rc-change last-rc-change - :ref:`epoch time ` - Node-local time at which the action first returned the current value of ``rc-code``. * - .. _lrm_rsc_op_exec_time: .. index:: pair: lrm_rsc_op; exec-time exec-time - :ref:`integer ` - Time (in seconds) that action execution took (if known) * - .. _lrm_rsc_op_queue_time: .. index:: pair: lrm_rsc_op; queue-time queue-time - :ref:`integer ` - Time (in seconds) that action was queued in the local executor (if known) * - .. _lrm_rsc_op_op_digest: .. index:: pair: lrm_rsc_op; op-digest op-digest - :ref:`text ` - If present, this is a hash of the parameters passed to the action. If a hash of the currently configured parameters does not match this, that means the resource configuration changed since the action was performed, and the resource must be reloaded or restarted. * - .. _lrm_rsc_op_op_restart_digest: .. index:: pair: lrm_rsc_op; op-restart-digest op-restart-digest - :ref:`text ` - If present, the resource agent supports reloadable parameters, and this is a hash of the non-reloadable parameters passed to the action. This allows the cluster to choose between reload and restart when one is needed. * - .. _lrm_rsc_op_op_secure_digest: .. index:: pair: lrm_rsc_op; op-secure-digest op-secure-digest - :ref:`text ` - If present, the resource agent marks some parameters as sensitive, and this is a hash of the non-sensitive parameters passed to the action. This allows the value of sensitive parameters to be removed from a saved copy of the CIB while still allowing scheduler simulations to be performed on that copy. Simple Operation History Example ________________________________ - + .. topic:: A monitor operation (determines current state of the ``apcstonith`` resource) .. code-block:: xml The above example shows the history entry for a probe (non-recurring monitor operation) for the ``apcstonith`` resource. The cluster schedules probes for every configured resource on a node when the node first starts, in order to determine the resource's current state before it takes any further action. - + From the ``transition-key``, we can see that this was the 22nd action of the 2nd graph produced by this instance of the controller (2668bbeb-06d5-40f9-936d-24cb7f87006a). The third field of the ``transition-key`` contains a 7, which indicates that the cluster expects to find the resource inactive. By looking at the ``rc-code`` property, we see that this was the case. As that is the only action recorded for this node, we can conclude that the cluster started the resource elsewhere. - + Complex Operation History Example _________________________________ - + .. topic:: Resource history of a ``pingd`` clone with multiple entries .. code-block:: xml - + When more than one history entry exists, it is important to first sort them by ``call-id`` before interpreting them. Once sorted, the above example can be summarized as: #. A non-recurring monitor operation returning 7 (not running), with a ``call-id`` of 3 #. A stop operation returning 0 (success), with a ``call-id`` of 32 #. A start operation returning 0 (success), with a ``call-id`` of 33 #. A recurring monitor returning 0 (success), with a ``call-id`` of 34 The cluster processes each history entry to build up a picture of the resource's state. After the first and second entries, it is considered stopped, and after the third it considered active. Based on the last operation, we can tell that the resource is currently active. Additionally, from the presence of a ``stop`` operation with a lower ``call-id`` than that of the ``start`` operation, we can conclude that the resource has been restarted. Specifically this occurred as part of actions 11 and 31 of transition 11 from the controller instance with the key ``2668bbeb...``. This information can be helpful for locating the relevant section of the logs when looking for the source of a failure.