Category: Cluster-HA

Keepalived addon IPFire

mkdir /var/ipfire/keepalived

— master

/var/ipfire/keepalived/keepalived.conf

global_defs {

}
vrrp_instance VI_1 {
state MASTER
interface green0
virtual_router_id 81
priority 150
advert_int 1
authentication {
auth_type AH
auth_pass F1mPlus

}
virtual_ipaddress {
172.16.0.1/24 brd 172.16.0.255 dev green0
}
}

 

—–slave

global_defs {

}

vrrp_instance VI_1 {
state BACKUP
interface green0
virtual_router_id 81
priority 100
advert_int 1
authentication {
auth_type AH
auth_pass F1mPlus
}
virtual_ipaddress {
172.16.0.1/24 brd 172.16.0.255 dev green0
}
}

 

/var/ipfire/keepalived/keepalived

#!/bin/bash
# start/stop script for ipfire’s keepalived packet
# (w) Cisco Bob 2013
# History:
# 22.Aug 2013 CB initial version

DAEMON=”/usr/sbin/keepalived”
VRRP=”–vrrp”
CHECK=”–check”
CFGFILE=”-f /var/ipfire/keepalived/keepalived.conf”
DEFAULTS=”/var/ipfire/keepalived/defaults”
PIDFILE=”/var/run/vrrp.pid”
DEBUG=””

daemonName=${DAEMON##*/}

if [ -s $DEFAULTS ]
then
. $DEFAULTS
fi

if [ ! -x $DAEMON ]
then
echo “File $DAEMON is not executable – bailout”
exit 3
fi

if [ ! $CFGFILE ]
then
echo “sorry configile $CFGFILE must exist – bailout”
exit 3
fi

function startProc () {
$DAEMON $DEBUG $VRRP $CHECK $CFGFILE –log-console –log-detail
[ $? -eq 0 ] && echo “$!” >$PIDFILE
}
function stopProc () {
if [ -f $PIDFILE ]
then
kill $(cat $PIDFILE)
rm -f $PIDFILE
else
list=$(ps -ef | grep keepalived | grep -v grep)
if [ -z $list ]
then
# no process found – exit silently
exit 0
fi
pidOfDaemonRaw=$(ps -ef | grep $daemonName | awk ‘{ print $2 “,”$3}’)
# returns 1555,1 if it is the daemon
pidOfParent=${pidOfDaemonRaw#*,}
pidOfDaemon=${pidOfDaemonRaw%,*}
if [ $pidOfParent = “1” ]
then
#echo “OK – killing $DAEMON with PID=$pidOfDaemon”
kill $pidOfDaemon
fi
fi
}

if [ $# -lt 1 ]
then
echo “usage: $0 start|stop|restart”
exit 3
fi

case $1 in
start)
startProc
;;
stop)
stopProc
;;
restart)
stopProc
sleep 1
startProc
;;
*)
echo “unsupported paramter: $1 should be start,stop,restart”
;;
esac
exit 0

 

/var/ipfire/keepalived/defaults

# gets sourced by keepalived start/stop script
DAEMON=”/usr/sbin/keepalived”
VRRP=”–vrrp”
#CHECK=”–check”
CHECK=””
CFGFILE=”-f /var/ipfire/keepalived/keepalived.conf”
#WDOG_VRRP=”–wdog-vrrp 1″
WDOG_VRRP=””
#WDOG_CHECK=”–wdog-check 30″
WDOG_CHECK=””
PIDFILE=”/var/run/vrrp.pid”
# for debugging set
#DEBUG=”–dont-fork –log-console –log-detail”
#DEBUG=”–log-detail”
DEBUG=””

 

— sh

#!/bin/bash
set +u
# setup for keepalived configuration
# (w) Cisco Bob
# History:
# 22.Aug 2013 CB initial version
#
script=”keepalived”
cfg=”/etc/$script/$script.conf”
srcDir=”/var/ipfire/$script”
backupFile=”/var/ipfire/backup/include”

if [ -f $cfg ]
then
mv $cfg ${cfg}.orig
fi
ln -sf $srcDir/${script}.conf $cfg
ln -sf $srcDir/$script /etc/init.d/${script}
ln -sf $srcDir/$script /etc/rc.d/rc3.d/S70${script}
ln -sf $srcDir/$script /etc/rc.d/rc0.d/K01${script}
ln -sf $srcDir/$script /etc/rc.d/rc6.d/K01${script}
echo “links created”

# now add it to the backup def file (multi call capable)
# yes I know not very elegant 😦 – but does the job
echo “filter backupfile”
grep -v $script $backupFile >/tmp/include
echo “add keepalived to backup file”
mv /tmp/include /var/ipfire/backup/include
echo “/var/ipfire/${script}/*” >>/var/ipfire/backup/include
echo “done”

Advertisements

How to install and configure MariaDB Galera as master to master replication cluster on Ubuntu 16.04 LTS

How do I install and configure MariaDB Galera master to master cluster on Ubuntu Linux 16.04 LTS server to get both read and write scalability?

MariaDB Galera Cluster is an open source and free synchronous multi-master cluster for MariaDB database. It is available on Linux only and only supports the XtraDB/InnoDB storage engines. There is experimental support for MyISAM, but it is not well tested. Starting with MariaDB 10.1, the wsrep API for Galera Cluster is included by default. Continue reading

Setting up a Load-Balancing Cluster with Heartbeat and Ldirectord

We will be setting up a load balancer with Heartbeat and Ldirector on CentOS 6.
Note
Ldirectord has been removed from RHEL 6 default repository and replaced with Piranha.
As of RHEL 6.6, Red Hat provides support for HAProxy and keepalived in addition to the Piranha load balancing software.
Piranha has been removed from RHEL 7 default repository and replaced with HAProxy and keepalived. Continue reading

Setting up a Load-Balancing HAProxy Cluster with Keepalived

We will be setting up a load balancer using two main technologies to monitor cluster members and cluster services: Keepalived and HAProxy. Keepalived uses LVS to perform load balancing and failover tasks on active and passive LVS routers, while HAProxy performs load balancing and high-availability services to TCP and HTTP applications. Continue reading