This is an old revision of the document!


Home tmade.de

Home Wiki

Linux-HA (heartbeat)

General Linux-HA

Configuration

Resource configuration files:

/var/lib/heartbeat/crm/cib.xml

Heartbeat Initscript:

/usr/lib/ocf/resource.d/heartbeat/

Commandline

crm_mon –i 2                                       #Overview Nodes/ Ressources with 2-sec-update
cibadmin -E --force                                #Delete the complete HA-Configuration (resources)
cibadmin -U -x /etc/ha.d/pen.xml                   #Update changes on HA-Config-File
crm_resource -r resourcename -M -H target_host     #Manual move of a resource
crm_resource -r resourcename -C -H target_host     #Delete status ob problems for a resource (unmanaged etc.)

Example:

crm_resource -r group_apache2 -M -H node1          #Move resource "group_apache2" to Node "node1"

To stop a resource temporary via cmd:

crm_resource --meta -r <resourcename> -p target_role -v stopped

To start a resource if heartbeat is running:

crm_resource --meta -r <resourcename> -p target_role -v started
crm_resource --meta -r squid -p target_role -v started

To stop an unmanaged ressource/ clear ressource status:

crm_resource -r <resourcename> -C -H node

To delete a running ressource permanentely:

cibadmin -D -X '<primitive id="lbppdf_21"/>'
cibadmin -D -X '<group id="lbppdf-cluster"/>'

Example Heartbeat-Config-File (ha.cf)

Heartbeat configuration: /etc/ha.d/ha.cf

udpport 694
auto_failback on
keepalive 2
deadtime 30
warntime 10
ping 10.0.0.1
#deadping 20
use_logd yes
#autojoin any
autojoin none
crm true
ucast eth1 10.0.0.5
ucast eth1 10.0.0.6
#ucast eth0 192.168.232.17
#ucast eth0 192.168.232.18
node nodename1
node nodename2
respawn root /usr/lib64/heartbeat/pingd -m 100 -d 5s -a pingd
apiauth ping gid=root uid=root

Example Config-File (*.xml)

<cib>
	<configuration>
		<crm_config/>
		<nodes/>
        	<resources>
                	<group id="lb1-cluster">
                        	<primitive class="ocf" provider="heartbeat" type="IPaddr2" id="ip1">
                                	<instance_attributes id="ia-ip1">
                                        	<attributes>
                                                  	<nvpair id="ia-ip1-1" name="ip" value="10.6.3.52"/>
                                               		<nvpair id="ia-ip1-2" name="cidr_netmask" value="24"/>
                                                	<nvpair id="ia-ip1-3" name="nic" value="eth0"/>
                                        	</attributes>
                                	</instance_attributes>
                                	<operations>
                                        	<op id="ip1-monitor" name="monitor" interval="15s" timeout="60s" start_delay="30s"/>
                                	</operations>
                        	</primitive>

                        	<primitive class="ocf" provider="heartbeat" type="pen_cas1_443" id="lb1_443">
                                	<operations>
                                        	<op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb1_443-monitor"/>
                                	</operations>
                        	</primitive>

                                <primitive class="ocf" provider="heartbeat" type="pen_cas1_80" id="lb1_80">
                                        <operations>
                                                <op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb1_80-monitor"/>
                                        </operations>
                                </primitive>

                	</group>

                        <group id="lb2-cluster">
                                <primitive class="ocf" provider="heartbeat" type="IPaddr2" id="ip2">
                                        <instance_attributes id="ia-ip2">
                                                <attributes>
                                                        <nvpair id="ia-ip2-1" name="ip" value="10.6.3.53"/>
                                                        <nvpair id="ia-ip2-2" name="cidr_netmask" value="24"/>
                                                        <nvpair id="ia-ip2-3" name="nic" value="eth0"/>
                                                </attributes>
                                        </instance_attributes>
                                        <operations>
                                                <op id="ip2-monitor" name="monitor" interval="15s" timeout="60s" start_delay="30s"/>
                                        </operations>
                                </primitive>

                                <primitive class="ocf" provider="heartbeat" type="pen_cas2_443" id="lb2_443">
                                        <operations>
                                                <op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb2_443-monitor"/>
                                        </operations>
                                </primitive>

                                <primitive class="ocf" provider="heartbeat" type="pen_cas2_80" id="lb2_80">
                                        <operations>
                                                <op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb2_80-monitor"/>
                                        </operations>
                                </primitive>

                        </group>

                        <group id="lb3-cluster">
                                <primitive class="ocf" provider="heartbeat" type="IPaddr2" id="ip3">
                                        <instance_attributes id="ia-ip3">
                                                <attributes>
                                                        <nvpair id="ia-ip3-1" name="ip" value="10.6.3.54"/>
                                                        <nvpair id="ia-ip3-2" name="cidr_netmask" value="24"/>
                                                        <nvpair id="ia-ip3-3" name="nic" value="eth0"/>
                                                </attributes>
                                        </instance_attributes>
                                        <operations>
                                                <op id="ip3-monitor" name="monitor" interval="15s" timeout="60s" start_delay="30s"/>
                                        </operations>
                                </primitive>

                                <primitive class="ocf" provider="heartbeat" type="pen_cas3_443" id="lb3_443">
                                        <operations>
                                                <op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb3_443-monitor"/>
                                        </operations>
                                </primitive>

                                <primitive class="ocf" provider="heartbeat" type="pen_cas3_80" id="lb3_80">
                                        <operations>
                                                <op name="monitor" interval="15s" timeout="60s" start_delay="1m" id="lb3_80-monitor"/>
                                        </operations>
                                </primitive>


                        </group>

        	</resources>

          <constraints>
		<rsc_location id="run_ip1" rsc="lb1-cluster">
    		<rule id="pref_run_ip1" score="100">
        		<expression attribute="#uname" operation="eq" value="host_1"/>
    		</rule>
		</rsc_location>

                <rsc_location id="run_ip2" rsc="lb2-cluster">
                <rule id="pref_run_ip2" score="100">
                        <expression attribute="#uname" operation="eq" value="host_2"/>
                </rule>
                </rsc_location>

                <rsc_location id="run_ip3" rsc="lb3-cluster">
                <rule id="pref_run_ip3" score="100">
                        <expression attribute="#uname" operation="eq" value="host_1"/>
                </rule>
                </rsc_location>

	  </constraints>

	</configuration>
	<status/>
</cib>

Example "Tomcat"

Example heartbeat (ocf) configuration for tomcat:

Tomcat-OCF

ocf-script

heartbeat/heartbeat.1519996414.txt.gz · Last modified: 2018/03/02 14:13 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki