diff --git a/doc/sphinx/Clusters_from_Scratch/active-active.rst b/doc/sphinx/Clusters_from_Scratch/active-active.rst index 031ace2465..96318fedee 100644 --- a/doc/sphinx/Clusters_from_Scratch/active-active.rst +++ b/doc/sphinx/Clusters_from_Scratch/active-active.rst @@ -1,284 +1,294 @@ +.. 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 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 the GFS2 command-line utilities and the Distributed Lock Manager (DLM) required by cluster filesystems: .. code-block:: none # yum install -y gfs2-utils dlm 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 script), and clone it: .. code-block:: none [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 -f dlm_cfg resource show ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-1 Clone Set: dlm-clone [dlm] Stopped: [ pcmk-1 pcmk-2 ] Activate our new configuration, and see how the cluster responds: .. code-block:: none [root@pcmk-1 ~]# pcs cluster cib-push dlm_cfg --config CIB updated [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-1 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Tue Sep 11 10:18:30 2018 Last change: Tue Sep 11 10:16:49 2018 by hacluster via crmd on pcmk-2 2 nodes configured 8 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ipmi-fencing (stonith:fence_ipmilan): Started pcmk-1 ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-1 Clone Set: dlm-clone [dlm] Started: [ pcmk-1 pcmk-2 ] Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled + Create and Populate GFS2 Filesystem ################################### -.. index:: - single: GFS2_prep - 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, Apache) using WebFS are not only stopped, but stopped in the correct order. .. code-block:: none [root@pcmk-1 ~]# pcs resource disable WebFS [root@pcmk-1 ~]# pcs resource ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Stopped Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] WebFS (ocf::heartbeat:Filesystem): Stopped (disabled) Clone Set: dlm-clone [dlm] Started: [ pcmk-1 pcmk-2 ] You can see that both Apache and WebFS have been stopped, and that **pcmk-1** is the current master 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:: none /dev/drbd1: Read-only file system .. code-block:: none [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 (131056 blocks) Journals: 2 Resource groups: 3 Locking protocol: "lock_dlm" Lock table: "mycluster:web" UUID: 0bcbffab-cada-4105-94d1-be8a26669ee0 The ``mkfs.gfs2`` command required a number of additional parameters: * ``-p lock_dlm`` specifies that we want to use the kernel's DLM. * ``-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 pcmk-1 | 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:: none [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:: none [root@pcmk-1 ~]# pcs resource show 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=20 timeout=40 (WebFS-monitor-interval-20) notify interval=0s timeout=60 (WebFS-notify-interval-0s) start interval=0s timeout=60 (WebFS-start-interval-0s) stop interval=0s timeout=60 (WebFS-stop-interval-0s) The fstype option needs to be updated to **gfs2** instead of **xfs**. .. code-block:: none [root@pcmk-1 ~]# pcs resource update WebFS fstype=gfs2 [root@pcmk-1 ~]# pcs resource show 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=20 timeout=40 (WebFS-monitor-interval-20) notify interval=0s timeout=60 (WebFS-notify-interval-0s) start interval=0s timeout=60 (WebFS-start-interval-0s) stop interval=0s timeout=60 (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:: none [root@pcmk-1 ~]# pcs constraint colocation add WebFS with dlm-clone INFINITY [root@pcmk-1 ~]# pcs constraint order dlm-clone then WebFS Adding dlm-clone WebFS (kind: Mandatory) (Options: first-action=start then-action=start) + +.. 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:: none [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: Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebDataClone 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 WebDataClone (score:INFINITY) (with-rsc-role:Master) 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 (aka. master). .. code-block:: none [root@pcmk-1 ~]# pcs -f active_cfg resource update WebDataClone master-max=2 Finally, load our configuration to the cluster, and re-enable the WebFS resource (which we disabled earlier). .. code-block:: none [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:: none [root@pcmk-1 ~]# pcs resource Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 pcmk-2 ] Clone Set: dlm-clone [dlm] Started: [ pcmk-1 pcmk-2 ] ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 Clone Set: WebFS-clone [WebFS] Started: [ pcmk-1 pcmk-2 ] WebSite (ocf::heartbeat:apache): Started pcmk-1 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/active-passive.rst b/doc/sphinx/Clusters_from_Scratch/active-passive.rst index f8c85bc5a1..f68f881240 100644 --- a/doc/sphinx/Clusters_from_Scratch/active-passive.rst +++ b/doc/sphinx/Clusters_from_Scratch/active-passive.rst @@ -1,270 +1,276 @@ Create an Active/Passive Cluster -------------------------------- +.. index:: + pair: resource; IP address + Add a Resource ############## Our first resource will be a unique IP address that the cluster can bring up on either node. Regardless of where any cluster service(s) are running, end users need a consistent address to contact them on. Here, I will choose 192.168.122.120 as the floating address, give it the imaginative name ClusterIP and tell the cluster to check whether it is running every 30 seconds. .. WARNING:: The chosen address must not already be in use on the network. Do not reuse an IP address one of the nodes already has configured. .. code-block:: none [root@pcmk-1 ~]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \ ip=192.168.122.120 cidr_netmask=24 op monitor interval=30s Another important piece of information here is **ocf:heartbeat:IPaddr2**. This tells Pacemaker three things about the resource you want to add: * The first field (**ocf** in this case) is the standard to which the resource script conforms and where to find it. * The second field (**heartbeat** in this case) is standard-specific; for OCF resources, it tells the cluster which OCF namespace the resource script is in. * The third field (**IPaddr2** in this case) is the name of the resource script. To obtain a list of the available resource standards (the **ocf** part of **ocf:heartbeat:IPaddr2**), run: .. code-block:: none [root@pcmk-1 ~]# pcs resource standards lsb ocf service systemd To obtain a list of the available OCF resource providers (the **heartbeat** part of **ocf:heartbeat:IPaddr2**), run: .. code-block:: none [root@pcmk-1 ~]# pcs resource providers heartbeat openstack pacemaker Finally, if you want to see all the resource agents available for a specific OCF provider (the **IPaddr2** part of **ocf:heartbeat:IPaddr2**), run: .. code-block:: none [root@pcmk-1 ~]# pcs resource agents ocf:heartbeat apache aws-vpc-move-ip awseip awsvip azure-lb clvm . . (skipping lots of resources to save space) . symlink tomcat VirtualDomain Xinetd Now, verify that the IP resource has been added, and display the cluster's status to see that it is now active: .. code-block:: none [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 16:55:26 2018 Last change: Mon Sep 10 16:53:42 2018 by root via cibadmin on pcmk-1 2 nodes configured 1 resource configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Perform a Failover ################## Since our ultimate goal is high availability, we should test failover of our new resource before moving on. First, find the node on which the IP address is running. .. code-block:: none [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 16:55:26 2018 Last change: Mon Sep 10 16:53:42 2018 by root via cibadmin on pcmk-1 2 nodes configured 1 resource configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 You can see that the status of the **ClusterIP** resource is **Started** on a particular node (in this example, **pcmk-1**). Shut down Pacemaker and Corosync on that machine to trigger a failover. .. code-block:: none [root@pcmk-1 ~]# pcs cluster stop pcmk-1 Stopping Cluster (pacemaker)... Stopping Cluster (corosync)... .. NOTE:: A cluster command such as ``pcs cluster stop `` can be run from any node in the cluster, not just the affected node. Verify that pacemaker and corosync are no longer running: .. code-block:: none [root@pcmk-1 ~]# pcs status Error: cluster is not currently running on this node Go to the other node, and check the cluster status. .. code-block:: none [root@pcmk-2 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 16:57:22 2018 Last change: Mon Sep 10 16:53:42 2018 by root via cibadmin on pcmk-1 2 nodes configured 1 resource configured Online: [ pcmk-2 ] OFFLINE: [ pcmk-1 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Notice that **pcmk-1** is **OFFLINE** for cluster purposes (its **pcsd** is still active, allowing it to receive ``pcs`` commands, but it is not participating in the cluster). Also notice that **ClusterIP** is now running on **pcmk-2** -- failover happened automatically, and no errors are reported. .. topic:: Quorum If a cluster splits into two (or more) groups of nodes that can no longer communicate with each other (aka. _partitions_), _quorum_ is used to prevent resources from starting on more nodes than desired, which would risk data corruption. A cluster has quorum when more than half of all known nodes are online in the same partition, or for the mathematically inclined, whenever the following equation is true: .. code-block:: none total_nodes < 2 * active_nodes For example, if a 5-node cluster split into 3- and 2-node paritions, the 3-node partition would have quorum and could continue serving resources. If a 6-node cluster split into two 3-node partitions, neither partition would have quorum; pacemaker's default behavior in such cases is to stop all resources, in order to prevent data corruption. Two-node clusters are a special case. By the above definition, a two-node cluster would only have quorum when both nodes are running. This would make the creation of a two-node cluster pointless, but corosync has the ability to treat two-node clusters as if only one node is required for quorum. The ``pcs cluster setup`` command will automatically configure **two_node: 1** in ``corosync.conf``, so a two-node cluster will "just work". If you are using a different cluster shell, you will have to configure ``corosync.conf`` appropriately yourself. Now, simulate node recovery by restarting the cluster stack on **pcmk-1**, and check the cluster's status. (It may take a little while before the cluster gets going on the node, but it eventually will look like the below.) .. code-block:: none [root@pcmk-1 ~]# pcs cluster start pcmk-1 pcmk-1: Starting Cluster... [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:00:04 2018 Last change: Mon Sep 10 16:53:42 2018 by root via cibadmin on pcmk-1 2 nodes configured 1 resource configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled + +.. index:: stickiness + Prevent Resources from Moving after Recovery ############################################ In most circumstances, it is highly desirable to prevent healthy resources from being moved around the cluster. Moving resources almost always requires a period of downtime. For complex services such as databases, this period can be quite long. To address this, Pacemaker has the concept of resource *stickiness*, which controls how strongly a service prefers to stay running where it is. You may like to think of it as the "cost" of any downtime. By default, Pacemaker assumes there is zero cost associated with moving resources and will do so to achieve "optimal" [#]_ resource placement. We can specify a different stickiness for every resource, but it is often sufficient to change the default. .. code-block:: none [root@pcmk-1 ~]# pcs resource defaults resource-stickiness=100 Warning: Defaults do not apply to resources which override them with their own defined values [root@pcmk-1 ~]# pcs resource defaults resource-stickiness: 100 .. [#] Pacemaker's definition of optimal may not always agree with that of a human's. The order in which Pacemaker processes lists of resources and nodes creates implicit preferences in situations where the administrator has not explicitly specified them. diff --git a/doc/sphinx/Clusters_from_Scratch/apache.rst b/doc/sphinx/Clusters_from_Scratch/apache.rst index 188a9f3ee0..0a6d696fcf 100644 --- a/doc/sphinx/Clusters_from_Scratch/apache.rst +++ b/doc/sphinx/Clusters_from_Scratch/apache.rst @@ -1,430 +1,450 @@ -Add Apache HTTP Server as a Cluster Service -------------------------------------------- - .. index:: single: Apache HTTP Server +Add Apache HTTP Server as a Cluster Service +------------------------------------------- + Now that we have a basic but functional active/passive two-node cluster, we're ready to add some real services. We're going to start with Apache HTTP Server because it is a feature of many clusters and relatively simple to configure. Install Apache ############## Before continuing, we need to make sure Apache is installed on both hosts. We also need the wget tool in order for the cluster to be able to check the status of the Apache server. .. code-block:: none # yum install -y httpd wget # firewall-cmd --permanent --add-service=http # firewall-cmd --reload .. IMPORTANT:: Do **not** enable the httpd service. Services that are intended to be managed via the cluster software should never be managed by the OS. It is often useful, however, to manually start the service, verify that it works, then stop it again, before adding it to the cluster. This allows you to resolve any non-cluster-related problems before continuing. Since this is a simple example, we'll skip that step here. Create Website Documents ######################## We need to create a page for Apache to serve. On |CFS_DISTRO| |CFS_DISTRO_VER|, the default Apache document root is /var/www/html, so we'll create an index file there. For the moment, we will simplify things by serving a static site and manually synchronizing the data between the two nodes, so run this command on both nodes: .. code-block:: none # cat <<-END >/var/www/html/index.html My Test Site - $(hostname) END -Enable the Apache status URL -############################ .. index:: - pair: Apache HTTP Server; /server-status + single: Apache HTTP Server; status URL + +Enable the Apache status URL +############################ In order to monitor the health of your Apache instance, and recover it if it fails, the resource agent used by Pacemaker assumes the server-status URL is available. On both nodes, enable the URL with: .. code-block:: none # cat <<-END >/etc/httpd/conf.d/status.conf SetHandler server-status Require local END .. NOTE:: If you are using a different operating system, server-status may already be enabled or may be configurable in a different location. If you are using a version of Apache HTTP Server less than 2.4, the syntax will be different. -Configure the Cluster -##################### .. index:: - pair: Apache HTTP Server; Apache resource configuration + pair: Apache HTTP Server; resource + +Configure the Cluster +##################### At this point, Apache is ready to go, and all that needs to be done is to add it to the cluster. Let's call the resource WebSite. We need to use an OCF resource script called apache in the heartbeat namespace [#]_. The script's only required parameter is the path to the main Apache configuration file, and we'll tell the cluster to check once a minute that Apache is still running. .. code-block:: none [root@pcmk-1 ~]# pcs resource create WebSite ocf:heartbeat:apache \ configfile=/etc/httpd/conf/httpd.conf \ statusurl="http://localhost/server-status" \ op monitor interval=1min By default, the operation timeout for all resources' start, stop, and monitor operations is 20 seconds. In many cases, this timeout period is less than a particular resource's advised timeout period. For the purposes of this tutorial, we will adjust the global operation timeout default to 240 seconds. .. code-block:: none [root@pcmk-1 ~]# pcs resource op defaults timeout=240s Warning: Defaults do not apply to resources which override them with their own defined values [root@pcmk-1 ~]# pcs resource op defaults timeout: 240s .. NOTE:: In a production cluster, it is usually better to adjust each resource's start, stop, and monitor timeouts to values that are appropriate to the behavior observed in your environment, rather than adjust the global default. After a short delay, we should see the cluster start Apache. .. code-block:: none [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:06:22 2018 Last change: Mon Sep 10 17:05:41 2018 by root via cibadmin on pcmk-1 2 nodes configured 2 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Wait a moment, the WebSite resource isn't running on the same host as our IP address! .. NOTE:: If, in the ``pcs status`` output, you see the WebSite resource has failed to start, then you've likely not enabled the status URL correctly. You can check whether this is the problem by running: .. code-block:: none wget -O - http://localhost/server-status If you see **Not Found** or **Forbidden** in the output, then this is likely the problem. Ensure that the **** block is correct. +.. index:: + single: constraint; colocation + single: colocation constraint + Ensure Resources Run on the Same Host ##################################### To reduce the load on any one machine, Pacemaker will generally try to spread the configured resources across the cluster nodes. However, we can tell the cluster that two resources are related and need to run on the same host (or not at all). Here, we instruct the cluster that WebSite can only run on the host that ClusterIP is active on. To achieve this, we use a *colocation constraint* that indicates it is mandatory for WebSite to run on the same node as ClusterIP. The "mandatory" part of the colocation constraint is indicated by using a score of INFINITY. The INFINITY score also means that if ClusterIP is not active anywhere, WebSite will not be permitted to run. .. NOTE:: If ClusterIP is not active anywhere, WebSite will not be permitted to run anywhere. .. IMPORTANT:: Colocation constraints are "directional", in that they imply certain things about the order in which the two resources will have a location chosen. In this case, we're saying that **WebSite** needs to be placed on the same machine as **ClusterIP**, which implies that the cluster must know the location of **ClusterIP** before choosing a location for **WebSite**. .. code-block:: none [root@pcmk-1 ~]# pcs constraint colocation add WebSite with ClusterIP INFINITY [root@pcmk-1 ~]# pcs constraint Location Constraints: Ordering Constraints: Colocation Constraints: WebSite with ClusterIP (score:INFINITY) Ticket Constraints: [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:08:54 2018 Last change: Mon Sep 10 17:08:27 2018 by root via cibadmin on pcmk-1 2 nodes configured 2 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled + +.. index:: + single: constraint; ordering + single: ordering constraint + Ensure Resources Start and Stop in Order ######################################## Like many services, Apache can be configured to bind to specific IP addresses on a host or to the wildcard IP address. If Apache binds to the wildcard, it doesn't matter whether an IP address is added before or after Apache starts; Apache will respond on that IP just the same. However, if Apache binds only to certain IP address(es), the order matters: If the address is added after Apache starts, Apache won't respond on that address. To be sure our WebSite responds regardless of Apache's address configuration, we need to make sure ClusterIP not only runs on the same node, but starts before WebSite. A colocation constraint only ensures the resources run together, not the order in which they are started and stopped. We do this by adding an ordering constraint. By default, all order constraints are mandatory, which means that the recovery of ClusterIP will also trigger the recovery of WebSite. .. code-block:: none [root@pcmk-1 ~]# pcs constraint order ClusterIP then WebSite Adding ClusterIP WebSite (kind: Mandatory) (Options: first-action=start then-action=start) [root@pcmk-1 ~]# pcs constraint Location Constraints: Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) Ticket Constraints: + +.. index:: + single: constraint; location + single: location constraint + Prefer One Node Over Another ############################ Pacemaker does not rely on any sort of hardware symmetry between nodes, so it may well be that one machine is more powerful than the other. In such cases, you may want to host the resources on the more powerful node when it is available, to have the best performance -- or you may want to host the resources on the _less_ powerful node when it's available, so you don't have to worry about whether you can handle the load after a failover. To do this, we create a location constraint. In the location constraint below, we are saying the WebSite resource prefers the node pcmk-1 with a score of 50. Here, the score indicates how strongly we'd like the resource to run at this location. .. code-block:: none [root@pcmk-1 ~]# pcs constraint location WebSite prefers pcmk-1=50 [root@pcmk-1 ~]# pcs constraint Location Constraints: Resource: WebSite Enabled on: pcmk-1 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) Ticket Constraints: [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:21:41 2018 Last change: Mon Sep 10 17:21:14 2018 by root via cibadmin on pcmk-1 2 nodes configured 2 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Wait a minute, the resources are still on pcmk-2! Even though WebSite now prefers to run on pcmk-1, that preference is (intentionally) less than the resource stickiness (how much we preferred not to have unnecessary downtime). To see the current placement scores, you can use a tool called crm_simulate. .. code-block:: none [root@pcmk-1 ~]# crm_simulate -sL Current cluster status: Online: [ pcmk-1 pcmk-2 ] ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-2 Allocation scores: native_color: ClusterIP allocation score on pcmk-1: 50 native_color: ClusterIP allocation score on pcmk-2: 200 native_color: WebSite allocation score on pcmk-1: -INFINITY native_color: WebSite allocation score on pcmk-2: 100 Transition Summary: + +.. index:: + single: resource; moving manually + Move Resources Manually ####################### There are always times when an administrator needs to override the cluster and force resources to move to a specific location. In this example, we will force the WebSite to move to pcmk-1. We will use the **pcs resource move** command to create a temporary constraint with a score of INFINITY. While we could update our existing constraint, using **move** allows to easily get rid of the temporary constraint later. If desired, we could even give a lifetime for the constraint, so it would expire automatically -- but we don't do that in this example. .. code-block:: none [root@pcmk-1 ~]# pcs resource move WebSite pcmk-1 [root@pcmk-1 ~]# pcs constraint Location Constraints: Resource: WebSite Enabled on: pcmk-1 (score:50) Enabled on: pcmk-1 (score:INFINITY) (role: Started) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) Ticket Constraints: [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:28:55 2018 Last change: Mon Sep 10 17:28:27 2018 by root via crm_resource on pcmk-1 2 nodes configured 2 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Once we've finished whatever activity required us to move the resources to pcmk-1 (in our case nothing), we can then allow the cluster to resume normal operation by removing the new constraint. Due to our first location constraint and our default stickiness, the resources will remain on pcmk-1. We will use the **pcs resource clear** command, which removes all temporary constraints previously created by **pcs resource move** or **pcs resource ban**. .. code-block:: none [root@pcmk-1 ~]# pcs resource clear WebSite [root@pcmk-1 ~]# pcs constraint Location Constraints: Resource: WebSite Enabled on: pcmk-1 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) Ticket Constraints: Note that the INFINITY location constraint is now gone. If we check the cluster status, we can also see that (as expected) the resources are still active on pcmk-1. .. code-block:: none [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:31:47 2018 Last change: Mon Sep 10 17:31:04 2018 by root via crm_resource on pcmk-1 2 nodes configured 2 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled To remove the constraint with the score of 50, we would first get the constraint's ID using **pcs constraint --full**, then remove it with **pcs constraint remove** and the ID. We won't show those steps here, but feel free to try it on your own, with the help of the pcs man page if necessary. .. [#] Compare the key used here, **ocf:heartbeat:apache**, with the one we used earlier for the IP address, **ocf:heartbeat:IPaddr2** diff --git a/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst b/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst index da68ba2fa7..abb632c985 100644 --- a/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst +++ b/doc/sphinx/Clusters_from_Scratch/cluster-setup.rst @@ -1,331 +1,334 @@ 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 CentOS, 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 install pacemaker, pcs, and some other command-line tools that will make our lives easier: .. code-block:: none # yum install -y pacemaker pcs psmisc policycoreutils-python .. 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. .. 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:: none # 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:: none [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. Start and enable the daemon by issuing the following commands on each node: .. code-block:: none # 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 a **hacluster** 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 **hacluster** user, using the same password on both nodes: .. code-block:: none # 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:: none [root@pcmk-1 ~]# ssh pcmk-2 -- 'echo mysupersecretpassword | passwd --stdin hacluster' Configure Corosync __________________ On either node, use ``pcs cluster auth`` to authenticate as the **hacluster** user: .. code-block:: none [root@pcmk-1 ~]# pcs cluster auth pcmk-1 pcmk-2 Username: hacluster Password: pcmk-2: Authorized pcmk-1: Authorized .. NOTE:: In Fedora 29 and CentOS 8.0, the command has been changed to ``pcs host auth``: .. code-block:: none [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:: none [root@pcmk-1 ~]# pcs cluster setup --name mycluster pcmk-1 pcmk-2 Destroying cluster on nodes: pcmk-1, pcmk-2... pcmk-2: Stopping Cluster (pacemaker)... pcmk-1: Stopping Cluster (pacemaker)... pcmk-1: Successfully destroyed cluster pcmk-2: Successfully destroyed cluster Sending 'pacemaker_remote authkey' to 'pcmk-1', 'pcmk-2' pcmk-2: successful distribution of the file 'pacemaker_remote authkey' pcmk-1: successful distribution of the file 'pacemaker_remote authkey' Sending cluster config files to the nodes... pcmk-1: Succeeded pcmk-2: Succeeded Synchronizing pcsd certificates on nodes pcmk-1, pcmk-2... pcmk-2: Success pcmk-1: Success Restarting pcsd on the nodes in order to reload the certificates... pcmk-2: Success pcmk-1: Success .. NOTE :: In Fedora 29 and CentOS 8.0, the syntax has been changed and the ``--name`` option has been dropped: .. code-block:: none [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-1: Successfully destroyed cluster pcmk-2: 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-2: successful distribution of the file 'corosync authkey' pcmk-2: successful distribution of the file 'pacemaker authkey' pcmk-1: successful distribution of the file 'corosync authkey' pcmk-1: successful distribution of the file 'pacemaker authkey' Synchronizing pcsd SSL certificates on nodes 'pcmk-1', 'pcmk-2'... pcmk-1: Success pcmk-2: Success Sending 'corosync.conf' to 'pcmk-1', 'pcmk-2' pcmk-2: successful distribution of the file 'corosync.conf' pcmk-1: successful distribution of the file 'corosync.conf' Cluster has been successfully set up. 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. .. NOTE:: If you are not using ``pcs`` for cluster administration, follow whatever procedures are appropriate for your tools to create a corosync.conf and copy it to all nodes. The ``pcs`` command will configure corosync to use UDP unicast transport; if you choose to use multicast instead, choose a multicast address carefully [#]_. 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:: none [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. --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. node Manage cluster nodes. alert Manage pacemaker alerts. 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:: none [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 [ | --full | --groups | --hide-inactive] Show all currently configured resources or if a resource is specified show the options for the configured resource. If --full is specified, all configured resource options will be displayed. If --groups is specified, only show groups (and their resources). If --hide-inactive is specified, only show active resources. groups View currently configured groups and their resources. 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. 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:: none [root@pcmk-1 ~]# pacemakerd --features Pacemaker 1.1.18-11.el7_5.3 (Build: 2b07d5c5a9) Supporting v3.0.14: generated-manpages agent-manpages ncurses libqb-logging libqb-ipc systemd nagios corosync-native atomic-attrd acls .. [#] For some subtle issues, see `Topics in High-Performance Messaging: Multicast Address Assignment `_ or the more detailed treatment in `Cisco's Guidelines for Enterprise IP Multicast Address Allocation `_. diff --git a/doc/sphinx/Clusters_from_Scratch/fencing.rst b/doc/sphinx/Clusters_from_Scratch/fencing.rst index bc2c399371..25975e0eab 100644 --- a/doc/sphinx/Clusters_from_Scratch/fencing.rst +++ b/doc/sphinx/Clusters_from_Scratch/fencing.rst @@ -1,218 +1,224 @@ +.. index:: fencing + Configure Fencing ----------------- What is Fencing? ################ Fencing protects your data from being corrupted, and your application from becoming unavailable, due to unintended concurrent access by rogue nodes. Just because a node is unresponsive doesn't mean it has stopped accessing your data. The only way to be 100% sure that your data is safe, is to use fencing to ensure that the node is truly offline before allowing the data to be accessed from another node. Fencing also has a role to play in the event that a clustered service cannot be stopped. In this case, the cluster uses fencing to force the whole node offline, thereby making it safe to start the service elsewhere. Fencing is also known as STONITH, an acronym for "Shoot The Other Node In The Head", since the most popular form of fencing is cutting a host's power. In order to guarantee the safety of your data [#]_, fencing is enabled by default. .. NOTE:: It is possible to tell the cluster not to use fencing, by setting the **stonith-enabled** cluster option to false: .. code-block:: none [root@pcmk-1 ~]# pcs property set stonith-enabled=false [root@pcmk-1 ~]# crm_verify -L However, this is completely inappropriate for a production cluster. It tells the cluster to simply pretend that failed nodes are safely powered off. Some vendors will refuse to support clusters that have fencing disabled. Even disabling it for a test cluster means you won't be able to test real failure scenarios. + +.. index:: + single: fencing; device + Choose a Fence Device ##################### The two broad categories of fence device are power fencing, which cuts off power to the target, and fabric fencing, which cuts off the target's access to some critical resource, such as a shared disk or access to the local network. Power fencing devices include: * Intelligent power switches * IPMI * Hardware watchdog device (alone, or in combination with shared storage used as a "poison pill" mechanism) Fabric fencing devices include: * Shared storage that can be cut off for a target host by another host (for example, an external storage device that supports SCSI-3 persistent reservations) * Intelligent network switches Using IPMI as a power fencing device may seem like a good choice. However, if the IPMI shares power and/or network access with the host (such as most onboard IPMI controllers), a power or network failure will cause both the host and its fencing device to fail. The cluster will be unable to recover, and must stop all resources to avoid a possible split-brain situation. Likewise, any device that relies on the machine being active (such as SSH-based "devices" sometimes used during testing) is inappropriate, because fencing will be required when the node is completely unresponsive. Configure the Cluster for Fencing ################################# #. Install the fence agent(s). To see what packages are available, run ``yum search fence-``. Be sure to install the package(s) on all cluster nodes. #. Configure the fence device itself to be able to fence your nodes and accept fencing requests. This includes any necessary configuration on the device and on the nodes, and any firewall or SELinux changes needed. Test the communication between the device and your nodes. #. Find the name of the correct fence agent: ``pcs stonith list`` #. Find the parameters associated with the device: ``pcs stonith describe `` #. Create a local copy of the CIB: ``pcs cluster cib stonith_cfg`` #. Create the fencing resource: ``pcs -f stonith_cfg stonith create [STONITH_DEVICE_OPTIONS]`` Any flags that do not take arguments, such as ``--ssl``, should be passed as ``ssl=1``. #. Enable fencing in the cluster: ``pcs -f stonith_cfg property set stonith-enabled=true`` #. If the device does not know how to fence nodes based on their cluster node name, you may also need to set the special **pcmk_host_map** parameter. See ``man pacemaker-fenced`` 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 ``man pacemaker-fenced`` for details. #. If the device does not expect the victim to be specified with the **port** parameter, you may also need to set the special **pcmk_host_argument** parameter. See ``man pacemaker-fenced`` for details. #. Commit the new configuration: ``pcs cluster cib-push stonith_cfg`` #. Once the fence device resource is running, test it (you might want to stop the cluster on that machine first): ``stonith_admin --reboot `` Example ####### For this example, assume we have a chassis containing four nodes and a separately powered IPMI device active on 10.0.0.1. Following the steps above would go something like this: Step 1: Install the **fence-agents-ipmilan** package on both nodes. Step 2: Configure the IP address, authentication credentials, etc. in the IPMI device itself. Step 3: Choose the **fence_ipmilan** STONITH agent. Step 4: Obtain the agent's possible parameters: .. code-block:: none [root@pcmk-1 ~]# pcs stonith describe fence_ipmilan fence_ipmilan - Fence agent for IPMI 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. Stonith options: ipport: TCP/UDP port to use for connection with device hexadecimal_kg: Hexadecimal-encoded Kg key for IPMIv2 authentication port: IP address or hostname of fencing device (together with --port-as-ip) inet6_only: Forces agent to use IPv6 addresses only ipaddr: IP Address or Hostname passwd_script: Script to retrieve password method: Method to fence (onoff|cycle) inet4_only: Forces agent to use IPv4 addresses only passwd: Login password or passphrase lanplus: Use Lanplus to improve security of connection auth: IPMI Lan Auth type. cipher: Ciphersuite to use (same as ipmitool -C parameter) target: Bridge IPMI requests to the remote target address privlvl: Privilege level on IPMI device timeout: Timeout (sec) for IPMI operation login: Login Name verbose: Verbose mode debug: Write debug information to given file power_wait: Wait X seconds after issuing ON/OFF login_timeout: Wait X seconds for cmd prompt after login delay: Wait X seconds before fencing is started power_timeout: Test X seconds for status change after ON/OFF ipmitool_path: Path to ipmitool binary shell_timeout: Wait X seconds for cmd prompt after issuing command port_as_ip: Make "port/plug" to be an alias to IP address retry_on: Count of attempts to retry power on sudo: Use sudo (without password) when calling 3rd party sotfware. priority: The priority of the stonith resource. Devices are tried in order of highest priority to lowest. pcmk_host_map: A mapping of host names to ports numbers for devices that do not support host names. Eg. node1:1;node2:2,3 would tell the cluster to use port 1 for node1 and ports 2 and 3 for node2 pcmk_host_list: A list of machines controlled by this device (Optional unless pcmk_host_check=static-list). pcmk_host_check: How to determine which machines are controlled by the device. Allowed values: dynamic-list (query the device), static-list (check the pcmk_host_list attribute), none (assume every device can fence every machine) pcmk_delay_max: Enable a random delay for stonith actions and specify the maximum of random delay. This prevents double fencing when using slow devices such as sbd. Use this to enable a random delay for stonith actions. The overall delay is derived from this random delay value adding a static delay so that the sum is kept below the maximum delay. pcmk_delay_base: Enable a base delay for stonith actions and specify base delay value. This prevents double fencing when different delays are configured on the nodes. Use this to enable a static delay for stonith actions. The overall delay is derived from a random delay value adding this static delay so that the sum is kept below the maximum delay. pcmk_action_limit: The maximum number of actions can be performed in parallel on this device Pengine property concurrent-fencing=true needs to be configured first. Then use this to specify the maximum number of actions can be performed in parallel on this device. -1 is unlimited. Default operations: monitor: interval=60s Step 5: ``pcs cluster cib stonith_cfg`` Step 6: Here are example parameters for creating our fence device resource: .. code-block:: none [root@pcmk-1 ~]# pcs -f stonith_cfg stonith create ipmi-fencing fence_ipmilan \ pcmk_host_list="pcmk-1 pcmk-2" ipaddr=10.0.0.1 login=testuser \ passwd=acd123 op monitor interval=60s [root@pcmk-1 ~]# pcs -f stonith_cfg stonith ipmi-fencing (stonith:fence_ipmilan): Stopped Steps 7-10: Enable fencing in the cluster: .. code-block:: none [root@pcmk-1 ~]# pcs -f stonith_cfg property set stonith-enabled=true [root@pcmk-1 ~]# pcs -f stonith_cfg property Cluster Properties: cluster-infrastructure: corosync cluster-name: mycluster dc-version: 1.1.18-11.el7_5.3-2b07d5c5a9 have-watchdog: false stonith-enabled: true Step 11: ``pcs cluster cib-push stonith_cfg --config`` Step 12: Test: .. code-block:: none [root@pcmk-1 ~]# pcs cluster stop pcmk-2 [root@pcmk-1 ~]# stonith_admin --reboot pcmk-2 After a successful test, login to any rebooted nodes, and start the cluster (with ``pcs cluster start``). .. [#] If the data is corrupt, there is little point in continuing to make it available. diff --git a/doc/sphinx/Clusters_from_Scratch/installation.rst b/doc/sphinx/Clusters_from_Scratch/installation.rst index 373f1e7fb0..249d58be38 100644 --- a/doc/sphinx/Clusters_from_Scratch/installation.rst +++ b/doc/sphinx/Clusters_from_Scratch/installation.rst @@ -1,414 +1,408 @@ Installation ------------ Install |CFS_DISTRO| |CFS_DISTRO_VER| ################################################################################################ Boot the Install Image ______________________ Download the 4GB |CFS_DISTRO| |CFS_DISTRO_VER| `DVD ISO `_. 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:: ../../shared/en-US/images/Welcome.png :scale: 80% :width: 1024 :height: 800 :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:: ../../shared/en-US/images/Installer.png :scale: 80% :width: 1024 :height: 800 :align: center :alt: Installation Summary Screen |CFS_DISTRO| |CFS_DISTRO_VER| Installation Summary Screen Ignore the **SOFTWARE SELECTION** section (try saying that 10 times quickly). The **Infrastructure Server** environment does have add-ons with much of the software we need, but we will leave it as a **Minimal Install** here, so that we can see exactly what software is required later. Configure Network _________________ In the **NETWORK & HOSTNAME** section: - Edit **Host Name:** as desired. For this example, we will use **pcmk-1.localdomain**. - Select your network device, press **Configure...**, and manually assign a fixed IP address. For this example, we'll use 192.168.122.101 under **IPv4 Settings** (with an appropriate netmask, gateway and DNS server). - Flip the switch to turn your network device on, and press **Done**. .. figure:: ../../shared/en-US/images/Editing-eth0.png :scale: 80% :width: 1024 :height: 800 :align: center :alt: Editing eth0 |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 ``/`` (aka. **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, ensure the hard drive you want to install to is selected, select **I will configure partitioning**, and press **Done**. In the **MANUAL PARTITIONING** screen that comes next, click the option to create mountpoints automatically. Select the ``/`` mountpoint, and reduce the desired capacity by 1GiB or so. Select **Modify...** by the volume group name, and 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:: ../../shared/en-US/images/Partitioning.png :scale: 80% :width: 1024 :height: 800 :align: center :alt: Manual Partitioning Screen |CFS_DISTRO| |CFS_DISTRO_VER| Manual Partitioning Screen Press **Done**, then **Accept changes**. 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. Finish Install ______________ Select **Begin Installation**. Once it completes, set a root password, and reboot as instructed. For the purposes of this document, it is not necessary to create any additional users. After the node reboots, you'll see a login prompt on the console. Login using **root** and the password you created earlier. .. figure:: ../../shared/en-US/images/Console.png :scale: 80% :width: 1024 :height: 768 :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:: none [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 valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:8e:eb:41 brd ff:ff:ff:ff:ff:ff inet 192.168.122.101/24 brd 192.168.122.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::e45:c99b:34c0:c657/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 **${device}** with the name of your network device: .. code-block:: none [root@pcmk-1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-${device} # manually edit as desired [root@pcmk-1 ~]# nmcli dev disconnect ${device} [root@pcmk-1 ~]# nmcli con reload ${device} [root@pcmk-1 ~]# nmcli con up ${device} This makes **NetworkManager** aware that a change was made on the config file. Next, ensure that the routes are as expected: .. code-block:: none [root@pcmk-1 ~]# ip route default via 192.168.122.1 dev eth0 proto static metric 100 192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.101 metric 100 If there is no line beginning with **default via**, then you may need to add a line such as -.. index :: - pair: source; Bash - ``GATEWAY="192.168.122.1"`` to the device configuration using the same process as described above for changing the IP address. Now, check for connectivity to the outside world. Start small by testing whether we can reach the gateway we configured. .. code-block:: none [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.254 ms --- 192.168.122.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.254/0.254/0.254/0.000 ms Now try something external; choose a location you know should be available. .. code-block:: none [root@pcmk-1 ~]# ping -c 1 www.clusterlabs.org PING oss-uk-1.clusterlabs.org (109.74.197.241) 56(84) bytes of data. 64 bytes from oss-uk-1.clusterlabs.org (109.74.197.241): icmp_seq=1 ttl=49 time=333 ms --- oss-uk-1.clusterlabs.org ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 333.204/333.204/333.204/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:: none beekhof@f16 ~ # 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_req=1 ttl=64 time=1.01 ms --- 192.168.122.101 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 1.012/1.012/1.012/0.000 ms Next, login as root via SSH. .. code-block:: none beekhof@f16 ~ # ssh -l 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 6e:b7:8f:e2:4c:94:43:54:a8:53:cc:20:0f:29:a4:e0. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.122.101' (ECDSA) to the list of known hosts. root@192.168.122.101's password: Last login: Tue Aug 11 13:14:39 2015 [root@pcmk-1 ~]# Apply Updates _____________ Apply any package updates released since your installation image was created: .. code-block:: none [root@pcmk-1 ~]# yum update + +.. 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: -.. index :: - pair: Nodes; short name - .. code-block:: none [root@pcmk-1 ~]# uname -n pcmk-1.localdomain -.. index :: - pair: Nodes; Domain name (Query) - We can use the `hostnamectl` tool to strip off the domain name: .. code-block:: none [root@pcmk-1 ~]# hostnamectl set-hostname $(uname -n | sed s/\\..*//) -.. index :: - pair: Nodes; Domain name (Remove from host name) - Now, check that the machine is using the correct name: .. code-block:: none [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:: none [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=0.343 ms 64 bytes from 192.168.122.102: icmp_seq=2 ttl=64 time=0.402 ms 64 bytes from 192.168.122.102: icmp_seq=3 ttl=64 time=0.558 ms --- 192.168.122.102 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 0.343/0.434/0.558/0.092 ms Now we need to make sure we can communicate with the machines by their name. If you have a DNS server, add additional entries for the two machines. Otherwise, you'll need to add the machines to ``/etc/hosts`` on both nodes. Below are the entries for my cluster nodes: .. code-block:: none [root@pcmk-1 ~]# grep pcmk /etc/hosts 192.168.122.101 pcmk-1.clusterlabs.org pcmk-1 192.168.122.102 pcmk-2.clusterlabs.org pcmk-2 We can now verify the setup by again using ping: .. code-block:: none [root@pcmk-1 ~]# ping -c 3 pcmk-2 PING pcmk-2.clusterlabs.org (192.168.122.101) 56(84) bytes of data. 64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=1 ttl=64 time=0.164 ms 64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=2 ttl=64 time=0.475 ms 64 bytes from pcmk-1.clusterlabs.org (192.168.122.101): icmp_seq=3 ttl=64 time=0.186 ms --- pcmk-2.clusterlabs.org ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.164/0.275/0.475/0.141 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. -.. index:: - single: SSH .. 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 + .Creating and Activating a new SSH Key .. code-block:: none [root@pcmk-1 ~]# ssh-keygen -t dsa -f ~/.ssh/id_dsa -N "" Generating public/private dsa key pair. Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: 91:09:5c:82:5a:6a:50:08:4e:b2:0c:62:de:cc:74:44 root@pcmk-1.clusterlabs.org The key's randomart image is: +--[ DSA 1024]----+ |==.ooEo.. | |X O + .o o | | * A + | | + . | | . S | | | | | | | | | +-----------------+ [root@pcmk-1 ~]# cp ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys -.. index:: - single: Creating and Activating a new SSH Key - Install the key on the other node: .. code-block:: none [root@pcmk-1 ~]# scp -r ~/.ssh pcmk-2: The authenticity of host 'pcmk-2 (192.168.122.102)' can't be established. ECDSA key fingerprint is SHA256:63xNPkPYq98rYznf3T9QYJAzlaGiAsSgFVNHOZjPWqc. ECDSA key fingerprint is MD5:d9:bf:6e:32:88:be:47:3d:96:f1:96:27:65:05:0b:c3. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'pcmk-2,192.168.122.102' (ECDSA) to the list of known hosts. root@pcmk-2's password: id_dsa id_dsa.pub authorized_keys known_hosts Test that you can now run commands remotely, without being prompted: .. code-block:: none [root@pcmk-1 ~]# ssh pcmk-2 -- uname -n pcmk-2 diff --git a/doc/sphinx/Clusters_from_Scratch/intro.rst b/doc/sphinx/Clusters_from_Scratch/intro.rst index eac0035379..fb0de2816a 100644 --- a/doc/sphinx/Clusters_from_Scratch/intro.rst +++ b/doc/sphinx/Clusters_from_Scratch/intro.rst @@ -1,29 +1,29 @@ Introduction ------------ The Scope of this Document ########################## Computer clusters can be used to provide highly available services or resources. The redundancy of multiple machines is used to guard against failures of many types. - + This document will walk through the installation and setup of simple clusters using the |CFS_DISTRO| distribution, version |CFS_DISTRO_VER|. - + The clusters described here will use Pacemaker and Corosync to provide resource management and messaging. Required packages and modifications to their configuration files are described along with the use of the Pacemaker command line tool for generating the XML used for cluster control. Pacemaker is a central component and provides the resource management required in these systems. This management includes detecting and recovering from the failure of various nodes, resources and services under its control. When more in-depth information is required, and for real-world usage, please refer to the `Pacemaker Explained `_ manual. .. include:: ../shared/pacemaker-intro.rst diff --git a/doc/sphinx/Clusters_from_Scratch/shared-storage.rst b/doc/sphinx/Clusters_from_Scratch/shared-storage.rst index d58cbb50bb..938b79ec1d 100644 --- a/doc/sphinx/Clusters_from_Scratch/shared-storage.rst +++ b/doc/sphinx/Clusters_from_Scratch/shared-storage.rst @@ -1,624 +1,627 @@ +.. 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 care 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. CentOS 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:: none # rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org # rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm Retrieving http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm Preparing... ################################# [100%] Updating / installing... 1:elrepo-release-7.0-3.el7.elrepo ################################# [100%] Now, we can install the DRBD kernel module and utilities: .. code-block:: none # yum install -y kmod-drbd84 drbd84-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:: none # 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:: none [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:: none [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. 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:: none [root@pcmk-1 ~]# vgdisplay | grep -e Name -e Free VG Name centos_pcmk-1 Free PE / Size 255 / 1020.00 MiB [root@pcmk-1 ~]# lvcreate --name drbd-demo --size 512M centos_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 centos_pcmk-1 -wi-a----- 512.00m root centos_pcmk-1 -wi-ao---- 3.00g swap centos_pcmk-1 -wi-ao---- 1.00g Repeat for the second node, making sure to use the same size: .. code-block:: none [root@pcmk-1 ~]# ssh pcmk-2 -- lvcreate --name drbd-demo --size 512M centos_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:: none # cat </etc/drbd.d/wwwdata.res resource wwwdata { protocol C; meta-disk internal; device /dev/drbd1; syncer { verify-alg sha1; } net { allow-two-primaries; } on pcmk-1 { disk /dev/centos_pcmk-1/drbd-demo; address 192.168.122.101:7789; } on pcmk-2 { disk /dev/centos_pcmk-2/drbd-demo; 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 **allow-two-primaries** 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:: none [root@pcmk-1 ~]# drbdadm create-md wwwdata --== Thank you for participating in the global usage survey ==-- The server's response is: you are the 2147th user to install this version 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: We can confirm DRBD's status on this node: .. code-block:: none [root@pcmk-1 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by mockbuild@, 2018-04-26 12:10:42 1: cs:WFConnection ro:Secondary/Unknown ds:Inconsistent/DUnknown C r----s ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:524236 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 local state is **WFConnection** (waiting for connection), and the partner node's status is marked as **Unknown**. 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, it shows: .. code-block:: none [root@pcmk-2 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by mockbuild@, 2018-04-26 12:10:42 1: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r----- ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:524236 You can see the state has changed to **Connected**, 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:: none [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:: none [root@pcmk-1 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by mockbuild@, 2018-04-26 12:10:42 1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----- ns:43184 nr:0 dw:0 dr:45312 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:481052 [>...................] sync'ed: 8.6% (481052/524236)K finish: 0:01:51 speed: 4,316 (4,316) K/sec We can see that this node has the **Primary** role, the partner node has the **Secondary** role, this node's data is now considered **UpToDate**, the partner node's data is still **Inconsistent**, and a progress bar shows how far along the partner node is in synchronizing the data. After a while, the sync should finish, and you'll see something like: .. code-block:: none [root@pcmk-1 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by mockbuild@, 2018-04-26 12:10:42 1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:524236 nr:0 dw:0 dr:526364 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 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:: none [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=0, sparse=0 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=855, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 .. 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:: none [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:: none [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:: none [root@pcmk-1 ~]# pcs -f drbd_cfg resource create WebData ocf:linbit:drbd \ drbd_resource=wwwdata op monitor interval=60s [root@pcmk-1 ~]# pcs -f drbd_cfg resource master WebDataClone WebData \ master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 \ notify=true [root@pcmk-1 ~]# pcs -f drbd_cfg resource show ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Stopped: [ pcmk-1 pcmk-2 ] .. NOTE:: In Fedora 29 and CentOS 8.0, 'master' resources have been renamed to 'promotable clone' resources and the `pcs` command has been changed accordingly: .. code-block:: none [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 The new command does not allow to set a custom name for the resulting promotable resource. ``pcs`` automatically creates a name for the resource in the form of **-clone**, that is **WebData-clone** in this case. To avoid confusion whether the ``pcs resource show`` command displays resources' status or configuration, the command has been deprecated in Fedora 29 and CentOS 8.0. Two new commands have been introduced for displaying resources' status and configuration: ``pcs resource status`` and ``pcs resource config``, respectively. 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:: none [root@pcmk-1 ~]# pcs cluster cib-push drbd_cfg --config CIB updated Let's see what the cluster did with the new configuration: .. code-block:: none [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 17:58:07 2018 Last change: Mon Sep 10 17:57:53 2018 by root via cibadmin on pcmk-1 2 nodes configured 4 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled We can see that **WebDataClone** (our DRBD device) is running as master (DRBD's primary role) on **pcmk-1** and slave (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:: none # 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:: none [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 WebDataClone INFINITY with-rsc-role=Master [root@pcmk-1 ~]# pcs -f fs_cfg constraint order \ promote WebDataClone then start WebFS Adding WebDataClone 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:: none [root@pcmk-1 ~]# pcs -f fs_cfg constraint colocation add WebSite with WebFS INFINITY [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:: none [root@pcmk-1 ~]# pcs -f fs_cfg constraint Location Constraints: Resource: WebSite Enabled on: pcmk-1 (score:50) Ordering Constraints: start ClusterIP then start WebSite (kind:Mandatory) promote WebDataClone then start WebFS (kind:Mandatory) start WebFS then start WebSite (kind:Mandatory) Colocation Constraints: WebSite with ClusterIP (score:INFINITY) WebFS with WebDataClone (score:INFINITY) (with-rsc-role:Master) WebSite with WebFS (score:INFINITY) Ticket Constraints: [root@pcmk-1 ~]# pcs -f fs_cfg resource show ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] WebFS (ocf::heartbeat:Filesystem): Stopped After reviewing the new configuration, upload it and watch the cluster put it into effect. .. code-block:: none [root@pcmk-1 ~]# pcs cluster cib-push fs_cfg --config CIB updated [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 18:02:24 2018 Last change: Mon Sep 10 18:02:14 2018 by root via cibadmin on pcmk-1 2 nodes configured 5 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-1 WebSite (ocf::heartbeat:apache): Started pcmk-1 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-1 ] Slaves: [ pcmk-2 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Test Cluster Failover ##################### Previously, we used ``pcs cluster stop pcmk-1`` to stop all cluster services on **pcmk-1**, 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:: none [root@pcmk-1 ~]# pcs cluster standby pcmk-1 [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 18:04:22 2018 Last change: Mon Sep 10 18:03:43 2018 by root via cibadmin on pcmk-1 2 nodes configured 5 resources configured Node pcmk-1: standby Online: [ pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-2 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-2 ] Stopped: [ pcmk-1 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Once we've done everything we needed to on pcmk-1 (in this case nothing, we just wanted to see the resources move), we can allow the node to be a full cluster member again. .. code-block:: none [root@pcmk-1 ~]# pcs cluster unstandby pcmk-1 [root@pcmk-1 ~]# pcs status Cluster name: mycluster Stack: corosync Current DC: pcmk-2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum Last updated: Mon Sep 10 18:05:22 2018 Last change: Mon Sep 10 18:05:21 2018 by root via cibadmin on pcmk-1 2 nodes configured 5 resources configured Online: [ pcmk-1 pcmk-2 ] Full list of resources: ClusterIP (ocf::heartbeat:IPaddr2): Started pcmk-2 WebSite (ocf::heartbeat:apache): Started pcmk-2 Master/Slave Set: WebDataClone [WebData] Masters: [ pcmk-2 ] Slaves: [ pcmk-1 ] WebFS (ocf::heartbeat:Filesystem): Started pcmk-2 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Notice that **pcmk-1** is back to the **Online** state, and that the cluster resources stay where they are due to our resource stickiness settings configured earlier. .. NOTE:: Since Fedora 29 and CentOS 8.0, the commands for controlling standby mode are ``pcs node standby`` and ``pcs node unstandby``. .. [#] See http://www.drbd.org for details. .. [#] Since version 2.6.33 diff --git a/doc/sphinx/Pacemaker_Administration/agents.rst b/doc/sphinx/Pacemaker_Administration/agents.rst index 18e1c5ce13..fada66e34b 100644 --- a/doc/sphinx/Pacemaker_Administration/agents.rst +++ b/doc/sphinx/Pacemaker_Administration/agents.rst @@ -1,380 +1,405 @@ +.. index:: + single: resource agent + Resource Agents --------------- -Resource Agent Actions -###################### + +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 __________________________ -.. index:: OCF resource agents - 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. .. table:: **Required Actions for OCF Agents** +--------------+-------------+------------------------------------------------+ | Action | Description | Instructions | +==============+=============+================================================+ - | start | Start the | Return 0 on success and an appropriate | - | | resource | error code otherwise. Must not report | + | start | Start the | .. index:: | + | | resource | single: OCF resource agent; start | + | | | single: start action | + | | | | + | | | Return 0 on success and an appropriate | + | | | error code otherwise. Must not report | | | | success until the resource is fully | | | | active. | - | | | | - | | | .. index:: | - | | | pair: start; OCF action | - | | | pair: start; action | +--------------+-------------+------------------------------------------------+ - | stop | Stop the | Return 0 on success and an appropriate | - | | resource | error code otherwise. Must not report | + | stop | Stop the | .. index:: | + | | resource | single: OCF resource agent; stop | + | | | single: stop action | + | | | | + | | | Return 0 on success and an appropriate | + | | | error code otherwise. Must not report | | | | success until the resource is fully | | | | stopped. | - | | | | - | | | .. index:: | - | | | pair: stop; OCF action | - | | | pair: stop; action | +--------------+-------------+------------------------------------------------+ - | monitor | Check the | Exit 0 if the resource is running, 7 | - | | resource's | if it is stopped, and any other OCF | - | | state | exit code if it is failed. NOTE: The | + | monitor | Check the | .. index:: | + | | resource's | single: OCF resource agent; monitor | + | | state | single: monitor action | + | | | | + | | | Exit 0 if the resource is running, 7 | + | | | if it is stopped, and any other OCF | + | | | exit code if it is failed. NOTE: The | | | | monitor script should test the state | | | | of the resource on the local machine | | | | only. | - | | | | - | | | .. index:: | - | | | pair: monitor; OCF action | - | | | pair: monitor; action | +--------------+-------------+------------------------------------------------+ - | meta-data | Describe | Provide information about this | - | | the | resource in the XML format defined by | - | | resource | the OCF standard. Exit with 0. NOTE: | + | meta-data | Describe | .. index:: | + | | the | single: OCF resource agent; meta-data | + | | resource | single: meta-data action | + | | | | + | | | Provide information about this | + | | | resource in the XML format defined by | + | | | the OCF standard. Exit with 0. NOTE: | | | | This is *not* required to be performed | | | | as root. | - | | | | - | | | .. index:: | - | | | pair: meta-data; OCF action | - | | | pair: meta-data; action | +--------------+-------------+------------------------------------------------+ - | validate-all | Verify the | Return 0 if parameters are valid, 2 if | - | | supplied | not valid, and 6 if resource is not | - | | parameters | configured. | + | validate-all | Verify the | .. index:: | + | | supplied | single: OCF resource agent; validate-all | + | | parameters | single: validate-all action | | | | | - | | | .. index:: | - | | | pair: validate-all; OCF action | - | | | pair: validate-all; action | + | | | Return 0 if parameters are valid, 2 if | + | | | not valid, and 6 if resource is not | + | | | configured. | +--------------+-------------+------------------------------------------------+ Additional requirements (not part of the OCF specification) are placed on agents that will be used for advanced concepts such as clone resources. .. table:: **Optional Actions for OCF Resource Agents** +--------------+-------------+------------------------------------------------+ | Action | Description | Instructions | +==============+=============+================================================+ - | promote | Promote the | Return 0 on success | - | | local | | - | | instance of | .. index:: | - | | a promotable| pair: promote; OCF action | - | | clone | pair: promote; action | + | promote | Promote the | .. index:: | + | | local | single: OCF resource agent; promote | + | | instance of | single: promote action | + | | a promotable| | + | | clone | Return 0 on success | | | resource to | | | | the master | | | | (primary) | | | | state. | | +--------------+-------------+------------------------------------------------+ - | demote | Demote the | Return 0 on success | - | | local | | - | | instance of | .. index:: | - | | a promotable| pair: demote; OCF action | - | | clone | pair: demote; action | + | demote | Demote the | .. index:: | + | | local | single: OCF resource agent; demote | + | | instance of | single: demote action | + | | a promotable| | + | | clone | Return 0 on success | | | resource to | | | | the slave | | | | (secondary) | | | | state. | | +--------------+-------------+------------------------------------------------+ - | notify | Used by the | Must not fail. Must exit with 0 | - | | cluster to | | - | | send | .. index:: | - | | the agent | pair: notify; OCF action | - | | pre- and | pair: notify; action | + | notify | Used by the | .. index:: | + | | cluster to | single: OCF resource agent; notify | + | | send | single: notify action | + | | the agent | | + | | pre- and | Must not fail. Must exit with 0 | | | post- | | | | notification| | | | events | | | | telling the | | | | resource | | | | what has | | | | happened and| | | | will happen.| | +--------------+-------------+------------------------------------------------+ One action specified in the OCF specs, ``recover``, is not currently used by the cluster. It is intended to be a variant of the ``start`` action that tries to recover a resource locally. .. important:: If you create a new OCF resource agent, use `ocf-tester` to verify that the agent complies with the OCF standard properly. -.. index:: ocf-tester + +.. 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: .. table:: **Types of recovery performed by the cluster** - +-------+------------------------------+--------------------------------------+ - | Type | Description | Action Taken by the Cluster | - +=======+==============================+======================================+ - | soft | A transient error occurred | Restart the resource or move it to a | - | | | new location | - | | .. index:: | | - | | pair: soft; OCF error | | - +-------+------------------------------+--------------------------------------+ - | hard | A non-transient error that | Move the resource elsewhere and | - | | may be specific to the | prevent it from being retried on the | - | | current node | current node | - | | | | - | | .. index:: | | - | | pair: hard; OCF error | | - +-------+------------------------------+--------------------------------------+ - | fatal | A non-transient error that | Stop the resource and prevent it | - | | will be common to all | from being started on any cluster | - | | cluster nodes (e.g. a bad | node | - | | configuration was specified) | | - | | | | - | | .. index:: | | - | | pair: fatal; OCF error | | - +-------+------------------------------+--------------------------------------+ + +-------+--------------------------------------------+--------------------------------------+ + | Type | Description | Action Taken by the Cluster | + +=======+============================================+======================================+ + | soft | .. index:: | Restart the resource or move it to a | + | | single: OCF resource agent; soft error | new location | + | | | | + | | A transient error occurred | | + +-------+--------------------------------------------+--------------------------------------+ + | hard | .. index:: | Move the resource elsewhere and | + | | single: OCF resource agent; hard error | prevent it from being retried on the | + | | | current node | + | | A non-transient error that | | + | | may be specific to the | | + | | current node | | + +-------+--------------------------------------------+--------------------------------------+ + | fatal | .. index:: | Stop the resource and prevent it | + | | single: OCF resource agent; fatal error | from being started on any cluster | + | | | node | + | | A non-transient error that | | + | | will be common to all | | + | | cluster nodes (e.g. a bad | | + | | configuration was specified) | | + +-------+--------------------------------------------+--------------------------------------+ .. _ocf_return_codes: OCF Return Codes ________________ The following table outlines the different OCF return codes and the type of recovery the cluster will initiate when a failure code is received. Although counterintuitive, even actions that return 0 (aka. ``OCF_SUCCESS``) can be considered to have failed, if 0 was not the expected return value. .. table:: **OCF Exit Codes and their Recovery Types** - +-------+-----------------------+---------------------------------------------+----------+ - | Exit | OCF Alias | Description | Recovery | - | Code | | | | - +=======+=======================+=============================================+==========+ - | 0 | OCF_SUCCESS | Success. The command completed successfully.| soft | - | | | This is the expected result for all start, | | - | | | stop, promote and demote commands. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_SUCCESS | | - | | | pair: return code; 0 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 1 | OCF_ERR_GENERIC | Generic "there was a problem" | soft | - | | | error code. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_GENERIC | | - | | | pair: return code; 1 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 2 | OCF_ERR_ARGS | The resource's configuration is not valid on| hard | - | | | this machine. E.g. it refers to a location | | - | | | not found on the node. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_ARGS | | - | | | pair: return code; 2 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 3 | OCF_ERR_UNIMPLEMENTED | The requested action is not | hard | - | | | implemented. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_UNIMPLEMENTED | | - | | | pair: return code; 3 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 4 | OCF_ERR_PERM | The resource agent does not have | hard | - | | | sufficient privileges to complete the task. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_PERM | | - | | | pair: return code; 4 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 5 | OCF_ERR_INSTALLED | The tools required by the resource are | hard | - | | | not installed on this machine. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_INSTALLED | | - | | | pair: return code; 5 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 6 | OCF_ERR_CONFIGURED | The resource's configuration is invalid. | fatal | - | | | E.g. required parameters are missing. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_ERR_CONFIGURED | | - | | | pair: return code; 6 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 7 | OCF_NOT_RUNNING | The resource is safely stopped. The cluster | N/A | - | | | will not attempt to stop a resource that | | - | | | returns this for any action. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_NOT_RUNNING | | - | | | pair: return code; 7 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 8 | OCF_RUNNING_MASTER | The resource is running in | soft | - | | | master mode. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_RUNNING_MASTER | | - | | | pair: return code; 8 | | - +-------+-----------------------+---------------------------------------------+----------+ - | 9 | OCF_FAILED_MASTER | The resource is in master mode but has | soft | - | | | failed. The resource will be demoted, | | - | | | stopped and then started (and possibly | | - | | | promoted) again. | | - | | | | | - | | | .. index:: | | - | | | pair: return code; OCF_FAILED_MASTER | | - | | | pair: return code; 9 | | - +-------+-----------------------+---------------------------------------------+----------+ - | other | *none* | Custom error code. | soft | - | | | | | - | | | .. index:: | | - | | | pair: return code; other | | - +-------+-----------------------+---------------------------------------------+----------+ + +-------+-----------------------+---------------------------------------------------+----------+ + | Exit | OCF Alias | Description | Recovery | + | Code | | | | + +=======+=======================+===================================================+==========+ + | 0 | OCF_SUCCESS | .. index:: | soft | + | | | single: OCF_SUCCESS | | + | | | single: OCF return code; OCF_SUCCESS | | + | | | pair: OCF return code; 0 | | + | | | | | + | | | Success. The command completed successfully. | | + | | | This is the expected result for all start, | | + | | | stop, promote and demote commands. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 1 | OCF_ERR_GENERIC | .. index:: | soft | + | | | single: OCF_ERR_GENERIC | | + | | | single: OCF return code; OCF_ERR_GENERIC | | + | | | pair: OCF return code; 1 | | + | | | | | + | | | Generic "there was a problem" error code. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 2 | OCF_ERR_ARGS | .. index:: | hard | + | | | single: OCF_ERR_ARGS | | + | | | single: OCF return code; OCF_ERR_ARGS | | + | | | pair: OCF return code; 2 | | + | | | | | + | | | The resource's configuration is not valid on | | + | | | this machine. E.g. it refers to a location | | + | | | not found on the node. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 3 | OCF_ERR_UNIMPLEMENTED | .. index:: | hard | + | | | single: OCF_ERR_UNIMPLEMENTED | | + | | | single: OCF return code; OCF_ERR_UNIMPLEMENTED | | + | | | pair: OCF return code; 3 | | + | | | | | + | | | The requested action is not implemented. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 4 | OCF_ERR_PERM | .. index:: | hard | + | | | single: OCF_ERR_PERM | | + | | | single: OCF return code; OCF_ERR_PERM | | + | | | pair: OCF return code; 4 | | + | | | | | + | | | The resource agent does not have | | + | | | sufficient privileges to complete the task. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 5 | OCF_ERR_INSTALLED | .. index:: | hard | + | | | single: OCF_ERR_INSTALLED | | + | | | single: OCF return code; OCF_ERR_INSTALLED | | + | | | pair: OCF return code; 5 | | + | | | | | + | | | The tools required by the resource are | | + | | | not installed on this machine. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 6 | OCF_ERR_CONFIGURED | .. index:: | fatal | + | | | single: OCF_ERR_CONFIGURED | | + | | | single: OCF return code; OCF_ERR_CONFIGURED | | + | | | pair: OCF return code; 6 | | + | | | | | + | | | The resource's configuration is invalid. | | + | | | E.g. required parameters are missing. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 7 | OCF_NOT_RUNNING | .. index:: | N/A | + | | | single: OCF_NOT_RUNNING | | + | | | single: OCF return code; OCF_NOT_RUNNING | | + | | | pair: OCF return code; 7 | | + | | | | | + | | | The resource is safely stopped. The cluster | | + | | | will not attempt to stop a resource that | | + | | | returns this for any action. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 8 | OCF_RUNNING_MASTER | .. index:: | soft | + | | | single: OCF_RUNNING_MASTER | | + | | | single: OCF return code; OCF_RUNNING_MASTER | | + | | | pair: OCF return code; 8 | | + | | | | | + | | | The resource is running in the master role. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 9 | OCF_FAILED_MASTER | .. index:: | soft | + | | | single: OCF_FAILED_MASTER | | + | | | single: OCF return code; OCF_FAILED_MASTER | | + | | | pair: OCF return code; 9 | | + | | | | | + | | | The resource is in the master role but has | | + | | | failed. The resource will be demoted, | | + | | | stopped and then started (and possibly | | + | | | promoted) again. | | + +-------+-----------------------+---------------------------------------------------+----------+ + | 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 master mode) 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. +.. 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/cluster.rst b/doc/sphinx/Pacemaker_Administration/cluster.rst index 26da9e5c68..069121f042 100644 --- a/doc/sphinx/Pacemaker_Administration/cluster.rst +++ b/doc/sphinx/Pacemaker_Administration/cluster.rst @@ -1,64 +1,71 @@ +.. index:: + single: cluster layer + The Cluster Layer ----------------- Pacemaker and the Cluster Layer ############################### Pacemaker utilizes an underlying cluster layer for two purposes: * obtaining quorum * messaging between nodes Currently, only Corosync 2 and later is supported for this layer. +.. index:: + single: cluster layer; Corosync + single: Corosync + Managing Nodes in a Corosync-Based Cluster ########################################## +.. index:: + pair: Corosync; add cluster node + Adding a New Corosync Node __________________________ -.. index:: - pair: corosync; add cluster node - To add a new node: #. Install Corosync and Pacemaker on the new host. #. Copy ``/etc/corosync/corosync.conf`` and ``/etc/corosync/authkey`` (if it exists) from an existing node. You may need to modify the ``mcastaddr`` option to match the new node's IP address. #. Start the cluster software on the new host. If a log message containing "Invalid digest" appears from Corosync, the keys are not consistent between the machines. +.. index:: + pair: Corosync; remove cluster node + Removing a Corosync Node ________________________ -.. index:: - pair: corosync; remove cluster node - Because the messaging and membership layers are the authoritative source for cluster nodes, deleting them from the CIB is not a complete solution. First, one must arrange for corosync to forget about the node (**pcmk-1** in the example below). #. Stop the cluster on the host to be removed. How to do this will vary with your operating system and installed versions of cluster software, for example, ``pcs cluster stop`` if you are using pcs for cluster management. #. From one of the remaining active cluster nodes, tell Pacemaker to forget about the removed host, which will also delete the node from the CIB: .. code-block:: none # crm_node -R pcmk-1 +.. index:: + pair: Corosync; replace cluster node + Replacing a Corosync Node _________________________ -.. index:: - pair: corosync; replace cluster node - To replace an existing cluster node: #. Make sure the old node is completely stopped. #. Give the new machine the same hostname and IP address as the old one. #. Follow the procedure above for adding a node. diff --git a/doc/sphinx/Pacemaker_Administration/configuring.rst b/doc/sphinx/Pacemaker_Administration/configuring.rst index b0321f1909..d3e638d67b 100644 --- a/doc/sphinx/Pacemaker_Administration/configuring.rst +++ b/doc/sphinx/Pacemaker_Administration/configuring.rst @@ -1,264 +1,278 @@ +.. index:: + single: configuration + single: CIB + Configuring Pacemaker --------------------- Pacemaker's configuration, the CIB, is stored in XML format. Cluster administrators have multiple options for modifying the configuration either via the XML, or at a more abstract (and easier for humans to understand) level. Pacemaker reacts to configuration changes as soon as they are saved. Pacemaker's command-line tools and most higher-level tools provide the ability to batch changes together and commit them at once, rather than make a series of small changes, which could cause avoid unnecessary actions as Pacemaker responds to each change individually. Pacemaker tracks revisions to the configuration and will reject any update older than the current revision. Thus, it is a good idea to serialize all changes to the configuration. Avoid attempting simultaneous changes, whether on the same node or different nodes, and whether manually or using some automated configuration tool. .. note:: It is not necessary to update the configuration on all cluster nodes. Pacemaker immediately synchronizes changes to all active members of the cluster. To reduce bandwidth, the cluster only broadcasts the incremental updates that result from your changes and uses checksums to ensure that each copy is consistent. Configuration Using Higher-level Tools ______________________________________ Most users will benefit from using higher-level tools provided by projects separate from Pacemaker. Some of the most commonly used include the crm shell, hawk, and pcs. [#]_ See those projects' documentation for details on how to configure Pacemaker using them. Configuration Using Pacemaker's Command-Line Tools __________________________________________________ Pacemaker provides lower-level, command-line tools to manage the cluster. Most configuration tasks can be performed with these tools, without needing any XML knowledge. To enable STONITH for example, one could run: .. code-block:: none # crm_attribute --name stonith-enabled --update 1 Or, to check whether **node1** is allowed to run resources, there is: .. code-block:: none # crm_standby --query --node node1 Or, to change the failure threshold of **my-test-rsc**, one can use: .. code-block:: none # crm_resource -r my-test-rsc --set-parameter migration-threshold --parameter-value 3 --meta Examples of using these tools for specific cases will be given throughout this document where appropriate. See the man pages for further details. See :ref:`cibadmin` for how to edit the CIB using XML. See :ref:`crm_shadow` for a way to make a series of changes, then commit them all at once to the live cluster. +.. index:: + single: configuration; CIB properties + single: CIB; properties + single: CIB property + Working with CIB Properties ########################### Although these fields can be written to by the user, in most cases the cluster will overwrite any values specified by the user with the "correct" ones. To change the ones that can be specified by the user, for example ``admin_epoch``, one should use: .. code-block:: none # cibadmin --modify --xml-text '' A complete set of CIB properties will look something like this: .. topic:: XML attributes set for a cib element .. code-block:: xml +.. index:: + single: configuration; cluster options + Querying and Setting Cluster Options #################################### -.. index:: - pair: cluster option; querying - pair: cluster option; setting - Cluster options can be queried and modified using the ``crm_attribute`` tool. To get the current value of ``cluster-delay``, you can run: .. code-block:: none # crm_attribute --query --name cluster-delay which is more simply written as .. code-block:: none # crm_attribute -G -n cluster-delay If a value is found, you'll see a result like this: .. code-block:: none # crm_attribute -G -n cluster-delay scope=crm_config name=cluster-delay value=60s If no value is found, the tool will display an error: .. code-block:: none # crm_attribute -G -n clusta-deway scope=crm_config name=clusta-deway value=(null) Error performing operation: No such device or address To use a different value (for example, 30 seconds), simply run: .. code-block:: none # crm_attribute --name cluster-delay --update 30s To go back to the cluster's default value, you can delete the value, for example: .. code-block:: none # crm_attribute --name cluster-delay --delete Deleted crm_config option: id=cib-bootstrap-options-cluster-delay name=cluster-delay When Options are Listed More Than Once ______________________________________ If you ever see something like the following, it means that the option you're modifying is present more than once. .. topic:: Deleting an option that is listed twice .. code-block:: none # crm_attribute --name batch-limit --delete Multiple attributes match name=batch-limit in crm_config: Value: 50 (set=cib-bootstrap-options, id=cib-bootstrap-options-batch-limit) Value: 100 (set=custom, id=custom-batch-limit) Please choose from one of the matches above and supply the 'id' with --id In such cases, follow the on-screen instructions to perform the requested action. To determine which value is currently being used by the cluster, refer to the "Rules" chapter of *Pacemaker Explained*. +.. index:: + single: configuration; remote + .. _remote_connection: Connecting from a Remote Machine ################################ -.. index:: - pair: cluster; remote connection - pair: cluster; remote administration - Provided Pacemaker is installed on a machine, it is possible to connect to the cluster even if the machine itself is not in the same cluster. To do this, one simply sets up a number of environment variables and runs the same commands as when working on a cluster node. .. table:: **Environment Variables Used to Connect to Remote Instances of the CIB** - +----------------------+-----------+----------------------------------------------+ - | Environment Variable | Default | Description | - +======================+===========+==============================================+ - | CIB_user | $USER | The user to connect as. Needs to be | - | | | part of the ``haclient`` group on | - | | | the target host. | - | | | | - | | | .. index:: | - | | | pair: environment variable; CIB_user | - +----------------------+-----------+----------------------------------------------+ - | CIB_passwd | | The user's password. Read from the | - | | | command line if unset. | - | | | | - | | | .. index:: | - | | | pair: environment variable; CIB_passwd | - +----------------------+-----------+----------------------------------------------+ - | CIB_server | localhost | The host to contact | - | | | | - | | | .. index:: | - | | | pair: environment variable; CIB_server | - +----------------------+-----------+----------------------------------------------+ - | CIB_port | | The port on which to contact the server; | - | | | required. | - | | | | - | | | .. index:: | - | | | pair: environment variable; CIB_port | - +----------------------+-----------+----------------------------------------------+ - | CIB_encrypted | TRUE | Whether to encrypt network traffic | - | | | | - | | | .. index:: | - | | | pair: environment variable; CIB_encrypted | - +----------------------+-----------+----------------------------------------------+ + +----------------------+-----------+------------------------------------------------+ + | Environment Variable | Default | Description | + +======================+===========+================================================+ + | CIB_user | $USER | .. index:: | + | | | single: CIB_user | + | | | single: environment variable; CIB_user | + | | | | + | | | The user to connect as. Needs to be | + | | | part of the ``haclient`` group on | + | | | the target host. | + +----------------------+-----------+------------------------------------------------+ + | CIB_passwd | | .. index:: | + | | | single: CIB_passwd | + | | | single: environment variable; CIB_passwd | + | | | | + | | | The user's password. Read from the | + | | | command line if unset. | + +----------------------+-----------+------------------------------------------------+ + | CIB_server | localhost | .. index:: | + | | | single: CIB_server | + | | | single: environment variable; CIB_server | + | | | | + | | | The host to contact | + +----------------------+-----------+------------------------------------------------+ + | CIB_port | | .. index:: | + | | | single: CIB_port | + | | | single: environment variable; CIB_port | + | | | | + | | | The port on which to contact the server; | + | | | required. | + +----------------------+-----------+------------------------------------------------+ + | CIB_encrypted | TRUE | .. index:: | + | | | single: CIB_encrypted | + | | | single: environment variable; CIB_encrypted | + | | | | + | | | Whether to encrypt network traffic | + +----------------------+-----------+------------------------------------------------+ So, if **c001n01** is an active cluster node and is listening on port 1234 for connections, and **someuser** is a member of the **haclient** group, then the following would prompt for **someuser**'s password and return the cluster's current configuration: .. code-block:: none # export CIB_port=1234; export CIB_server=c001n01; export CIB_user=someuser; # cibadmin -Q For security reasons, the cluster does not listen for remote connections by default. If you wish to allow remote access, you need to set the ``remote-tls-port`` (encrypted) or ``remote-clear-port`` (unencrypted) CIB properties (i.e., those kept in the ``cib`` tag, like ``num_updates`` and ``epoch``). .. table:: **Extra top-level CIB properties for remote access** +----------------------+-----------+------------------------------------------------------+ | CIB Property | Default | Description | +======================+===========+======================================================+ - | remote-tls-port | | Listen for encrypted remote connections | - | | | on this port. | + | remote-tls-port | | .. index:: | + | | | single: remote-tls-port | + | | | single: CIB property; remote-tls-port | | | | | - | | | .. index:: | - | | | pair: remote connection option; remote-tls-port | - +----------------------+-----------+------------------------------------------------------+ - | remote-clear-port | | Listen for plaintext remote connections | + | | | Listen for encrypted remote connections | | | | on this port. | + +----------------------+-----------+------------------------------------------------------+ + | remote-clear-port | | .. index:: | + | | | single: remote-clear-port | + | | | single: CIB property; remote-clear-port | | | | | - | | | .. index:: | - | | | pair: remote connection option; remote-clear-port | + | | | Listen for plaintext remote connections | + | | | on this port. | +----------------------+-----------+------------------------------------------------------+ .. important:: The Pacemaker version on the administration host must be the same or greater than the version(s) on the cluster nodes. Otherwise, it may not have the schema files necessary to validate the CIB. .. rubric:: Footnotes .. [#] For a list, see "Configuration Tools" at https://clusterlabs.org/components.html diff --git a/doc/sphinx/Pacemaker_Administration/installing.rst b/doc/sphinx/Pacemaker_Administration/installing.rst index 334a06ca88..179f4fe665 100644 --- a/doc/sphinx/Pacemaker_Administration/installing.rst +++ b/doc/sphinx/Pacemaker_Administration/installing.rst @@ -1,107 +1,112 @@ Installing Cluster Software --------------------------- +.. index:: installation + Installing the Software ####################### Most major Linux distributions have pacemaker packages in their standard package repositories, or the software can be built from source code. See the `Install wiki page `_ for details. Enabling Pacemaker ################## +.. index:: + pair: configuration; Corosync + Enabling Pacemaker For Corosync version 2 and greater _____________________________________________________ High-level cluster management tools are available that can configure corosync for you. This document focuses on the lower-level details if you want to configure corosync yourself. Corosync configuration is normally located in ``/etc/corosync/corosync.conf``. .. topic:: Corosync configuration file for two nodes **myhost1** and **myhost2** .. code-block:: none totem { version: 2 secauth: off cluster_name: mycluster transport: udpu } nodelist { node { ring0_addr: myhost1 nodeid: 1 } node { ring0_addr: myhost2 nodeid: 2 } } quorum { provider: corosync_votequorum two_node: 1 } logging { to_syslog: yes } .. topic:: Corosync configuration file for three nodes **myhost1**, **myhost2** and **myhost3** .. code-block:: none totem { version: 2 secauth: off cluster_name: mycluster transport: udpu } nodelist { node { ring0_addr: myhost1 nodeid: 1 } node { ring0_addr: myhost2 nodeid: 2 } node { ring0_addr: myhost3 nodeid: 3 } } quorum { provider: corosync_votequorum } logging { to_syslog: yes } In the above examples, the ``totem`` section defines what protocol version and options (including encryption) to use, [#]_ and gives the cluster a unique name (``mycluster`` in these examples). The ``node`` section lists the nodes in this cluster. The ``quorum`` section defines how the cluster uses quorum. The important thing is that two-node clusters must be handled specially, so ``two_node: 1`` must be defined for two-node clusters (it will be ignored for clusters of any other size). The ``logging`` section should be self-explanatory. .. rubric:: Footnotes .. [#] Please consult the Corosync website (http://www.corosync.org/) and documentation for details on enabling encryption and peer authentication for the cluster. diff --git a/doc/sphinx/Pacemaker_Administration/tools.rst b/doc/sphinx/Pacemaker_Administration/tools.rst index aff767d9e9..64fd4789ae 100644 --- a/doc/sphinx/Pacemaker_Administration/tools.rst +++ b/doc/sphinx/Pacemaker_Administration/tools.rst @@ -1,553 +1,570 @@ +.. 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 --text-fancy Use more highly formatted output +.. index:: + single: crm_mon + single: command-line tool; crm_mon + .. _crm_mon: Monitor a Cluster with crm_mon ############################## -.. index:: - pair: command-line tool; 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. -.. _crm_mon_css: - -Styling crm_mon output -______________________ - .. 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 ############################## -.. index:: - pair: command-line tool; 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 ########################################### -.. index:: - pair: command-line tool; 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] # 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 ########################################### -.. index:: - pair: command-line tool; 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 ``--dot-file`` 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 --dot-file $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. * Loops should not happen, and should be reported as a bug if found. .. topic:: Small Cluster Transition .. image:: ../../shared/en-US/images/Policy-Engine-small.png :alt: An example transition graph as represented by Graphviz :height: 325 :width: 1161 :scale: 75 % :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/en-US/images/Policy-Engine-big.png :alt: Complex transition graph that you're not expected to be able to read :width: 1455 :height: 1945 :scale: 75 % :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. .. _attrd_updater: .. _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 ######################################################################################### -.. index:: - pair: command-line tool; attrd_updater - pair: command-line tool; crm_attribute - ``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 | +-----------+----------+-------------------+------------------+----------------+----------------+ 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: -.. index:: - pair: command-line tool; crm_failcount - pair: command-line tool; crm_node - pair: command-line tool; crm_report - pair: command-line tool; crm_standby - pair: command-line tool; crm_verify - pair: command-line tool; stonith_admin - * ``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 53970a0f94..c740361e9a 100644 --- a/doc/sphinx/Pacemaker_Administration/troubleshooting.rst +++ b/doc/sphinx/Pacemaker_Administration/troubleshooting.rst @@ -1,67 +1,73 @@ +.. 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``). 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. +.. 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 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. Further Information About Troubleshooting ######################################### Andrew Beekhof wrote a series of articles about troubleshooting in his blog, `The Cluster Guy `_: * `Debugging Pacemaker `_ * `Debugging the Policy Engine `_ * `Pacemaker Logging `_ The articles were written for an earlier version of Pacemaker, so many of the specific names and log messages to look for have changed, but the concepts are still valid. diff --git a/doc/sphinx/Pacemaker_Administration/upgrading.rst b/doc/sphinx/Pacemaker_Administration/upgrading.rst index 1d6f0f68ad..b31cb24567 100644 --- a/doc/sphinx/Pacemaker_Administration/upgrading.rst +++ b/doc/sphinx/Pacemaker_Administration/upgrading.rst @@ -1,485 +1,505 @@ +.. 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 | - | | | | | | | | - | .. index:: | | | | | | | - | pair: cluster; upgrade with shutdown | | | | | | | - | pair: upgrade; upgrade with shutdown | | | | | | | +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ | Rolling (node by node) | no | yes | always | yes | yes | no | | | | | [#]_ | | | | - | | | | | | | | - | .. index:: | | | | | | | - | pair: cluster; rolling upgrade | | | | | | | - | pair: upgrade; rolling upgrade | | | | | | | +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ | Detach and reattach | yes | no | only | no | no | yes | | | | | due to | | | | | | | | failure| | | | - | | | | | | | | - | .. index:: | | | | | | | - | pair: cluster; upgrade with detach and reattach| | | | | | | - | pair: upgrade; upgrade with detach and reattach| | | | | | | +---------------------------------------------------+----------+----------+--------+---------+----------+----------+ + +.. 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 ClusterLabs wiki's `release calendar `_ to figure out whether the CRM feature set and/or Pacemaker Remote protocol version changed between the 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.) #. Shutdown the cluster software (pacemaker and the messaging layer) on the node. #. 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. #. 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. .. 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. .. table:: **Version Compatibility Table** +-------------------------+---------------------------+ | Version being Installed | Oldest Compatible Version | +=========================+===========================+ | Pacemaker 2.y.z | Pacemaker 1.1.11 [#]_ | +-------------------------+---------------------------+ | Pacemaker 1.y.z | Pacemaker 1.0.0 | +-------------------------+---------------------------+ | Pacemaker 0.7.z | Pacemaker 0.6.z | +-------------------------+---------------------------+ +.. 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 ########################### -.. index:: - pair: upgrading; 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): - .. index:: - pair: verify; configuration - .. 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, visit the `Validation FAQ wiki page `_ and/or 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.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, though it will take longer for the full terminology change to be completed. * 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 the `Pacemaker 2.0 Changes `_ page 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. .. [#] As of Pacemaker 2.0.0, only schema versions pacemaker-1.0 and higher are supported (excluding pacemaker-1.1, which was an experimental schema now known as pacemaker-next). diff --git a/doc/sphinx/Pacemaker_Development/c.rst b/doc/sphinx/Pacemaker_Development/c.rst index 7f9bc68155..1b6aed11ec 100644 --- a/doc/sphinx/Pacemaker_Development/c.rst +++ b/doc/sphinx/Pacemaker_Development/c.rst @@ -1,287 +1,304 @@ +.. index:: + single: C + pair: C; guidelines + C Coding Guidelines ------------------- +.. index:: + pair: C; style + Style Guidelines ################ Pacemaker is a large, distributed 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. The guidelines in this section are not technically better than alternative approaches, but make project management easier. Many of these simply ensure stylistic consistency, which makes reading, writing, and reviewing code easier. .. index:: pair: C; boilerplate - pair: licensing; C boilerplate + pair: license; C + pair: copyright; C C Boilerplate _____________ Every C file should start with a short copyright 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 in the form ``PCMK____H``. For example: .. code-block:: c #ifndef PCMK__MY_HEADER_H # define PCMK__MY_HEADER_H // header code here #endif // PCMK__MY_HEADER_H Public API header files should additionally declare "C" compatibility for inclusion by C++, and give a Doxygen file description. For example: .. code-block:: c #ifdef __cplusplus extern "C" { #endif /*! * \file * \brief My brief description here * \ingroup core */ // header code here #ifdef __cplusplus } #endif -Line Formatting -_______________ - .. 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 significantly impacts readability. +.. index:: + pair: C; pointer + Pointers ________ -.. index:: - pair: C; pointers - * The ``*`` goes by the variable name, not the type: .. code-block:: c char *foo; * Use a space before the ``*`` and after the closing parenthesis in a cast: .. code-block:: c char *foo = (char *) bar; +.. index:: + pair: C; function + Function Definitions ____________________ -.. index:: - pair: C; functions - * In the function definition, put the return type on its own line, and place the opening brace by itself on a line. * For functions with enough arguments that they must break to the next line, align arguments with the first argument. * When a function argument is a function itself, use the pointer form. .. code-block:: c static int function_name(int bar, const char *a, const char *b, const char *c, void (*d)()) { * If a function name gets really long, start the arguments on their own line with 8 spaces of indentation: .. code-block:: c static int really_really_long_function_name_this_is_getting_silly_now( int bar, const char *a, const char *b, const char *c, const char *d) { Control Statements (if, else, while, for, switch) _________________________________________________ * The keyword is followed by one space, then left parenthesis without space, condition, right parenthesis, space, opening bracket on the same line. ``else`` and ``else if`` are on the same line with the ending brace and opening brace, separated by a space. * 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 any chance of bad indenting making a line incorrectly appear to be part of the block. * Do not put assignments in ``if`` or ``while`` conditionals. This ensures that the developer's intent is always clear, making code reviews easier and reducing the chance of using assignment where comparison is intended. .. code-block:: c a = f(); if (a < 0) { statement1; } else if (some_other_condition) { statement2; } else { statement3; } * In a ``switch`` statement, ``case`` is indented one level, and the body of each ``case`` is indented by another level. The opening brace is on the same line as ``switch``. .. code-block:: c switch (expression) { case 0: command1; break; case 1: command2; break; default: command3; } +.. index:: + pair: C; operator + Operators _________ -.. index:: - pair: C; operators - * Operators have spaces from both sides. * Do not rely on operator precedence; use parentheses when mixing operators with different priority. * No space is used after opening parenthesis and before closing parenthesis. .. code-block:: c x = a + b - (c * d); Best Practices ############## The guidelines in this section offer technical advantages. .. index:: pair: C; struct pair: C; enum New Struct and Enum Members ___________________________ In the public APIs, always add new ``struct`` members to the end of the ``struct``. This allows us to maintain backward API/ABI compatibility (as long as the application being linked allocates structs via API functions). This generally applies to ``enum`` values as well, as the compiler will define ``enum`` values to 0, 1, etc., in the order given, so inserting a value in the middle will change the numerical values of all later values, making them backward-incompatible. However, if enum numerical values are explicitly specified rather than left to the compiler, new values can be added anywhere. .. index:: pair: C; API documentation -Documentation -_____________ +API documentation +_________________ All public API header files, functions, structs, enums, etc., should be documented with Doxygen comment blocks, as Pacemaker's `online API documentation `_ is automatically generated via Doxygen. It is helpful to document private symbols in the same way, with an ``\internal`` tag in the Doxygen comment. -Symbol Naming -_____________ - .. index:: pair: C; naming +Symbol Naming +_____________ + * All file and function names should be unique across the entire project, to allow for individual tracing via ``PCMK_trace_files`` and ``PCMK_trace_functions``, as well as making detail logs easier to follow. * Any exposed symbols in libraries (non-``static`` function names, type names, etc.) must begin with a prefix appropriate to the library, for example, ``pcmk_``, ``pe_``, ``st_``, ``lrm_``. This reduces the chance of naming collisions with software linked against the library. * Time intervals are sometimes represented in Pacemaker code as user-defined text specifications (e.g. "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 (e.g. ``interval_spec``, ``interval_ms``, or ``interval_ms_s`` instead of ``interval``). +.. index:: + pair: C; memory + Memory Allocation _________________ * 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. +.. index:: + pair: C; logging + Logging _______ * 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* pass ``NULL`` as an argument to satisfy the ``%s`` format specifier in logging (and more generally, ``printf``-style) functions. When the string "" is a sufficient output representation in such case, you can use the ``crm_str()`` convenience macro; otherwise, the ternary operator is an obvious choice. +.. index:: + pair: C; regular expression + Regular Expressions ___________________ - Use ``REG_NOSUB`` with ``regcomp()`` whenever possible, for efficiency. - Be sure to use ``regfree()`` appropriately. vim Settings ____________ .. index:: vim 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/faq.rst b/doc/sphinx/Pacemaker_Development/faq.rst index 75aac0cc8e..8e029f5c18 100644 --- a/doc/sphinx/Pacemaker_Development/faq.rst +++ b/doc/sphinx/Pacemaker_Development/faq.rst @@ -1,143 +1,148 @@ 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:: downloads, source code, git, GitHub +.. 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:: branches +.. index:: + single: git; branch :Q: What are the different Git branches and repositories used for? :A: * The `master branch `_ is the primary branch used for development. * The `2.0 branch `_ contains the latest official release, and normally does not receive any changes. During the release cycle, it will contain release candidates for the next official release, and will receive only bug fixes. * The `1.1 branch `_ is similar to both the master and 2.0 branches, but for the 1.1 release series. The 1.1 branch receives only backports of certain bug fixes and backward-compatible features from the master branch. During the release cycle, it will contain release candidates for the next official 1.1 release. * The `1.0 repository `_ is a frozen snapshot of the 1.0 release series, and is no longer developed. * Messages will be posted to the `developers@ClusterLabs.org `_ mailing list during the release cycle, with instructions about which branches to use when submitting requests. ---- :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:: - pair: git; commit messages + single: git; commit message :Q: How should I format my Git commit messages? :A: See existing examples in the git log. The first line should look like +change-type: affected-code: explanation+ where +change-type+ should be +Fix+ or +Bug+ for most bug fixes, +Feature+ for new features, +Log+ for changes to log messages or handling, +Doc+ for changes to documentation or comments, or +Test+ for changes in CTS and regression tests. You will sometimes see +Low+, +Med+ (or +Mid+) and +High+ used instead for bug fixes, to indicate the severity. The important thing is that only commits with +Feature+, +Fix+, +Bug+, or +High+ will automatically be included in the change log for the next release. The +affected-code+ 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 +explanation+ 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 then a longer explanation of 'why' the change was made. ---- :Q: How can I test my changes? :A: Most importantly, Pacemaker has regression tests for most major components; these will automatically be run for any pull requests submitted through GitHub. Additionally, Pacemaker's Cluster Test Suite (CTS) can be used to set up a test cluster and run a wide variety of complex tests. This document will have more detail on testing in the future. ---- -.. index:: licensing +.. 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 and libraries 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 lists +.. index:: mailing list :Q: What if I still have questions? :A: Ask on the `developers@ClusterLabs.org `_ mailing list for development-related questions, or on the `users@ClusterLabs.org `_ mailing list for general questions about using Pacemaker. Developers often also hang out on `freenode's `_ #clusterlabs IRC channel. diff --git a/doc/sphinx/Pacemaker_Development/general.rst b/doc/sphinx/Pacemaker_Development/general.rst index a1fd103fc9..9d9dcec1cf 100644 --- a/doc/sphinx/Pacemaker_Development/general.rst +++ b/doc/sphinx/Pacemaker_Development/general.rst @@ -1,37 +1,40 @@ +.. index:: + single: guidelines; all languages + General Guidelines for All Languages ------------------------------------ +.. index:: copyright + Copyright ######### -.. index:: 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. diff --git a/doc/sphinx/Pacemaker_Development/python.rst b/doc/sphinx/Pacemaker_Development/python.rst index 5b2495e2b1..8c28d44f8e 100644 --- a/doc/sphinx/Pacemaker_Development/python.rst +++ b/doc/sphinx/Pacemaker_Development/python.rst @@ -1,147 +1,153 @@ +.. index:: + single: Python + pair: Python; guidelines + Python Coding Guidelines ------------------------ +.. index:: + pair: Python; boilerplate + pair: license; Python + pair: copyright; Python + .. _s-python-boilerplate: Python Boilerplate ################## -.. index:: - pair: Python; boilerplate - pair: licensing; Python boilerplate - If a Python file is meant to be executed (as opposed to imported), it should have a ``.in`` extension, and its first line should be: .. code-block:: python #!@PYTHON@ which will be replaced with the appropriate python executable when Pacemaker is built. To make that happen, add an ``AC_CONFIG_FILES()`` line to ``configure.ac``, and add the file name without ``.in`` to ``.gitignore`` (see existing examples). After the above line if any, every Python file should start like this: .. code-block:: python """ """ # Pacemaker targets compatibility with Python 2.7 and 3.2+ from __future__ import print_function, unicode_literals, absolute_import, division __copyright__ = "Copyright the Pacemaker project contributors" __license__ = " WITHOUT ANY WARRANTY" ** is obviously a brief description of the file's purpose. The string may contain any other information typically used in a Python file `docstring `_. The ``import`` statement is discussed further in :ref:`s-python-future-imports`. ```` 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+)". -Python Compatibility -#################### - .. index:: single: Python; 2 single: Python; 3 - single: Python; versions + single: Python; version + +Python Compatibility +#################### Pacemaker targets compatibility with Python 2.7, and Python 3.2 and later. These versions have added features to be more compatible with each other, allowing us to support both the 2 and 3 series with the same code. It is a good idea to test any changes with both Python 2 and 3. .. _s-python-future-imports: Python Future Imports _____________________ The future imports used in :ref:`s-python-boilerplate` mean: * All print statements must use parentheses, and printing without a newline is accomplished with the ``end=' '`` parameter rather than a trailing comma. * All string literals will be treated as Unicode (the ``u`` prefix is unnecessary, and must not be used, because it is not available in Python 3.2). * Local modules must be imported using ``from . import`` (rather than just ``import``). To import one item from a local module, use ``from .modulename import`` (rather than ``from modulename import``). * Division using ``/`` will always return a floating-point result (use ``//`` if you want the integer floor instead). Other Python Compatibility Requirements _______________________________________ * When specifying an exception variable, always use ``as`` instead of a comma (e.g. ``except Exception as e`` or ``except (TypeError, IOError) as e``). Use ``e.args`` to access the error arguments (instead of iterating over or subscripting ``e``). * Use ``in`` (not ``has_key()``) to determine if a dictionary has a particular key. * Always use the I/O functions from the ``io`` module rather than the native I/O functions (e.g. ``io.open()`` rather than ``open()``). * When opening a file, always use the ``t`` (text) or ``b`` (binary) mode flag. * When creating classes, always specify a parent class to ensure that it is a "new-style" class (e.g. ``class Foo(object):`` rather than ``class Foo:``). * Be aware of the bytes type added in Python 3. Many places where strings are used in Python 2 use bytes or bytearrays in Python 3 (for example, the pipes used with ``subprocess.Popen()``). Code should handle both possibilities. * Be aware that the ``items()``, ``keys()``, and ``values()`` methods of dictionaries return lists in Python 2 and views in Python 3. In many case, no special handling is required, but if the code needs to use list methods on the result, cast the result to list first. * Do not raise or catch strings as exceptions (e.g. ``raise "Bad thing"``). * Do not use the ``cmp`` parameter of sorting functions (use ``key`` instead, if needed) or the ``__cmp__()`` method of classes (implement rich comparison methods such as ``__lt__()`` instead, if needed). * Do not use the ``buffer`` type. * Do not use features not available in all targeted Python versions. Common examples include: * The ``html``, ``ipaddress``, and ``UserDict`` modules * The ``subprocess.run()`` function * The ``subprocess.DEVNULL`` constant * ``subprocess`` module-specific exceptions Python Usages to Avoid ______________________ Avoid the following if possible, otherwise research the compatibility issues involved (hacky workarounds are often available): * long integers * octal integer literals * mixed binary and string data in one data file or variable * metaclasses * ``locale.strcoll`` and ``locale.strxfrm`` * the ``configparser`` and ``ConfigParser`` modules * importing compatibility modules such as ``six`` (so we don't have to add them to Pacemaker's dependencies) +.. index:: + pair: Python; whitespace + Formatting Python Code ###################### -.. index:: Python; 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 significantly impacts readability. For Python, this limitation is flexible since breaking a line often impacts readability, but definitely keep it under 120 characters. * Where not conflicting with this style guide, it is recommended (but not required) to follow `PEP 8 `_. * It is recommended (but not required) to format Python code such that ``pylint --disable=line-too-long,too-many-lines,too-many-instance-attributes,too-many-arguments,too-many-statements`` produces minimal complaints (even better if you don't need to disable all those checks). diff --git a/doc/sphinx/Pacemaker_Explained/alerts.rst b/doc/sphinx/Pacemaker_Explained/alerts.rst index baa121edc8..32afcc6c59 100644 --- a/doc/sphinx/Pacemaker_Explained/alerts.rst +++ b/doc/sphinx/Pacemaker_Explained/alerts.rst @@ -1,422 +1,496 @@ +.. index:: + single: alert + single: resource; alert + single: node; alert + single: fencing; alert + pair: XML element; alert + pair: XML element; alerts + Alerts ------ -.. Convert_to_RST: - - anchor:ch-alerts[Chapter 7, Alerts] - indexterm:[Resource,Alerts] - - 'Alerts' may be configured to take some external action when a cluster event - occurs (node failure, resource starting or stopping, etc.). - - - == 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.). - - - .Simple alert configuration - ===== - [source,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. - - == 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. - - .Alert configuration with recipient - ===== - [source,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. - - - == Alert Meta-Attributes == - - As with resource agents, meta-attributes can be configured for alert agents - to affect how Pacemaker calls them. - - .Meta-Attributes of an Alert - - [width="95%",cols="m,1,<2",options="header",align="center"] - |========================================================= +*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. - |Meta-Attribute - |Default - |Description + +.. index:: + single: alert; recipient + pair: XML element; recipient + +Alert Recipients +################ - |timestamp-format - |%H:%M:%S.%06N - |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. - indexterm:[Alert,Option,timestamp-format] - - |timeout - |30s - |If the alert agent does not complete within this amount of time, it will be - terminated. - indexterm:[Alert,Option,timeout] +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. - Meta-attributes can be configured per alert agent and/or per recipient. - .Alert configuration with meta-attributes - ===== - [source,XML] - ----- - - - +.. index:: + single: alert; meta-attributes + single: meta-attribute; alert meta-attributes + +Alert Meta-Attributes +##################### + +As with resource agents, meta-attributes can be configured for alert agents +to affect how Pacemaker calls them. + +.. table:: **Meta-Attributes of an Alert** + + +------------------+---------------+-----------------------------------------------------+ + | Meta-Attribute | Default | Description | + +==================+===============+=====================================================+ + | timestamp-format | %H:%M:%S.%06N | .. 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. | + +------------------+---------------+-----------------------------------------------------+ + | 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 agent 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+. - - - == 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. - - .Alert configuration with instance attributes - ===== - [source,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 + + + + - + - + - - - - - ----- - ===== - - - == 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 configuration to receive only node events and fencing events - ===== - [source,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. + +.. topic:: Alert configuration to receive only node events and fencing events + + .. code-block:: xml + + + + - - - - - ----- - ===== - - The possible options within +`` are ````, +````, ````, and ````. + +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. + + + +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. - == Using the Sample 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. +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. +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. - .Sending cluster events as SNMP traps - ===== - [source,XML] - ----- - - - +.. topic:: Sending cluster events as SNMP traps + + .. code-block:: xml + + + + - + - + - - - - ----- - ===== - - .Sending cluster events as e-mails - ===== - [source,XML] - ----- - - - - - - - - - - - ----- - ===== - - - == Writing an Alert Agent == - - .Environment variables passed to alert agents - - [width="95%",cols="m,<2",options="header",align="center"] - |========================================================= - - |Environment Variable - |Description - - |CRM_alert_kind - |The type of alert (+node+, +fencing+, +resource+, or +attribute+) - indexterm:[Environment Variable,CRM_alert_,kind] - - |CRM_alert_version - |The version of Pacemaker sending the alert - indexterm:[Environment Variable,CRM_alert_,version] - - |CRM_alert_recipient - |The configured recipient - indexterm:[Environment Variable,CRM_alert_,recipient] - - |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. - Be aware that this number has no cluster-wide meaning. - indexterm:[Environment Variable,CRM_alert_node_,sequence] - - |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.). - indexterm:[Environment Variable,CRM_alert_,timestamp] - - |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. - indexterm:[Environment Variable,CRM_alert_,timestamp_epoch] - - |CRM_alert_timestamp_usec - |The same time as +CRM_alert_timestamp+, expressed as the integer number of - microseconds since +CRM_alert_timestamp_epoch+. - indexterm:[Environment Variable,CRM_alert_,timestamp_usec] - - |CRM_alert_node - |Name of affected node - indexterm:[Environment Variable,CRM_alert_,node] - - |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+. - indexterm:[Environment Variable,CRM_alert_,desc] - - |CRM_alert_nodeid - |ID of node whose status changed (provided with +node+ alerts only) - indexterm:[Environment Variable,CRM_alert_,nodeid] - - |CRM_alert_task - |The requested fencing or resource operation - (provided with +fencing+ and +resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,task] - - |CRM_alert_rc - |The numerical return code of the fencing or resource operation - (provided with +fencing+ and +resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,rc] - - |CRM_alert_rsc - |The name of the affected resource (+resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,rsc] - - |CRM_alert_interval - |The interval of the resource operation (+resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,interval] - - |CRM_alert_target_rc - |The expected numerical return code of the operation (+resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,target_rc] - - |CRM_alert_status - |A numerical code used by Pacemaker to represent the operation result - (+resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,status] - - |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. (+resource+ alerts only) - indexterm:[Environment Variable,CRM_alert_,exec_time] - - |CRM_alert_attribute_name - |The name of the node attribute that changed (+attribute+ alerts only) - indexterm:[Environment Variable,CRM_alert_,attribute_name] - - |CRM_alert_attribute_value - |The new value of the node attribute that changed (+attribute+ alerts only) - indexterm:[Environment Variable,CRM_alert_,attribute_value] - - |========================================================= - - 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 +hacluster+ 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 hacluster-level - access to the cluster nodes, it is a potential security concern as well, to - avoid the possibility of code injection. - - [NOTE] - ===== + + + + +.. topic:: Sending cluster events as e-mails + + .. code-block:: xml + + + + + + + + + + + + + +Writing an Alert Agent +###################### + +.. index:: + single: alert; environment variables + single: environment variable; alert agents + +.. table:: **Environment variables passed to alert agents** + + +---------------------------+----------------------------------------------------------------+ + | Environment Variable | Description | + +===========================+================================================================+ + | CRM_alert_kind | .. index:: | + | | single:environment variable; CRM_alert_kind | + | | single:CRM_alert_kind | + | | | + | | The type of alert (``node``, ``fencing``, ``resource``, or | + | | ``attribute``) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_node | .. index:: | + | | single:environment variable; CRM_alert_node | + | | single:CRM_alert_node | + | | | + | | Name of affected node | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_node_sequence | .. index:: | + | | single:environment variable; CRM_alert_sequence | + | | single:CRM_alert_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. | + | | | + | | Be aware that this number has no cluster-wide meaning. | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_recipient | .. index:: | + | | single:environment variable; CRM_alert_recipient | + | | single:CRM_alert_recipient | + | | | + | | The configured recipient | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_timestamp | .. index:: | + | | single:environment variable; CRM_alert_timestamp | + | | single: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.). | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_timestamp_epoch | .. index:: | + | | single:environment variable; CRM_alert_timestamp_epoch | + | | single: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. | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_timestamp_usec | .. index:: | + | | single:environment variable; CRM_alert_timestamp_usec | + | | single:CRM_alert_timestamp_usec | + | | | + | | The same time as ``CRM_alert_timestamp``, expressed as the | + | | integer number of microseconds since | + | | ``CRM_alert_timestamp_epoch``. | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_version | .. index:: | + | | single:environment variable; CRM_alert_version | + | | single:CRM_alert_version | + | | | + | | The version of Pacemaker sending the alert | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_desc | .. index:: | + | | single:environment variable; CRM_alert_desc | + | | single: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``. | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_nodeid | .. index:: | + | | single:environment variable; CRM_alert_nodeid | + | | single:CRM_alert_nodeid | + | | | + | | ID of node whose status changed (provided with ``node`` alerts | + | | only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_rc | .. index:: | + | | single:environment variable; CRM_alert_rc | + | | single:CRM_alert_rc | + | | | + | | The numerical return code of the fencing or resource operation | + | | (provided with ``fencing`` and ``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_task | .. index:: | + | | single:environment variable; CRM_alert_task | + | | single:CRM_alert_task | + | | | + | | The requested fencing or resource operation (provided with | + | | ``fencing`` and ``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_exec_time | .. index:: | + | | single:environment variable; CRM_alert_exec_time | + | | single: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. (``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_interval | .. index:: | + | | single:environment variable; CRM_alert_interval | + | | single:CRM_alert_interval | + | | | + | | The interval of the resource operation (``resource`` alerts | + | | only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_rsc | .. index:: | + | | single:environment variable; CRM_alert_rsc | + | | single:CRM_alert_rsc | + | | | + | | The name of the affected resource (``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_status | .. index:: | + | | single:environment variable; CRM_alert_status | + | | single:CRM_alert_status | + | | | + | | A numerical code used by Pacemaker to represent the operation | + | | result (``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_target_rc | .. index:: | + | | single:environment variable; CRM_alert_target_rc | + | | single:CRM_alert_target_rc | + | | | + | | The expected numerical return code of the operation | + | | (``resource`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_attribute_name | .. index:: | + | | single:environment variable; CRM_alert_attribute_name | + | | single:CRM_alert_attribute_name | + | | | + | | The name of the node attribute that changed (``attribute`` | + | | alerts only) | + +---------------------------+----------------------------------------------------------------+ + | CRM_alert_attribute_value | .. index:: | + | | single:environment variable; CRM_alert_attribute_value | + | | single:CRM_alert_attribute_value | + | | | + | | The new value of the node attribute that changed | + | | (``attribute`` alerts only) | + +---------------------------+----------------------------------------------------------------+ + +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 ``hacluster`` 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 + ``hacluster``-level access to the cluster nodes, it is a potential security + concern as well, to avoid the possibility of code injection. + +.. note:: **ocf:pacemaker:ClusterMon compatibility** + The alerts interface is designed to be backward compatible with the external - scripts interface used by the +ocf:pacemaker:ClusterMon+ resource, which is - now deprecated. To preserve this compatibility, the environment variables - passed to alert agents are available prepended with +CRM_notify_+ - as well as +CRM_alert_+. One break in compatibility is that ClusterMon ran - external scripts as the +root+ user, while alert agents are run as the - +hacluster+ user. - ===== + scripts interface used by the ``ocf:pacemaker:ClusterMon`` resource, which + is now deprecated. To preserve this compatibility, the environment variables + passed to alert agents are available prepended with ``CRM_notify_`` + as well as ``CRM_alert_``. One break in compatibility is that ``ClusterMon`` + ran external scripts as the ``root`` user, while alert agents are run as the + ``hacluster`` user. diff --git a/doc/sphinx/Pacemaker_Remote/alternatives.rst b/doc/sphinx/Pacemaker_Remote/alternatives.rst index b0b8bab720..83ed67cafc 100644 --- a/doc/sphinx/Pacemaker_Remote/alternatives.rst +++ b/doc/sphinx/Pacemaker_Remote/alternatives.rst @@ -1,80 +1,95 @@ Alternative Configurations -------------------------- These alternative configurations may be appropriate in limited cases, such as a test cluster, but are not the best method in most situations. They are presented here for completeness and as an example of Pacemaker's flexibility to suit your needs. +.. index:: + single: virtual machine; as cluster node + Virtual Machines as Cluster Nodes ################################# The preferred use of virtual machines in a Pacemaker cluster is as a cluster resource, whether opaque or as a guest node. However, it is possible to run the full cluster stack on a virtual node instead. This is commonly used to set up test environments; a single physical host (that does not participate in the cluster) runs two or more virtual machines, all running the full cluster stack. This can be used to simulate a larger cluster for testing purposes. In a production environment, fencing becomes more complicated, especially if the underlying hosts run any services besides the clustered VMs. If the VMs are not guaranteed a minimum amount of host resources, CPU and I/O contention can cause timing issues for cluster components. Another situation where this approach is sometimes used is when the cluster owner leases the VMs from a provider and does not have direct access to the underlying host. The main concerns in this case are proper fencing (usually via a custom resource agent that communicates with the provider's APIs) and maintaining a static IP address between reboots, as well as resource contention issues. +.. index:: + single: virtual machine; as remote node + Virtual Machines as Remote Nodes ################################ Virtual machines may be configured following the process for remote nodes rather than guest nodes (i.e., using an **ocf:pacemaker:remote** resource rather than letting the cluster manage the VM directly). This is mainly useful in testing, to use a single physical host to simulate a larger cluster involving remote nodes. Pacemaker's Cluster Test Suite (CTS) uses this approach to test remote node functionality. +.. index:: + single: container; as guest node + single: container; LXC + single: container; Docker + single: container; bundle + single: LXC + single: Docker + single: bundle + Containers as Guest Nodes ######################### `Containers `_ and in particular Linux containers (LXC) and Docker, have become a popular method of isolating services in a resource-efficient manner. The preferred means of integrating containers into Pacemaker is as a -cluster resource, whether opaque or using Pacemaker's 'bundle' resource type. +cluster resource, whether opaque or using Pacemaker's ``bundle`` resource type. -However, it is possible to run `pacemaker_remote` inside a container, +However, it is possible to run ``pacemaker_remote`` inside a container, following the process for guest nodes. This is not recommended but can be useful, for example, in testing scenarios, to simulate a large number of guest nodes. The configuration process is very similar to that described for guest nodes using virtual machines. Key differences: * The underlying host must install the libvirt driver for the desired container technology -- for example, the ``libvirt-daemon-lxc`` package to get the `libvirt-lxc `_ driver for LXC containers. * Libvirt XML definitions must be generated for the containers. The ``pacemaker-cts`` package includes a script for this purpose, ``/usr/share/pacemaker/tests/cts/lxc_autogen.sh``. Run it with the ``--help`` option for details on how to use it. It is intended for testing purposes only, and hardcodes various parameters that would need to be set appropriately in real usage. Of course, you can create XML definitions manually, following the appropriate libvirt driver documentation. * To share the authentication key, either share the host's ``/etc/pacemaker`` directory with the container, or copy the key into the container's filesystem. * The **VirtualDomain** resource for a container will need **force_stop="true"** and an appropriate hypervisor option, for example **hypervisor="lxc:///"** for LXC containers. diff --git a/doc/sphinx/Pacemaker_Remote/baremetal-tutorial.rst b/doc/sphinx/Pacemaker_Remote/baremetal-tutorial.rst index b1ccb24d77..02a86b816d 100644 --- a/doc/sphinx/Pacemaker_Remote/baremetal-tutorial.rst +++ b/doc/sphinx/Pacemaker_Remote/baremetal-tutorial.rst @@ -1,331 +1,341 @@ +.. index:: + single: remote node; walk-through + Remote Node Walk-through ------------------------ **What this tutorial is:** An in-depth walk-through of how to get Pacemaker to integrate a remote node into the cluster as a node capable of running cluster resources. **What this tutorial is not:** A realistic deployment scenario. The steps shown here are meant to get users familiar with the concept of remote nodes as quickly as possible. This tutorial requires three machines: two to act as cluster nodes, and a third to act as the remote node. Configure Remote Node ##################### +.. index:: + single: remote node; firewall + Configure Firewall on Remote Node _________________________________ Allow cluster-related services through the local firewall: .. code-block:: none # 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:: none # setenforce 0 # sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config # systemctl mask firewalld.service # systemctl stop firewalld.service # iptables --flush Configure pacemaker_remote on Remote Node _________________________________________ Install the pacemaker_remote daemon on the remote node. .. code-block:: none # yum install -y pacemaker-remote resource-agents pcs Create a location for the shared authentication key: .. code-block:: none # mkdir -p --mode=0750 /etc/pacemaker # chgrp haclient /etc/pacemaker All nodes (both cluster nodes and remote nodes) must have the same authentication key installed for the communication to work correctly. If you already have a key on an existing node, copy it to the new remote node. Otherwise, create a new key, for example: .. code-block:: none # dd if=/dev/urandom of=/etc/pacemaker/authkey bs=4096 count=1 Now start and enable the pacemaker_remote daemon on the remote node. .. code-block:: none # systemctl enable pacemaker_remote.service # systemctl start pacemaker_remote.service Verify the start is successful. .. code-block:: none # systemctl status pacemaker_remote pacemaker_remote.service - Pacemaker Remote Service Loaded: loaded (/usr/lib/systemd/system/pacemaker_remote.service; enabled) Active: active (running) since Fri 2018-01-12 15:21:20 CDT; 20s ago Main PID: 21273 (pacemaker_remot) CGroup: /system.slice/pacemaker_remote.service └─21273 /usr/sbin/pacemaker-remoted Jan 12 15:21:20 remote1 systemd[1]: Starting Pacemaker Remote Service... Jan 12 15:21:20 remote1 systemd[1]: Started Pacemaker Remote Service. Jan 12 15:21:20 remote1 pacemaker-remoted[21273]: notice: crm_add_logfile: Additional logging available in /var/log/pacemaker.log Jan 12 15:21:20 remote1 pacemaker-remoted[21273]: notice: lrmd_init_remote_tls_server: Starting a tls listener on port 3121. Jan 12 15:21:20 remote1 pacemaker-remoted[21273]: notice: bind_and_listen: Listening on address :: Verify Connection to Remote Node ################################ Before moving forward, it's worth verifying that the cluster nodes can contact the remote node on port 3121. Here's a trick you can use. Connect using ssh from each of the cluster nodes. The connection will get destroyed, but how it is destroyed tells you whether it worked or not. First, add the remote node's hostname (we're using **remote1** in this tutorial) to the cluster nodes' ``/etc/hosts`` files if you haven't already. This is required unless you have DNS set up in a way where remote1's address can be discovered. Execute the following on each cluster node, replacing the IP address with the actual IP address of the remote node. .. code-block:: none # cat << END >> /etc/hosts 192.168.122.10 remote1 END If running the ssh command on one of the cluster nodes results in this output before disconnecting, the connection works: .. code-block:: none # ssh -p 3121 remote1 ssh_exchange_identification: read: Connection reset by peer If you see one of these, the connection is not working: .. code-block:: none # ssh -p 3121 remote1 ssh: connect to host remote1 port 3121: No route to host .. code-block:: none # ssh -p 3121 remote1 ssh: connect to host remote1 port 3121: Connection refused Once you can successfully connect to the remote node from the both cluster nodes, move on to setting up Pacemaker on the cluster nodes. Configure Cluster Nodes ####################### Configure Firewall on Cluster Nodes ___________________________________ On each cluster node, allow cluster-related services through the local firewall, following the same procedure as in `Configure Firewall on Remote Node`_. Install Pacemaker on Cluster Nodes __________________________________ On the two cluster nodes, install the following packages. .. code-block:: none # yum install -y pacemaker corosync pcs resource-agents Copy Authentication Key to Cluster Nodes ________________________________________ Create a location for the shared authentication key, and copy it from any existing node: .. code-block:: none # mkdir -p --mode=0750 /etc/pacemaker # chgrp haclient /etc/pacemaker # scp remote1:/etc/pacemaker/authkey /etc/pacemaker/authkey Configure Corosync on Cluster Nodes ___________________________________ Corosync handles Pacemaker's cluster membership and messaging. The corosync config file is located in ``/etc/corosync/corosync.conf``. That config file must be initialized with information about the two cluster nodes before pacemaker can start. To initialize the corosync config file, execute the following pcs command on both nodes, filling in the information in <> with your nodes' information. .. code-block:: none # pcs cluster setup --force --local --name mycluster Start Pacemaker on Cluster Nodes ________________________________ Start the cluster stack on both cluster nodes using the following command. .. code-block:: none # pcs cluster start Verify corosync membership .. code-block:: none # pcs status corosync Membership information ---------------------- Nodeid Votes Name 1 1 node1 (local) Verify Pacemaker status. At first, the ``pcs cluster status`` output will look like this. .. code-block:: none # pcs status Cluster name: mycluster Stack: corosync Current DC: NONE Last updated: Fri Jan 12 16:14:05 2018 Last change: Fri Jan 12 14:02:14 2018 1 node configured 0 resources configured After about a minute, you should see your two cluster nodes come online. .. code-block:: none # pcs status Cluster name: mycluster Stack: corosync Current DC: node1 (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 16:16:32 2018 Last change: Fri Jan 12 14:02:14 2018 2 nodes configured 0 resources configured Online: [ node1 node2 ] For the sake of this tutorial, we are going to disable stonith to avoid having to cover fencing device configuration. .. code-block:: none # pcs property set stonith-enabled=false Integrate Remote Node into Cluster ################################## Integrating a remote node into the cluster is achieved through the creation of a remote node connection resource. The remote node connection resource both establishes the connection to the remote node and defines that the remote node exists. Note that this resource is actually internal to Pacemaker's controller. A metadata file for this resource can be found in the ``/usr/lib/ocf/resource.d/pacemaker/remote`` file that describes what options are available, but there is no actual **ocf:pacemaker:remote** resource agent script that performs any work. Define the remote node connection resource to our remote node, **remote1**, using the following command on any cluster node. .. code-block:: none # pcs resource create remote1 ocf:pacemaker:remote That's it. After a moment you should see the remote node come online. .. code-block:: none Cluster name: mycluster Stack: corosync Current DC: node1 (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 17:13:09 2018 Last change: Fri Jan 12 17:02:02 2018 3 nodes configured 1 resources configured Online: [ node1 node2 ] RemoteOnline: [ remote1 ] Full list of resources: remote1 (ocf::pacemaker:remote): Started node1 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Starting Resources on Remote Node ################################# Once the remote node is integrated into the cluster, starting resources on a remote node is the exact same as on cluster nodes. Refer to the `Clusters from Scratch `_ document for examples of resource creation. .. WARNING:: Never involve a remote node connection resource in a resource group, colocation constraint, or order constraint. + +.. index:: + single: remote node; fencing + Fencing Remote Nodes #################### Remote nodes are fenced the same way as cluster nodes. No special considerations are required. Configure fencing resources for use with remote nodes the same as you would with cluster nodes. Note, however, that remote nodes can never 'initiate' a fencing action. Only cluster nodes are capable of actually executing a fencing operation against another node. Accessing Cluster Tools from a Remote Node ########################################## Besides allowing the cluster to manage resources on a remote node, pacemaker_remote has one other trick. The pacemaker_remote daemon allows nearly all the pacemaker tools (``crm_resource``, ``crm_mon``, ``crm_attribute``, ``crm_master``, etc.) to work on remote nodes natively. Try it: Run ``crm_mon`` on the remote node after pacemaker has integrated it into the cluster. These tools just work. These means resource agents such as promotable resources (which need access to tools like ``crm_master``) work seamlessly on the remote nodes. Higher-level command shells such as ``pcs`` may have partial support on remote nodes, but it is recommended to run them from a cluster node. diff --git a/doc/sphinx/Pacemaker_Remote/example.rst b/doc/sphinx/Pacemaker_Remote/example.rst index 196fc01746..7493c97d82 100644 --- a/doc/sphinx/Pacemaker_Remote/example.rst +++ b/doc/sphinx/Pacemaker_Remote/example.rst @@ -1,134 +1,133 @@ +.. index:: + single: guest node; example + Guest Node Quick Example ------------------------ If you already know how to use Pacemaker, you'll likely be able to grasp this new concept of guest nodes by reading through this quick example without having to sort through all the detailed walk-through steps. Here are the key configuration ingredients that make this possible using libvirt and KVM virtual guests. These steps strip everything down to the very basics. -.. index:: - single: guest node - pair: node; guest node - Mile-High View of Configuration Steps ##################################### * Give each virtual machine that will be used as a guest node a static network address and unique hostname. * Put the same authentication key with the path ``/etc/pacemaker/authkey`` on every cluster node and virtual machine. This secures remote communication. Run this command if you want to make a somewhat random key: .. code-block:: none # dd if=/dev/urandom of=/etc/pacemaker/authkey bs=4096 count=1 * Install pacemaker_remote on every virtual machine, enabling it to start at boot, and if a local firewall is used, allow the node to accept connections on TCP port 3121. .. code-block:: none # yum install pacemaker-remote resource-agents # systemctl enable pacemaker_remote # firewall-cmd --add-port 3121/tcp --permanent .. NOTE:: If you just want to see this work, you may want to simply disable the local firewall and put SELinux in permissive mode while testing. This creates security risks and should not be done on a production machine exposed to the Internet, but can be appropriate for a protected test machine. * Create a Pacemaker resource to launch each virtual machine, using the **remote-node** meta-attribute to let Pacemaker know this will be a guest node capable of running resources. .. code-block:: none # pcs resource create vm-guest1 VirtualDomain hypervisor="qemu:///system" config="vm-guest1.xml" meta remote-node="guest1" The above command will create CIB XML similar to the following: .. code-block:: xml In the example above, the meta-attribute **remote-node="guest1"** tells Pacemaker that this resource is a guest node with the hostname **guest1**. The cluster will attempt to contact the virtual machine's pacemaker_remote service at the hostname **guest1** after it launches. .. NOTE:: The ID of the resource creating the virtual machine (**vm-guest1** in the above example) 'must' be different from the virtual machine's uname (**guest1** in the above example). Pacemaker will create an implicit internal resource for the pacemaker_remote connection to the guest, named with the value of **remote-node**, so that value cannot be used as the name of any other resource. Using a Guest Node ================== Guest nodes will show up in ``crm_mon`` output as normal. For example, this is the ``crm_mon`` output after **guest1** is integrated into the cluster: .. code-block:: none Stack: corosync Current DC: node1 (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 13:52:39 2018 Last change: Fri Jan 12 13:25:17 2018 via pacemaker-controld on node1 2 nodes configured 2 resources configured Online: [ node1 guest1] vm-guest1 (ocf::heartbeat:VirtualDomain): Started node1 Now, you could place a resource, such as a webserver, on **guest1**: .. code-block:: none # pcs resource create webserver apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=30s # pcs constraint location webserver prefers guest1 Now, the crm_mon output would show: .. code-block:: none Stack: corosync Current DC: node1 (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 13:52:39 2018 Last change: Fri Jan 12 13:25:17 2018 via pacemaker-controld on node1 2 nodes configured 2 resources configured Online: [ node1 guest1] vm-guest1 (ocf::heartbeat:VirtualDomain): Started node1 webserver (ocf::heartbeat::apache): Started guest1 It is worth noting that after **guest1** is integrated into the cluster, nearly all the Pacemaker command-line tools immediately become available to the guest node. This means things like ``crm_mon``, ``crm_resource``, and ``crm_attribute`` will work natively on the guest node, as long as the connection between the guest node and a cluster node exists. This is particularly important for any promotable clone resources executing on the guest node that need access to ``crm_master`` to set transient attributes. diff --git a/doc/sphinx/Pacemaker_Remote/intro.rst b/doc/sphinx/Pacemaker_Remote/intro.rst index 903fbeea4d..361d4fb82d 100644 --- a/doc/sphinx/Pacemaker_Remote/intro.rst +++ b/doc/sphinx/Pacemaker_Remote/intro.rst @@ -1,186 +1,190 @@ Scaling a Pacemaker Cluster --------------------------- Overview ######## In a basic Pacemaker high-availability cluster [#]_ each node runs the full -cluster stack of corosync and all Pacemaker components. This allows great +cluster stack of Corosync and all Pacemaker components. This allows great flexibility but limits scalability to around 16 nodes. To allow for scalability to dozens or even hundreds of nodes, Pacemaker allows nodes not running the full cluster stack to integrate into the cluster and have the cluster manage their resources as if they were a cluster node. Terms ##### +.. index:: + single: cluster node + single: node; cluster node + **cluster node** A node running the full high-availability stack of corosync and all Pacemaker components. Cluster nodes may run cluster resources, run all Pacemaker command-line tools (``crm_mon``, ``crm_resource`` and so on), execute fencing actions, count toward cluster quorum, and serve as the cluster's Designated Controller (DC). - .. index:: - single: cluster node - pair: node; cluster node +.. index:: pacemaker_remoted -**pacemaker_remote** +**pacemaker_remoted** A small service daemon that allows a host to be used as a Pacemaker node - without running the full cluster stack. Nodes running pacemaker_remote + without running the full cluster stack. Nodes running ``pacemaker_remoted`` 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. The pacemaker_remote daemon is an enhanced + voting, or DC eligibility. The ``pacemaker_remoted`` daemon is an enhanced version of Pacemaker's local resource management daemon (LRMD). - .. index:: - single: pacemaker_remote +.. index:: + single: remote node + single: node; remote node + +**pacemaker_remote** + The name of the systemd service that manages ``pacemaker_remoted`` + +**Pacemaker Remote** + A way to refer to the general technology implementing nodes running + ``pacemaker_remoted``, including the cluster-side implementation + and the communication protocol between them. **remote node** - A physical host running pacemaker_remote. Remote nodes have a special + A physical host running ``pacemaker_remoted``. Remote nodes have a special resource that manages communication with the cluster. This is sometimes - referred to as the 'baremetal' case. + referred to as the *bare metal* case. - .. index:: - single: remote node - pair: node; remote node +.. index:: + single: guest node + single: node; guest node **guest node** - A virtual host running pacemaker_remote. Guest nodes differ from remote + A virtual host running ``pacemaker_remoted``. Guest nodes differ from remote nodes mainly in that the guest node is itself a resource that the cluster manages. - .. index:: - single: guest node - pair: node; guest node - .. NOTE:: - 'Remote' in this document refers to the node not being a part of the underlying + *Remote* in this document refers to the node not being a part of the underlying corosync cluster. It has nothing to do with physical proximity. Remote nodes and guest nodes are subject to the same latency requirements as cluster nodes, which means they are typically in the same data center. .. 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 resource, without the cluster having any awareness of the services running inside the virtual - machine. The virtual machine is 'opaque' to the cluster. - * A virtual machine can be a cluster resource, and run pacemaker_remote + machine. The virtual machine is *opaque* to the cluster. + * A virtual machine can be a cluster resource, and run ``pacemaker_remoted`` to make it a guest node, allowing the cluster to manage services - inside it. The virtual machine is 'transparent' to the cluster. + inside it. The virtual machine is *transparent* to the cluster. + +.. index:: + single: virtual machine; as guest node Guest Nodes ########### -.. index:: - single: guest node - pair: node; guest node - **"I want a Pacemaker cluster to manage virtual machine resources, but I also want Pacemaker to be able to manage the resources that live within those virtual machines."** -Without pacemaker_remote, the possibilities for implementing the above use case -have significant limitations: +Without ``pacemaker_remoted``, the possibilities for implementing the above use +case have significant limitations: * The cluster stack could be run on the physical hosts only, which loses the ability to monitor resources within the guests. * A separate cluster could be on the virtual guests, which quickly hits scalability issues. * The cluster stack could be run on the guests using the same cluster as the physical hosts, which also hits scalability issues and complicates fencing. -With pacemaker_remote: +With ``pacemaker_remoted``: * The physical hosts are cluster nodes (running the full cluster stack). -* The virtual machines are guest nodes (running the pacemaker_remote service). +* The virtual machines are guest nodes (running ``pacemaker_remoted``). Nearly zero configuration is required on the virtual machine. * The cluster stack on the cluster nodes launches the virtual machines and - immediately connects to the pacemaker_remote service on them, allowing the + immediately connects to ``pacemaker_remoted`` on them, allowing the virtual machines to integrate into the cluster. The key difference here between the guest nodes and the cluster nodes is that the guest nodes do not run the cluster stack. This means they will never become the DC, initiate fencing actions or participate in quorum voting. On the other hand, this also means that they are not bound to the scalability limits associated with the cluster stack (no 16-node corosync member limits to deal with). That isn't to say that guest nodes can scale indefinitely, but it is known that guest nodes scale horizontally much further than cluster nodes. Other than the quorum limitation, these guest nodes behave just like cluster nodes with respect to resource management. The cluster is fully capable of managing and monitoring resources on each guest node. You can build constraints against guest nodes, put them in standby, or do whatever else you'd expect to be able to do with cluster nodes. They even show up in ``crm_mon`` output as nodes. To solidify the concept, below is an example that is very similar to an actual deployment we test in our developer environment to verify guest node scalability: -* 16 cluster nodes running the full corosync + pacemaker stack -* 64 Pacemaker-managed virtual machine resources running pacemaker_remote configured as guest nodes -* 64 Pacemaker-managed webserver and database resources configured to run on the 64 guest nodes +* 16 cluster nodes running the full Corosync + Pacemaker stack +* 64 Pacemaker-managed virtual machine resources running ``pacemaker_remoted`` + configured as guest nodes +* 64 Pacemaker-managed webserver and database resources configured to run on + the 64 guest nodes With this deployment, you would have 64 webservers and databases running on 64 virtual machines on 16 hardware nodes, all of which are managed and monitored by -the same Pacemaker deployment. It is known that pacemaker_remote can scale to -these lengths and possibly much further depending on the specific scenario. +the same Pacemaker deployment. It is known that ``pacemaker_remoted`` can scale +to these lengths and possibly much further depending on the specific scenario. Remote Nodes ############ -.. index:: - single: remote node - pair: node; remote node - **"I want my traditional high-availability cluster to scale beyond the limits imposed by the corosync messaging layer."** Ultimately, the primary advantage of remote nodes over cluster nodes is scalability. There are likely some other use cases related to geographically distributed HA clusters that remote nodes may serve a purpose in, but those use cases are not well understood at this point. Like guest nodes, remote nodes will never become the DC, initiate fencing actions or participate in quorum voting. That is not to say, however, that fencing of a remote node works any differently than that of a cluster node. The Pacemaker scheduler understands how to fence remote nodes. As long as a fencing device exists, the cluster is capable of ensuring remote nodes are fenced in the exact same way as cluster nodes. Expanding the Cluster Stack ########################### -With pacemaker_remote, the traditional view of the high-availability stack can -be expanded to include a new layer: +With ``pacemaker_remoted``, the traditional view of the high-availability stack +can be expanded to include a new layer: Traditional HA Stack ____________________ .. image:: images/pcmk-ha-cluster-stack.png :width: 17cm :height: 9cm :alt: Traditional Pacemaker+Corosync Stack :align: center HA Stack With Guest Nodes _________________________ .. image:: images/pcmk-ha-remote-stack.png :width: 20cm :height: 10cm - :alt: Pacemaker+Corosync Stack with pacemaker_remote + :alt: Pacemaker+Corosync Stack with pacemaker_remoted :align: center -.. [#] See the ``_ Pacemaker documentation, - especially 'Clusters From Scratch' and 'Pacemaker Explained'. +.. [#] See the ``_ Pacemaker documentation, + especially *Clusters From Scratch* and *Pacemaker Explained*. diff --git a/doc/sphinx/Pacemaker_Remote/kvm-tutorial.rst b/doc/sphinx/Pacemaker_Remote/kvm-tutorial.rst index 82b7e61982..210af8021a 100644 --- a/doc/sphinx/Pacemaker_Remote/kvm-tutorial.rst +++ b/doc/sphinx/Pacemaker_Remote/kvm-tutorial.rst @@ -1,614 +1,623 @@ +.. index:: + single: guest node; walk-through + Guest Node Walk-through ----------------------- **What this tutorial is:** An in-depth walk-through of how to get Pacemaker to manage a KVM guest instance and integrate that guest into the cluster as a guest node. **What this tutorial is not:** A realistic deployment scenario. The steps shown here are meant to get users familiar with the concept of guest nodes as quickly as possible. Configure the Physical Host ########################### .. NOTE:: For this example, we will use a single physical host named **example-host**. A production cluster would likely have multiple physical hosts, in which case you would run the commands here on each one, unless noted otherwise. Configure Firewall on Host __________________________ On the physical host, allow cluster-related services through the local firewall: .. code-block:: none # 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:: none [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 Install Cluster Software ________________________ .. code-block:: none # yum install -y pacemaker corosync pcs resource-agents Configure Corosync __________________ Corosync handles pacemaker's cluster membership and messaging. The corosync config file is located in ``/etc/corosync/corosync.conf``. That config file must be initialized with information about the cluster nodes before pacemaker can start. To initialize the corosync config file, execute the following ``pcs`` command, replacing the cluster name and hostname as desired: .. code-block:: none # pcs cluster setup --force --local --name mycluster example-host .. NOTE:: If you have multiple physical hosts, you would execute the setup command on only one host, but list all of them at the end of the command. Configure Pacemaker for Remote Node Communication _________________________________________________ Create a place to hold an authentication key for use with pacemaker_remote: .. code-block:: none # mkdir -p --mode=0750 /etc/pacemaker # chgrp haclient /etc/pacemaker Generate a key: .. code-block:: none # dd if=/dev/urandom of=/etc/pacemaker/authkey bs=4096 count=1 .. NOTE:: If you have multiple physical hosts, you would generate the key on only one host, and copy it to the same location on all hosts. Verify Cluster Software _______________________ Start the cluster .. code-block:: none # pcs cluster start Verify corosync membership .. code-block:: none # pcs status corosync Membership information ---------------------- Nodeid Votes Name 1 1 example-host (local) Verify pacemaker status. At first, the output will look like this: .. code-block:: none # pcs status Cluster name: mycluster WARNING: no stonith devices and stonith-enabled is not false Stack: corosync Current DC: NONE Last updated: Fri Jan 12 15:18:32 2018 Last change: Fri Jan 12 12:42:21 2018 by root via cibadmin on example-host 1 node configured 0 resources configured Node example-host: UNCLEAN (offline) No active resources Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled After a short amount of time, you should see your host as a single node in the cluster: .. code-block:: none # pcs status Cluster name: mycluster WARNING: no stonith devices and stonith-enabled is not false Stack: corosync Current DC: example-host (version 1.1.16-12.el7_4.5-94ff4df) - partition WITHOUT quorum Last updated: Fri Jan 12 15:20:05 2018 Last change: Fri Jan 12 12:42:21 2018 by root via cibadmin on example-host 1 node configured 0 resources configured Online: [ example-host ] No active resources Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Disable STONITH and Quorum __________________________ Now, enable the cluster to work without quorum or stonith. This is required for the sake of getting this tutorial to work with a single cluster node. .. code-block:: none # pcs property set stonith-enabled=false # pcs property set no-quorum-policy=ignore .. WARNING:: The use of ``stonith-enabled=false`` is completely inappropriate for a production cluster. It tells the cluster to simply pretend that failed nodes are safely powered off. Some vendors will refuse to support clusters that have STONITH disabled. We disable STONITH here only to focus the discussion on pacemaker_remote, and to be able to use a single physical host in the example. Now, the status output should look similar to this: .. code-block:: none # pcs status Cluster name: mycluster Stack: corosync Current DC: example-host (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 15:22:49 2018 Last change: Fri Jan 12 15:22:46 2018 by root via cibadmin on example-host 1 node configured 0 resources configured Online: [ example-host ] No active resources Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Go ahead and stop the cluster for now after verifying everything is in order. .. code-block:: none # pcs cluster stop --force Install Virtualization Software _______________________________ .. code-block:: none # yum install -y kvm libvirt qemu-system qemu-kvm bridge-utils virt-manager # systemctl enable libvirtd.service Reboot the host. .. NOTE:: While KVM is used in this example, any virtualization platform with a Pacemaker resource agent can be used to create a guest node. The resource agent needs only to support usual commands (start, stop, etc.); Pacemaker implements the **remote-node** meta-attribute, independent of the agent. Configure the KVM guest ####################### Create Guest ____________ We will not outline here the installation steps required to create a KVM guest. There are plenty of tutorials available elsewhere that do that. Just be sure to configure the guest with a hostname and a static IP address (as an example here, we will use guest1 and 192.168.122.10). +.. index:: + single: guest node; firewall + Configure Firewall on Guest ___________________________ On each guest, allow cluster-related services through the local firewall, following the same procedure as in `Configure Firewall on Host`_. Verify Connectivity ___________________ At this point, you should be able to ping and ssh into guests from hosts, and vice versa. -Configure pacemaker_remote -__________________________ +Configure pacemaker_remoted +___________________________ -Install pacemaker_remote, and enable it to run at start-up. Here, we also -install the pacemaker package; it is not required, but it contains the dummy -resource agent that we will use later for testing. +Install ``pacemaker_remoted``, and enable it to run at start-up. Here, we also +install the ``pacemaker`` package; it is not required, but it contains the +dummy resource agent that we will use later for testing. .. code-block:: none # yum install -y pacemaker pacemaker-remote resource-agents # systemctl enable pacemaker_remote.service Copy the authentication key from a host: .. code-block:: none # mkdir -p --mode=0750 /etc/pacemaker # chgrp haclient /etc/pacemaker # scp root@example-host:/etc/pacemaker/authkey /etc/pacemaker -Start pacemaker_remote, and verify the start was successful: +Start ``pacemaker_remoted``, and verify the start was successful: .. code-block:: none # systemctl start pacemaker_remote # systemctl status pacemaker_remote pacemaker_remote.service - Pacemaker Remote Service Loaded: loaded (/usr/lib/systemd/system/pacemaker_remote.service; enabled) Active: active (running) since Thu 2013-03-14 18:24:04 EDT; 2min 8s ago Main PID: 1233 (pacemaker_remot) CGroup: name=systemd:/system/pacemaker_remote.service └─1233 /usr/sbin/pacemaker-remoted Mar 14 18:24:04 guest1 systemd[1]: Starting Pacemaker Remote Service... Mar 14 18:24:04 guest1 systemd[1]: Started Pacemaker Remote Service. Mar 14 18:24:04 guest1 pacemaker-remoted[1233]: notice: lrmd_init_remote_tls_server: Starting a tls listener on port 3121. Verify Host Connection to Guest _______________________________ Before moving forward, it's worth verifying that the host can contact the guest on port 3121. Here's a trick you can use. Connect using ssh from the host. The connection will get destroyed, but how it is destroyed tells you whether it worked or not. -First add guest1 to the host machine's +/etc/hosts+ file if you haven't -already. This is required unless you have DNS setup in a way where guest1's +First add guest1 to the host machine's ``/etc/hosts`` file if you haven't +already. This is required unless you have DNS setup in a way where **guest1**'s address can be discovered. .. code-block:: none # cat << END >> /etc/hosts 192.168.122.10 guest1 END -If running the ssh command on one of the cluster nodes results in this +If running the ``ssh`` command on one of the cluster nodes results in this output before disconnecting, the connection works: .. code-block:: none # ssh -p 3121 guest1 ssh_exchange_identification: read: Connection reset by peer If you see one of these, the connection is not working: .. code-block:: none # ssh -p 3121 guest1 ssh: connect to host guest1 port 3121: No route to host .. code-block:: none # ssh -p 3121 guest1 ssh: connect to host guest1 port 3121: Connection refused -Once you can successfully connect to the guest from the host, shutdown the guest. Pacemaker will be managing the virtual machine from this point forward. +Once you can successfully connect to the guest from the host, shutdown the +guest. Pacemaker will be managing the virtual machine from this point forward. Integrate Guest into Cluster ############################ -Now the fun part, integrating the virtual machine you've just created into the cluster. It is incredibly simple. +Now the fun part, integrating the virtual machine you've just created into the +cluster. It is incredibly simple. Start the Cluster _________________ -On the host, start pacemaker. +On the host, start Pacemaker. .. code-block:: none # pcs cluster start Wait for the host to become the DC. The output of ``pcs status`` should look as it did in `Disable Stonith and Quorum`_. Integrate as Guest Node _______________________ If you didn't already do this earlier in the verify host to guest connection section, add the KVM guest's IP address to the host's ``/etc/hosts`` file so we can connect by hostname. For this example: .. code-block:: none # cat << END >> /etc/hosts 192.168.122.10 guest1 END We will use the **VirtualDomain** resource agent for the management of the virtual machine. This agent requires the virtual machine's XML config to be dumped to a file on disk. To do this, pick out the name of the virtual machine you just created from the output of this list. .. code-block:: none # virsh list --all Id Name State ---------------------------------------------------- - guest1 shut off -In my case I named it guest1. Dump the xml to a file somewhere on the host using the following command. +In my case I named it **guest1**. Dump the XML to a file somewhere on the host +using the following command. .. code-block:: none # virsh dumpxml guest1 > /etc/pacemaker/guest1.xml -Now just register the resource with pacemaker and you're set! +Now just register the resource with Pacemaker, and you're set! .. code-block:: none # pcs resource create vm-guest1 VirtualDomain hypervisor="qemu:///system" \ config="/etc/pacemaker/guest1.xml" meta remote-node=guest1 .. NOTE:: - This example puts the guest XML under /etc/pacemaker because the + This example puts the guest XML under ``/etc/pacemaker`` because the permissions and SELinux labeling should not need any changes. If you run into trouble with this or any step, try disabling SELinux with ``setenforce 0``. If it works after that, see SELinux documentation for how to troubleshoot, if you wish to reenable SELinux. .. NOTE:: Pacemaker will automatically monitor pacemaker_remote connections for failure, - so it is not necessary to create a recurring monitor on the VirtualDomain + so it is not necessary to create a recurring monitor on the **VirtualDomain** resource. Once the **vm-guest1** resource is started you will see **guest1** appear in the ``pcs status`` output as a node. The final ``pcs status`` output should look something like this. .. code-block:: none # pcs status Cluster name: mycluster Stack: corosync Current DC: example-host (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 18:00:45 2018 Last change: Fri Jan 12 17:53:44 2018 by root via crm_resource on example-host 2 nodes configured 2 resources configured Online: [ example-host ] GuestOnline: [ guest1@example-host ] Full list of resources: vm-guest1 (ocf::heartbeat:VirtualDomain): Started example-host Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Starting Resources on KVM Guest _______________________________ The commands below demonstrate how resources can be executed on both the guest node and the cluster node. Create a few Dummy resources. Dummy resources are real resource agents used just for testing purposes. They actually execute on the host they are assigned to just like an apache server or database would, except their execution just means a file was created. When the resource is stopped, that the file it created is removed. .. code-block:: none # pcs resource create FAKE1 ocf:pacemaker:Dummy # pcs resource create FAKE2 ocf:pacemaker:Dummy # pcs resource create FAKE3 ocf:pacemaker:Dummy # pcs resource create FAKE4 ocf:pacemaker:Dummy # pcs resource create FAKE5 ocf:pacemaker:Dummy Now check your ``pcs status`` output. In the resource section, you should see something like the following, where some of the resources started on the cluster node, and some started on the guest node. .. code-block:: none Full list of resources: vm-guest1 (ocf::heartbeat:VirtualDomain): Started example-host FAKE1 (ocf::pacemaker:Dummy): Started guest1 FAKE2 (ocf::pacemaker:Dummy): Started guest1 FAKE3 (ocf::pacemaker:Dummy): Started example-host FAKE4 (ocf::pacemaker:Dummy): Started guest1 FAKE5 (ocf::pacemaker:Dummy): Started example-host The guest node, **guest1**, reacts just like any other node in the cluster. For example, pick out a resource that is running on your cluster node. For my purposes, I am picking FAKE3 from the output above. We can force FAKE3 to run on **guest1** in the exact same way we would any other node. .. code-block:: none # pcs constraint location FAKE3 prefers guest1 Now, looking at the bottom of the `pcs status` output you'll see FAKE3 is on **guest1**. .. code-block:: none Full list of resources: vm-guest1 (ocf::heartbeat:VirtualDomain): Started example-host FAKE1 (ocf::pacemaker:Dummy): Started guest1 FAKE2 (ocf::pacemaker:Dummy): Started guest1 FAKE3 (ocf::pacemaker:Dummy): Started guest1 FAKE4 (ocf::pacemaker:Dummy): Started example-host FAKE5 (ocf::pacemaker:Dummy): Started example-host Testing Recovery and Fencing ____________________________ Pacemaker's scheduler is smart enough to know fencing guest nodes associated with a virtual machine means shutting off/rebooting the virtual machine. No special configuration is necessary to make this happen. If you are interested in testing this functionality out, trying stopping the guest's pacemaker_remote daemon. This would be equivalent of abruptly terminating a cluster node's corosync membership without properly shutting it down. ssh into the guest and run this command. .. code-block:: none # kill -9 $(pidof pacemaker-remoted) Within a few seconds, your ``pcs status`` output will show a monitor failure, and the **guest1** node will not be shown while it is being recovered. .. code-block:: none # pcs status Cluster name: mycluster Stack: corosync Current DC: example-host (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 18:08:35 2018 Last change: Fri Jan 12 18:07:00 2018 by root via cibadmin on example-host 2 nodes configured 7 resources configured Online: [ example-host ] Full list of resources: vm-guest1 (ocf::heartbeat:VirtualDomain): Started example-host FAKE1 (ocf::pacemaker:Dummy): Stopped FAKE2 (ocf::pacemaker:Dummy): Stopped FAKE3 (ocf::pacemaker:Dummy): Stopped FAKE4 (ocf::pacemaker:Dummy): Started example-host FAKE5 (ocf::pacemaker:Dummy): Started example-host Failed Actions: * guest1_monitor_30000 on example-host 'unknown error' (1): call=8, status=Error, exitreason='none', last-rc-change='Fri Jan 12 18:08:29 2018', queued=0ms, exec=0ms Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled .. NOTE:: A guest node involves two resources: the one you explicitly configured creates the guest, and Pacemaker creates an implicit resource for the pacemaker_remote connection, which will be named the same as the value of the **remote-node** attribute of the explicit resource. When we killed pacemaker_remote, it is the implicit resource that failed, which is why the failed action starts with **guest1** and not **vm-guest1**. Once recovery of the guest is complete, you'll see it automatically get re-integrated into the cluster. The final ``pcs status`` output should look something like this. .. code-block:: none Cluster name: mycluster Stack: corosync Current DC: example-host (version 1.1.16-12.el7_4.5-94ff4df) - partition with quorum Last updated: Fri Jan 12 18:18:30 2018 Last change: Fri Jan 12 18:07:00 2018 by root via cibadmin on example-host 2 nodes configured 7 resources configured Online: [ example-host ] GuestOnline: [ guest1@example-host ] Full list of resources: vm-guest1 (ocf::heartbeat:VirtualDomain): Started example-host FAKE1 (ocf::pacemaker:Dummy): Started guest1 FAKE2 (ocf::pacemaker:Dummy): Started guest1 FAKE3 (ocf::pacemaker:Dummy): Started guest1 FAKE4 (ocf::pacemaker:Dummy): Started example-host FAKE5 (ocf::pacemaker:Dummy): Started example-host Failed Actions: * guest1_monitor_30000 on example-host 'unknown error' (1): call=8, status=Error, exitreason='none', last-rc-change='Fri Jan 12 18:08:29 2018', queued=0ms, exec=0ms Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled Normally, once you've investigated and addressed a failed action, you can clear the failure. However Pacemaker does not yet support cleanup for the implicitly created connection resource while the explicit resource is active. If you want to clear the failed action from the status output, stop the guest resource before clearing it. For example: .. code-block:: none # pcs resource disable vm-guest1 --wait # pcs resource cleanup guest1 # pcs resource enable vm-guest1 Accessing Cluster Tools from Guest Node _______________________________________ Besides allowing the cluster to manage resources on a guest node, pacemaker_remote has one other trick. The pacemaker_remote daemon allows nearly all the pacemaker tools (``crm_resource``, ``crm_mon``, ``crm_attribute``, ``crm_master``, etc.) to work on guest nodes natively. Try it: Run ``crm_mon`` on the guest after pacemaker has integrated the guest node into the cluster. These tools just work. This means resource agents such as promotable resources (which need access to tools like ``crm_master``) work seamlessly on the guest nodes. Higher-level command shells such as ``pcs`` may have partial support on guest nodes, but it is recommended to run them from a cluster node. diff --git a/doc/sphinx/Pacemaker_Remote/options.rst b/doc/sphinx/Pacemaker_Remote/options.rst index 86b632446b..c855a1aedd 100644 --- a/doc/sphinx/Pacemaker_Remote/options.rst +++ b/doc/sphinx/Pacemaker_Remote/options.rst @@ -1,134 +1,146 @@ +.. index:: + single: configuration + Configuration Explained ----------------------- The walk-through examples use some of these options, but don't explain exactly what they mean or do. This section is meant to be the go-to resource for all -the options available for configuring pacemaker_remote-based nodes. +the options available for configuring Pacemaker Remote. .. index:: - single: configuration + pair: configuration; guest node + single: guest node; meta-attribute Resource Meta-Attributes for 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 metadata -parameters. +**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 pacemaker_remote daemon and cluster resources. An additional requirement is that fencing the host running the guest node resource must be sufficient for ensuring the guest node is stopped. This means, for example, that not all -hypervisors supported by VirtualDomain may be used to create guest nodes; if -the guest can survive the hypervisor being fenced, it may not be used as a +hypervisors supported by **VirtualDomain** may be used to create guest nodes; +if the guest can survive the hypervisor being fenced, it may not be used as a guest node. -Below are the metadata options available to enable a resource as a guest node +Below are the meta-attributes available to enable a resource as a guest node and define its connection parameters. .. table:: **Meta-attributes for configuring VM resources as guest nodes** +------------------------+-----------------+-----------------------------------------------------------+ | Option | Default | Description | +========================+=================+===========================================================+ | remote-node | none | The node name of the guest node this resource defines. | | | | This both enables the resource as a guest node and | | | | defines the unique name used to identify the guest node. | | | | If no other parameters are set, this value will also be | | | | assumed as the hostname to use when connecting to | | | | pacemaker_remote on the VM. This value **must not** | | | | overlap with any resource or node IDs. | +------------------------+-----------------+-----------------------------------------------------------+ | remote-port | 3121 | The port on the virtual machine that the cluster will | | | | use to connect to pacemaker_remote. | +------------------------+-----------------+-----------------------------------------------------------+ | remote-addr | 'value of' | The IP address or hostname to use when connecting to | | | ``remote-node`` | pacemaker_remote on the VM. | +------------------------+-----------------+-----------------------------------------------------------+ | remote-connect-timeout | 60s | How long before a pending guest connection will time out. | +------------------------+-----------------+-----------------------------------------------------------+ +.. index:: + pair: configuration; remote node + Connection Resources for Remote Nodes ##################################### A remote node is defined by a connection resource. That connection resource has instance attributes that define where the remote node is located on the network and how to communicate with it. Descriptions of these instance attributes can be retrieved using the following ``pcs`` command: .. code-block:: none # pcs resource describe remote ocf:pacemaker:remote - remote resource agent Resource options: server: Server location to connect to. This can be an ip address or hostname. port: tcp port to connect to. reconnect_interval: Interval in seconds at which Pacemaker will attempt to reconnect to a remote node after an active connection to the remote node has been severed. When this value is nonzero, Pacemaker will retry the connection indefinitely, at the specified interval. When defining a remote node's connection resource, it is common and recommended to name the connection resource the same as the remote node's hostname. By -default, if no **server** option is provided, the cluster will attempt to contact +default, if no ``server`` option is provided, the cluster will attempt to contact the remote node using the resource name as the hostname. Example defining a remote node with the hostname **remote1**: .. code-block:: none # pcs resource create remote1 remote Example defining a remote node to connect to a specific IP address and port: .. code-block:: none # pcs resource create remote1 remote server=192.168.122.200 port=8938 +.. index:: + single: configuration; environment variable + single: environment variable + Environment Variables for Daemon Start-up ######################################### Authentication and encryption of the connection between cluster nodes and nodes running pacemaker_remote is achieved using with `TLS-PSK `_ encryption/authentication over TCP (port 3121 by default). This means that both the cluster node and remote node must share the same private key. By default, this key is placed at ``/etc/pacemaker/authkey`` on each node. You can change the default port and/or key location for Pacemaker and -pacemaker_remote via environment variables. How these variables are set varies -by OS, but usually they are set in the ``/etc/sysconfig/pacemaker`` or +``pacemaker_remoted`` via environment variables. How these variables are set +varies by OS, but usually they are set in the ``/etc/sysconfig/pacemaker`` or ``/etc/default/pacemaker`` file. .. code-block:: none #==#==# Pacemaker Remote # Use a custom directory for finding the authkey. PCMK_authkey_location=/etc/pacemaker/authkey # # Specify a custom port for Pacemaker Remote connections PCMK_remote_port=3121 Removing Remote Nodes and Guest Nodes ##################################### If the resource creating a guest node, or the **ocf:pacemaker:remote** resource creating a connection to a remote node, is removed from the configuration, the affected node will continue to show up in output as an offline node. -If you want to get rid of that output, run (replacing $NODE_NAME appropriately): +If you want to get rid of that output, run (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.