Permalink
Browse files

Merge pull request #31 from gao-yan/rsc-template

Rsc templates
  • Loading branch information...
2 parents 92ff7dc + 272ba07 commit 517a4da15981a245e728bbc3fb6f4f247da2a66f @beekhof beekhof committed Feb 28, 2012
@@ -23,8 +23,9 @@
<firstname>Tanja</firstname><surname>Roth</surname>
<affiliation><orgname>SUSE</orgname></affiliation>
<contrib>Utilization chapter</contrib>
+ <contrib>Resource Templates chapter</contrib>
<contrib>Multi-Site Clusters chapter</contrib>
- <email>troth@suse.com</email>
+ <email>taroth@suse.com</email>
</othercredit>
<othercredit>
<firstname>Lars</firstname><surname>Marowsky-Bree</surname>
@@ -36,14 +37,22 @@
<firstname>Yan</firstname><surname>Gao</surname>
<affiliation><orgname>SUSE</orgname></affiliation>
<contrib>Utilization chapter</contrib>
+ <contrib>Resource Templates chapter</contrib>
<contrib>Multi-Site Clusters chapter</contrib>
<email>ygao@suse.com</email>
</othercredit>
<othercredit>
<firstname>Thomas</firstname><surname>Schraitle</surname>
<affiliation><orgname>SUSE</orgname></affiliation>
<contrib>Utilization chapter</contrib>
+ <contrib>Resource Templates chapter</contrib>
<contrib>Multi-Site Clusters chapter</contrib>
<email>toms@suse.com</email>
</othercredit>
+ <othercredit>
+ <firstname>Dejan</firstname><surname>Muhamedagic</surname>
+ <affiliation><orgname>SUSE</orgname></affiliation>
+ <contrib>Resource Templates chapter</contrib>
+ <email>dmuhamedagic@suse.com</email>
+ </othercredit>
</authorgroup>
@@ -159,10 +159,9 @@ demoted to slave mode if `ticketA` is revoked:
<rsc_ticket id="rsc1-req-ticketA" rsc="rsc1" rsc-role="Master" ticket="ticketA" loss-policy="demote"/>
-------
-If you want other resources to depend on further tickets, create as many
-constraints as necessary with `rsc_ticket`.
-
-
+You can create more `rsc_ticket` constraints to let multiple resources
+depend on the same ticket.
+
`rsc_ticket` also supports resource sets. So one can easily list all the
resources in one `rsc_ticket` constraint. For example:
@@ -180,6 +179,9 @@ resources in one `rsc_ticket` constraint. For example:
</rsc_ticket>
-------
+If you want other resources to depend on further tickets, create as many
+constraints as necessary with `rsc_ticket`.
+
== Managing Multi-Site Clusters ==
@@ -143,6 +143,12 @@ The number of jobs that the TE is allowed to execute in parallel. The
"correct" value will depend on the speed and load of your network and
cluster nodes.
+| migration-limit | -1 (unlimited) |
+indexterm:[migration-limit Cluster Options]
+indexterm:[Cluster Options,migration-limit]
+The number of migration jobs that the TE is allowed to execute in
+parallel on a node.
+
| no-quorum-policy | stop |
indexterm:[no-quorum-policy Cluster Options]
indexterm:[Cluster Options,no-quorum-policy]
@@ -0,0 +1,222 @@
+= Resource Templates =
+
+== Abstract ==
+
+If you want to create lots of resources with similar configurations, defining a
+resource template simplifies the task. Once defined, it can be referenced in
+primitives or in certain types of constraints.
+
+
+== Configuring Resources with Templates ==
+
+The primitives referencing the template will inherit all meta
+attributes, instance attributes, utilization attributes and operations defined
+in the template. And you can define specific attributes and operations for any
+of the primitives. If any of these are defined in both the template and the
+primitive, the values defined in the primitive will take precedence over the
+ones defined in the template.
+
+Hence, resource templates help to reduce the amount of configuration work.
+If any changes are needed, they can be done to the template definition and
+will take effect globally in all resource definitions referencing that
+template.
+
+Resource templates have a similar syntax like primitives. For example:
+
+[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 defined the new resource template, you can use it in primitives:
+
+[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>
+----
+
+The new primitive `vm1` is going to inherit everything from the `vm-template`. For
+example, the equivalent of the above two would be:
+
+[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.
+
+For instance, the following new primitive `vm2` has special
+attribute values. Its `monitor` operation has a longer `timeout` and `interval`, and
+the primitive has an additional `stop` operation.
+
+[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>
+----
+
+The following command shows the resulting definition of a resource:
+
+[source,Bash]
+----
+# crm_resource --query-xml --resource vm2
+----
+
+The following command shows its raw definition in cib:
+
+[source,Bash]
+----
+# crm_resource --query-xml-raw --resource vm2
+----
+
+== Referencing Templates in Constraints ==
+
+A resource template can be referenced in the following types of constraints:
+
+- `order` constraints
+- `colocation` constraints,
+- `rsc_ticket` constraints (for multi-site clusters).
+
+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:
+
+[source,XML]
+----
+<rsc_colocation id="vm-template-colo-base-rsc" rsc="vm-template" rsc-role="Started" with-rsc="base-rsc" score="INFINITY"/>
+----
+
+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`, and the other reference must be a regular resource.
+======
+
+Resource templates can also be referenced in resource sets.
+
+For example:
+
+[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:
+
+[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>
+----
+
+If the resources referencing the template can run in parallel:
+
+[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>
+----
@@ -36,7 +36,7 @@ configuration needs. However, the attribute's values must be `integers`.
First, specify the capacities the nodes provide:
-[source,Bash]
+[source,XML]
----
<node id="node1" type="normal" uname="node1">
<utilization id="node1-utilization">
@@ -54,7 +54,7 @@ First, specify the capacities the nodes provide:
Then, specify the capacities the resources require:
-[source,Bash]
+[source,XML]
----
<primitive id="rsc-small" class="ocf" provider="pacemaker" type="Dummy">
<utilization id="rsc-small-utilization">
@@ -166,7 +166,7 @@ define multiple types of `capacity`, for example:
`nodeB` has more free capacity.
-=== Which resource is preferred to be chosen to get assigned first?
+=== Which resource is preferred to be chosen to get assigned first? ===
- The resource that has the highest priority gets allocated first.
@@ -180,7 +180,7 @@ first (to prevent resource shuffling).
- If the scores above are equal, the first runnable resource listed in cib gets allocated first.
-== Limitations
+== Limitations ==
This type of problem Pacemaker is dealing with here is known as the
http://en.wikipedia.org/wiki/Knapsack_problem[knapsack problem] and falls into
@@ -206,7 +206,7 @@ In the contrived example above:
Which is not ideal.
-== Strategies for Dealing with the Limitations
+== Strategies for Dealing with the Limitations ==
- Ensure you have sufficient physical capacity.
It might sounds obvious, but if the physical capacity of your nodes is (close to)
@@ -20,6 +20,7 @@
<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-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"/>
View
@@ -9,6 +9,7 @@
<zeroOrMore>
<choice>
<ref name="element-primitive"/>
+ <ref name="element-template"/>
<ref name="element-group"/>
<ref name="element-clone"/>
<ref name="element-master"/>
@@ -22,6 +23,44 @@
<attribute name="id"><data type="ID"/></attribute>
<choice>
<group>
+ <choice>
+ <group>
+ <attribute name="class"><value>ocf</value></attribute>
+ <attribute name="provider"><text/></attribute>
+ </group>
+ <attribute name="class">
+ <choice>
+ <value>lsb</value>
+ <value>heartbeat</value>
+ <value>stonith</value>
+ <value>upstart</value>
+ </choice>
+ </attribute>
+ </choice>
+ <attribute name="type"><text/></attribute>
+ </group>
+ <attribute name="template"><data type="IDREF"/></attribute>
+ </choice>
+ <optional>
+ <attribute name="description"><text/></attribute>
+ </optional>
+ <ref name="element-resource-extra"/>
+ <ref name="element-operations"/>
+ <zeroOrMore>
+ <element name="utilization">
+ <externalRef href="nvset.rng"/>
+ </element>
+ </zeroOrMore>
+ </interleave>
+ </element>
+ </define>
+
+ <define name="element-template">
+ <element name="template">
+ <interleave>
+ <attribute name="id"><data type="ID"/></attribute>
+ <choice>
+ <group>
<attribute name="class"><value>ocf</value></attribute>
<attribute name="provider"><text/></attribute>
</group>

0 comments on commit 517a4da

Please sign in to comment.