Tuesday, March 24, 2009

Heartbeat2 - Add resources WITHOUT the GUI

I keep seeing tutorials for how to make a heartbeat2 cluster and they (mostly) all involve using the GUI. The problem is that I keep seeing people say to not use the GUI because it will break the cluster. So how do you manage the heartbeat2 cluster without the GUI? How do you get that initial configuration?

Get used to the cibadmin command. Since you are not supposed to modify the actual cib.xml file, you need to use the cibadmin command to modify it. cibadmin --help with give you a list of options, here are the basic ones you really need to know:
-C = Create
-U = Update
-E = Erase
-Q = Query

To get that first resource running, you need to create an xml file. The one I use for a cluster managed IP address looks simply like this:

<primitive id="IP-1-15" class="ocf" type="IPaddr" provider="heartbeat">
<instance_attributes id="IP-1-15-I"$gt;
<attributes>
<nvpair id="ip1" name="ip" value="192.168.1.15" />
</attributes>
</instance_attributes>
</primitive>

One very important thing to keep in mind is nvpair id="ip1". This has to be unique throughout the configuration, otherwise it won't load. Save the files as myip.xml (name it whatever you want).

To load this into your config, you just run this command:
cibadmin -C -o resources -x /etc/ha.d/myip.xml

That means we want to -C create this -o resource resource from -x myip.xml xml file.

If you check your cluster with crm_mon you should see your new IP address.

Now let's say you want to add monitoring to that resource. You just add that section in the xml file like this:

<primitive id="IP-1-15" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="1" name="monitor" interval="5s" timeout="3s" />
</operations>
<instance_attributes id="IP-1-15-I">
<attributes>
<nvpair id="ip1" name="ip" value="192.168.1.15" />
</attributes>
</instance_attributes>
</primitive>

And then update the cib like this:

cibadmin -U -o resources -x /etc/ha.d/myip.xml

0 comments: