diff --git a/doc/Pacemaker_Explained/en-US/Ap-LSB.txt b/doc/Pacemaker_Explained/en-US/Ap-LSB.txt index 8fa80f2b05..dd479111e3 100644 --- a/doc/Pacemaker_Explained/en-US/Ap-LSB.txt +++ b/doc/Pacemaker_Explained/en-US/Ap-LSB.txt @@ -1,82 +1,82 @@ [appendix] [[ap-lsb]] -== init-Script LSB Compliance == +== Init Script LSB Compliance == -The relevant part of -http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html[LSB spec] +The relevant part of the +http://refspecs.linuxfoundation.org/lsb.shtml[LSB specifications] includes a description of all the return codes listed here. -Assuming +some_service+ is configured correctly and currently not -active, the following sequence will help you determine if it is LSB -compatible: +Assuming `some_service` is configured correctly and currently +inactive, the following sequence will help you determine if it is +LSB-compatible: . Start (stopped): + ---- # /etc/init.d/some_service start ; echo "result: $?" ---- + .. Did the service start? .. Did the command print result: 0 (in addition to the regular output)? + . Status (running): + ---- # /etc/init.d/some_service status ; echo "result: $?" ---- + .. Did the script accept the command? .. Did the script indicate the service was running? .. Did the command print result: 0 (in addition to the regular output)? + . Start (running): + ---- # /etc/init.d/some_service start ; echo "result: $?" ---- + .. Is the service still running? .. Did the command print result: 0 (in addition to the regular output)? + . Stop (running): + ---- # /etc/init.d/some_service stop ; echo "result: $?" ---- + .. Was the service stopped? .. Did the command print result: 0 (in addition to the regular output)? + . Status (stopped): + ---- # /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 command print result: 3 (in addition to the regular output)? + . Stop (stopped): + ---- # /etc/init.d/some_service stop ; echo "result: $?" ---- + .. Is the service still stopped? .. Did the command print result: 0 (in addition to the regular 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/Pacemaker_Explained/en-US/Ap-Upgrade-Config.txt b/doc/Pacemaker_Explained/en-US/Ap-Upgrade-Config.txt index d83618840c..ef2d311fb5 100644 --- a/doc/Pacemaker_Explained/en-US/Ap-Upgrade-Config.txt +++ b/doc/Pacemaker_Explained/en-US/Ap-Upgrade-Config.txt @@ -1,131 +1,123 @@ [appendix] == Upgrading the Configuration from 0.6 == -=== Preparation === indexterm:[Upgrading the Configuration] indexterm:[Configuration,Upgrading] -indexterm:[Download,DTD] -indexterm:[DTD,Download] - -Download the latest -http://hg.clusterlabs.org/pacemaker/stable-1.0/file-raw/tip/xml/crm.dtd[DTD] -and ensure your configuration validates. - === Perform the upgrade === ==== Upgrade the software ==== Refer to the appendix: <> ==== Upgrade the Configuration ==== As XML is not the friendliest of languages, it is common for cluster administrators to have scripted some of their activities. In such cases, it is likely that those scripts will not work with the new 1.0 syntax. In order to support such environments, it is actually possible to continue using the old 0.6 syntax. The downside is, however, that not all the new features will be available 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 advisable to follow the upgrade procedure to ensure that the cluster is able to use your existing configuration (since it will perform much the same task internally). . Create a shadow copy to work with + ----- # crm_shadow --create upgrade06 ----- . Verify the configuration is valid indexterm:[Configuration,Verify]indexterm:[Verify,Configuration] + ----- # crm_verify --live-check ----- . Fix any errors or warnings . Perform the upgrade: + ----- # cibadmin --upgrade ----- . If this step fails, there are three main possibilities: .. The configuration was not valid to start with - go back to step 2 .. The transformation failed - report a bug or mailto:pacemaker@oss.clusterlabs.org?subject=Transformation%20failed%20during%20upgrade[email the project] .. The transformation was successful but produced an invalid result footnote:[ The most common reason is ID values being repeated or invalid. Pacemaker 1.0 is much stricter regarding this type of validation. ] + 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 http://clusterlabs.org/wiki/Validation_FAQ and/or try the procedure described below under <> + . Check the changes + ----- # 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. Since the shadow configuration is not in use by the cluster, it is safe to edit the file manually: + ----- # 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 + Test what the cluster will do when you upload the new configuration + ------ # crm_simulate --live-check --save-dotfile upgrade06.dot -S # graphviz upgrade06.dot ------ + 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 <> for further details on how to interpret the output of `crm_simulate` + . Upload the changes + ----- # crm_shadow --commit upgrade06 --force ----- If this step fails, something really strange has occurred. You should report a bug. [[s-upgrade-config-manual]] ==== Manually Upgrading the Configuration ==== indexterm:[Configuration,Upgrade manually] It is also possible to perform the configuration upgrade steps manually. To do this Locate the 'upgrade06.xsl' conversion script or download the latest version from https://github.com/ClusterLabs/pacemaker/tree/master/xml/upgrade06.xsl[Git] . Convert the XML blob: indexterm:[XML,Convert] + ----- # xsltproc /path/to/upgrade06.xsl config06.xml > config10.xml ----- + . Locate the 'pacemaker.rng' script. . Check the XML validity: indexterm:[Validate Configuration]indexterm:[Configuration,Validate XML] + ---- # 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 should be more informative (despite being generated by the same library!) since they include line numbers. diff --git a/doc/Pacemaker_Explained/en-US/Ch-Advanced-Options.txt b/doc/Pacemaker_Explained/en-US/Ch-Advanced-Options.txt index e3dde0b1aa..12c468c296 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Advanced-Options.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Advanced-Options.txt @@ -1,682 +1,682 @@ = Advanced Configuration = [[s-remote-connection]] == Connecting from a Remote Machine == indexterm:[Cluster,Remote connection] indexterm:[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. .Environment Variables Used to Connect to Remote Instances of the CIB [width="95%",cols="1m,2<",options="header",align="center"] |========================================================= |Environment Variable |Description |CIB_user |The user to connect as. Needs to be part of the +hacluster+ group on the target host. Defaults to _$USER_. indexterm:[Environment Variable,CIB_user] |CIB_passwd |The user's password. Read from the command line if unset. indexterm:[Environment Variable,CIB_passwd] |CIB_server |The host to contact. Defaults to _localhost_. indexterm:[Environment Variable,CIB_server] |CIB_port |The port on which to contact the server; required. indexterm:[Environment Variable,CIB_port] |CIB_encrypted |Encrypt network traffic; defaults to _true_. indexterm:[Environment Variable,CIB_encrypted] |========================================================= So, if +c001n01+ is an active cluster node and is listening on +1234+ for connections, and +someguy+ is a member of the +hacluster+ group, then the following would prompt for +someguy+'s password and return the cluster's current configuration: ---- # export CIB_port=1234; export CIB_server=c001n01; export CIB_user=someguy; # 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) top-level options (ie., those kept in the cib tag, like +num_updates+ and +epoch+). .Extra top-level CIB options for remote access [width="95%",cols="1m,2<",options="header",align="center"] |========================================================= |Field |Description |remote-tls-port |Listen for encrypted remote connections on this port. Default: _none_ indexterm:[remote-tls-port,Remote Connection Option] indexterm:[Remote Connection,Option,remote-tls-port] |remote-clear-port |Listen for plaintext remote connections on this port. Default: _none_ indexterm:[remote-clear-port,Remote Connection Option] indexterm:[Remote Connection,Option,remote-clear-port] |========================================================= [[s-recurring-start]] == Specifying When Recurring Actions are Performed == By default, recurring actions are scheduled relative to when the resource started. So if your resource was last started at 14:32 and you have a backup set to be performed every 24 hours, then the backup will always run at in the middle of the business day - hardly desirable. To specify a date/time that the operation should be relative to, set the operation's +interval-origin+. The cluster uses this point to calculate the correct +start-delay+ such that the operation will occur at _origin + (interval * N)_. So, if the operation's interval is 24h, it's interval-origin is set to +02:00+ and it is currently +14:32+, then the cluster would initiate the operation with a start delay of 11 hours and 28 minutes. If the resource is moved to another node before 2am, then the operation is of course cancelled. The value specified for interval and +interval-origin+ can be any date/time conforming to the http://en.wikipedia.org/wiki/ISO_8601[ISO8601 standard]. By way of example, to specify an operation that would run on the first Monday of 2009 and every Monday after that you would add: .Specifying a Base for Recurring Action Intervals ===== [source,XML] ===== == Moving Resources == indexterm:[Moving,Resources] indexterm:[Resource,Moving] === Manual Intervention === There are primarily two occasions when you would want to move a -resource from it's current location: when the whole node is under +resource from its current location: when the whole node is under maintenance, and when a single resource needs to be moved. Since everything eventually comes down to a score, you could create constraints for every resource to prevent them from running on one node. While the configuration can seem convoluted at times, not even we would require this of administrators. Instead one can set a special node attribute which tells the cluster "don't let anything run here". There is even a helpful tool to help query and set it, called `crm_standby`. To check the standby status of the current machine, simply run: ---- # crm_standby --get-value ---- A value of +true+ indicates that the node is _NOT_ able to host any resources, while a value of +false+ says that it _CAN_. You can also check the status of other nodes in the cluster by specifying the `--node-uname` option: ---- # crm_standby --get-value --node-uname sles-2 ---- To change the current node's standby status, use `--attr-value` instead of `--get-value`. ---- # crm_standby --attr-value ---- Again, you can change another host's value by supplying a host name with `--node-uname`. When only one resource is required to move, we do this by creating location constraints. However, once again we provide a user friendly shortcut as part of the `crm_resource` command, which creates and -modifies the extra constraints for you. If +Email+ was running on +modifies the extra constraints for you. If +Email+ were running on +sles-1+ and you wanted it moved to a specific location, the command would look something like: ---- # crm_resource -M -r Email -H sles-2 ---- Behind the scenes, the tool will create the following location constraint: [source,XML] It is important to note that subsequent invocations of `crm_resource -M` are not cumulative. So, if you ran these commands ---- # crm_resource -M -r Email -H sles-2 # crm_resource -M -r Email -H sles-3 ---- then it is as if you had never performed the first command. To allow the resource to move back again, use: ---- # crm_resource -U -r Email ---- Note the use of the word _allow_. The resource can move back to its original location but, depending on +resource-stickiness+, it might stay where it is. To be absolutely certain that it moves back to +sles-1+, move it there before issuing the call to `crm_resource -U`: ---- # crm_resource -M -r Email -H sles-1 # crm_resource -U -r Email ---- Alternatively, if you only care that the resource should be moved from its current location, try ---- # crm_resource -M -r Email` ---- Which will instead create a negative constraint, like [source,XML] This will achieve the desired effect, but will also have long-term consequences. As the tool will warn you, the creation of a +-INFINITY+ constraint will prevent the resource from running on that node until `crm_resource -U` is used. This includes the situation where every other cluster node is no longer available! In some cases, such as when +resource-stickiness+ is set to +INFINITY+, it is possible that you will end up with the problem described in <>. The tool can detect some of these cases and deals with them by also creating both a positive and negative constraint. Eg. +Email+ prefers +sles-1+ with a score of +-INFINITY+ +Email+ prefers +sles-2+ with a score of +INFINITY+ which has the same long-term consequences as discussed earlier. [[s-failure-migration]] === Moving Resources Due to Failure === New in 1.0 is the concept of a migration threshold. footnote:[ The naming of this option was perhaps unfortunate as it is easily confused with true migration, the process of moving a resource from one node to another without stopping it. Xen virtual guests are the most common example of resources that can be migrated in this manner. ] Simply define +migration-threshold=N+ for a resource and it will migrate to a new node after N failures. There is no threshold defined by default. To determine the resource's current failure status and limits, use `crm_mon --failcounts`. By default, once the threshold has been reached, this node will no longer be allowed to run the failed resource until the administrator manually resets the resource's failcount using `crm_failcount` (after hopefully first fixing the failure's cause). However it is possible to expire them by setting the resource's +failure-timeout+ option. So a setting of +migration-threshold=2+ and +failure-timeout=60s+ would cause the resource to move to a new node after 2 failures, and allow it to move back (depending on the stickiness and constraint scores) after one minute. There are two exceptions to the migration threshold concept; they occur when a resource either fails to start or fails to stop. Start failures cause the failcount to be set to +INFINITY+ and thus always cause the resource to move immediately. Stop failures are slightly different and crucial. If a resource fails to stop and STONITH is enabled, then the cluster will fence the node in order to be able to start the resource elsewhere. If STONITH is not enabled, then the cluster has no way to continue and will not try to start the resource elsewhere, but will try to stop it again after the failure timeout. [IMPORTANT] Please read <> before enabling this option. === Moving Resources Due to Connectivity Changes === Setting up the cluster to move resources when external connectivity is lost is a two-step process. ==== Tell Pacemaker to monitor connectivity ==== To do this, you need to add a +ping+ resource to the cluster. The +ping+ resource uses the system utility of the same name to a test if list of machines (specified by DNS hostname or IPv4/IPv6 address) are reachable and uses the results to maintain a node attribute normally called +pingd+. footnote:[ The attribute name is customizable; that allows multiple ping groups to be defined. ] [NOTE] Older versions of Heartbeat required users to add ping nodes to _ha.cf_ - this is no longer required. [IMPORTANT] =========== Older versions of Pacemaker used a custom binary called 'pingd' for this functionality; this is now deprecated in favor of 'ping'. If your version of Pacemaker does not contain the ping agent, you can download the latest version from https://github.com/ClusterLabs/pacemaker/tree/master/extra/resources/ping =========== Normally the resource will run on all cluster nodes, which means that you'll need to create a clone. A template for this can be found below along with a description of the most interesting parameters. .Common Options for a 'ping' Resource [width="95%",cols="1m,4<",options="header",align="center"] |========================================================= |Field |Description |dampen |The time to wait (dampening) for further changes to occur. Use this to prevent a resource from bouncing around the cluster when cluster nodes notice the loss of connectivity at slightly different times. indexterm:[dampen,Ping Resource Option] indexterm:[Ping Resource,Option,dampen] |multiplier |The number of connected ping nodes gets multiplied by this value to get a score. Useful when there are multiple ping nodes configured. indexterm:[multiplier,Ping Resource Option] indexterm:[Ping Resource,Option,multiplier] |host_list |The machines to contact in order to determine the current connectivity status. Allowed values include resolvable DNS host names, IPv4 and IPv6 addresses. indexterm:[host_list,Ping Resource Option] indexterm:[Ping Resource,Option,host_list] |========================================================= .An example ping cluster resource that checks node connectivity once every minute ===== [source,XML] ------------ ------------ ===== [IMPORTANT] =========== You're only half done. The next section deals with telling Pacemaker how to deal with the connectivity status that +ocf:pacemaker:ping+ is recording. =========== ==== Tell Pacemaker how to interpret the connectivity data ==== [NOTE] ====== Before reading the following, please make sure you have read and understood <> above. ====== There are a number of ways to use the connectivity data provided by Heartbeat. The most common setup is for people to have a single ping node, to prevent the cluster from running a resource on any unconnected node. //// TODO: is the idea that only nodes that can reach eg. the router should have active resources? //// .Don't run on unconnected nodes ===== [source,XML] ------- ------- ===== A more complex setup is to have a number of ping nodes configured. You can require the cluster to only run resources on nodes that can connect to all (or a minimum subset) of them. .Run only on nodes connected to three or more ping nodes; this assumes +multiplier+ is set to 1000: ===== [source,XML] ------- ------- ===== Instead you can tell the cluster only to _prefer_ nodes with the best connectivity. Just be sure to set +multiplier+ to a value higher than that of +resource-stickiness+ (and don't set either of them to +INFINITY+). .Prefer the node with the most connected ping nodes ===== [source,XML] ------- ------- ===== It is perhaps easier to think of this in terms of the simple constraints that the cluster translates it into. For example, if +sles-1+ is connected to all 5 ping nodes but +sles-2+ is only connected to 2, then it would be as if you instead had the following constraints in your configuration: .How the cluster translates the pingd constraint ===== [source,XML] ------- ------- ===== The advantage is that you don't have to manually update any constraints whenever your network connectivity changes. You can also combine the concepts above into something even more complex. The example below shows how you can prefer the node with the most connected ping nodes provided they have connectivity to at least three (again assuming that +multiplier+ is set to 1000). .A more complex example of choosing a location based on connectivity ===== [source,XML] ------- ------- ===== === Resource Migration === Some resources, such as Xen virtual guests, are able to move to another location without loss of state. We call this resource migration; this is different from the normal practice of stopping the resource on the first machine and starting it elsewhere. Not all resources are able to migrate, see the Migration Checklist below, and those that can, won't do so in all situations. Conceptually there are two requirements from which the other prerequisites follow: * the resource must be active and healthy at the old location * everything required for the resource to run must be available on both the old and new locations The cluster is able to accommodate both push and pull migration models by requiring the resource agent to support two new actions: +migrate_to+ (performed on the current location) and +migrate_from+ (performed on the destination). In push migration, the process on the current location transfers the resource to the new location where is it later activated. In this scenario, most of the work would be done in the +migrate_to+ action and, if anything, the activation would occur during +migrate_from+. Conversely for pull, the +migrate_to+ action is practically empty and +migrate_from+ does most of the work, extracting the relevant resource state from the old location and activating it. There is no wrong or right way to implement migration for your service, as long as it works. ==== Migration Checklist ==== * The resource may not be a clone. * The resource must use an OCF style agent. * The resource must not be in a failed or degraded state. * The resource must not, directly or indirectly, depend on any primitive or group resources. * The resource must support two new actions: +migrate_to+ and +migrate_from+, and advertise them in its metadata. * The resource must have the +allow-migrate+ meta-attribute set to +true+ (which is not the default). //// TODO: how can a KVM with DRBD migrate? //// If the resource depends on a clone, and at the time the resource needs to be move, the clone has instances that are stopping and instances that are starting, then the resource will be moved in the traditional manner. The Policy Engine is not yet able to model this situation correctly and so takes the safe (yet less optimal) path. [[s-reusing-config-elements]] == Reusing Rules, Options and Sets of Operations == Sometimes a number of constraints need to use the same set of rules, and resources need to set the same options and parameters. To simplify this situation, you can refer to an existing object using an +id-ref+ instead of an id. So if for one resource you have [source,XML] ------ ------ Then instead of duplicating the rule for all your other resources, you can instead specify: .Referencing rules from other constraints ===== [source,XML] ------- ------- ===== [IMPORTANT] =========== The cluster will insist that the +rule+ exists somewhere. Attempting to add a reference to a non-existing rule will cause a validation failure, as will attempting to remove a +rule+ that is referenced elsewhere. =========== The same principle applies for +meta_attributes+ and +instance_attributes+ as illustrated in the example below: .Referencing attributes, options, and operations from other resources ===== [source,XML] ------- ------- ===== == Reloading Services After a Definition Change == The cluster automatically detects changes to the definition of services it manages. However, the normal response is to stop the service (using the old definition) and start it again (with the new definition). This works well, but some services are smarter and can be told to use a new set of options without restarting. To take advantage of this capability, your resource agent must: . Accept the +reload+ operation and perform any required actions. _The steps required here depend completely on your application!_ + .The DRBD Agent's Control logic for Supporting the +reload+ Operation ===== [source,Bash] ------- case $1 in start) drbd_start ;; stop) drbd_stop ;; reload) drbd_reload ;; monitor) drbd_monitor ;; *) drbd_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? ------- ===== . Advertise the +reload+ operation in the +actions+ section of its metadata + .The DRBD Agent Advertising Support for the +reload+ Operation ===== [source,XML] ------- 1.1 Master/Slave OCF Resource Agent for DRBD ... ------- ===== . Advertise one or more parameters that can take effect using +reload+. + Any parameter with the +unique+ set to 0 is eligible to be used in this way. + .Parameter that can be changed using reload ===== [source,XML] ------- Full path to the drbd.conf file. Path to drbd.conf ------- ===== Once these requirements are satisfied, the cluster will automatically know to reload the resource (instead of restarting) when a non-unique -fields changes. +field changes. [NOTE] ====== The metadata is re-read when the resource is started. This may mean that the resource will be restarted the first time, even though you changed a parameter with +unique=0+ ====== [NOTE] ====== If both a unique and non-unique field are changed simultaneously, the resource will still be restarted. ====== diff --git a/doc/Pacemaker_Explained/en-US/Ch-Advanced-Resources.txt b/doc/Pacemaker_Explained/en-US/Ch-Advanced-Resources.txt index 8262578da5..c663e10e75 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Advanced-Resources.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Advanced-Resources.txt @@ -1,1019 +1,1017 @@ = Advanced Resource Types = [[group-resources]] == Groups - A Syntactic Shortcut == indexterm:[Group Resources] indexterm:[Resources,Groups] One of the most common elements of a cluster is a set of resources that need to be located together, start sequentially, and stop in the reverse order. To simplify this configuration we support the concept of groups. .An example group ====== [source,XML] ------- ------- ====== Although the example above contains only two resources, there is no limit to the number of resources a group can contain. The example is also sufficient to explain the fundamental properties of a group: * Resources are started in the order they appear in (+Public-IP+ first, then +Email+) * Resources are stopped in the reverse order to which they appear in (+Email+ first, then +Public-IP+) If a resource in the group can't run anywhere, then nothing after that is allowed to run, too. * If +Public-IP+ can't run anywhere, neither can +Email+; * but if +Email+ can't run anywhere, this does not affect +Public-IP+ in any way The group above is logically equivalent to writing: .How the cluster sees a group resource ====== [source,XML] ------- ------- ====== Obviously as the group grows bigger, the reduced configuration effort can become significant. Another (typical) example of a group is a DRBD volume, the filesystem mount, an IP address, and an application that uses them. === Group Properties === .Properties of a Group Resource [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the group indexterm:[id,Group Resource Property] indexterm:[Resource,Group Property,id] |========================================================= === Group Options === Options inherited from <> resources: +priority, target-role, is-managed+ === Group Instance Attributes === Groups have no instance attributes, however any that are set here will be inherited by the group's children. === Group Contents === Groups may only contain a collection of <> cluster resources. To refer to the child of a group resource, just use the child's id instead of the group's. === Group Constraints === Although it is possible to reference the group's children in constraints, it is usually preferable to use the group's name instead. .Example constraints involving groups ====== [source,XML] ------- ------- ====== === Group Stickiness === indexterm:[resource-stickiness,Groups] Stickiness, the measure of how much a resource wants to stay where it is, is additive in groups. Every active resource of the group will contribute its stickiness value to the group's total. So if the default +resource-stickiness+ is 100, and a group has seven members, five of which are active, then the group as a whole will prefer its current location with a score of 500. [[s-resource-clone]] == Clones - Resources That Get Active on Multiple Hosts == indexterm:[Clone Resources] indexterm:[Resources,Clones] Clones were initially conceived as a convenient way to start N instances of an IP resource and have them distributed throughout the cluster for load balancing. They have turned out to quite useful for a number of purposes including integrating with Red Hat's DLM, the fencing subsystem, and OCFS2. You can clone any resource, provided the resource agent supports it. Three types of cloned resources exist: * Anonymous * Globally Unique * Stateful Anonymous clones are the simplest type. These resources behave completely identically everywhere they are running. Because of this, there can only be one copy of an anonymous clone active per machine. Globally unique clones are distinct entities. A copy of the clone running on one machine is not equivalent to another instance on another node. Nor would any two copies on the same node be equivalent. Stateful clones are covered later in <>. .An example clone ====== [source,XML] ------- ------- ====== === Clone Properties === .Properties of a Clone Resource [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the clone indexterm:[id,Clone Property] indexterm:[Clone,Property,id] |========================================================= === Clone Options === Options inherited from <> resources: +priority, target-role, is-managed+ .Clone specific configuration options [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |clone-max |How many copies of the resource to start. Defaults to the number of nodes in the cluster. indexterm:[clone-max,Clone Option] indexterm:[Clone,Option,clone-max] |clone-node-max |How many copies of the resource can be started on a single node; default _1_. indexterm:[clone-node-max,Clone Option] indexterm:[Clone,Option,clone-node-max] |notify |When stopping or starting a copy of the clone, tell all the other copies beforehand and when the action was successful. Allowed values: _false_, +true+ indexterm:[notify,Clone Option] indexterm:[Clone,Option,notify] |globally-unique |Does each copy of the clone perform a different function? Allowed values: _false_, +true+ indexterm:[globally-unique,Clone Option] indexterm:[Clone,Option,globally-unique] |ordered |Should the copies be started in series (instead of in parallel). Allowed values: _false_, +true+ indexterm:[ordered,Clone Option] indexterm:[Clone,Option,ordered] |interleave |Changes the behavior of ordering constraints (between clones/masters) so that instances can start/stop as soon as their peer instance has (rather than waiting for every instance of the other clone has). Allowed values: _false_, +true+ indexterm:[interleave,Clone Option] indexterm:[Clone,Option,interleave] |========================================================= === Clone Instance Attributes === Clones have no instance attributes; however, any that are set here will be inherited by the clone's children. === Clone Contents === Clones must contain exactly one group or one regular resource. [WARNING] You should never reference the name of a clone's child. If you think you need to do this, you probably need to re-evaluate your design. === Clone Constraints === In most cases, a clone will have a single copy on each active cluster node. If this is not the case, you can indicate which nodes the cluster should preferentially assign copies to with resource location constraints. These constraints are written no differently to those for regular resources except that the clone's id is used. Ordering constraints behave slightly differently for clones. In the example below, +apache-stats+ will wait until all copies of the clone that need to be started have done so before being started itself. Only if _no_ copies can be started +apache-stats+ will be prevented from being active. Additionally, the clone will wait for +apache-stats+ to be stopped before stopping the clone. Colocation of a regular (or group) resource with a clone means that the resource can run on any machine with an active copy of the clone. The cluster will choose a copy based on where the clone is running and the resource's own location preferences. Colocation between clones is also possible. In such cases, the set of allowed locations for the clone is limited to nodes on which the clone is (or will be) active. Allocation is then performed as normally. .Example constraints involving clones ====== [source,XML] ------- ------- ====== === Clone Stickiness === indexterm:[resource-stickiness,Clones] To achieve a stable allocation pattern, clones are slightly sticky by default. If no value for +resource-stickiness+ is provided, the clone will use a value of 1. Being a small value, it causes minimal disturbance to the score calculations of other resources but is enough to prevent Pacemaker from needlessly moving copies around the cluster. === Clone Resource Agent Requirements === Any resource can be used as an anonymous clone, as it requires no additional support from the resource agent. Whether it makes sense to do so depends on your resource and its resource agent. Globally unique clones do require some additional support in the resource agent. In particular, it must only respond with -+${OCF_SUCCESS}+ if the node has that exact instance active. All ++$\{OCF_SUCCESS}+ if the node has that exact instance active. All other probes for instances of the clone should result in -+${OCF_NOT_RUNNING}+. Unless of course they are failed, in which case -they should return one of the other OCF error codes. ++$\{OCF_NOT_RUNNING}+ (or one of the other OCF error codes if +they are failed). Copies of a clone are identified by appending a colon and a numerical offset, eg. +apache:2+. Resource agents can find out how many copies there are by examining the +OCF_RESKEY_CRM_meta_clone_max+ environment variable and which copy it is by examining +OCF_RESKEY_CRM_meta_clone+. You should not make any assumptions (based on +OCF_RESKEY_CRM_meta_clone+) about which copies are active. In particular, the list of active copies will not always be an unbroken sequence, nor always start at 0. ==== Clone Notifications ==== Supporting notifications requires the +notify+ action to be implemented. Once supported, the notify action will be passed a number of extra variables which, when combined with additional context, can be used to calculate the current state of the cluster and what is about to happen to it. .Environment variables supplied with Clone notify actions [width="95%",cols="5,3<",options="header",align="center"] |========================================================= |Variable |Description |OCF_RESKEY_CRM_meta_notify_type |Allowed values: +pre+, +post+ indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,type] indexterm:[type,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_operation |Allowed values: +start+, +stop+ indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,operation] indexterm:[operation,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_start_resource |Resources to be started indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,start_resource] indexterm:[start_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_stop_resource |Resources to be stopped indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,stop_resource] indexterm:[stop_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_active_resource |Resources that are running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,active_resource] indexterm:[active_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_inactive_resource |Resources that are not running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,inactive_resource] indexterm:[inactive_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_start_uname |Nodes on which resources will be started indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,start_uname] indexterm:[start_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_stop_uname |Nodes on which resources will be stopped indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,stop_uname] indexterm:[stop_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_active_uname |Nodes on which resources are running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,active_uname] indexterm:[active_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_inactive_uname |Nodes on which resources are not running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,inactive_uname] indexterm:[inactive_uname,Notification Environment Variable] |========================================================= The variables come in pairs, such as +OCF_RESKEY_CRM_meta_notify_start_resource+ and +OCF_RESKEY_CRM_meta_notify_start_uname+ and should be treated as an array of whitespace separated elements. Thus in order to indicate that +clone:0+ will be started on +sles-1+, +clone:2+ will be started on +sles-3+, and +clone:3+ will be started on +sles-2+, the cluster would set .Example notification variables ====== [source,Bash] ------- OCF_RESKEY_CRM_meta_notify_start_resource="clone:0 clone:2 clone:3" OCF_RESKEY_CRM_meta_notify_start_uname="sles-1 sles-3 sles-2" ------- ====== ==== Proper Interpretation of Notification Environment Variables ==== .Pre-notification (stop): * Active resources: +$OCF_RESKEY_CRM_meta_notify_active_resource+ * Inactive resources: +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ .Post-notification (stop) / Pre-notification (start): * Active resources ** +$OCF_RESKEY_CRM_meta_notify_active_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Inactive resources ** +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources that were started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources that were stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ .Post-notification (start): * Active resources: ** +$OCF_RESKEY_CRM_meta_notify_active_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Inactive resources: ** +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources that were started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources that were stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ [[s-resource-multistate]] == Multi-state - Resources That Have Multiple Modes == indexterm:[Multi-state Resources] indexterm:[Resources,Multi-state] Multi-state resources are a specialization of Clone resources; please ensure you understand the section on clones before continuing! They allow the instances to be in one of two operating modes; these are called +Master+ and +Slave+, but can mean whatever you wish them to mean. The only limitation is that when an instance is started, it must come up in the +Slave+ state. === Multi-state Properties === .Properties of a Multi-State Resource [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the multi-state resource indexterm:[id,Multi-State Property] indexterm:[Multi-State,Property,id] |========================================================= === Multi-state Options === Options inherited from <> resources: +priority+, +target-role+, +is-managed+ Options inherited from <> resources: +clone-max+, +clone-node-max+, +notify+, +globally-unique+, +ordered+, +interleave+ .Multi-state specific resource configuration options [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |master-max |How many copies of the resource can be promoted to +master+ status; default 1. indexterm:[master-max,Multi-State Option] indexterm:[Multi-State,Option,master-max] |master-node-max |How many copies of the resource can be promoted to +master+ status on a single node; default 1. indexterm:[master-node-max,Multi-State Option] indexterm:[Multi-State,Option,master-node-max] |========================================================= === Multi-state Instance Attributes === Multi-state resources have no instance attributes; however, any that are set here will be inherited by master's children. === Multi-state Contents === Masters must contain exactly one group or one regular resource. [WARNING] You should never reference the name of a master's child. If you think you need to do this, you probably need to re-evaluate your design. === Monitoring Multi-State Resources === The normal type of monitor actions are not sufficient to monitor a multi-state resource in the +Master+ state. To detect failures of the +Master+ instance, you need to define an additional monitor action with +role="Master"+. [IMPORTANT] =========== It is crucial that _every_ monitor operation has a different interval! This is because Pacemaker currently differentiates between operations only by resource and interval; so if eg. a master/slave resource has the same monitor interval for both roles, Pacemaker would ignore the role when checking the status - which would cause unexpected return codes, and therefore unnecessary complications. =========== .Monitoring both states of a multi-state resource ====== [source,XML] ------- ------- ====== === Multi-state Constraints === -In most cases, a multi-state resources will have a single copy on each +In most cases, multi-state resources will have a single copy on each active cluster node. If this is not the case, you can indicate which nodes the cluster should preferentially assign copies to with resource location constraints. These constraints are written no differently to those for regular resources except that the master's id is used. When considering multi-state resources in constraints, for most purposes it is sufficient to treat them as clones. The exception is when the +rsc-role+ and/or +with-rsc-role+ fields (for colocation constraints) and +first-action+ and/or +then-action+ fields (for ordering constraints) are used. .Additional constraint options relevant to multi-state resources [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |rsc-role |An additional attribute of colocation constraints that specifies the role that +rsc+ must be in. Allowed values: _Started_, +Master+, +Slave+. indexterm:[rsc-role,Ordering Constraints] indexterm:[Constraints,Ordering,rsc-role] |with-rsc-role |An additional attribute of colocation constraints that specifies the role that +with-rsc+ must be in. Allowed values: _Started_, +Master+, +Slave+. indexterm:[with-rsc-role,Ordering Constraints] indexterm:[Constraints,Ordering,with-rsc-role] |first-action |An additional attribute of ordering constraints that specifies the action that the +first+ resource must complete before executing the specified action for the +then+ resource. Allowed values: _start_, +stop+, +promote+, +demote+. indexterm:[first-action,Ordering Constraints] indexterm:[Constraints,Ordering,first-action] |then-action |An additional attribute of ordering constraints that specifies the action that the +then+ resource can only execute after the +first-action+ on the +first+ resource has completed. Allowed values: +start+, +stop+, +promote+, +demote+. Defaults to the value (specified or implied) of +first-action+. indexterm:[then-action,Ordering Constraints] indexterm:[Constraints,Ordering,then-action] |========================================================= In the example below, +myApp+ will wait until one of the database copies has been started and promoted to master before being started itself. Only if no copies can be promoted will +apache-stats+ be prevented from being active. Additionally, the database will wait for +myApp+ to be stopped before it is demoted. .Example constraints involving multi-state resources ====== [source,XML] ------- ------- ====== Colocation of a regular (or group) resource with a multi-state resource means that it can run on any machine with an active copy of the multi-state resource that is in the specified state (+Master+ or +Slave+). In the example, the cluster will choose a location based on where database is running as a +Master+, and if there are multiple +Master+ instances it will also factor in +myApp+'s own location preferences when deciding which location to choose. Colocation with regular clones and other multi-state resources is also possible. In such cases, the set of allowed locations for the +rsc+ clone is (after role filtering) limited to nodes on which the +with-rsc+ multi-state resource is (or will be) in the specified role. Allocation is then performed as-per-normal. ==== Using Multi-state Resources in Colocation/Ordering Sets ==== .Additional colocation set options relevant to multi-state resources [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |role |An additional attribute of colocation constraint sets that specifies the role that *all members of the set* must be in. Allowed values: _Started_, +Master+, +Slave+. indexterm:[role,Ordering Constraints] indexterm:[Constraints,Ordering,role] |========================================================= In the following example +B+'s master must be located on the same node as +A+'s master. Additionally resources +C+ and +D+ must be located on the same node as +B+'s master. -.Colocate C and C with A and B's master instances +.Colocate C and D with A's and B's master instances ====== [source,XML] ------- - + - - - + ------- ====== .Additional ordered set options relevant to multi-state resources [width="95%",cols="3m,5<",options="header",align="center"] |========================================================= |Field |Description |action |An additional attribute of ordering constraint set that specifies the action that applies to *all members of the set*. Allowed values: +start+, +stop+, +promote+, +demote+. Defaults to the value (specified or implied) of +first-action+. indexterm:[action,Ordering Constraints] indexterm:[Constraints,Ordering,action] |========================================================= In the following example +B+ cannot be promoted until +A+'s has been promoted. Additionally resources +C+ and +D+ must wait until +A+ and +B+ have been promoted before they can start. -.Start C and C after first promoting A and B +.Start C and D after first promoting A and B ====== [source,XML] ------- - - + + - + - + ------- ====== === Multi-state Stickiness === indexterm:[resource-stickiness,Multi-State] To achieve a stable allocation pattern, multi-state resources are slightly sticky by default. If no value for +resource-stickiness+ is provided, the multi-state resource will use a value of 1. Being a small value, it causes minimal disturbance to the score calculations of other resources but is enough to prevent Pacemaker from needlessly moving copies around the cluster. === Which Resource Instance is Promoted === During the start operation, most Resource Agent scripts should call the `crm_master` utility. This tool automatically detects both the resource and host and should be used to set a preference for being promoted. Based on this, +master-max+, and +master-node-max+, the instance(s) with the highest preference will be promoted. The other alternative is to create a location constraint that indicates which nodes are most preferred as masters. .Manually specifying which node should be promoted ====== [source,XML] ------- ------- ====== === Multi-state Resource Agent Requirements === Since multi-state resources are an extension of cloned resources, all the requirements of Clones are also requirements of multi-state resources. Additionally, multi-state resources require two extra actions: +demote+ and +promote+; these actions are responsible for changing the state of the resource. Like +start+ and +stop+, they should return +OCF_SUCCESS+ if they completed successfully or a relevant error code if they did not. The states can mean whatever you wish, but when the resource is started, it must come up in the mode called +Slave+. From there the cluster will then decide which instances to promote to +Master+. In addition to the Clone requirements for monitor actions, agents must also _accurately_ report which state they are in. The cluster relies on the agent to report its status (including role) accurately and does not indicate to the agent what role it currently believes it to be in. .Role implications of OCF return codes [width="95%",cols="5,3<",options="header",align="center"] |========================================================= |Monitor Return Code |Description |OCF_NOT_RUNNING |Stopped indexterm:[Return Code,OCF_NOT_RUNNING] |OCF_SUCCESS |Running (Slave) indexterm:[Return Code,OCF_SUCCESS] |OCF_RUNNING_MASTER |Running (Master) indexterm:[Return Code,OCF_RUNNING_MASTER] |OCF_FAILED_MASTER |Failed (Master) indexterm:[Return Code,OCF_FAILED_MASTER] |Other |Failed (Slave) |========================================================= === Multi-state Notifications === Like clones, supporting notifications requires the +notify+ action to be implemented. Once supported the notify action will be passed a number of extra variables which, when combined with additional context, can be used to calculate the current state of the cluster and what is about to happen to it. .Environment variables supplied with Master notify actions footnote:[Emphasized variables are specific to +Master+ resources and all behave in the same manner as described for Clone resources.] [width="95%",cols="5,3<",options="header",align="center"] |========================================================= |Variable |Description |OCF_RESKEY_CRM_meta_notify_type |Allowed values: +pre+, +post+ indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,type] indexterm:[type,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_operation |Allowed values: +start+, +stop+ indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,operation] indexterm:[operation,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_active_resource |Resources the that are running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,active_resource] indexterm:[active_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_inactive_resource |Resources the that are not running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,inactive_resource] indexterm:[inactive_resource,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_master_resource_ |Resources that are running in +Master+ mode indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,master_resource] indexterm:[master_resource,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_slave_resource_ |Resources that are running in +Slave+ mode indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,slave_resource] indexterm:[slave_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_start_resource |Resources to be started indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,start_resource] indexterm:[start_resource,Notification Environment Variable] |indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,stop_resource] indexterm:[stop_resource,Notification Environment Variable] OCF_RESKEY_CRM_meta_notify_stop_resource |Resources to be stopped |_OCF_RESKEY_CRM_meta_notify_promote_resource_ |Resources to be promoted indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,promote_resource] indexterm:[promote_resource,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_demote_resource_ |Resources to be demoted indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,demote_resource] indexterm:[demote_resource,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_start_uname |Nodes on which resources will be started indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,start_uname] indexterm:[start_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_stop_uname |Nodes on which resources will be stopped indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,stop_uname] indexterm:[stop_uname,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_promote_uname_ |Nodes on which resources will be promote indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,promote_uname] indexterm:[promote_uname,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_demote_uname_ |Nodes on which resources will be demoted indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,demote_uname] indexterm:[demote_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_active_uname |Nodes on which resources are running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,active_uname] indexterm:[active_uname,Notification Environment Variable] |OCF_RESKEY_CRM_meta_notify_inactive_uname |Nodes on which resources are not running indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,inactive_uname] indexterm:[inactive_uname,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_master_uname_ |Nodes on which resources are running in +Master+ mode indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,master_uname] indexterm:[master_uname,Notification Environment Variable] |_OCF_RESKEY_CRM_meta_notify_slave_uname_ |Nodes on which resources are running in +Slave+ mode indexterm:[Environment Variable,OCF_RESKEY_CRM_meta_notify_,slave_uname] indexterm:[slave_uname,Notification Environment Variable] |========================================================= === Multi-state - Proper Interpretation of Notification Environment Variables === .Pre-notification (demote): * +Active+ resources: +$OCF_RESKEY_CRM_meta_notify_active_resource+ * +Master+ resources: +$OCF_RESKEY_CRM_meta_notify_master_resource+ * +Slave+ resources: +$OCF_RESKEY_CRM_meta_notify_slave_resource+ * Inactive resources: +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources to be demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ .Post-notification (demote) / Pre-notification (stop): * +Active+ resources: +$OCF_RESKEY_CRM_meta_notify_active_resource+ * +Master+ resources: ** +$OCF_RESKEY_CRM_meta_notify_master_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * +Slave+ resources: +$OCF_RESKEY_CRM_meta_notify_slave_resource+ * Inactive resources: +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources to be demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources that were demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ .Post-notification (stop) / Pre-notification (start) * +Active+ resources: ** +$OCF_RESKEY_CRM_meta_notify_active_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * +Master+ resources: ** +$OCF_RESKEY_CRM_meta_notify_master_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * +Slave+ resources: ** +$OCF_RESKEY_CRM_meta_notify_slave_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Inactive resources: ** +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources to be demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources that were demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources that were stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ .Post-notification (start) / Pre-notification (promote) * +Active+ resources: ** +$OCF_RESKEY_CRM_meta_notify_active_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * +Master+ resources: ** +$OCF_RESKEY_CRM_meta_notify_master_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * +Slave+ resources: ** +$OCF_RESKEY_CRM_meta_notify_slave_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Inactive resources: ** +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources to be demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources that were started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources that were demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources that were stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ .Post-notification (promote) * +Active+ resources: ** +$OCF_RESKEY_CRM_meta_notify_active_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * +Master+ resources: ** +$OCF_RESKEY_CRM_meta_notify_master_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_demote_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * +Slave+ resources: ** +$OCF_RESKEY_CRM_meta_notify_slave_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_start_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Inactive resources: ** +$OCF_RESKEY_CRM_meta_notify_inactive_resource+ ** plus +$OCF_RESKEY_CRM_meta_notify_stop_resource+ ** minus +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources to be promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources to be demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources to be stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ * Resources that were started: +$OCF_RESKEY_CRM_meta_notify_start_resource+ * Resources that were promoted: +$OCF_RESKEY_CRM_meta_notify_promote_resource+ * Resources that were demoted: +$OCF_RESKEY_CRM_meta_notify_demote_resource+ * Resources that were stopped: +$OCF_RESKEY_CRM_meta_notify_stop_resource+ diff --git a/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt b/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt index 84d272b42c..7f1c5b9c55 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt @@ -1,667 +1,670 @@ = Resource Constraints = indexterm:[Resource,Constraints] == Scores == Scores of all kinds are integral to how the cluster works. Practically everything from moving a resource to deciding which resource to stop in a degraded cluster is achieved by manipulating scores in some way. Scores are calculated on a per-resource basis and any node with a negative score for a resource can't run that resource. After calculating the scores for a resource, the cluster then chooses the node with the highest one. === Infinity Math === +INFINITY+ is currently defined as 1,000,000 and addition/subtraction with it follows these three basic rules: * Any value + +INFINITY+ = +INFINITY+ * Any value - +INFINITY+ = -+INFINITY+ * +INFINITY+ - +INFINITY+ = -+INFINITY+ == Deciding Which Nodes a Resource Can Run On == indexterm:[Location Constraints] indexterm:[Resource,Constraints,Location] There are two alternative strategies for specifying which nodes a resources can run on. One way is to say that by default they can run anywhere and then create location constraints for nodes that are not allowed. The other option is to have nodes "opt-in"... to start with nothing able to run anywhere and selectively enable allowed nodes. === Options === .Options for Simple Location Constraints [width="95%",cols="2m,1,5<",options="header",align="center"] |========================================================= |Field |Default |Description |id | |A unique name for the constraint indexterm:[id,Location Constraints] indexterm:[Constraints,Location,id] |rsc | |A resource name indexterm:[rsc,Location Constraints] indexterm:[Constraints,Location,rsc] |node | |A node's name indexterm:[node,Location Constraints] indexterm:[Constraints,Location,node] |score | |Positive values indicate the resource should run on this node. Negative values indicate the resource should not run on this node. Values of \+/- +INFINITY+ change "should"/"should not" to "must"/"must not". indexterm:[score,Location Constraints] indexterm:[Constraints,Location,score] |resource-discovery |+always+ |Indicates whether or not Pacemaker should perform resource discovery on this node for the specified resource. Limiting resource discovery to a subset of nodes the resource is physically capable of running on can significantly boost performance when a large set of nodes are preset. When pacemaker_remote is in use to expand the node count into the 100s of nodes range, this option should be considered. * 'always' - Always perform resource discovery for the specified resource on this node. * 'never' - Never perform resource discovery for the specified resource on this node. This option should generally be used with a -INFINITY score. Although that is not strictly required. * 'exclusive' - Only perform resource discovery for the specified resource on this node. Multiple location constraints using 'exclusive' discovery for the same resource across different nodes creates a subset of nodes resource-discovery is exclusive to. If a resource is marked for 'exclusive' discovery on one or more nodes, that resource is only allowed to be placed within that subset of nodes. indexterm:[Resource Discovery,Location Constraints] indexterm:[Constraints,Location,Resource Discovery] |========================================================= === Asymmetrical "Opt-In" Clusters === indexterm:[Asymmetrical Opt-In Clusters] indexterm:[Cluster Type,Asymmetrical Opt-In] To create an opt-in cluster, start by preventing resources from running anywhere by default: ---- # crm_attribute --attr-name symmetric-cluster --attr-value false ---- Then start enabling nodes. The following fragment says that the web server prefers +sles-1+, the database prefers +sles-2+ and both can fail over to +sles-3+ if their most preferred node fails. .Example set of opt-in location constraints ====== [source,XML] ------- ------- ====== === Symmetrical "Opt-Out" Clusters === indexterm:[Symmetrical Opt-Out Clusters] indexterm:[Cluster Type,Symmetrical Opt-Out] To create an opt-out cluster, start by allowing resources to run anywhere by default: ---- # crm_attribute --attr-name symmetric-cluster --attr-value true ---- Then start disabling nodes. The following fragment is the equivalent of the above opt-in configuration. .Example set of opt-out location constraints ====== [source,XML] ------- ------- ====== Whether you should choose opt-in or opt-out depends both on your personal preference and the make-up of your cluster. If most of your resources can run on most of the nodes, then an opt-out arrangement is likely to result in a simpler configuration. On the other-hand, if most resources can only run on a small subset of nodes an opt-in configuration might be simpler. [[node-score-equal]] === What if Two Nodes Have the Same Score === If two nodes have the same score, then the cluster will choose one. This choice may seem random and may not be what was intended, however the cluster was not given enough information to know any better. .Example of two resources that prefer two nodes equally ====== [source,XML] ------- ------- ====== In the example above, assuming no other constraints and an inactive cluster, Webserver would probably be placed on sles-1 and Database on sles-2. It would likely have placed Webserver based on the node's uname and Database based on the desire to spread the resource load evenly across the cluster. However other factors can also be involved in more complex configurations. [[s-resource-ordering]] == Specifying in which Order Resources Should Start/Stop == indexterm:[Resource,Constraints,Ordering] indexterm:[Resource,Start Order] indexterm:[Ordering Constraints] The way to specify the order in which resources should start is by creating +rsc_order+ constraints. .Properties of an Ordering Constraint [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |id |A unique name for the constraint indexterm:[id,Ordering Constraints] indexterm:[Constraints,Ordering,id] |first |The name of a resource that must be started before the +then+ resource is allowed to. indexterm:[first,Ordering Constraints] indexterm:[Constraints,Ordering,first] |then |The name of a resource. This resource will start after the +first+ resource. indexterm:[then,Ordering Constraints] indexterm:[Constraints,Ordering,then] |kind |How to enforce the constraint. ('Since 1.1.2') * Optional - Just a suggestion. Only applies if both resources are starting/stopping. * Mandatory - Always. If 'first' is stopping or cannot be started, 'then' must be stopped. * Serialize - Ensure that no two stop/start actions occur concurrently for a set of resources. indexterm:[kind,Ordering Constraints] indexterm:[Constraints,Ordering,kind] |symmetrical |If true, which is the default, stop the resources in the reverse order. Default value: _true_ indexterm:[symmetrical,Ordering Constraints] indexterm:[Ordering Constraints,symmetrical] |========================================================= === Mandatory Ordering === When the +then+ resource cannot run without the +first+ resource being active, one should use mandatory constraints. To specify a constraint is mandatory, use scores greater than zero. This will ensure that the then resource will react when the first resource changes state. * If the +first+ resource was running and is stopped, the +then+ resource will also be stopped (if it is running). * If the +first+ resource was not running and cannot be started, the +then+ resource will be stopped (if it is running). * If the +first+ resource is (re)started while the +then+ resource is running, the +then+ resource will be stopped and restarted. === Advisory Ordering === On the other hand, when +score="0"+ is specified for a constraint, the constraint is considered optional and only has an effect when both resources are stopping and/or starting. Any change in state by the +first+ resource will have no effect on the +then+ resource. .Example of an optional and mandatory ordering constraint ====== [source,XML] ------- ------- ====== Some additional information on ordering constraints can be found in the document http://clusterlabs.org/doc/Ordering_Explained.pdf[Ordering Explained]. [[s-resource-colocation]] == Placing Resources Relative to other Resources == indexterm:[Resource,Constraints,Colocation] indexterm:[Resource,Location Relative to other Resources] When the location of one resource depends on the location of another one, we call this colocation. There is an important side-effect of creating a colocation constraint between two resources: it affects the order in which resources are assigned to a node. If you think about it, it's somewhat obvious. You can't place A relative to B unless you know where B is. footnote:[ While the human brain is sophisticated enough to read the constraint in any order and choose the correct one depending on the situation, the cluster is not quite so smart. Yet. ] So when you are creating colocation constraints, it is important to consider whether you should colocate A with B or B with A. -Another thing to keep in mind is that, assuming A is collocated with -B, the cluster will also take into account A's preferences when +Another thing to keep in mind is that, assuming A is colocated with +B, the cluster will take into account A's preferences when deciding which node to choose for B. -For a detailed look at exactly how this occurs, see the -http://www.clusterlabs.org/mediawiki/images/6/61/Colocation_Explained.pdf[Colocation -Explained] document. +For a detailed look at exactly how this occurs, see +http://clusterlabs.org/doc/Colocation_Explained.pdf[Colocation Explained]. === Options === -.Properties of a Collocation Constraint +.Properties of a Colocation Constraint [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |id |A unique name for the constraint. indexterm:[id,Colocation Constraints] indexterm:[Constraints,Colocation,id] |rsc |The colocation source. If the constraint cannot be satisfied, the cluster may decide not to allow the resource to run at all. indexterm:[rsc,Colocation Constraints] indexterm:[Constraints,Colocation,rsc] |with-rsc |The colocation target. The cluster will decide where to put this resource first and then decide where to put the resource in the +rsc+ field. indexterm:[with-rsc,Colocation Constraints] indexterm:[Constraints,Colocation,with-rsc] |score |Positive values indicate the resource should run on the same node. Negative values indicate the resources should not run on the same node. Values of \+/- +INFINITY+ change "should" to "must". indexterm:[score,Colocation Constraints] indexterm:[Constraints,Colocation,score] |========================================================= === Mandatory Placement === Mandatory placement occurs any time the constraint's score is ++INFINITY+ or +-INFINITY+. In such cases, if the constraint can't be satisfied, then the +rsc+ resource is not permitted to run. For +score=INFINITY+, this includes cases where the +with-rsc+ resource is not active. If you need +resource1+ to always run on the same machine as +resource2+, you would add the following constraint: .An example colocation constraint [source,XML] Remember, because +INFINITY+ was used, if +resource2+ can't run on any of the cluster nodes (for whatever reason) then +resource1+ will not be allowed to run. Alternatively, you may want the opposite... that +resource1+ cannot run on the same machine as +resource2+. In this case use +score="-INFINITY"+ .An example anti-colocation constraint [source,XML] Again, by specifying +-INFINTY+, the constraint is binding. So if the only place left to run is where +resource2+ already is, then +resource1+ may not run anywhere. === Advisory Placement === If mandatory placement is about "must" and "must not", then advisory placement is the "I'd prefer if" alternative. For constraints with scores greater than +-INFINITY+ and less than +INFINITY+, the cluster will try and accommodate your wishes but may ignore them if the alternative is to stop some of the cluster resources. Like in life, where if enough people prefer something it effectively becomes mandatory, advisory colocation constraints can combine with other elements of the configuration to behave as if they were mandatory. .An example advisory-only colocation constraint [source,XML] [[s-resource-sets-ordering]] == Ordering Sets of Resources == A common situation is for an administrator to create a chain of ordered resources, such as: .A chain of ordered resources ====== [source,XML] ------- ------- ====== .Visual representation of the four resources' start order for the above constraints image::images/resource-set.png["Ordered set",width="16cm",height="2.5cm",align="center"] === Ordered Set === To simplify this situation, there is an alternate format for ordering constraints: .A chain of ordered resources expressed as a set ====== [source,XML] ------- ------- ====== [WARNING] ========= Always pay attention to how your tools expose this functionality. In some tools +create set A B+ is *NOT* equivalent to +create A then B+. ========= While the set-based format is not less verbose, it is significantly easier to get right and maintain. It can also be expanded to allow ordered sets of (un)ordered resources. In the example below, +rscA+ and +rscB+ can both start in parallel, as can +rscC+ and +rscD+, however +rscC+ and +rscD+ can only start once _both_ +rscA+ _and_ +rscB+ are active. .Ordered sets of unordered resources ====== [source,XML] ------- ------- ====== .Visual representation of the start order for two ordered sets of unordered resources image::images/two-sets.png["Two ordered sets",width="13cm",height="7.5cm",align="center"] Of course either set -- or both sets -- of resources can also be internally ordered (by setting +sequential="true"+) and there is no limit to the number of sets that can be specified. .Advanced use of set ordering - Three ordered sets, two of which are internally unordered ====== [source,XML] ------- ------- ====== .Visual representation of the start order for the three sets defined above image::images/three-sets.png["Three ordered sets",width="16cm",height="7.5cm",align="center"] === Resource Set OR Logic === The unordered set logic discussed so far has all been "AND" logic. To illustrate this take the 3 resource set figure in the previous section. -Those sets can be expressed, +(A and B) then (C) then (D) then (E and F)+ +Those sets can be expressed, +(A and B) then \(C) then (D) then (E and F)+. -Say for example we want change the first set, (A and B), to use "OR" logic -so the sets look like this, +(A or B) then (C) then (D) then (E and F)+. +Say for example we want to change the first set, +(A and B)+, to use "OR" logic +so the sets look like this: +(A or B) then \(C) then (D) then (E and F)+. This functionality can be achieved through the use of the +require-all+ option. By default this option is 'require-all=true' which is why the "AND" logic is used by default. Changing +require-all=false+ means only one resource in the set needs to be started before continuing on to the next set. Note that the 'require-all=false' option only makes sense to use in conjunction with unordered sets, 'sequential=false'. Think of it like this, 'sequential=false' modifies the set to be an unordered set that uses "AND" logic by default, by adding 'require-all=false' the unordered set's "AND" logic is flipped to "OR" logic. .Resource Set "OR" logic. Three ordered sets, where the first set is internally unordered with "OR" logic. ====== [source,XML] ------- ------- ====== [[s-resource-sets-colocation]] -== Collocating Sets of Resources == +== Colocating Sets of Resources == Another common situation is for an administrator to create a set of -collocated resources. Previously this was possible either by defining -a resource group (See <>) which could not always -accurately express the design; or by defining each relationship as an -individual constraint, causing a constraint explosion as the number of -resources and combinations grew. +colocated resources. -.A chain of collocated resources +One way to do this would be to define a resource group (see +<>), but that cannot always accurately express the desired +state. + +Another way would be to define each relationship as an individual constraint, +but that causes a constraint explosion as the number of resources and +combinations grow. An example of this approach: + +.Chain of colocated resources ====== [source,XML] ------- - - - + + + ------- ====== To make things easier, we allow an alternate form of colocation -constraints using +resource_sets+. Just like the expanded version, a -resource that can't be active also prevents any resource that must be -collocated with it from being active. For example, if +B+ was not -able to run, then both +C+ (and by inference +D+) must also remain -stopped. +constraints using +resource_set+. As with the chained version, a +resource that can't be active prevents any resource that must be +colocated with it from being active. For example, if +C+ is not +able to run, then both +B+ and by inference +A+ must also remain +stopped. Here is an example +resource_set+: -.The equivalent colocation chain expressed using +resource_sets+ +.Equivalent colocation chain expressed using +resource_set+ ====== [source,XML] ------- - + ------- ====== [WARNING] ========= Always pay attention to how your tools expose this functionality. In some tools +create set A B+ is *NOT* equivalent to +create A with B+. ========= .A group resource with the equivalent colocation rules [source,XML] ------- ------- This notation can also be used in this context to tell the cluster that a set of resources must all be located with a common peer, but have no dependencies on each other. In this scenario, unlike the previous, +B would+ be allowed to remain active even if +A or+ +C+ (or both) were inactive. .Using colocation sets to specify a common peer. ====== [source,XML] ------- - + - + ------- ====== Of course there is no limit to the number and size of the sets used. The only thing that matters is that in order for any member of set N to be active, all the members of set N+1 must also be active (and naturally on the same node); and if a set has +sequential="true"+, then in order for member M to be active, member M+1 must also be active. You can even specify the role in which the members of a set must be in using the set's role attribute. .A colocation chain where the members of the middle set have no inter-dependencies and the last has master status. ====== [source,XML] ------- - + - + - + ------- ====== .Visual representation of a colocation chain where the members of the middle set have no inter-dependencies image::images/three-sets-complex.png["Colocation chain",width="16cm",height="9cm",align="center"] diff --git a/doc/Pacemaker_Explained/en-US/Ch-Notifications.txt b/doc/Pacemaker_Explained/en-US/Ch-Notifications.txt index 13b835d4f7..fdad43c64f 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Notifications.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Notifications.txt @@ -1,138 +1,138 @@ = Receiving Notification for Cluster Events = //// -We prefer [[ch-notifications]], but older versions of asciidoc dont deal well +We prefer [[ch-notifications]], but older versions of asciidoc don't deal well with that construct for chapter headings //// anchor:ch-notifications[Chapter 7, Receiving Notification for Cluster Events] indexterm:[Resource,Notification] A Pacemaker cluster is an event driven system. In this context, an event is a resource failure or configuration change (not exhaustive). The +ocf:pacemaker:ClusterMon+ resource can monitor the cluster status and triggers alerts on each cluster event. This resource runs +crm_mon+ in the background at regular intervals (configurable) and uses +crm_mon+ capabilities to send emails (SMTP), SNMP traps or to execute an external program via the +extra_options+ parameter. [NOTE] ===== Depending on your system settings and compilation settings, SNMP or email alerts might be unavailable. Check +crm_mon --help+ output to see if these options are available to you. In any case, executing an external agent will always be available, and you can have this agent to send emails, SNMP traps, or whatever action you develop. ===== [[s-notification-snmp]] == Configuring SNMP Notifications == indexterm:[Resource,Notification,SNMP] Requires an IP to send SNMP traps to, and a SNMP community. Pacemaker MIB is found in _/usr/share/snmp/mibs/PCMK-MIB.txt_ .Configuring ClusterMon to send SNMP traps ===== [source,XML] ----- ----- ===== [[s-notification-email]] == Configuring Email Notifications == indexterm:[Resource,Notification,SMTP,Email] Requires a user to send mail alerts to. "Mail-From", SMTP relay and Subject prefix can also be configured. .Configuring ClusterMon to send email alerts ===== [source,XML] ----- ----- ===== [[s-notification-external]] == Configuring Notifications via External-Agent == Requires a program (external-agent) to run when resource operations take place, and an external-recipient (IP address, Email address, URI). When triggered, the external-agent is fed with dynamically filled environnement variables describing precisely the cluster event that occurred. By making smart usage of these variables in your external-agent code, you can trigger any action. .Configuring ClusterMon to execute an external-agent ===== [source,XML] ----- ----- ===== .Environment Variables Passed to the External Agent [width="95%",cols="1m,2<",options="header",align="center"] |========================================================= |Environment Variable |Description |CRM_notify_recipient | The static external-recipient from the resource definition. indexterm:[Environment Variable,CRM_notify_recipient] |CRM_notify_node | The node on which the status change happened. indexterm:[Environment Variable,CRM_notify_node] |CRM_notify_rsc | The name of the resource that changed the status. indexterm:[Environment Variable,CRM_notify_rsc] |CRM_notify_task | The operation that caused the status change. indexterm:[Environment Variable,CRM_notify_task] |CRM_notify_desc | The textual output relevant error code of the operation (if any) that caused the status change. indexterm:[Environment Variable,CRM_notify_desc] |CRM_notify_rc | The return code of the operation. indexterm:[Environment Variable,CRM_notify_rc] |CRM_notify_target_rc | The expected return code of the operation. indexterm:[Environment Variable,CRM_notify_target_rc] |CRM_notify_status | The numerical representation of the status of the operation. indexterm:[Environment Variable,CRM_notify_target_rc] |========================================================= diff --git a/doc/Pacemaker_Explained/en-US/Ch-Resources.txt b/doc/Pacemaker_Explained/en-US/Ch-Resources.txt index 784ef720ad..f98fe8adf3 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Resources.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Resources.txt @@ -1,718 +1,706 @@ = Cluster Resources = == What is a Cluster Resource == indexterm:[Resource] The role of a resource agent is to abstract the service it provides and present a consistent view to the cluster, which allows the cluster to be agnostic about the resources it manages. The cluster doesn't need to understand how the resource works because it relies on the resource agent to do the right thing when given a +start+, +stop+ or +monitor+ command. For this reason it is crucial that resource agents are well tested. Typically resource agents come in the form of shell scripts, however they can be written using any technology (such as C, Python or Perl) that the author is comfortable with. [[s-resource-supported]] == Supported Resource Classes == indexterm:[Resource,class] There are six classes of agents supported by Pacemaker: * OCF * LSB * Upstart * Systemd * Fencing * Service * Nagios -indexterm:[Resource,Heartbeat] -indexterm:[Heartbeat,Resources] - -Version 1 of Heartbeat came with its own style of resource agents and -it is highly likely that many people have written their own agents -based on its conventions. footnote:[ See -http://wiki.linux-ha.org/HeartbeatResourceAgent for more information ] - -Although deprecated with the release of Heartbeat v2, they were -supported by Pacemaker up until the release of 1.1.8 to enable -administrators to continue to use these agents. - === Open Cluster Framework === indexterm:[Resource,OCF] indexterm:[OCF,Resources] indexterm:[Open Cluster Framework,Resources] The OCF standard footnote:[ http://www.opencf.org/cgi-bin/viewcvs.cgi/specs/ra/resource-agent-api.txt?rev=HEAD - at least as it relates to resource agents. ] footnote:[ The Pacemaker implementation has been somewhat extended from the OCF Specs, but none of those changes are incompatible with the original OCF specification. ] is basically an extension of the Linux Standard Base conventions for init scripts to: * support parameters, * make them self describing and * extensible OCF specs have strict definitions of the exit codes that actions must return. footnote:[ Included with the cluster is the ocf-tester script, which can be useful in this regard. ] The cluster follows these specifications exactly, and giving the wrong exit code will cause the cluster to behave in ways you will likely find puzzling and annoying. In particular, the cluster needs to distinguish a completely stopped resource from one which is in some erroneous and indeterminate state. Parameters are passed to the script as environment variables, with the special prefix +OCF_RESKEY_+. So, a parameter which the user thinks of as ip it will be passed to the script as +OCF_RESKEY_ip+. The number and purpose of the parameters is completely arbitrary, however your script should advertise any that it supports using the +meta-data+ command. The OCF class is the most preferred one as it is an industry standard, highly flexible (allowing parameters to be passed to agents in a non-positional manner) and self-describing. For more information, see the http://www.linux-ha.org/wiki/OCF_Resource_Agents[reference] and <>. === Linux Standard Base === indexterm:[Resource,LSB] indexterm:[LSB,Resources] indexterm:[Linux Standard Base,Resources] LSB resource agents are those found in '/etc/init.d'. Generally they are provided by the OS/distribution and, in order to be used with the cluster, they must conform to the LSB Spec. footnote:[ See http://refspecs.linux-foundation.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html for the LSB Spec (as it relates to init scripts). ] Many distributions claim LSB compliance but ship with broken init scripts. For details on how to check if your init script is LSB-compatible, see <>. The most common problems are: * Not implementing the status operation at all * Not observing the correct exit status codes for start/stop/status actions * Starting a started resource returns an error (this violates the LSB spec) * Stopping a stopped resource returns an error (this violates the LSB spec) === Systemd === indexterm:[Resource,Systemd] indexterm:[Systemd,Resources] Some newer distributions have replaced the old http://en.wikipedia.org/wiki/Init#SysV-style[SYS-V] style of initialization daemons (and scripts) with an alternative called http://www.freedesktop.org/wiki/Software/systemd[Systemd]. Pacemaker is able to manage these services _if they are present_. Instead of +init scripts+, systemd has +unit files+. Generally the services (or unit files) are provided by the OS/distribution but there are some instructions for converting from init scripts at: http://0pointer.de/blog/projects/systemd-for-admins-3.html [NOTE] ====== Remember to make sure the computer is +not+ configured to start any services at boot time that should be controlled by the cluster. ====== === Upstart === indexterm:[Resource,Upstart] indexterm:[Upstart,Resources] Some newer distributions have replaced the old http://en.wikipedia.org/wiki/Init#SysV-style[SYS-V] style of initialization daemons (and scripts) with an alternative called http://upstart.ubuntu.com[Upstart]. Pacemaker is able to manage these services _if they are present_. Instead of +init scripts+, upstart has +jobs+. Generally the services (or jobs) are provided by the OS/distribution. [NOTE] ====== Remember to make sure the computer is +not+ configured to start any services at boot time that should be controlled by the cluster. ====== === System Services === indexterm:[Resource,System Services] indexterm:[System Service,Resources] Since there are now many "common" types of system services (+systemd+, +upstart+, and +lsb+), Pacemaker supports a special alias which intelligently figures out which one applies to a given cluster node. This is particularly useful when the cluster contains a mix of +systemd+, +upstart+, and +lsb+. In order, Pacemaker will try to find the named service as: . an LSB (SYS-V) init script . a Systemd unit file . an Upstart job === STONITH === indexterm:[Resource,STONITH] indexterm:[STONITH,Resources] There is also an additional class, STONITH, which is used exclusively for fencing related resources. This is discussed later in <>. === Nagios Plugins === indexterm:[Resource,Nagios Plugins] indexterm:[Nagios Plugins,Resources] Nagios plugins allow us to monitor services on the remote hosts. http://nagiosplugins.org[Nagios Plugins]. Pacemaker is able to do remote monitoring with the plugins _if they are present_. -An use case is to configure them as resources belonging to a resource -container, which usually is a VM, and the container will be restarted -if any of them has failed. While they can also be configured as ordinary -resources to be just used for monitoring hosts or services via network. +A common use case is to configure them as resources belonging to a resource +container (usually a virtual machine), and the container will be restarted +if any of them has failed. Another use is to configure them as ordinary +resources to be used for monitoring hosts or services via the network. The supported parameters are same as the long options of a nagios plugin. [[primitive-resource]] == Resource Properties == These values tell the cluster which script to use for the resource, where to find that script and what standards it conforms to. .Properties of a Primitive Resource [width="95%",cols="1m,6<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the resource indexterm:[id,Resource] indexterm:[Resource,Property,id] |class |The standard the script conforms to. Allowed values: +ocf+, +service+, +upstart+, +systemd+, +lsb+, +stonith+ indexterm:[class,Resource] indexterm:[Resource,Property,class] |type |The name of the Resource Agent you wish to use. Eg. _IPaddr_ or _Filesystem_ indexterm:[type,Resource] indexterm:[Resource,Property,type] |provider |The OCF spec allows multiple vendors to supply the same ResourceAgent. To use the OCF resource agents supplied with Heartbeat, you should specify +heartbeat+ here. indexterm:[provider,Resource] indexterm:[Resource,Property,provider] |========================================================= Resource definitions can be queried with the `crm_resource` tool. For example ---- # crm_resource --resource Email --query-xml ---- might produce: .An example system resource ===== [source,XML] ===== [NOTE] ===== One of the main drawbacks to system services (such as LSB, Systemd and Upstart) resources is that they do not allow any parameters! ===== .An example OCF resource ===== [source,XML] ------- ------- ===== [[s-resource-options]] == Resource Options == Options are used by the cluster to decide how your resource should behave and can be easily set using the `--meta` option of the `crm_resource` command. .Options for a Primitive Resource [width="95%",cols="1m,1,4<",options="header",align="center"] |========================================================= |Field |Default |Description |priority |+0+ |If not all resources can be active, the cluster will stop lower priority resources in order to keep higher priority ones active. indexterm:[priority,Resource Option] indexterm:[Resource,Option,priority] |target-role |+Started+ |What state should the cluster attempt to keep this resource in? Allowed values: * 'Stopped' - Force the resource to be stopped * 'Started' - Allow the resource to be started (In the case of <> resources, they will not promoted to master) * 'Master' - Allow the resource to be started and, if appropriate, promoted indexterm:[target-role,Resource Option] indexterm:[Resource,Option,target-role] |is-managed |+TRUE+ |Is the cluster allowed to start and stop the resource? Allowed values: +true+, +false+ indexterm:[is-managed,Resource Option] indexterm:[Resource,Option,is-managed] |resource-stickiness |Calculated |How much does the resource prefer to stay where it is? Defaults to the value of +resource-stickiness+ in the +rsc_defaults+ section indexterm:[resource-stickiness,Resource Option] indexterm:[Resource,Option,resource-stickiness] |requires |Calculated |Under what conditions can the resource be started. ('Since 1.1.8') Defaults to +fencing+ unless +stonith-enabled+ is 'false' or +class+ is 'stonith' - under those conditions the default is +quorum+. Possible values: * 'nothing' - can always be started * 'quorum' - The cluster can only start this resource if a majority of the configured nodes are active * 'fencing' - The cluster can only start this resource if a majority of the configured nodes are active _and_ any failed or unknown nodes have been powered off. * 'unfencing' - The cluster can only start this resource if a majority of the configured nodes are active _and_ any failed or unknown nodes have been powered off _and_ only on nodes that have been 'unfenced' indexterm: Option[requires,Resource] indexterm:[Resource,Option,requires] |migration-threshold |+INFINITY+ (disabled) |How many failures may occur for this resource on a node, before this node is marked ineligible to host this resource. indexterm:[migration-threshold,Resource Option] indexterm:[Resource,Option,migration-threshold] |failure-timeout |+0+ (disabled) |How many seconds to wait before acting as if the failure had not occurred, and potentially allowing the resource back to the node on which it failed. indexterm:[failure-timeout,Resource Option] indexterm:[Resource,Option,failure-timeout] |multiple-active |+stop_start+ |What should the cluster do if it ever finds the resource active on more than one node. Allowed values: * 'block' - mark the resource as unmanaged * 'stop_only' - stop all active instances and leave them that way * 'stop_start' - stop all active instances and start the resource in one location only indexterm:[multiple-active,Resource Option] indexterm:[Resource,Option,multiple-active] |remote-node |++ (disabled) |The name of the remote-node this resource defines. This both enables the resource as a remote-node and defines the unique name used to identify the remote-node. If no other parameters are set, this value will also be assumed as the hostname to connect to at port 3121. +WARNING+ This value cannot overlap with any resource or node IDs. |remote-port |+3121+ |Configure a custom port to use for the guest connection to pacemaker_remote. |remote-addr |+remote-node+ value used as hostname |The ip address or hostname to connect to if remote-node's name is not the hostname of the guest. |+remote-connect-timeout+ |+60s+ |How long before a pending guest connection will time out. |========================================================= If you performed the following commands on the previous LSB Email resource ------- # crm_resource --meta --resource Email --set-parameter priority --property-value 100 # crm_resource --meta --resource Email --set-parameter multiple-active --property-value block ------- the resulting resource definition would be .An LSB resource with cluster options ===== [source,XML] ------- ------- ===== [[s-resource-defaults]] == Setting Global Defaults for Resource Options == To set a default value for a resource option, simply add it to the +rsc_defaults+ section with `crm_attribute`. Thus, ---- # crm_attribute --type rsc_defaults --attr-name is-managed --attr-value false ---- would prevent the cluster from starting or stopping any of the resources in the configuration (unless of course the individual resources were specifically enabled and had +is-managed+ set to +true+). == Instance Attributes == The scripts of some resource classes (LSB not being one of them) can be given parameters which determine how they behave and which instance of a service they control. If your resource agent supports parameters, you can add them with the `crm_resource` command. For instance ---- # crm_resource --resource Public-IP --set-parameter ip --property-value 1.2.3.4 ---- would create an entry in the resource like this: .An example OCF resource with instance attributes ===== [source,XML] ------- ------- ===== For an OCF resource, the result would be an environment variable called +OCF_RESKEY_ip+ with a value of +1.2.3.4+. The list of instance attributes supported by an OCF script can be found by calling the resource script with the `meta-data` command. The output contains an XML description of all the supported attributes, their purpose and default values. .Displaying the metadata for the Dummy resource agent template ===== ------- # export OCF_ROOT=/usr/lib/ocf # $OCF_ROOT/resource.d/pacemaker/Dummy meta-data ------- [source,XML] ------- 1.0 This is a Dummy Resource Agent. It does absolutely nothing except keep track of whether its running or not. Its purpose in life is for testing and to serve as a template for RA writers. Dummy resource agent Location to store the resource state in. State file Dummy attribute that can be changed to cause a reload Dummy attribute that can be changed to cause a reload ------- ===== == Resource Operations == indexterm:[Resource,Action] === Monitoring Resources for Failure === By default, the cluster will not ensure your resources are still healthy. To instruct the cluster to do this, you need to add a +monitor+ operation to the resource's definition. .An OCF resource with a recurring health check ===== [source,XML] ------- ------- ===== .Properties of an Operation [width="95%",cols="1m,6<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the action. Must be unique. indexterm:[id,Action Property] indexterm:[Action,Property,id] |name |The action to perform. Common values: +monitor+, +start+, +stop+ indexterm:[name,Action Property] indexterm:[Action,Property,name] |interval |How frequently (in seconds) to perform the operation. Default value: +0+, meaning never. indexterm:[interval,Action Property] indexterm:[Action,Property,interval] |timeout |How long to wait before declaring the action has failed. indexterm:[timeout,Action Property] indexterm:[Action,Property,timeout] |on-fail |The action to take if this action ever fails. Allowed values: * 'ignore' - Pretend the resource did not fail * 'block' - Don't perform any further operations on the resource * 'stop' - Stop the resource and do not start it elsewhere * 'restart' - Stop the resource and start it again (possibly on a different node) * 'fence' - STONITH the node on which the resource failed * 'standby' - Move _all_ resources away from the node on which the resource failed The default for the +stop+ operation is +fence+ when STONITH is enabled and +block+ otherwise. All other operations default to +restart+. indexterm:[on-fail,Action Property] indexterm:[Action,Property,on-fail] |enabled |If +false+, the operation is treated as if it does not exist. Allowed values: +true+, +false+ indexterm:[enabled,Action Property] indexterm:[Action,Property,enabled] |record-pending |If +true+, the intention to perform the operation is recorded so that GUIs and CLI tools can indicate that an operation is in progress. This is best set as an 'operation default' (see next section). Allowed values: +true+, +false+. indexterm:[enabled,Action Property] indexterm:[Action,Property,enabled] |========================================================= [[s-operation-defaults]] === Setting Global Defaults for Operations === To set a default value for a operation option, simply add it to the +op_defaults+ section with `crm_attribute`. Thus, ---- # crm_attribute --type op_defaults --attr-name timeout --attr-value 20s ---- would default each operation's +timeout+ to 20 seconds. If an operation's definition also includes a value for +timeout+, then that value would be used instead (for that operation only). -==== When Resources Take a Long Time to Start/Stop ==== +=== When Resources Take a Long Time to Start/Stop === There are a number of implicit operations that the cluster will always perform - +start+, +stop+ and a non-recurring +monitor+ operation (used at startup to check the resource isn't already active). If one of these is taking too long, then you can create an entry for them and simply specify a new value. .An OCF resource with custom timeouts for its implicit actions ===== [source,XML] ------- ------- ===== -==== Multiple Monitor Operations ==== +=== Multiple Monitor Operations === Provided no two operations (for a single resource) have the same name and interval you can have as many monitor operations as you like. In this way you can do a superficial health check every minute and progressively more intense ones at higher intervals. To tell the resource agent what kind of check to perform, you need to provide each monitor with a different value for a common parameter. The OCF standard creates a special parameter called +OCF_CHECK_LEVEL+ for this purpose and dictates that it is _"made available to the resource agent without the normal +OCF_RESKEY+ prefix"_. Whatever name you choose, you can specify it by adding an +instance_attributes+ block to the op tag. Note that it is up to each resource agent to look for the parameter and decide how to use it. .An OCF resource with two recurring health checks, performing different levels of checks - specified via +OCF_CHECK_LEVEL+. ===== [source,XML] ------- ------- ===== -==== Disabling a Monitor Operation ==== +=== Disabling a Monitor Operation === The easiest way to stop a recurring monitor is to just delete it. However, there can be times when you only want to disable it temporarily. In such cases, simply add +enabled="false"+ to the operation's definition. .Example of an OCF resource with a disabled health check ===== [source,XML] ------- ------- ===== This can be achieved from the command-line by executing ---- # cibadmin -M -X '' ---- Once you've done whatever you needed to do, you can then re-enable it with diff --git a/doc/Pacemaker_Explained/en-US/Ch-Rules.txt b/doc/Pacemaker_Explained/en-US/Ch-Rules.txt index 4f80983915..7e8b205873 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Rules.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Rules.txt @@ -1,561 +1,561 @@ = Rules = //// -We prefer [[ch-rules]], but older versions of asciidoc dont deal well +We prefer [[ch-rules]], but older versions of asciidoc don't deal well with that construct for chapter headings //// anchor:ch-rules[Chapter 8, Rules] indexterm:[Resource,Constraint,Rule] Rules can be used to make your configuration more dynamic. One common example is to set one value for +resource-stickiness+ during working hours, to prevent resources from being moved back to their most preferred location, and another on weekends when no-one is around to notice an outage. Another use of rules might be to assign machines to different processing groups (using a node attribute) based on time and to then use that attribute when creating location constraints. Each rule can contain a number of expressions, date-expressions and even other rules. The results of the expressions are combined based on the rule's +boolean-op+ field to determine if the rule ultimately evaluates to +true+ or +false+. What happens next depends on the context in which the rule is being used. .Properties of a Rule [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |role |Limits the rule to apply only when the resource is in that role. Allowed values: _Started_, +Slave,+ and +Master+. NOTE: A rule with +role="Master"+ can not determine the initial location of a clone instance. It will only affect which of the active instances will be promoted. indexterm:[role,Constraint Rule] indexterm:[Constraint,Rule,role] |score |The score to apply if the rule evaluates to +true+. Limited to use in rules that are part of location constraints. indexterm:[score,Constraint Rule] indexterm:[Constraint,Rule,score] |score-attribute |The node attribute to look up and use as a score if the rule evaluates to +true+. Limited to use in rules that are part of location constraints. indexterm:[score-attribute,Constraint Rule] indexterm:[Constraint,Rule,score-attribute] |boolean-op |How to combine the result of multiple expression objects. Allowed values: _and_ and +or+. indexterm:[boolean-op,Constraint Rule] indexterm:[Constraint,Rule,boolean-op] |========================================================= == Node Attribute Expressions == indexterm:[Resource,Constraint,Attribute Expression] Expression objects are used to control a resource based on the attributes defined by a node or nodes. In addition to any attributes added by the administrator, each node has a built-in node attribute called +#uname+ that can also be used. .Properties of an Expression [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |value |User supplied value for comparison indexterm:[value,Constraint Expression] indexterm:[Constraint,Attribute Expression,value] |attribute |The node attribute to test indexterm:[attribute,Constraint Expression] indexterm:[Constraint,Attribute Expression,attribute] |type |Determines how the value(s) should be tested. Allowed values: _string_, +integer+, +version+ indexterm:[type,Constraint Expression] indexterm:[Constraint,Attribute Expression,type] |operation |The comparison to perform. Allowed values: * 'lt' - True if the node attribute's value is less than +value+ * 'gt' - True if the node attribute's value is greater than +value+ * 'lte' - True if the node attribute's value is less than or equal to +value+ * 'gte' - True if the node attribute's value is greater than or equal to +value+ * 'eq' - True if the node attribute's value is equal to +value+ * 'ne' - True if the node attribute's value is not equal to +value+ * 'defined' - True if the node has the named attribute * 'not_defined' - True if the node does not have the named attribute indexterm:[operation,Constraint Expression] indexterm:[Constraint,Attribute Expression,operation] |========================================================= == Time/Date Based Expressions == indexterm:[Time Based Expressions] indexterm:[Resource,Constraint,Date/Time Expression] As the name suggests, +date_expressions+ are used to control a resource or cluster option based on the current date/time. They can contain an optional +date_spec+ and/or +duration+ object depending on the context. .Properties of a Date Expression [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |start |A date/time conforming to the ISO8601 specification. indexterm:[start,Constraint Expression] indexterm:[Constraint,Date/Time Expression,start] |end |A date/time conforming to the ISO8601 specification. Can be inferred by supplying a value for +start+ and a +duration+. indexterm:[end,Constraint Expression] indexterm:[Constraint,Date/Time Expression,end] |operation |Compares the current date/time with the start and/or end date, depending on the context. Allowed values: * 'gt' - True if the current date/time is after +start+ * 'lt' - True if the current date/time is before +end+ * 'in-range' - True if the current date/time is after +start+ and before +end+ * 'date-spec' - performs a cron-like comparison to the current date/time indexterm:[operation,Constraint Expression] indexterm:[Constraint,Date/Time Expression,operation] |========================================================= [NOTE] ====== As these comparisons (except for +date_spec+) include the time, the +eq+, +neq+, +gte+ and +lte+ operators have not been implemented since they would only be valid for a single second. ====== === Date Specifications === indexterm:[Date Specification] indexterm:[Resource,Constraint,Date Specification] +date_spec+ objects are used to create cron-like expressions relating to time. Each field can contain a single number or a single range. Instead of defaulting to zero, any field not supplied is ignored. For example, +monthdays="1"+ matches the first day of every month and +hours="09-17"+ matches the hours between 9am and 5pm (inclusive). However, at this time one cannot specify +weekdays="1,2"+ or +weekdays="1-2,5-6"+ since they contain multiple ranges. Depending on demand, this may be implemented in a future release. .Properties of a Date Spec [width="95%",cols="2m,5<",options="header",align="center"] |========================================================= |Field |Description |id |A unique name for the date indexterm:[id,Date Specification] indexterm:[Constraint,Date Specification,id] |hours |Allowed values: 0-23 indexterm:[hours,Date Specification] indexterm:[Constraint,Date Specification,hours] |monthdays -|Allowed values: 0-31 (depending on month and year) +|Allowed values: 1-31 (depending on month and year) indexterm:[monthdays,Date Specification] indexterm:[Constraint,Date Specification,monthdays] |weekdays |Allowed values: 1-7 (1=Monday, 7=Sunday) indexterm:[weekdays,Date Specification] indexterm:[Constraint,Date Specification,weekdays] |yeardays |Allowed values: 1-366 (depending on the year) indexterm:[yeardays,Date Specification] indexterm:[Constraint,Date Specification,yeardays] |months |Allowed values: 1-12 indexterm:[months,Date Specification] indexterm:[Constraint,Date Specification,months] |weeks |Allowed values: 1-53 (depending on weekyear) indexterm:[weeks,Date Specification] indexterm:[Constraint,Date Specification,weeks] |years |Year according the Gregorian calendar indexterm:[years,Date Specification] indexterm:[Constraint,Date Specification,years] |weekyears |May differ from Gregorian years; Eg. +2005-001 Ordinal+ is also +2005-01-01 Gregorian+ is also +2004-W53-6 Weekly+ indexterm:[weekyears,Date Specification] indexterm:[Constraint,Date Specification,weekyears] |moon |Allowed values: 0-7 (0 is new, 4 is full moon). Seriously, you can use this. This was implemented to demonstrate the ease with which new comparisons could be added. indexterm:[moon,Date Specification] indexterm:[Constraint,Date Specification,moon] |========================================================= === Durations === indexterm:[Duration] indexterm:[Resource,Constraint,Duration] Durations are used to calculate a value for +end+ when one is not supplied to in_range operations. They contain the same fields as +date_spec+ objects but without the limitations (ie. you can have a duration of 19 months). Like +date_specs+, any field not supplied is ignored. == Sample Time Based Expressions == A small sample of how time based expressions can be used. //// -On older versions of asciidoc, the [source] directive makes the title dissappear +On older versions of asciidoc, the [source] directive makes the title disappear //// .True if now is any time in the year 2005 ==== [source,XML] ---- ---- ==== .Equivalent expression ==== [source,XML] ---- ---- ==== .9am-5pm, Mon-Friday ==== [source,XML] ------- ------- ==== Please note that the +16+ matches up to +16:59:59+, as the numeric value (hour) still matches! .9am-6pm, Mon-Friday, or all day saturday ==== [source,XML] ------- ------- ==== .9am-5pm or 9pm-12pm, Mon-Friday ==== [source,XML] ------- ------- ==== .Mondays in March 2005 ==== [source,XML] ------- ------- ==== [NOTE] ====== Because no time is specified, 00:00:00 is implied. This means that the range includes all of 2005-03-01 but none of 2005-04-01. You may wish to write +end="2005-03-31T23:59:59"+ to avoid confusion. ====== .A full moon on Friday the 13th ===== [source,XML] ------- ------- ===== == Using Rules to Determine Resource Location == indexterm:[Rule,Determine Resource Location] indexterm:[Resource,Location,Determine by Rules] If the constraint's outer-most rule evaluates to +false+, the cluster treats the constraint as if it was not there. When the rule evaluates to +true+, the node's preference for running the resource is updated with the score associated with the rule. -If this sounds familiar, its because you have been using a simplified +If this sounds familiar, it is because you have been using a simplified syntax for location constraint rules already. Consider the following location constraint: .Prevent myApacheRsc from running on c001n03 ===== [source,XML] ------- ------- ===== This constraint can be more verbosely written as: .Prevent myApacheRsc from running on c001n03 - expanded version ===== [source,XML] ------- ------- ===== The advantage of using the expanded form is that one can then add extra clauses to the rule, such as limiting the rule such that it only applies during certain times of the day or days of the week (this is discussed in subsequent sections). It also allows us to match on node properties other than its name. If we rated each machine's CPU power such that the cluster had the following nodes section: .A sample nodes section for use with score-attribute ===== [source,XML] ------- ------- ===== then we could prevent resources from running on underpowered machines with the rule [source,XML] ------- - ------- === Using +score-attribute+ Instead of +score+ === When using +score-attribute+ instead of +score+, each node matched by the rule has its score adjusted differently, according to its value for the named node attribute. Thus, in the previous example, if a rule used +score-attribute="cpu_mips"+, +c001n01+ would have its preference to run the resource increased by +1234+ whereas +c001n02+ would have its preference increased by +5678+. == Using Rules to Control Resource Options == Often some cluster nodes will be different from their peers; sometimes these differences (the location of a binary or the names of network interfaces) require resources to be configured differently depending on the machine they're hosted on. By defining multiple +instance_attributes+ objects for the resource and adding a rule to each, we can easily handle these special cases. In the example below, +mySpecialRsc+ will use eth1 and port 9999 when run on +node1+, eth2 and port 8888 on +node2+ and default to eth0 and port 9999 for all other nodes. .Defining different resource options based on the node name ===== [source,XML] ------- ------- ===== The order in which +instance_attributes+ objects are evaluated is determined by their score (highest to lowest). If not supplied, score defaults to zero and objects with an equal score are processed in listed order. If the +instance_attributes+ object does not have a +rule+ or has a +rule+ that evaluates to +true+, then for any parameter the resource does not yet have a value for, the resource will use the parameter values defined by the +instance_attributes+ object. == Using Rules to Control Cluster Options == indexterm:[Rule,Controlling Cluster Options] indexterm:[Cluster,Setting Options with Rules] Controlling cluster options is achieved in much the same manner as specifying different resource options on different nodes. The difference is that because they are cluster options, one cannot (or should not, because they won't work) use attribute based expressions. The following example illustrates how to set a different +resource-stickiness+ value during and outside of work hours. This allows resources to automatically move back to their most preferred hosts, but at a time that (in theory) does not interfere with business activities. .Change +resource-stickiness+ during working hours ===== [source,XML] ------- ------- ===== [[s-rules-recheck]] == Ensuring Time Based Rules Take Effect == A Pacemaker cluster is an event driven system. As such, it won't recalculate the best place for resources to run in unless something (like a resource failure or configuration change) happens. This can mean that a location constraint that only allows resource X to run between 9am and 5pm is not enforced. If you rely on time based rules, it is essential that you set the +cluster-recheck-interval+ option. This tells the cluster to periodically recalculate the ideal state of the cluster. For example, if you set +cluster-recheck-interval=5m+, then sometime between 9:00 and 9:05 the cluster would notice that it needs to start resource X, and between 17:00 and 17:05 it would realize that X needed to be stopped. Note that the timing of the actual start and stop actions depends on what else needs to be performed first . diff --git a/doc/Pacemaker_Explained/en-US/Ch-Stonith.txt b/doc/Pacemaker_Explained/en-US/Ch-Stonith.txt index b27524c646..bdb8ba673b 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Stonith.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Stonith.txt @@ -1,739 +1,739 @@ = Configure STONITH = //// -We prefer [[ch-stonith]], but older versions of asciidoc dont deal well +We prefer [[ch-stonith]], but older versions of asciidoc don't deal well with that construct for chapter headings //// anchor:ch-stonith[Chapter 13, STONITH] indexterm:[STONITH, Configuration] == What Is STONITH == STONITH is an acronym for Shoot-The-Other-Node-In-The-Head and it protects your data from being corrupted by rogue nodes or concurrent access. Just because a node is unresponsive, this doesn't mean it isn't accessing your data. The only way to be 100% sure that your data is safe, is to use STONITH so we can be certain that the node is truly offline, before allowing the data to be accessed from another node. STONITH also has a role to play in the event that a clustered service cannot be stopped. In this case, the cluster uses STONITH to force the whole node offline, thereby making it safe to start the service elsewhere. == What STONITH Device Should You Use == It is crucial that the STONITH device can allow the cluster to differentiate between a node failure and a network one. The biggest mistake people make in choosing a STONITH device is to -use remote power switch (such as many on-board IMPI controllers) that +use a remote power switch (such as many on-board IPMI controllers) that shares power with the node it controls. In such cases, the cluster cannot be sure if the node is really offline, or active and suffering from a network fault. Likewise, any device that relies on the machine being active (such as SSH-based "devices" used during testing) are inappropriate. == Differences of STONITH Resources == Stonith resources are somewhat special in Pacemaker. In previous versions, only "running" resources could be used by Pacemaker for fencing. This requirement has been relaxed to allow other parts of the cluster (such as resources like DRBD) to reliably initiate fencing. footnote:[Fencing a node while Pacemaker was moving stonith resources around would otherwise fail] Now all nodes have access to their definitions and instantiate them on-the-fly when needed, however preference is given to 'verified' instances which are the ones the cluster has explicitly started. In the case of a cluster split, the partition with a verified instance will have a slight advantage as stonith-ng in the other partition will have to hear from all its current peers before choosing a node to perform the fencing. [NOTE] =========== To disable a fencing device/resource, 'target-role' can be set as you would for a normal resource. =========== [NOTE] =========== To prevent a specific node from using a fencing device, location constraints will work as expected. =========== [IMPORTANT] =========== -Currently there is a limitation that fencing resources may only have a +Currently there is a limitation that fencing resources may only have one set of meta-attributes and one set of instance-attributes. This can be revisited if it becomes a significant limitation for people. =========== .Properties of Fencing Devices [width="95%",cols="1m,1m,1m,5<",options="header",align="center"] |========================================================= |Field |Type |Default |Description |stonith-timeout |time |60s |How long to wait for the STONITH action to complete per a stonith device. Overrides the stonith-timeout cluster property indexterm:[stonith-timeout,Fencing] indexterm:[Fencing,Property,stonith-timeout] |priority |integer |0 |The priority of the stonith resource. Devices are tried in order of highest priority to lowest. indexterm:[priority,Fencing] indexterm:[Fencing,Property,priority] |pcmk_host_argument |string |port |Advanced use only: An alternate parameter to supply instead of 'port' Some devices do not support the standard 'port' parameter or may provide additional ones. Use this to specify an alternate, device-specific, parameter that should indicate the machine to be fenced. A value of 'none' can be used to tell the cluster not to supply any additional parameters. indexterm:[pcmk_host_argument,Fencing] indexterm:[Fencing,Property,pcmk_host_argument] |pcmk_host_map |string | |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 indexterm:[pcmk_host_map,Fencing] indexterm:[Fencing,Property,pcmk_host_map] |pcmk_host_list |string | |A list of machines controlled by this device (Optional unless pcmk_host_check=static-list). indexterm:[pcmk_host_list,Fencing] indexterm:[Fencing,Property,pcmk_host_list] |pcmk_host_check |string |dynamic-list |How to determin 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) indexterm:[pcmk_host_check,Fencing] indexterm:[Fencing,Property,pcmk_host_check] |pcmk_reboot_action |string |reboot |Advanced use only: An alternate command to run instead of 'reboot' Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific, command that implements the 'reboot' action. indexterm:[pcmk_reboot_action,Fencing] indexterm:[Fencing,Property,pcmk_reboot_action] |pcmk_reboot_timeout |time |60s |Advanced use only: Specify an alternate timeout to use for reboot actions instead of stonith-timeout Some devices need much more/less time to complete than normal. Use this to specify an alternate, device-specific, timeout for 'reboot' actions. indexterm:[pcmk_reboot_timeout,Fencing] indexterm:[Fencing,Property,pcmk_reboot_timeout] |pcmk_reboot_retries |integer |2 |Advanced use only: The maximum number of times to retry the 'reboot' command within the timeout period Some devices do not support multiple connections. Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries 'reboot' actions before giving up. indexterm:[pcmk_reboot_retries,Fencing] indexterm:[Fencing,Property,pcmk_reboot_retries] |pcmk_off_action |string |off |Advanced use only: An alternate command to run instead of 'off' Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific, command that implements the 'off' action. indexterm:[pcmk_off_action,Fencing] indexterm:[Fencing,Property,pcmk_off_action] |pcmk_off_timeout |time |60s |Advanced use only: Specify an alternate timeout to use for off actions instead of stonith-timeout Some devices need much more/less time to complete than normal. Use this to specify an alternate, device-specific, timeout for 'off' actions. indexterm:[pcmk_off_timeout,Fencing] indexterm:[Fencing,Property,pcmk_off_timeout] |pcmk_off_retries |integer |2 |Advanced use only: The maximum number of times to retry the 'off' command within the timeout period Some devices do not support multiple connections. Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries 'off' actions before giving up. indexterm:[pcmk_off_retries,Fencing] indexterm:[Fencing,Property,pcmk_off_retries] |pcmk_list_action |string |list |Advanced use only: An alternate command to run instead of 'list' Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific, command that implements the 'list' action. indexterm:[pcmk_list_action,Fencing] indexterm:[Fencing,Property,pcmk_list_action] |pcmk_list_timeout |time |60s |Advanced use only: Specify an alternate timeout to use for list actions instead of stonith-timeout Some devices need much more/less time to complete than normal. Use this to specify an alternate, device-specific, timeout for 'list' actions. indexterm:[pcmk_list_timeout,Fencing] indexterm:[Fencing,Property,pcmk_list_timeout] |pcmk_list_retries |integer |2 |Advanced use only: The maximum number of times to retry the 'list' command within the timeout period Some devices do not support multiple connections. Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries 'list' actions before giving up. indexterm:[pcmk_list_retries,Fencing] indexterm:[Fencing,Property,pcmk_list_retries] |pcmk_monitor_action |string |monitor |Advanced use only: An alternate command to run instead of 'monitor' Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific, command that implements the 'monitor' action. indexterm:[pcmk_monitor_action,Fencing] indexterm:[Fencing,Property,pcmk_monitor_action] |pcmk_monitor_timeout |time |60s |Advanced use only: Specify an alternate timeout to use for monitor actions instead of stonith-timeout Some devices need much more/less time to complete than normal. Use this to specify an alternate, device-specific, timeout for 'monitor' actions. indexterm:[pcmk_monitor_timeout,Fencing] indexterm:[Fencing,Property,pcmk_monitor_timeout] |pcmk_monitor_retries |integer |2 |Advanced use only: The maximum number of times to retry the 'monitor' command within the timeout period Some devices do not support multiple connections. Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries 'monitor' actions before giving up. indexterm:[pcmk_monitor_retries,Fencing] indexterm:[Fencing,Property,pcmk_monitor_retries] |pcmk_status_action |string |status |Advanced use only: An alternate command to run instead of 'status' Some devices do not support the standard commands or may provide additional ones. Use this to specify an alternate, device-specific, command that implements the 'status' action. indexterm:[pcmk_status_action,Fencing] indexterm:[Fencing,Property,pcmk_status_action] |pcmk_status_timeout |time |60s |Advanced use only: Specify an alternate timeout to use for status actions instead of stonith-timeout Some devices need much more/less time to complete than normal. Use this to specify an alternate, device-specific, timeout for 'status' actions. indexterm:[pcmk_status_timeout,Fencing] indexterm:[Fencing,Property,pcmk_status_timeout] |pcmk_status_retries |integer |2 |Advanced use only: The maximum number of times to retry the 'status' command within the timeout period Some devices do not support multiple connections. Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining. Use this option to alter the number of times Pacemaker retries 'status' actions before giving up. indexterm:[pcmk_status_retries,Fencing] indexterm:[Fencing,Property,pcmk_status_retries] |========================================================= == Configuring STONITH == [NOTE] =========== Both configuration shells include functionality to simplify the process below, particularly the step for deciding which parameters are required. However since this document deals only with core components, you should refer to the Stonith chapter of +Clusters from Scratch+ for those details. =========== . Find the correct driver: +stonith_admin --list-installed+ . Find the required parameters associated with the device: +stonith_admin --metadata --agent + . Create a file called +stonith.xml+ containing a primitive resource with a class of 'stonith', a type of and a parameter for each of the values returned in step 2. . If the device does not know how to fence nodes based on their uname, you may also need to set the special +pcmk_host_map+ parameter. See +man stonithd+ 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 stonithd+ 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 stonithd+ for details. . Upload it into the CIB using cibadmin: +cibadmin -C -o resources --xml-file stonith.xml+ . Set stonith-enabled to true. +crm_attribute -t crm_config -n stonith-enabled -v true+ . Once the stonith resource is running, you can test it by executing: +stonith_admin --reboot nodename+. Although you might want to stop the cluster on that machine first. === Example === Assuming we have an chassis containing four nodes and an IPMI device active on 10.0.0.1, then we would chose the fence_ipmilan driver in step 2 and obtain the following list of parameters .Obtaining a list of STONITH Parameters ---- # stonith_admin --metadata -a fence_ipmilan ---- [source,XML] ---- fence_ipmilan is an I/O Fencing agent which can be used with machines controlled by IPMI. This agent calls support software using ipmitool (http://ipmitool.sf.net/). To use fence_ipmilan with HP iLO 3 you have to enable lanplus option (lanplus / -P) and increase wait after operation to 4 seconds (power_wait=4 / -T 4) IPMI Lan Auth type (md5, password, or none) IPMI Lan IP to talk to Password (if required) to control power on IPMI device Script to retrieve password (if required) Use Lanplus Username/Login (if required) to control power on IPMI device Operation to perform. Valid operations: on, off, reboot, status, list, diag, monitor or metadata Timeout (sec) for IPMI operation Ciphersuite to use (same as ipmitool -C parameter) Method to fence (onoff or cycle) Wait X seconds after on/off operation Wait X seconds before fencing is started Verbose mode ---- from which we would create a STONITH resource fragment that might look like this: .Sample STONITH Resource [source,XML] ---- ---- And finally, since we disabled it earlier, we need to re-enable STONITH. ---- # crm_attribute -t crm_config -n stonith-enabled -v true ---- == Advanced Fencing Configurations == Some people consider that having one fencing device is a single point of failure footnote:[Not true, since a node or resource must fail before fencing even has a chance to], others prefer removing the node from the storage and network instead of turning it off. Whatever the reason, Pacemaker supports fencing nodes with multiple devices through a feature called fencing topologies. Simply create the individual devices as you normally would and then define one or more fencing levels in the fencing-topology section in the configuration. * Each level is attempted in +ascending index+ order * If a device fails, +processing terminates+ for the current level. No further devices in that level are exercised and the next level is attempted instead. * If the operation succeeds for all the listed devices in a level, the level is deemed to have passed * The operation is finished +when a level has passed+ (success), or all levels have been attempted (failed) * If the operation failed, the next step is determined by the Policy Engine and/or crmd. Some possible uses of topologies include: * try poison-pill and fail back to power * try disk and network, and fall back to power if either fails * initiate a kdump and then poweroff the node .Properties of Fencing Levels [width="95%",cols="1m,6<",options="header",align="center"] |========================================================= |Field |Description |id |Your name for the level indexterm:[id,fencing-level] indexterm:[Fencing,fencing-level,id] |target |The node to which this level applies indexterm:[target,fencing-level] indexterm:[Fencing,fencing-level,target] |index |The order in which to attempt the levels. Levels are attempted in +ascending index+ order +until one succeeds+. indexterm:[index,fencing-level] indexterm:[Fencing,fencing-level,index] |devices -|A comma separated list of devices for which the +|A comma-separated list of devices that must all be tried for this level indexterm:[devices,fencing-level] indexterm:[Fencing,fencing-level,devices] |========================================================= === Example use of Fencing Topologies === [source,XML] ---- ... ... ---- === Example use of advanced Fencing Topologies: dual layer and dual devices === -The following example illustrates an advanced use of +fencing_topology+ in a cluster with the following properties: +The following example illustrates an advanced use of +fencing-topology+ in a cluster with the following properties: * 3 nodes (2 active prod-mysql nodes, 1 prod_mysql-rep in standby for quorum purposes) * the active nodes have an IPMI-controlled power board reached at 10.10.10.1 and 10.10.10.2 * the active nodes also have two independant PSUs (Power Supplu Units) connected to two independant PDUs (Power Distribution Unit) reached at 10.20.1.1 (port 10 and port 11) and 10.20.2.1 (port 10 and port 11) * the first fencing method uses the +fence_ipmi+ agent * the second fencing method uses the +fence_apc_snmp+ agent targetting 2 fencing devices (one per PSU, either port 10 or 11) * fencing is only implemented for the active nodes and has location constraints * fencing topology is set to try IPMI fencing first then default to a "sure-kill" dual PDU fencing In a normal failure scenario, STONITH will first select +fence_ipmi+ to try and kill the faulty node. -Using a +fencing_topology+, if that first method fails, STONITH will then move on to selecting +fence_apc_snmp+ twice: +Using a fencing topology, if that first method fails, STONITH will then move on to selecting +fence_apc_snmp+ twice: * once for the first PDU * again for the second PDU The fence action is considered successful only if both PDUs report the required status. If any of them fails, STONITH loops back to the first fencing method, +fence_ipmi+, and so on until the node is fenced or fencing action is cancelled. .First fencing method: single IPMI device Each cluster node has it own dedicated IPMI channel that can be called for fencing using the following primitives: [source,XML] ---- ---- .Second fencing method: dual PDU devices Each cluster node also has two distinct power channels controlled by two distinct PDUs. That means a total of 4 fencing devices configured as follows: - Node 1, PDU 1, PSU 1 @ port 10 - Node 1, PDU 2, PSU 2 @ port 10 - Node 2, PDU 1, PSU 1 @ port 11 - Node 2, PDU 2, PSU 2 @ port 11 The matching fencing agents are configured as follows: [source,XML] ---- ---- .Location Constraints To prevent STONITH from running a fencing agent on the very same node it is supposed to fence, constraints are placed on all the fencing primitives: [source,XML] ---- ---- .Fencing topology Now that all the fencing resources are defined, it's time to create the right topology. We want to first fence using IPMI and if that does not work, fence both PDUs to effectively and surely kill the node. [source,XML] ---- ---- -Please note, in +fencing_topology+, the lower index value determines the priority of the first fencing method. +Please note, in +fencing-topology+, the lowest +index+ value determines the priority of the first fencing method. .Final configuration Put together, the configuration looks like this: [source,XML] ---- ... ... ---- diff --git a/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml b/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml index aa1eab4482..fe054f3f05 100644 --- a/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml +++ b/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml @@ -1,47 +1,47 @@ Further Reading - Project Website - Project Documentation + Project Website: + Project Documentation: - A comprehensive guide to cluster commands has been written by Novell + SUSE High Availibility Guide: Heartbeat configuration: Corosync Configuration: