• No results found

Chapter 2. Introduction to Linux-HA release 2

2.2 Heartbeat version 2 architecture

2.2.5 Cluster Information Base

The CIB XML file contains everything that is needed to understand the cluster:

specifically its resources and the current cluster status. The master CIB is maintained by the Designated Coordinator in the cluster, and the DC replicates the master CIB to the other nodes in the cluster. The CIB represents two parts:

򐂰 The cluster configuration, which includes node and resource information, and constraints that exist in the cluster

This information represents how the cluster administrator would like to run the cluster. This part stays the constant during the runtime of Heartbeat, and only changes when the cluster administrator makes changes to the nodes, resources or constraints as a result of a configuration change.

򐂰 A snapshot of the current cluster state

The information in the snapshot depicts which nodes are alive and which resources are active.

Whenever there is a change in the cluster state, the PE on the DC node compares the state information against the configuration information and determines a list of actions to take to get the state to conform to the configuration policies.

There are a few ways to create and manipulate the cib.xml file. The first method is to use the CLI tools. The second method is to use the graphical HA

Management client. The third method is to create or edit an XML file and then use the cibadmin CLI to import it into the cluster. You can mix and match these methods in your administrative tasks. Always use the graphical management tool and the CLIs used in preference to editing the XML file manually, especially if the cluster is active. However, it might be easier to start by importing a template cib.xml file and then using the CLIs or the graphical tool to manage the cluster.

For more information about the graphical management tool and the CLI tools, see 2.3, “Heartbeat cluster management tools” on page 26.

There might be times when you want to look at the XML file for specific

information or update a CIB template for importing into your cluster. We discuss the CIB structure in the section that follows.

CIB structure

The CIB contains two types of information:

򐂰 Cluster configuration information

This information does not change with the status of the cluster. The

configuration information includes cluster information, resources in the cluster and their constraints, and property settings related to the cluster. When the

administrator updates the configurations of the cluster, this part of the CIB changes. For instance, when the administrator adds another node to the cluster, the configuration portion updates with the new information.

򐂰 Cluster status information

This information conveys the current status of the cluster. Think of this information as the dynamic portion of the CIB. It tells you what the cluster looks like right now, including information about current cluster membership and the status of cluster resources.

The CIB is stored and processed as white space that is insignificant to XML, and its layout and mandatory information is in the CIB Document Type Definition (DTD). The current version of the DTD is available from the following Web address:

http://hg.clusterlabs.org/pacemaker/dev/file/tip/xml/crm-1.0.dtd

High level structure of the CIB

The entire CIB is enclosed by the <cib> ... </cib> tags. The configuration section is defined in the <configuration> ... </configuration> tags. It is followed by the status section defined in the <status> ... </status> tags.

You see four general sections in the cluster configuration portion of the CIB:

򐂰 Cluster properties are defined inside the <cluster_property_set> ...

</cluster_property_set> tags.

򐂰 The nodes in the cluster are defined inside the <nodes> ... </nodes> tags.

򐂰 Resources are defined inside the <resources> ... </resources> tags.

򐂰 Resource constraints are defined inside the <constraints> ...

</constraints> tags.

For cluster properties, nodes, and resources, you can define attributes as nvpairs that tell Heartbeat how to run the cluster, node, or resource. In Example 2-1, the two attributes are defined to an IPaddr resource. The two attributes are IP address and the net mask associated with the IP address. An identifier (id) must be associated with each attribute. This value is arbitrary as long as it is unique in the cluster. The name denotes the name of the attribute, and the value conveys the user-defined value of the attribute. Therefore, for the first attribute in Example 2-1 on page 22, the name of the attribute is ip, and the value is 192.168.0.10.

Example 2-1 Defined attributes

The attributes that are available for definitions associated with cluster properties are the same for each cluster. For nodes, the same concept applies.

For resources, the attributes that you can define depend on the type of resource.

For example, the ip and cidr_netmask attributes apply to the IPaddr resource but not the nfsserver resource.

Remember that you do not have to define all the attributes that are available to a particular entity. For most attributes, there are default values. For some, you must define a few mandatory attributes. For example, in Example 2-1 on page 22, the ip attribute is mandatory for the IPaddr resource, but the cidr_netmask attribute is not.

In the status portion of the CIB, the status of each node in the cluster is defined inside the <node_state> ... </node_state> tags. There is one such section per cluster node. In each node_state section, there is information about the node, the resources in the node, and the operations that are active for each resource.

While the cluster is active, you can generate the CIB file by using the following command:

# cibadmin -Q > cib.xml

This command places the cib.xml file in the directory from which you are running the command.

If you are importing an XML file into a CIB, make sure that you check the syntax and semantics first by running the ciblint command as follows:

# ciblint -f myconfig.xml

For more information about the ciblint command, see “Validating the cib.xml file” on page 256.

Attention: Do not directly edit the CIB. Always use the command line tools to update or add to the CIB or use the Heartbeat GUI.

To import an XML file that contains resource definitions into the resources section of a running CIB, use the cibadmin command as follows:

# cibadmin -C -o resources -x myresource.xml

To import an XML file containing cluster properties into the cluster properties section of a running CIB, use the following command:

# cibadmin -C -o crm_config -x mycluster_properties.xml

To import an XML file that contains constraints into the constraints section of the a running CIB, use the following command:

# cibadmin -C -o constraints -x myconstraints.xml

For more information about Heartbeat’s command line tools, see 2.3.1,

“Command line interface” on page 26.

For a real-life scenario that uses CIB XML files, see 5.2, “Shared-disk clustered file system” on page 166.