  <chapter id="ch-intro"><title>Read-Me-First</title>
    <section id="s-intro-scope">
      <title>The Scope of this Document </title>
      <para>
	The purpose of this document is to definitively explain the concepts used to configure Pacemaker.
	To achieve this best, it will focus exclusively on the XML syntax used to configure the CIB.
      </para>
      <para>
	For those that are allergic to XML, Pacemaker comes with a cluster shell and a Python based GUI exists, however these tools will not be covered at all in this document
	<footnote>
	  <para>It is hoped however, that having understood the concepts explained here, that the functionality of these tools will also be more readily understood.</para>
	</footnote>
	, precisely because they hide the XML.
      </para>
      <para>
	Additionally, this document is NOT a step-by-step how-to guide for configuring a specific clustering scenario.
	Although such guides exist, the purpose of this document is to provide an understanding of the building blocks that can be used to construct any type of Pacemaker cluster.
      </para>
    </section>
    <section id="s-intro-pacemaker">
      <title>What Is Pacemaker?</title>
      <para>
	Pacemaker is a cluster resource manager.
	It achieves maximum availability for your cluster services (aka. resources) by detecting and recovering from node and resource-level failures by making use of the messaging and membership capabilities provided by your preferred cluster infrastructure (either <ulink url="http://www.corosync.org/">Corosync</ulink> or Heartbeat).
      </para>
      <para>Pacemaker's key features include:</para>
      <itemizedlist>
	<listitem><para>Detection and recovery of node and service-level failures</para></listitem>
	<listitem><para>Storage agnostic, no requirement for shared storage</para></listitem>
	<listitem><para>Resource agnostic, anything that can be scripted can be clustered</para></listitem>
	<listitem><para>Supports <ulink url="http://en.wikipedia.org/wiki/STONITH">STONITH</ulink> for ensuring data integrity</para></listitem>
	<listitem><para>Supports large and small clusters</para></listitem>
	<listitem><para>Supports both <ulink url="http://en.wikipedia.org/wiki/Quorum_(Distributed_Systems)">quorate</ulink> and <ulink url="http://devresources.linux-foundation.org/dev/clusters/docs/ResourceDrivenClusters.pdf">resource driven</ulink> clusters</para></listitem>
	<listitem><para>Supports practically any <ulink url="http://en.wikipedia.org/wiki/High-availability_cluster#Node_configurations">redundancy configuration</ulink></para></listitem>
	<listitem><para>Automatically replicated configuration that can be updated from any node</para></listitem>
	<listitem><para>Ability to specify cluster-wide service ordering, colocation and anti-colocation</para></listitem>
	<listitem><para>Support for advanced services type
	  <itemizedlist>
	    <listitem><para>Clones: for services which need to be active on multiple nodes</para></listitem>
	    <listitem><para>Multi-state: for services with multiple modes (eg. master/slave, primary/secondary)</para></listitem>
	  </itemizedlist>
	</para></listitem>
	<listitem><para>Unified, scriptable, cluster shell</para></listitem>
      </itemizedlist>
    </section>
    <section id="s-intro-redundancy">
      <title>Types of Pacemaker Clusters</title>
      <para>Pacemaker makes no assumptions about your environment, this allows it to support practically any <ulink url="http://en.wikipedia.org/wiki/High-availability_cluster#Node_configurations">redundancy configuration</ulink> including Active/Active, Active/Passive, N+1, N+M, N-to-1 and N-to-N.</para>

      <para>
	<figure id="fig-redundancy-active-passsive">
	  <title>Active/Passive Redundancy</title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref="images/pcmk-active-passive.png" width="10cm" depth="7.5cm" align="center"/>
	    </imageobject>
	    <caption>Two-node Active/Passive clusters using Pacemaker and DRBD are a cost-effective solution for many High Availability situations.</caption>
	  </mediaobject>
	</figure>
      </para>
      <para>
	<figure id="fig-redundancy-n-plus-one">
	  <title>Shared Failover</title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref="images/pcmk-shared-failover.png" width="10cm" depth="7.5cm" align="center"/> 
	    </imageobject>
	    <caption>By supporting many nodes, Pacemaker can dramatically reduce hardware costs by allowing several active/passive clusters to be combined and share a common backup node</caption>
	  </mediaobject>
	</figure>
      </para>
      <para>
	<figure id="fig-redundancy-n-to-n">
	  <title>N to N Redundancy</title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref="images/pcmk-active-active.png" width="10cm" depth="7.5cm" align="center"/>
	    </imageobject>
	    <caption>
	      When shared storage is available, every node can potentially be used for failover.
	      Pacemaker can even run multiple copies of services to spread out the workload.
	    </caption>
	  </mediaobject>
	</figure>
      </para>
    </section>
    <section id="s-intro-architecture">
      <title>Pacemaker Architecture</title>
      <para>At the highest level, the cluster is made up of three pieces:</para>
      <itemizedlist>
	<listitem><para>
          Core cluster infrastructure providing messaging and membership functionality (illustrated in red)
	</para></listitem>
	<listitem><para>
          Non-cluster aware components (illustrated in blue).
	  In a Pacemaker cluster, these pieces include not only the scripts that knows how to start, stop and monitor resources, but also a local daemon that masks the differences between the different standards these scripts implement.
	</para></listitem>
	<listitem><para>
          A brain (illustrated in green) that processes and reacts to events from the cluster (nodes leaving or joining) and resources (eg. monitor failures) as well as configuration changes from the administrator.
	  In response to all of these events, Pacemaker will compute the ideal state of the cluster and plot a path to achieve it.
	  This may include moving resources, stopping nodes and even forcing them offline with remote power switches.
	</para></listitem>
      </itemizedlist>
      <para>
	<figure id="fig-stack-concept">
	  <title>Conceptual Stack Overview</title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref="images/pcmk-overview.png" width="10cm" depth="7.5cm" align="center"/> 
	    </imageobject>
	    <caption>Conceptual overview of the cluster stack</caption>
	  </mediaobject>
	</figure>
      </para>
      <para>When combined with Corosync, Pacemaker also supports popular open source cluster filesystems
	<footnote>
          <para>
	    Even though Pacemaker also supports Heartbeat, the filesystems need to use the stack for messaging and membership and Corosync seems to be what they're standardizing on.
	    Technically it would be possible for them to support Heartbeat as well, however there seems little interest in this.
	  </para>
	</footnote>
	Due to recent standardization within the cluster filesystem community, they make use of a common distributed lock manager which makes use of Corosync for its messaging capabilities and Pacemaker for its membership (which nodes are up/down) and fencing services.
      </para>
      <para>
	<figure id="fig-stack-ais">
	  <title>The Pacemaker Stack</title>
	  <mediaobject>
	    <imageobject>
	      <imagedata fileref="images/pcmk-stack.png" width="10cm" depth="7.5cm" align="center"/> 
	    </imageobject>
	    <caption>The Pacemaker stack when running on Corosync</caption>
	  </mediaobject>
	</figure>
      </para>
      <section id="s-pcmk-internals">
	<title>Internal Components</title>
	<para>Pacemaker itself is composed of four key components (illustrated below in the same color scheme as the previous diagram):</para>
	<itemizedlist>
	  <listitem><para>CIB (aka. Cluster Information Base)</para></listitem>
	  <listitem><para>CRMd (aka. Cluster Resource Management daemon)</para></listitem>
	  <listitem><para>PEngine (aka. PE or Policy Engine)</para></listitem>
	  <listitem><para>STONITHd</para></listitem>
	</itemizedlist>
	<para>
	  <figure id="fig-stack-internal">
	    <title>Internal Components</title>
	    <mediaobject>
	      <imageobject>
		<imagedata fileref="images/pcmk-internals.png" width="10cm" depth="7.5cm" align="center"/> 
	      </imageobject>
	      <caption>Subsystems of a Pacemaker cluster running on Corosync</caption>
	    </mediaobject>
	  </figure>
	</para>
	<para>
	  The CIB uses XML to represent both the cluster's configuration and current state of all resources in the cluster.
	  The contents of the CIB are automatically kept in sync across the entire cluster and are used by the PEngine to compute the ideal state of the cluster and how it should be achieved.
	</para>
	<para>
	  This list of instructions is then fed to the DC (Designated Co-ordinator).
	  Pacemaker centralizes all cluster decision making by electing one of the CRMd instances to act as a master.
	  Should the elected CRMd process, or the node it is on, fail...
	  a new one is quickly established.
	</para>
	<para>The DC carries out the PEngine's instructions in the required order by passing them to either the LRMd (Local Resource Management daemon) or CRMd peers on other nodes via the cluster messaging infrastructure (which in turn passes them on to their LRMd process).</para>
	<para>The peer nodes all report the results of their operations back to the DC and based on the expected and actual results, will either execute any actions that needed to wait for the previous one to complete, or abort processing and ask the PEngine to recalculate the ideal cluster state based on the unexpected results.</para>
	<para>
	  In some cases, it may be necessary to power off nodes in order to protect shared data or complete resource recovery.
	  For this Pacemaker comes with STONITHd.
	  STONITH is an acronym for Shoot-The-Other-Node-In-The-Head and is usually implemented with a remote power switch.
	  In Pacemaker, STONITH devices are modeled as resources (and configured in the CIB) to enable them to be easily monitored for failure, however STONITHd takes care of understanding the STONITH topology such that its clients simply request a node be fenced and it does the rest.
	</para>
      </section>
    </section>
  </chapter>
