# Kit of scripts for configure PostgreSQL + PgPool-II + JBoss 7.2.0.Final + Apache 2.4 ModCluster
* httpd - Contains nessary configs files, and script for automatic configure httpd and mod_cluster
* jboss Contains script for configure two servers as one cluster, applications for test cluster and some console utils
* pgpool - Contains examples configs, init script and script for autoconfigure pgpool-II
* postgres - Contains auto configure stream replication and console utils

## Getting started
First you need edit config file [contrib/config](https://sergeserver.noip.me/gitlab/iSergio/jboss-cluster/blob/master/contrib/config) and fill in the values based on your cluster settings
1. PRIMARY_HOST - Host which will be primary in you system
2. STANDBY_HOST - Host which will be standby in you system
3. CLUSTER_SUBNET - Network subnet for access mod cluster manager
4. PGPOOL_TRUSTED_SERVERS - Trusted server list which are used to confirm network connection (hostA,hostB,hostC,...)
5. PGPOOL_DELEGATE_IP - Delegate IP address. If this is empty, virtual IP never bring up.
6. PGPOOL_INTERFACE - Interface on which will be up/down virtual ip address

All runs commands assuming what all components placed on one server. Example:

Primary server:
* PostgreSQL
* PgPool-II
* Httpd(ServerGOD)
* JBoss 7.2.0.Final

Standby server:
* PostgreSQL
* PgPool-II
* Httpd(ServerGOD)
* JBoss 7.2.0.Final

### Configure Primary server
1. Configure PostgreSQL stream replication
    1. cd postgresql
    2. ./configure.sh
    3. pg_replication -c
2. Configure pgpool:
    1. cd pgpool
    2. ./configure.sh
3. Configure https (ServerGOD)
    1. cd httpd
    2. ./configure.sh
4. Configure JBoss 7.2.0.Final
    1. cd jboss
    2. ./configure.sh -p -d

### Configure Standby server
1. Configure pgpool:
    1. cd pgpool
    2. ./configure.sh -s
2. Configure https (ServerGOD)
    1. cd httpd
    2. ./configure.sh -s
3. Configure JBoss 7.2.0.Final
    1. cd jboss
    2. ./configure.sh -s

## Provided utils
### PostgreSQL and PgPool-II utils
pg_attach_node - Simple attach node to pgpool. Only one parameter need - number of node

pg_auto_attach_node - Try auto attach down node. This script executes once a minute by cron. Or may be executed by hand

pg_failover - This script fires when any node in failed.

pg_recovery - Auto recovery node(See -h).

pg_replication - Configure stream replication between two servers(-c). Show status of replication, pgpool nodes and watchdog(-s). Also see help (-h)

### JBoss 7.2.0.Final utils
dodeploy [dir for recurse search] - deploy war/ear/jar to JBoss from directory recursive