Forum Discussion

paragarw's avatar
paragarw
Level 4
10 years ago

Need inputs in adding IP routes on failover

I have a requirement where I need to update the add the routes for my application  to connect to the network and source systems everytime the failover or switchover happens.

If Application is running on node 1 then following routes should be added

route add -net IP netmask 255.255.255.255 10.225.230.1 gw dev bond0: 1
route add -net IP1 netmask 255.255.255.255 10.225.230.1 gw dev bond0: 1
route add -net IP2 netmask 255.255.255.255 10.225.230.1 gw dev bond0: 1

If Application is running on node 2 then following routes should be added

route add -net IP netmask 255.255.255.255 10.225.230.1 gw dev bond0: 0
route add -net IP1 netmask 255.255.255.255 10.225.230.1 gw dev bond0: 0
route add -net IP2 netmask 255.255.255.255 10.225.230.1 gw dev bond0: 0

  • You have at least 3 choices - add these route commands to a:

    1. preonline trigger script
    2. postonline trigger script
    3. application resource

    The preonline trigger runs before your group onlines and the postonline trigger run after your group onlines - see the VCS user guide for more info on trigger scripts.  The trigger scripts are passed the system, but the triggers are on each node, so easy enough to run different commands on different systems.

    For creating an application resource, this can go anywhere in the resource dependency tree so you can create a resource something like:

    dard template like below:

    ARG=$2
    LOCKFILE=/tmp/.{$2}.DO_NOT_REMOVE
    case "$1" in
    start)
        touch $LOCKFILE
        add routes using $ARG - example:
        route add -net IP netmask 255.255.255.255 10.225.230.1 gw dev bond0: $ARG ;;
    stop)
        rm $LOCKFILE
        Optionally remove routes using $ARG;;
        ;;
    monitor)
    if [ -a $LOCKFILE ]
    then
            exit 110
        else
            exit 100
        fi ;;
    *) 
        echo "Usage: $0 {start|stop|monitor} arg
        exit 1
        ;;
    esac 
     

    and then create application resource with localised (per system) attributes like:

    Application routes (
      StartProgram @node1 = "/opt/VRTSvcs/bin/routes.sh start 1"
      StartProgram @node2 = "/opt/VRTSvcs/bin/routes.sh start 0"
      StopProgram @node1 = "/opt/VRTSvcs/bin/routes.sh stop 1"
      StopProgram @node2 = "/opt/VRTSvcs/bin/routes.sh stop 0"
      MonitorProgram @node1 = "/opt/VRTSvcs/bin/routes.sh monitor 1"
      MonitorProgram @node2 = "/opt/VRTSvcs/bin/routes.sh monitor 0"
    )

     

    Or you could make routes.sh different on each of the nodes to add the routes requires

    Mike