diff --git a/doc/Pacemaker_Explained/en-US/Ch-Resource-Templates.txt b/doc/Pacemaker_Explained/en-US/Ch-Reusing-Configuration.txt similarity index 85% rename from doc/Pacemaker_Explained/en-US/Ch-Resource-Templates.txt rename to doc/Pacemaker_Explained/en-US/Ch-Reusing-Configuration.txt index 06cf32e8ac..1324c25d10 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Resource-Templates.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Reusing-Configuration.txt @@ -1,232 +1,238 @@ -= Resource Templates = += Reusing Parts of the Configuration = -If you want to create lots of resources with similar configurations, defining a -resource template simplifies the task. Once defined, it can be referenced in +Pacemaker provides multiple ways to simplify the configuration XML by reusing +parts of it in multiple places. + +Besides simplifying the XML, this also allows you to manipulate multiple +configuration elements with a single reference. + +== Reusing Resource Definitions == + +If you want to create lots of resources with similar configurations, defining a +'resource template' simplifies the task. Once defined, it can be referenced in primitives or in certain types of constraints. - -== Configuring Resources with Templates == + +=== Configuring Resources with Templates === The primitives referencing the template will inherit all meta-attributes, -instance attributes, utilization attributes and operations defined -in the template. And you can define specific attributes and operations for any -of the primitives. If any of these are defined in both the template and the -primitive, the values defined in the primitive will take precedence over the -ones defined in the template. - -Hence, resource templates help to reduce the amount of configuration work. -If any changes are needed, they can be done to the template definition and +instance attributes, utilization attributes and operations defined +in the template. And you can define specific attributes and operations for any +of the primitives. If any of these are defined in both the template and the +primitive, the values defined in the primitive will take precedence over the +ones defined in the template. + +Hence, resource templates help to reduce the amount of configuration work. +If any changes are needed, they can be done to the template definition and will take effect globally in all resource definitions referencing that template. Resource templates have a syntax similar to that of primitives. -.Resource template for a migratable Xen virtual machine +.Resource template for a migratable Xen virtual machine ==== [source,XML] ---- <template id="vm-template" class="ocf" provider="heartbeat" type="Xen"> <meta_attributes id="vm-template-meta_attributes"> <nvpair id="vm-template-meta_attributes-allow-migrate" name="allow-migrate" value="true"/> </meta_attributes> <utilization id="vm-template-utilization"> <nvpair id="vm-template-utilization-memory" name="memory" value="512"/> </utilization> <operations> <op id="vm-template-monitor-15s" interval="15s" name="monitor" timeout="60s"/> <op id="vm-template-start-0" interval="0" name="start" timeout="60s"/> </operations> </template> ---- ==== Once you define a resource template, you can use it in primitives by specifying the +template+ property. .Xen primitive resource using a resource template ==== [source,XML] ---- <primitive id="vm1" template="vm-template"> <instance_attributes id="vm1-instance_attributes"> <nvpair id="vm1-instance_attributes-name" name="name" value="vm1"/> <nvpair id="vm1-instance_attributes-xmfile" name="xmfile" value="/etc/xen/shared-vm/vm1"/> </instance_attributes> </primitive> ---- ==== - -In the example above, the new primitive +vm1+ will inherit everything from +vm-template+. For + +In the example above, the new primitive +vm1+ will inherit everything from +vm-template+. For example, the equivalent of the above two examples would be: .Equivalent Xen primitive resource not using a resource template ==== [source,XML] ---- <primitive id="vm1" class="ocf" provider="heartbeat" type="Xen"> <meta_attributes id="vm-template-meta_attributes"> <nvpair id="vm-template-meta_attributes-allow-migrate" name="allow-migrate" value="true"/> </meta_attributes> <utilization id="vm-template-utilization"> <nvpair id="vm-template-utilization-memory" name="memory" value="512"/> </utilization> <operations> <op id="vm-template-monitor-15s" interval="15s" name="monitor" timeout="60s"/> <op id="vm-template-start-0" interval="0" name="start" timeout="60s"/> </operations> <instance_attributes id="vm1-instance_attributes"> <nvpair id="vm1-instance_attributes-name" name="name" value="vm1"/> <nvpair id="vm1-instance_attributes-xmfile" name="xmfile" value="/etc/xen/shared-vm/vm1"/> </instance_attributes> </primitive> ---- ==== - -If you want to overwrite some attributes or operations, add them to the -particular primitive's definition. + +If you want to overwrite some attributes or operations, add them to the +particular primitive's definition. .Xen resource overriding template values ==== [source,XML] ---- <primitive id="vm2" template="vm-template"> <meta_attributes id="vm2-meta_attributes"> <nvpair id="vm2-meta_attributes-allow-migrate" name="allow-migrate" value="false"/> </meta_attributes> <utilization id="vm2-utilization"> <nvpair id="vm2-utilization-memory" name="memory" value="1024"/> </utilization> <instance_attributes id="vm2-instance_attributes"> <nvpair id="vm2-instance_attributes-name" name="name" value="vm2"/> <nvpair id="vm2-instance_attributes-xmfile" name="xmfile" value="/etc/xen/shared-vm/vm2"/> </instance_attributes> <operations> <op id="vm2-monitor-30s" interval="30s" name="monitor" timeout="120s"/> <op id="vm2-stop-0" interval="0" name="stop" timeout="60s"/> </operations> </primitive> ---- ==== - -In the example above, the new primitive +vm2+ has special -attribute values. Its +monitor+ operation has a longer +timeout+ and +interval+, and + +In the example above, the new primitive +vm2+ has special +attribute values. Its +monitor+ operation has a longer +timeout+ and +interval+, and the primitive has an additional +stop+ operation. To see the resulting definition of a resource, run: - + ---- # crm_resource --query-xml --resource vm2 ---- - + To see the raw definition of a resource in the CIB, run: - + ---- # crm_resource --query-xml-raw --resource vm2 ---- -== Referencing Templates in Constraints == - +=== Using Templates in Constraints === + A resource template can be referenced in the following types of constraints: - +order+ constraints (see <<s-resource-ordering>>) - +colocation+ constraints (see <<s-resource-colocation>>) - +rsc_ticket+ constraints (for multi-site clusters as described in <<s-ticket-constraints>>) -Resource templates referenced in constraints stand for all primitives which are -derived from that template. This means, the constraint applies to all primitive -resources referencing the resource template. Referencing resource templates in -constraints is an alternative to resource sets and can simplify the cluster +Resource templates referenced in constraints stand for all primitives which are +derived from that template. This means, the constraint applies to all primitive +resources referencing the resource template. Referencing resource templates in +constraints is an alternative to resource sets and can simplify the cluster configuration considerably. For example, given the example templates earlier in this chapter: [source,XML] <rsc_colocation id="vm-template-colo-base-rsc" rsc="vm-template" rsc-role="Started" with-rsc="base-rsc" score="INFINITY"/> would colocate all VMs with +base-rsc+ and is the equivalent of the following constraint configuration: [source,XML] ---- <rsc_colocation id="vm-colo-base-rsc" score="INFINITY"> <resource_set id="vm-colo-base-rsc-0" sequential="false" role="Started"> <resource_ref id="vm1"/> <resource_ref id="vm2"/> </resource_set> <resource_set id="vm-colo-base-rsc-1"> <resource_ref id="base-rsc"/> </resource_set> </rsc_colocation> ---- [NOTE] ====== In a colocation constraint, only one template may be referenced from either `rsc` or `with-rsc`; the other reference must be a regular resource. ====== -=== Referencing Resource Templates in Sequential Resource Sets === +=== Using Templates in Resource Sets === Resource templates can also be referenced in resource sets. -For example: +For example, given the example templates earlier in this section, then: [source,XML] ---- <rsc_order id="order1" score="INFINITY"> <resource_set id="order1-0"> <resource_ref id="base-rsc"/> <resource_ref id="vm-template"/> <resource_ref id="top-rsc"/> </resource_set> </rsc_order> ---- -is the equivalent of the following constraint configuration: +is the equivalent of the following constraint using a sequential resource set: [source,XML] ---- <rsc_order id="order1" score="INFINITY"> <resource_set id="order1-0"> <resource_ref id="base-rsc"/> <resource_ref id="vm1"/> <resource_ref id="vm2"/> <resource_ref id="top-rsc"/> </resource_set> </rsc_order> ---- -=== Referencing Resource Templates in Parallel Resource Sets === - -If the resources referencing the template can run in parallel: +Or, if the resources referencing the template can run in parallel, then: [source,XML] ---- <rsc_order id="order2" score="INFINITY"> <resource_set id="order2-0"> <resource_ref id="base-rsc"/> </resource_set> <resource_set id="order2-1" sequential="false"> <resource_ref id="vm-template"/> </resource_set> <resource_set id="order2-2"> <resource_ref id="top-rsc"/> </resource_set> </rsc_order> ---- is the equivalent of the following constraint configuration: [source,XML] ---- <rsc_order id="order2" score="INFINITY"> <resource_set id="order2-0"> <resource_ref id="base-rsc"/> </resource_set> <resource_set id="order2-1" sequential="false"> <resource_ref id="vm1"/> <resource_ref id="vm2"/> </resource_set> <resource_set id="order2-2"> <resource_ref id="top-rsc"/> </resource_set> </rsc_order> ---- diff --git a/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml b/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml index 52f9236d8d..ca79641054 100644 --- a/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml +++ b/doc/Pacemaker_Explained/en-US/Pacemaker_Explained.xml @@ -1,45 +1,45 @@ <?xml version='1.0' encoding='utf-8' ?> <!DOCTYPE Book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ ]> <book> <xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include> <xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include> <xi:include href="Ch-Intro.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Basics.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Options.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Nodes.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Resources.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Constraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Alerts.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Rules.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Advanced-Options.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Advanced-Resources.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> + <xi:include href="Ch-Reusing-Configuration.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Utilization.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> - <xi:include href="Ch-Resource-Templates.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Stonith.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Status.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ch-Multi-site-Clusters.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-FAQ.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-OCF.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-Install.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-Upgrade.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-LSB.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="Ap-Samples.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <appendix id="ap-further-reading"> <title>Further Reading</title> <itemizedlist spacing="compact"> <listitem><para>Project Website: <ulink url="http://www.clusterlabs.org/"/></para></listitem> <listitem><para>Project Documentation: <ulink url="http://www.clusterlabs.org/wiki/Documentation"/></para></listitem> <listitem> <para>SUSE High Availibility Guide: <ulink url="http://www.suse.com/documentation/sle_ha/book_sleha/data/book_sleha.html"/></para> </listitem> <listitem><para>Heartbeat configuration: <ulink url="http://www.linux-ha.org/"/></para></listitem> <listitem><para>Corosync Configuration: <ulink url="http://www.corosync.org/"/></para></listitem> </itemizedlist> </appendix> <xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include> <index></index> </book>