You can create more complex behaviors by combining multiple affinities. For example, the state of an application might be recorded by a related replica server. The node selection requirements for this example are as follows:
The replica server must run on a different node from the application.
If the application fails over from its current node, the application should fail over to the node where the replica server is running.
If the application fails over to the node where the replica server is running, the replica server must fail over to a different node. If no other node is available, the replica server must go offline.
You can satisfy these requirements by configuring resource groups for the application and the replica server as follows:
The resource group that contains the application declares a weak positive affinity for the resource group that contains the replica server.
The resource group that contains the replica server declares a strong negative affinity for the resource group that contains the application.
This example shows the commands for combining affinities between the following resource groups.
Resource group app-rg represents an application whose state is tracked by a replica server.
Resource group rep-rg represents the replica server.
In this example, the resource groups declare affinities as follows:
Resource group app-rg declares a weak positive affinity for resource group rep-rg.
Resource group rep-rg declares a strong negative affinity for resource group app-rg.
This example assumes that both resource groups exist.
# clresourcegroup set -p RG_affinities=+rep-rg app-rg # clresourcegroup set -p RG_affinities=--app-rg rep-rg