if the server 1 does not crash completely, but only one of the
services stop unexpectedly, can heartbeat be configured to watch out
for it and start it?
Sure, heartbeat version 2 can do it.
With version 1, your /etc/ha.d/haresources
looks like this:
master 129.79.136.4 apache
then you can generate the heartbeat 2 configuration file by running:
python /usr/lib64/heartbeat/haresources2cib.py > /var/lib/heartbeat/crm/cib.xml
/var/lib/heartbeat/crm/cib.xml
...
<resources>
<group id="group_1">
<primitive class="ocf" id="IPaddr_129_79_136_4" provider="heartbeat" type="IPaddr">
<operations>
<op id="IPaddr_129_79_136_4_mon" interval="5s" name="monitor" timeout="5s"/>
</operations>
<instance_attributes id="IPaddr_129_79_136_4_inst_attr">
<attributes>
<nvpair id="IPaddr_129_79_136_4_attr_0" name="ip" value="129.79.136.4"/>
</attributes>
</instance_attributes>
</primitive>
<primitive class="ocf" id="apache_2" provider="heartbeat" type="apache">
<operations>
<op id="apache_2_mon" interval="120s" name="monitor" timeout="60s"/>
</operations>
</primitive>
</group>
</resources>
...
But I would suggest you should go with corosync
and Pacemaker
.