Skip to content

Instantly share code, notes, and snippets.

@meteozond meteozond/clusterip
Created Jan 30, 2015

Embed
What would you like to do?
Heartbeat ClusterIP resource manager
#!/bin/sh
#
#
# Description: wrapper of OCF RA clustgerip, based on original heartbeat RA. See
# OCF RA cluserip for more information.
#
# Author: Alexander Klimenko <alex@erix.ru>
# Support: alex@erix.ru
# License: GNU General Public License (GPL)
# Copyright: (C) 2005 International Business Machines
#
# Usage
#
# Supposed you've git two servers which traffic is ballanced with ClusterIP.
#
# First one:
#
# iptables -A INPUT -d 10.0.0.1 -i eth1 -j CLUSTERIP --new \
# --hashmode sourceip-sourceport --clustermac 01:00:5E:00:00:20 \
# --total-nodes 2 --local-node 1
#
# Second:
#
# iptables -A INPUT -d 10.0.0.1 -i eth1 -j CLUSTERIP --new \
# --hashmode sourceip-sourceport --clustermac 01:00:5E:00:00:20 \
# --total-nodes 2 --local-node 2
#
# To provide failover, update your /etc/ha.d/haresources like this:
#
# node1 clusterip::10.0.0.1::1
# node2 clusterip::10.0.0.1::2
#
PREFIX=/proc/net/ipt_CLUSTERIP
usage() {
echo "usage: $0 [clusterip] [node] $LEGAL_ACTIONS"
exit 1
}
case $3 in
start)
echo +$2 > $PREFIX/$1 || true;
;;
stop)
echo -$2 > $PREFIX/$1 || true;
;;
status)
nodes=`cat $PREFIX/$1`;
if (echo "$nodes" | fgrep -q "$2"); then
echo 'ok';
else
echo 'fail'
fi
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.