Setup a online.net failover IP with heartbeat on Debian
Online.net provide a fail-over IP functionality for Dedibox servers. This functionality can be configured by a REST interface. This howto setup a REST client for the high-availability cluster software Heartbeat allowing to change fail-over IP destination when a member of the cluster crash.
This howto is tested on:
- Debian 7.0 Wheezy
Prerequisite
This howto needs:
- the high-availability cluster software Heartbeat, as described by Install Heartbeat on Debian.
Parameters
Provide the REST API authentication key (available in the API page of Online.net console):
API_TOKEN="061652d05e21be8febf8af5d53abaf5ecf7fb6f4"
Provide the name of the network interface linked to the failover IP:
NET_DEV="eth0"
Provide the failover IP address assigned to the cluster:
FAILOVER_IP="xx.xx.xx.xx"
Installation
Detect the destination IP address of the failover IP:
NET_IP="$(command ifconfig "${NET_DEV}" \
| command grep 'inet ' \
| command sed -e 's/^.*inet [^:]*:\([^ ]*\) .*$/\1/')"
Environment preparation
Install the needed software:
command apt-get install curl
Download the Heartbeat resource script:
command wget 'https://raw.github.com/biapy/howto.biapy.com/master/various/OnlineFailoverIP' \
--quiet --no-check-certificate --output-document='/etc/ha.d/resource.d/OnlineFailoverIP'
command chmod +x '/etc/ha.d/resource.d/OnlineFailoverIP'
Configuration
Configure Heartbeat:
command sed -i \
-e "s/${FAILOVER_IP}.*$/& OnlineFailoverIP::${API_TOKEN}::${FAILOVER_IP}::${NET_IP}/" \
'/etc/ha.d/haresources'
Reload Heartbeat configuration:
service heartbeat reload
Thanks
- Thanks to Online for Online.net REST API.