Commit 7a4ad0a9 authored by iSergio's avatar iSergio
Browse files

Add DB_CLUSTER option

parent 00c7f67e
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -18,14 +18,19 @@ fi
TYPE=primary
VERBOSE=false
CATEGORY=a
DB_CLUSTER=false

usage="$(basename "$0") [-h] [-p] [-s] [-a|b]-- Script configure pgpool-II
usage="$(basename "$0") [-h] [-p] [-s] [-a|b] [-d] -- Script configure pgpool-II
 where:
     -h  show this help text and exit
     -p  configure pgpool as primary
     -s  configure pgpool as standby
     -a  configure pgpool for category A (4 servers) (separate jboss and postgresql clusters) (Default: a)
     -b  configure pgpool for category B (2 servers) (jboss and postgresql cluster on same hasts) (Default: a)
     -d  configure pgpool for PostgreSQL cluster (Default: false)
 Example usage:
    configure.sh -p -a    -- PgPool will be configured for primary server Category A (without PostgreSQL) (app-primary)
    configure.sh -p -a -d -- PgPool will be configured for primary server Category A without PostgreSQL (db-primary)
"

while getopts ':psvhab' option; do
@@ -40,6 +45,8 @@ while getopts ':psvhab' option; do
            ;;
        b) CATEGORY=b
            ;;
        d) DB_CLUSTER=true
            ;;
        h) echo "$usage"
            exit
            ;;
@@ -55,7 +62,7 @@ if [[ ! -z $_TYPE ]]; then
    TYPE=$_TYPE
fi

if [[ "$CATEGORY" == "a" ]]; then
if [[ $DB_CLUSTER == false && "$CATEGORY" == "a" ]]; then
    PGPOOL_PRIMARY_HOST=$JBOSS_PRIMARY_HOST
    PGPOOL_STANDBY_HOST=$JBOSS_STANDBY_HOST
fi
@@ -95,7 +102,7 @@ sed -i 's/__PGPOOL_TRUSTED_SERVERS__/'$PGPOOL_TRUSTED_SERVERS'/g' $PGPOOL_CONFIG
sed -i 's/__PGPOOL_DELEGATE_IP__/'$PGPOOL_DELEGATE_IP'/g' $PGPOOL_CONFIG
sed -i 's/__PGPOOL_INTERFACE__/'$PGPOOL_INTERFACE'/g' $PGPOOL_CONFIG

if [[ "$CATEGORY" == "a" ]]; then
if [[ $DB_CLUSTER == false && "$CATEGORY" == "a" ]]; then
    sed -i 's/PGPOOLUSER=postgres/PGPOOLUSER=root/g' /etc/init.d/pgpool
    sed -i 's/socket_dir = '\''\/var\/pgtmp'\''/socket_dir = '\''\/var\/tmp'\''/g' $PGPOOL_CONFIG
    sed -i 's/load_balance_mode = on/load_balance_mode = off/g' $PGPOOL_CONFIG
@@ -114,7 +121,7 @@ chmod 4755 /usr/sbin/arping


mkdir -p /var/log/pgpool
if [[ "$CATEGORY" == "b" ]]; then
if [[ $DB_CLUSTER == false && "$CATEGORY" == "b" ]]; then
    touch /etc/pgpool-II/pool_passwd
    chown postgres /etc/pgpool-II/pool_passwd