diff --git a/doc/Makefile.am b/doc/Makefile.am index 1c4a1d3a57..aa9ff637f2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,341 +1,327 @@ # -# doc: Pacemaker code +# Copyright 2004-2019 Andrew Beekhof # -# Copyright (C) 2008 Andrew Beekhof -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# This source code is licensed under the GNU General Public License version 2 +# or later (GPLv2+) WITHOUT ANY WARRANTY. # include $(top_srcdir)/Makefile.common helpdir = $(datadir)/$(PACKAGE) ascii = crm_fencing.txt acls.txt docbook = Clusters_from_Scratch \ Pacemaker_Administration \ Pacemaker_Development \ Pacemaker_Explained \ Pacemaker_Remote doc_DATA = $(ascii) $(generated_docs) # toplevel rsync destination for www targets (without trailing slash) RSYNC_DEST ?= root@www.clusterlabs.org:/var/www/html # recursive, preserve symlinks/permissions/times, verbose, compress, # don't cross filesystems, sparse, show progress RSYNC_OPTS = -rlptvzxS --progress publican_docs = generated_docs = generated_mans = # What formats to build: pdf,html,html-single,html-desktop,epub DOCBOOK_FORMATS := html-desktop # What languages to build DOCBOOK_LANGS := en-US # What languages to build for uploading to website # (currently only en-US because translations aren't up-to-date) UPLOAD_LANGS = en-US # @TODO We could simplify this (and .gitignore) by establishing a convention # that original image source begins with an uppercase letter and generated # files with lowercase. # Scheduler transition graphs # @TODO Add original XML, and generate DOTs via crm_simulate DOTS = $(wildcard shared/en-US/images/*.dot) # Vector sources for images # @TODO Generate transition SVGs from DOTs via dot SVGS = $(wildcard shared/en-US/images/pcmk-*.svg) \ $(DOTS:%.dot=%.svg) # Final images PNGS_ORIGINAL = Pacemaker_Remote/en-US/images/pcmk-ha-cluster-stack.png \ Pacemaker_Remote/en-US/images/pcmk-ha-remote-stack.png \ shared/en-US/images/Console.png \ shared/en-US/images/Editing-eth0.png \ shared/en-US/images/Installer.png \ shared/en-US/images/Network.png \ shared/en-US/images/Partitioning.png \ shared/en-US/images/Welcome.png \ shared/en-US/images/resource-set.png \ - shared/en-US/images/three-sets-complex.png \ shared/en-US/images/three-sets.png \ shared/en-US/images/two-sets.png PNGS_GENERATED = $(SVGS:%.svg=%-small.png) \ $(SVGS:%.svg=%.png) \ $(SVGS:%.svg=%-large.png) PNGS = $(PNGS_ORIGINAL) $(PNGS_GENERATED) graphics: $(PNGS) %.png: %.svg $(AM_V_IMG)$(INKSCAPE) --file=$< --export-dpi=90 -C --export-png=$@ %-small.png: %.svg $(AM_V_IMG)$(INKSCAPE) --file=$< --export-dpi=45 -C --export-png=$@ %-large.png: %.svg $(AM_V_IMG)$(INKSCAPE) --file=$< --export-dpi=180 -C --export-png=$@ if BUILD_ASCIIDOC generated_docs += $(ascii:%.txt=%.html) if BUILD_DOCBOOK publican_docs += $(docbook) endif endif EXTRA_DIST = $(docbook:%=%.xml) %.html: %.txt if IS_ASCIIDOC $(AM_V_ASCII)$(ASCIIDOC_CONV) --unsafe --backend=xhtml11 $< else $(AM_V_ASCII)$(ASCIIDOC_CONV) --backend=html5 $< endif # publican-clusterlabs/xsl/{html,html-single,pdf}.xsl refer to URIs # requiring Internet access, hence we shadow that with a XML catalog-based # redirect to local files brought with Publican installation; # this is what newer Publican normally does with the system-wide catalog # upon its installation, but let's provide a compatibility for older # or badly installed instances (via adding the created file into # XML_CATALOG_FILES for libxml2 backing Publican as a fallback); # note that nextCatalog arrangement needed so as to overcome # https://rt.cpan.org/Public/Bug/Display.html?id=113781 publican-catalog-fallback: @exec >$@-t \ && echo '' \ && echo '' \ && echo '' $(AM_V_GEN)mv $@-t $@ publican-catalog: publican-catalog-fallback @exec >$@-t \ && echo '' \ && echo '' \ && echo '' \ && echo '' $(AM_V_GEN)mv $@-t $@ SHARED_TXT=$(wildcard shared/en-US/*.txt) SHARED_XML=$(SHARED_TXT:%.txt=%.xml) CFS_SHARED_TXT=$(addprefix shared/en-US/,pacemaker-intro.txt) CFS_SHARED_XML=$(CFS_SHARED_TXT:%.txt=%.xml) CFS_TXT=$(wildcard Clusters_from_Scratch/en-US/*.txt) CFS_XML=$(CFS_TXT:%.txt=%.xml) $(CFS_XML): $(CFS_SHARED_XML) PUBLICAN_INTREE_DEPS = if PUBLICAN_INTREE_BRAND PUBLICAN_INTREE_DEPS += publican-catalog endif # We have to hardcode the book name # With '%' the test for 'newness' fails Clusters_from_Scratch.build: $(PNGS) $(wildcard Clusters_from_Scratch/en-US/*.xml) $(CFS_XML) $(CFS_SHARED_XML) $(PUBLICAN_INTREE_DEPS) $(PCMK_V) @echo Building $(@:%.build=%) because of $? rm -rf $(@:%.build=%)/publish/* $(@:%.build=%)/tmp if PUBLICAN_INTREE_BRAND $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" XML_CATALOG_FILES="$(CURDIR)/publican-catalog" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) --brand_dir=../publican-clusterlabs \ $(PCMK_quiet) else $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) \ $(PCMK_quiet) endif rm -rf $(@:%.build=%)/tmp touch $@ PA_TXT=$(wildcard Pacemaker_Administration/en-US/*.txt) PA_XML=$(PA_TXT:%.txt=%.xml) # We have to hardcode the book name # With '%' the test for 'newness' fails Pacemaker_Administration.build: $(wildcard Pacemaker_Administration/en-US/*.xml) $(PA_XML) $(PUBLICAN_INTREE_DEPS) $(PCMK_V) @echo Building $(@:%.build=%) because of $? rm -rf $(@:%.build=%)/publish/* if PUBLICAN_INTREE_BRAND $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" XML_CATALOG_FILES="$(CURDIR)/publican-catalog" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) --brand_dir=../publican-clusterlabs \ $(PCMK_quiet) else $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) \ $(PCMK_quiet) endif rm -rf $(@:%.build=%)/tmp touch $@ PD_TXT=$(wildcard Pacemaker_Development/en-US/*.txt) PD_XML=$(PD_TXT:%.txt=%.xml) # We have to hardcode the book name # With '%' the test for 'newness' fails Pacemaker_Development.build: $(wildcard Pacemaker_Development/en-US/*.xml) $(PD_XML) $(PUBLICAN_INTREE_DEPS) $(PCMK_V) @echo Building $(@:%.build=%) because of $? rm -rf $(@:%.build=%)/publish/* $(@:%.build=%)/tmp if PUBLICAN_INTREE_BRAND $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" XML_CATALOG_FILES="$(CURDIR)/publican-catalog" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) --brand_dir=../publican-clusterlabs \ $(PCMK_quiet) else $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) \ $(PCMK_quiet) endif rm -rf $(@:%.build=%)/tmp touch $@ PE_SHARED_TXT=$(addprefix shared/en-US/,pacemaker-intro.txt) PE_SHARED_XML=$(PE_SHARED_TXT:%.txt=%.xml) PE_TXT=$(wildcard Pacemaker_Explained/en-US/*.txt) PE_XML=$(PE_TXT:%.txt=%.xml) $(PE_XML): $(PE_SHARED_XML) # We have to hardcode the book name # With '%' the test for 'newness' fails Pacemaker_Explained.build: $(PNGS) $(wildcard Pacemaker_Explained/en-US/*.xml) $(PE_XML) $(PE_SHARED_XML) $(PUBLICAN_INTREE_DEPS) $(PCMK_V) @echo Building $(@:%.build=%) because of $? rm -rf $(@:%.build=%)/publish/* $(@:%.build=%)/tmp if PUBLICAN_INTREE_BRAND $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" XML_CATALOG_FILES="$(CURDIR)/publican-catalog" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) --brand_dir=../publican-clusterlabs \ $(PCMK_quiet) else $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) \ $(PCMK_quiet) endif rm -rf $(@:%.build=%)/tmp touch $@ PR_TXT=$(wildcard Pacemaker_Remote/en-US/*.txt) PR_XML=$(PR_TXT:%.txt=%.xml) # We have to hardcode the book name # With '%' the test for 'newness' fails Pacemaker_Remote.build: $(PNGS) $(wildcard Pacemaker_Remote/en-US/*.xml) $(PR_XML) $(PUBLICAN_INTREE_DEPS) $(PCMK_V) @echo Building $(@:%.build=%) because of $? rm -rf $(@:%.build=%)/publish/* $(@:%.build=%)/tmp if PUBLICAN_INTREE_BRAND $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" XML_CATALOG_FILES="$(CURDIR)/publican-catalog" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) --brand_dir=../publican-clusterlabs \ $(PCMK_quiet) else $(AM_V_PUB)cd $(@:%.build=%) \ && RPM_BUILD_DIR="" \ $(PUBLICAN) build --publish --langs=$(DOCBOOK_LANGS) --formats=$(DOCBOOK_FORMATS) \ $(PCMK_quiet) endif rm -rf $(@:%.build=%)/tmp touch $@ # Update the translation template pot: for book in $(docbook); do \ echo "Updating translation templates in: $$book"; \ ( cd $$book && RPM_BUILD_DIR="" $(PUBLICAN) update_pot ); \ done # Update the actual translations po: pot for book in $(docbook); do \ echo "Updating translations in: $$book"; \ ( cd $$book && RPM_BUILD_DIR="" $(PUBLICAN) update_po --langs=all );\ done if BUILD_DOCBOOK docbook_build = $(docbook:%=%.build) all-local: $(docbook_build) */publican.cfg install-data-local: all-local for book in $(docbook); do \ filelist=`find $$book/publish/* -print`; \ for f in $$filelist; do \ p=`echo $$f | sed s:publish/:: | sed s:Pacemaker/::`; \ if [ -d $$f ]; then \ $(INSTALL) -d -m 775 $(DESTDIR)$(docdir)/$$p; \ else \ $(INSTALL) -m 644 $$f $(DESTDIR)$(docdir)/$$p; \ fi \ done; \ done endif BRAND_DEPS = $(wildcard publican-clusterlabs/en-US/*.png) \ $(wildcard publican-clusterlabs/en-US/*.xml) brand-build: $(BRAND_DEPS) cd publican-clusterlabs && publican build --formats=xml --langs=all --publish brand: brand-build echo "Installing..." cd publican-clusterlabs && sudo publican install_brand --path=$(datadir)/publican/Common_Content brand-rpm-clean: find publican-clusterlabs -name "*.noarch.rpm" -exec rm -f \{\} \; brand-rpm-build: brand-rpm-clean brand-build cd publican-clusterlabs && $(PUBLICAN) package --binary brand-rpm-install: brand-rpm-build find publican-clusterlabs -name "*.noarch.rpm" -exec sudo rpm -Uvh --force \{\} \; pdf: make DOCBOOK_FORMATS="pdf" all-local www: clean-local $(generated_docs) $(ascii) for book in $(docbook); do \ sed -i.sed 's@^brand:.*@brand: clusterlabs@' $$book/publican.cfg; \ done make DOCBOOK_FORMATS="pdf,html,html-single,epub" DOCBOOK_LANGS="$(UPLOAD_LANGS)" all-local echo Uploading current $(PACKAGE_SERIES) documentation set to clusterlabs.org if BUILD_DOCBOOK for book in $(docbook); do \ echo Uploading $$book...; \ echo "Generated on `date` from version: $(shell git log --pretty="format:%h %d" -n 1)" >> $$book/publish/build-$(PACKAGE_SERIES).txt; \ rsync $(RSYNC_OPTS) $$book/publish/* "$(RSYNC_DEST)/$(PACKAGE)/doc/"; \ done endif rsync $(RSYNC_OPTS) $(generated_docs) $(ascii) "$(RSYNC_DEST)/$(PACKAGE)/doc/" clean-local: -rm -f $(PNGS_GENERATED) -rm -rf $(generated_docs) $(generated_mans) $(docbook_build) -rm -rf $(SHARED_XML) $(CFS_XML) $(PE_XML) $(PR_XML) -rm -rf publican-catalog-fallback publican-catalog for book in $(docbook); do rm -rf $$book/tmp $$book/publish; done diff --git a/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt b/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt index 3f76d8a475..c28c8e9219 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Constraints.txt @@ -1,887 +1,900 @@ :compat-mode: legacy = Resource Constraints = //// We prefer [[ch-constraints]], but older versions of asciidoc don't deal well with that construct for chapter headings //// anchor:ch-constraints[Chapter 7, Alerts] 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 per resource and node. Any node with a negative score for a resource can't run that resource. The cluster places a resource on the node with the highest score for it. === Infinity Math === Pacemaker implements +INFINITY+ (or equivalently, ++INFINITY+) internally as a score of 1,000,000. Addition and subtraction with it follow these three basic rules: * Any value + +INFINITY+ = +INFINITY+ * Any value - +INFINITY+ = +-INFINITY+ * +INFINITY+ - +INFINITY+ = +-INFINITY+ [NOTE] ====== What if you want to use a score higher than 1,000,000? Typically this possibility arises when someone wants to base the score on some external metric that might go above 1,000,000. The short answer is you can't. The long answer is it is sometimes possible work around this limitation creatively. You may be able to set the score to some computed value based on the external metric rather than use the metric directly. For nodes, you can store the metric as a node attribute, and query the attribute when computing the score (possibly as part of a custom resource agent). ====== == Deciding Which Nodes a Resource Can Run On == indexterm:[Location Constraints] indexterm:[Resource,Constraints,Location] 'Location constraints' tell the cluster which nodes a resource can run on. There are two alternative strategies. One way is to say that, by default, resources can run anywhere, and then the location constraints specify nodes that are not allowed (an 'opt-out' cluster). The other way is to start with nothing able to run anywhere, and use location constraints to selectively enable allowed nodes (an 'opt-in' cluster). Whether you should choose opt-in or opt-out depends on your personal preference and the make-up of your cluster. If most of your resources can run on most of the nodes, then an opt-out arrangement is likely to result in a simpler configuration. On the other-hand, if most resources can only run on a small subset of nodes, an opt-in configuration might be simpler. === Location Properties === .Properties of a rsc_location Constraint [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 | |The name of the resource to which this constraint applies indexterm:[rsc,Location Constraints] indexterm:[Constraints,Location,rsc] |rsc-pattern | |An extended regular expression (as defined in http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04[POSIX]) matching the names of resources to which this constraint applies, if +rsc+ is not specified; if the regular expression contains submatches and the constraint is governed by a rule (see <>), the submatches can be referenced as +%0+ through +%9+ in the rule's +score-attribute+ or a rule expression's +attribute+ indexterm:[rsc-pattern,Location Constraints] indexterm:[Constraints,Location,rsc-pattern] |node | |A node's name indexterm:[node,Location Constraints] indexterm:[Constraints,Location,node] |score | |Positive values indicate a preference for running the affected resource(s) on this node -- the higher the value, the stronger the preference. Negative values indicate the resource(s) should avoid this node (a value of +-INFINITY+ changes "should" to "must"). indexterm:[score,Location Constraints] indexterm:[Constraints,Location,score] |resource-discovery |always a|Whether Pacemaker should perform resource discovery (that is, check whether the resource is already running) for this resource on this node. This should normally be left as the default, so that rogue instances of a service can be stopped when they are running where they are not supposed to be. However, there are two situations where disabling resource discovery is a good idea: when a service is not installed on a node, discovery might return an error (properly written OCF agents will not, so this is usually only seen with other agent types); and when Pacemaker Remote is used to scale a cluster to hundreds of nodes, limiting resource discovery to allowed nodes can significantly boost performance. * +always:+ Always perform resource discovery for the specified resource on this node. * +never:+ Never perform resource discovery for the specified resource on this node. This option should generally be used with a -INFINITY score, although that is not strictly required. * +exclusive:+ Perform resource discovery for the specified resource only on this node (and other nodes similarly marked as +exclusive+). Multiple location constraints using +exclusive+ discovery for the same resource across different nodes creates a subset of nodes resource-discovery is exclusive to. If a resource is marked for +exclusive+ discovery on one or more nodes, that resource is only allowed to be placed within that subset of nodes. indexterm:[Resource Discovery,Location Constraints] indexterm:[Constraints,Location,Resource Discovery] |========================================================= [WARNING] ========= Setting resource-discovery to +never+ or +exclusive+ removes Pacemaker's ability to detect and stop unwanted instances of a service running where it's not supposed to be. It is up to the system administrator (you!) to make sure that the service can 'never' be active on nodes without resource-discovery (such as by leaving the relevant software uninstalled). ========= === 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 --name symmetric-cluster --update false ---- Then start enabling nodes. The following fragment says that the web server prefers *sles-1*, the database prefers *sles-2* and both can fail over to *sles-3* if their most preferred node fails. .Opt-in location constraints for two resources ====== [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 --name symmetric-cluster --update true ---- Then start disabling nodes. The following fragment is the equivalent of the above opt-in configuration. .Opt-out location constraints for two resources ====== [source,XML] ------- ------- ====== [[node-score-equal]] === What if Two Nodes Have the Same Score === If two nodes have the same score, then the cluster will choose one. This choice may seem random and may not be what was intended, however the cluster was not given enough information to know any better. .Constraints where a resource prefers 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 the Order in which Resources Should Start/Stop == indexterm:[Resource,Constraints,Ordering] indexterm:[Resource,Start Order] indexterm:[Ordering Constraints] 'Ordering constraints' tell the cluster the order in which resources should start. [IMPORTANT] ==== Ordering constraints affect 'only' the ordering of resources; they do 'not' require that the resources be placed on the same node. If you want resources to be started on the same node 'and' in a specific order, you need both an ordering constraint 'and' a colocation constraint (see <>), or alternatively, a group (see <>). ==== === Ordering Properties === .Properties of a rsc_order Constraint [width="95%",cols="1m,1,<4",options="header",align="center"] |========================================================= |Field |Default |Description |id | |A unique name for the constraint indexterm:[id,Ordering Constraints] indexterm:[Constraints,Ordering,id] |first | |Name of the resource that the +then+ resource depends on indexterm:[first,Ordering Constraints] indexterm:[Constraints,Ordering,first] |then | |Name of the dependent resource indexterm:[then,Ordering Constraints] indexterm:[Constraints,Ordering,then] |first-action |start |The action that the +first+ resource must complete before +then-action+ can be initiated for the +then+ resource. Allowed values: +start+, +stop+, +promote+, +demote+. indexterm:[first-action,Ordering Constraints] indexterm:[Constraints,Ordering,first-action] |then-action |value of +first-action+ |The action that the +then+ resource can execute only after the +first-action+ on the +first+ resource has completed. Allowed values: +start+, +stop+, +promote+, +demote+. indexterm:[then-action,Ordering Constraints] indexterm:[Constraints,Ordering,then-action] |kind |Mandatory a|How to enforce the constraint. Allowed values: * +Optional:+ Just a suggestion. Only applies if both resources are executing the specified actions. Any change in state by the +first+ resource will have no effect on the +then+ resource. * +Mandatory:+ Always. If +first+ does not perform +first-action+, +then+ will not be allowed to performed +then-action+. If +first+ is restarted, +then+ (if running) will be stopped beforehand and started afterward. * +Serialize:+ Ensure that no two stop/start actions occur concurrently for the resources. +First+ and +then+ can start in either order, but one must complete starting before the other can be started. A typical use case is when resource start-up puts a high load on the host. indexterm:[kind,Ordering Constraints] indexterm:[Constraints,Ordering,kind] |symmetrical |TRUE for +Mandatory+ and +Optional+ kinds. FALSE for +Serialize+ kind. |If true, the reverse of the constraint applies for the opposite action (for example, if B starts after A starts, then B stops before A stops). +Serialize+ orders cannot be symmetrical. indexterm:[symmetrical,Ordering Constraints] indexterm:[Ordering Constraints,symmetrical] |========================================================= +Promote+ and +demote+ apply to the master role of <> resources. === Optional and mandatory ordering === Here is an example of ordering constraints where +Database+ 'must' start before +Webserver+, and +IP+ 'should' start before +Webserver+ if they both need to be started: .Optional and mandatory ordering constraints ====== [source,XML] ------- ------- ====== Because the above example lets +symmetrical+ default to TRUE, +Webserver+ must be stopped before +Database+ can be stopped, and +Webserver+ should be stopped before +IP+ if they both need to be stopped. [[s-resource-colocation]] == Placing Resources Relative to other Resources == indexterm:[Resource,Constraints,Colocation] indexterm:[Resource,Location Relative to other Resources] 'Colocation constraints' tell the cluster that the location of one resource depends on the location of another one. Colocation has an important side-effect: it affects the order in which resources are assigned to a node. Think about it: You can't place A relative to B unless you know where B is. 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 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 http://clusterlabs.org/doc/Colocation_Explained.pdf[Colocation Explained]. [IMPORTANT] ==== Colocation constraints affect 'only' the placement of resources; they do 'not' require that the resources be started in a particular order. If you want resources to be started on the same node 'and' in a specific order, you need both an ordering constraint (see <>) 'and' a colocation constraint, or alternatively, a group (see <>). ==== === Colocation Properties === .Properties of a rsc_colocation Constraint [width="95%",cols="1m,1,<4",options="header",align="center"] |========================================================= |Field |Default |Description |id | |A unique name for the constraint (required). indexterm:[id,Colocation Constraints] indexterm:[Constraints,Colocation,id] |rsc | |The name of a resource that should be located relative to +with-rsc+ (required). indexterm:[rsc,Colocation Constraints] indexterm:[Constraints,Colocation,rsc] |with-rsc | |The name of the resource used as the colocation target. The cluster will decide where to put this resource first and then decide where to put +rsc+ (required). indexterm:[with-rsc,Colocation Constraints] indexterm:[Constraints,Colocation,with-rsc] |node-attribute |#uname |The node attribute that must be the same on the node running +rsc+ and the node running +with-rsc+ for the constraint to be satisfied. (For details, see <>.) indexterm:[node-attribute,Colocation Constraints] indexterm:[Constraints,Colocation,node-attribute] |score | |Positive values indicate the resources should run on the same node. Negative values indicate the resources should run on different nodes. Values of \+/- +INFINITY+ change "should" to "must". indexterm:[score,Colocation Constraints] indexterm:[Constraints,Colocation,score] |========================================================= === Mandatory Placement === Mandatory placement occurs when the constraint's score is ++INFINITY+ or +-INFINITY+. In such cases, if the constraint can't be satisfied, then the +rsc+ resource is not permitted to run. For +score=INFINITY+, this includes cases where the +with-rsc+ resource is not active. If you need resource +A+ to always run on the same machine as resource +B+, you would add the following constraint: .Mandatory colocation constraint for two resources ==== [source,XML] ==== Remember, because +INFINITY+ was used, if +B+ can't run on any of the cluster nodes (for whatever reason) then +A+ will not be allowed to run. Whether +A+ is running or not has no effect on +B+. Alternatively, you may want the opposite -- that +A+ 'cannot' run on the same machine as +B+. In this case, use +score="-INFINITY"+. .Mandatory anti-colocation constraint for two resources ==== [source,XML] ==== Again, by specifying +-INFINITY+, the constraint is binding. So if the only place left to run is where +B+ already is, then +A+ may not run anywhere. As with +INFINITY+, +B+ can run even if +A+ is stopped. However, in this case +A+ also can run if +B+ is stopped, because it still meets the constraint of +A+ and +B+ not running on the same node. === Advisory Placement === If mandatory placement is about "must" and "must not", then advisory placement is the "I'd prefer if" alternative. For constraints with scores greater than +-INFINITY+ and less than +INFINITY+, the cluster will try to accommodate your wishes but may ignore them if the alternative is to stop some of the cluster resources. As 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. .Advisory colocation constraint for two resources ==== [source,XML] ==== [[s-coloc-attribute]] === Colocation by Node Attribute === The +node-attribute+ property of a colocation constraints allows you to express the requirement, "these resources must be on similar nodes". As an example, imagine that you have two Storage Area Networks (SANs) that are not controlled by the cluster, and each node is connected to one or the other. You may have two resources +r1+ and +r2+ such that +r2+ needs to use the same SAN as +r1+, but doesn't necessarily have to be on the same exact node. In such a case, you could define a <> named +san+, with the value +san1+ or +san2+ on each node as appropriate. Then, you could colocate +r2+ with +r1+ using +node-attribute+ set to +san+. [[s-resource-sets]] == Resource Sets == 'Resource sets' allow multiple resources to be affected by a single constraint. .A set of 3 resources ==== [source,XML] ---- ---- ==== Resource sets are valid inside +rsc_location+, +rsc_order+ (see <>), +rsc_colocation+ (see <>), and +rsc_ticket+ (see <>) constraints. A resource set has a number of properties that can be set, though not all have an effect in all contexts. .Properties of a resource_set [width="95%",cols="2m,1,<5",options="header",align="center"] |========================================================= |Field |Default |Description |id | |A unique name for the set indexterm:[id,Resource Sets] indexterm:[Constraints,Resource Sets,id] |sequential |true |Whether the members of the set must be acted on in order. Meaningful within +rsc_order+ and +rsc_colocation+. indexterm:[sequential,Resource Sets] indexterm:[Constraints,Resource Sets,sequential] |require-all |true |Whether all members of the set must be active before continuing. With the current implementation, the cluster may continue even if only one member of the set is started, but if more than one member of the set is starting at the same time, the cluster will still wait until all of those have started before continuing (this may change in future versions). Meaningful within +rsc_order+. indexterm:[require-all,Resource Sets] indexterm:[Constraints,Resource Sets,require-all] |role | |Limit the effect of the constraint to the specified role. Meaningful within +rsc_location+, +rsc_colocation+ and +rsc_ticket+. indexterm:[role,Resource Sets] indexterm:[Constraints,Resource Sets,role] |action | |Limit the effect of the constraint to the specified action. Meaningful within +rsc_order+. indexterm:[action,Resource Sets] indexterm:[Constraints,Resource Sets,action] |score | |'Advanced use only.' Use a specific score for this set within the constraint. indexterm:[score,Resource Sets] indexterm:[Constraints,Resource Sets,score] |========================================================= [[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, resource sets (see <>) can be used within ordering constraints: .A chain of ordered resources expressed as a set ====== [source,XML] ------- ------- ====== While the set-based format is not less verbose, it is significantly easier to get right and maintain. [IMPORTANT] ========= If you use a higher-level tool, pay attention to how it exposes this functionality. Depending on the tool, creating a set +A B+ may be equivalent to +A then B+, or +B then A+. ========= === Ordering Multiple Sets === The syntax can be expanded to allow sets of resources to be ordered relative to each other, where the members of each individual set may be ordered or unordered (controlled by the +sequential+ property). In the example below, +A+ and +B+ can both start in parallel, as can +C+ and +D+, however +C+ and +D+ can only start once _both_ +A+ _and_ +B+ are active. .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"] [IMPORTANT] ==== An ordered set with +sequential=false+ makes sense only if there is another set in the constraint. Otherwise, the constraint has no effect. ==== === Resource Set OR Logic === The unordered set logic discussed so far has all been "AND" logic. To illustrate this take the 3 resource set figure in the previous section. Those sets can be expressed, +(A and B) then \(C) then (D) then (E and F)+. Say for example we want to change the first set, +(A and B)+, to use "OR" logic so the sets look like this: +(A or B) then \(C) then (D) then (E and F)+. This functionality can be achieved through the use of the +require-all+ option. This option defaults to TRUE which is why the "AND" logic is used by default. Setting +require-all=false+ means only one resource in the set needs to be started before continuing on to the next set. .Resource Set "OR" logic: Three ordered sets, where the first set is internally unordered with "OR" logic ====== [source,XML] ------- ------- ====== [IMPORTANT] ==== An ordered set with +require-all=false+ makes sense only in conjunction with +sequential=false+. Think of it like this: +sequential=false+ modifies the set to be an unordered set using "AND" logic by default, and adding +require-all=false+ flips the unordered set's "AND" logic to "OR" logic. ==== [[s-resource-sets-colocation]] == Colocating Sets of Resources == Another common situation is for an administrator to create a set of colocated resources. -One way to do this would be to define a resource group (see +The simplest way to do this is to define a resource group (see <>), but that cannot always accurately express the desired -state. +relationships. For example, maybe the resources do not need to be ordered. Another way would be to define each relationship as an individual constraint, -but that causes a constraint explosion as the number of resources and -combinations grow. An example of this approach: +but that causes a difficult-to-follow constraint explosion as the number of +resources and combinations grow. -.Chain of colocated resources +.Colocation chain as individual constraints, where A is placed first, then B, then C, then D ====== [source,XML] ------- ------- ====== -To make things easier, resource sets (see <>) can be used -within colocation constraints. 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 +B+ is not -able to run, then both +C+ and by inference +D+ must also remain -stopped. Here is an example +resource_set+: +To express complicated relationships with a simplified syntax +footnote:[which is not the same as saying easy to follow], +<> can be used within colocation constraints. .Equivalent colocation chain expressed using +resource_set+ ====== [source,XML] ------- ------- ====== +[NOTE] +==== +Within a +resource_set+, the resources are listed in the order they are +_placed_, which is the reverse of the order in which they are _colocated_. +In the above example, resource +A+ is placed before resource +B+, which is +the same as saying resource +B+ is colocated with resource +A+. +==== + +As with individual constraints, a resource that can't be active prevents any +resource that must be colocated with it from being active. In both of the two +previous examples, if +B+ is unable to run, then both +C+ and by inference +D+ +must remain stopped. + [IMPORTANT] ========= If you use a higher-level tool, pay attention to how it exposes this functionality. Depending on the tool, creating a set +A B+ may be equivalent to +A with B+, or +B with A+. ========= -This notation can also be used to tell the cluster that sets of resources must -be colocated relative to each other, where the individual members of each set -may or may not depend on each other being active (controlled by the -+sequential+ property). +Resource sets can also be used to tell the cluster that entire _sets_ of +resources must be colocated relative to each other, while the individual +members within any one set may or may not be colocated relative to each other +(determined by the set's +sequential+ property). -In this example, +A+, +B+, and +C+ will each be colocated with +D+. -+D+ must be active, but any of +A+, +B+, or +C+ may be inactive without -affecting any other resources. +In the following example, resources +B+, +C+, and +D+ will each be colocated +with +A+ (which will be placed first). +A+ must be able to run in order for any +of the resources to run, but any of +B+, +C+, or +D+ may be stopped without +affecting any of the others. -.Using colocated sets to specify a common peer +.Using colocated sets to specify a shared dependency ====== [source,XML] ------- - - + - - + + + ------- ====== +[NOTE] +==== +Pay close attention to the order in which resources and sets are listed. +While the members of any one sequential set are placed first to last (i.e., the +colocation dependency is last with first), multiple sets are placed last to +first (i.e. the colocation dependency is first with last). +==== + [IMPORTANT] ==== -A colocated set with +sequential=false+ makes sense only if there is another -set in the constraint. Otherwise, the constraint has no effect. +A colocated set with +sequential="false"+ makes sense only if there is +another set in the constraint. Otherwise, the constraint has no effect. ==== There is no inherent limit to the number and size of the sets used. The only thing that matters is that in order for any member of one set in the constraint to be active, all members of sets listed after it must also be active (and naturally on the same node); and if a set has +sequential="true"+, then in order for one member of that set to be active, all members listed before it must also be active. If desired, you can restrict the dependency to instances of promotable clone resources that are in a specific role, using the set's +role+ property. -.Colocation chain in which the members of the middle set have no interdependencies, and the last listed set (which the cluster places first) is restricted to instances in master status. +.Colocation in which the members of the middle set have no interdependencies, and the last set listed applies only to instances in the master role ====== [source,XML] ------- - - + + - - + + ------- ====== -.Visual representation the above example (resources to the left are placed first) -image::images/three-sets-complex.png["Colocation chain",width="16cm",height="9cm",align="center"] +.Visual representation of the above example (resources are placed from left to right) +image::images/pcmk-colocated-sets.png["Colocation chain",width="960px",height="431px",align="center"] [NOTE] ==== -Pay close attention to the order in which resources and sets are listed. -While the colocation dependency for members of any one set is last-to-first, -the colocation dependency for multiple sets is first-to-last. In the above -example, +B+ is colocated with +A+, but +colocated-set-1+ is -colocated with +colocated-set-2+. - Unlike ordered sets, colocated sets do not use the +require-all+ option. ==== diff --git a/doc/shared/en-US/images/pcmk-colocated-sets.svg b/doc/shared/en-US/images/pcmk-colocated-sets.svg new file mode 100644 index 0000000000..9e53fc48f9 --- /dev/null +++ b/doc/shared/en-US/images/pcmk-colocated-sets.svg @@ -0,0 +1,436 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + A + A + + + + B + B + + + + C + C + + + + D + D + + + + E + E + + + + F + F + + + + G + G + + + + + + + + + + + diff --git a/doc/shared/en-US/images/three-sets-complex.png b/doc/shared/en-US/images/three-sets-complex.png deleted file mode 100644 index 4318f6c62f..0000000000 Binary files a/doc/shared/en-US/images/three-sets-complex.png and /dev/null differ