How to Configure Service Dependency in Red Hat Cluster Suite
Red Hat failover clustering has an interesting feature for controlling a dependent service when its primary service starts or stops. The key is the “depend_mode” attribute, available in the Red Hat Enterprise and Cluster Suite versions listed below. The following Red Hat and Cluster Suite versions support this feature:
- Red Hat Enterprise Linux (RHEL) 5 update 3 and rgmanager-2.0.38-2 or later
- Red Hat Enterprise Linux (RHEL) 4 update 7 and rgmanager-1.9.80-1 or later
There are two ways to define the behavior of a dependent service:
- Hard: the dependent service follows the state of the primary service.
- Soft: the dependent service starts when the primary service starts, but does not stop when the primary service stops.
Here is an example. We want service2 to follow service1 when service1 starts or stops. Set depend_mode=“hard” for service2, as shown below.
/etc/cluster.conf
...
<service autostart="1" domain="RHCS-FailOver" name="service1">
<ip ref="192.168.0.10">
<script ref="apache"></script>
</ip>
</service>
<service autostart="1" depend="service:service1" depend_mode="hard" domain="RHCS-FailOver" name="service2" recovery="restart">
<ip ref="192.168.0.12" ></ip>
</service>
...
service1 must start before service2 because the service2 configuration contains depend=“service:service1”. If service2 starts before service1, the error “Operation violates dependency rule” appears. If service2 stops, this does not affect service1. Thanks: [Red Hat]