Loading postgres/bin/pg_replication +9 −4 Original line number Diff line number Diff line Loading @@ -5,8 +5,11 @@ if [[ "$(whoami)" != "root" ]]; then exit -1 fi PRIMARY_HOST=__PRIMARY_HOST__ STANDBY_HOST=__STANDBY_HOST__ PGSQL_PRIMARY_HOST=__PGSQL_PRIMARY_HOST__ PGSQL_STANDBY_HOST=__PGSQL_STANDBY_HOST__ PGPOOL_PRIMARY_HOST=__PGPOOL_PRIMARY_HOST__ PGPOOL_STANDBY_HOST=__PGPOOL_STANDBY_HOST__ PG_CONNECTIONS=2000 Loading Loading @@ -36,8 +39,8 @@ function add_pg_host () { } # Prepare hosts add_pg_host "$PRIMARY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$STANDBY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$PGSQL_PRIMARY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$PGSQL_STANDBY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" # Configure postgres users access via ssh by RSA keys function exchange_rsa_keys () { Loading Loading @@ -113,6 +116,8 @@ archive_command = '$archive_command'" >> ${PG_CONFS[0]} echo "#REPLICATION BEGIN local all all trust host all all $PGPOOL_PRIMARY_HOST trust host all all $PGPOOL_STANDBY_HOST trust host all all 127.0.0.1/32 trust" >> ${PG_HBAS[0]} for (( i = 0; i < ${#PG_HOSTS[*]}; i++ )); do echo "host all all ${PG_HOSTS[$i]}/32 trust Loading postgres/configure.sh +23 −11 Original line number Diff line number Diff line Loading @@ -20,19 +20,31 @@ fi cp bin/pg_* /usr/local/bin/ # Configure listen ip address echo -n "Please, enter a ip address of PRIMARY server(Default: $PRIMARY_HOST): " read _PRIMARY_HOST echo -n "Please, enter a ip address of STANDBY server(Default: $STANDBY_HOST) " read _STANDBY_HOST if [[ ! -z $_PRIMARY_HOST ]]; then PRIMARY_HOST=$_PRIMARY_HOST echo -n "Please, enter a ip address of PRIMARY PostgreSQL server(Default: $PGSQL_PRIMARY_HOST): " read _PGSQL_PRIMARY_HOST echo -n "Please, enter a ip address of PRIMARY PgPool server(Default: $PGPOOL_PRIMARY_HOST): " read _PGPOOL_PRIMARY_HOST echo -n "Please, enter a ip address of STANDBY PostgreSQL server(Default: $PGSQL_STANDBY_HOST): " read _PGSQL_STANDBY_HOST echo -n "Please, enter a ip address of STANDBY PgPool server(Default: $PGPOOL_STANDBY_HOST): " read _PGPOOL_STANDBY_HOST if [[ ! -z $_PGSQL_PRIMARY_HOST ]]; then PGSQL_PRIMARY_HOST=$_PGSQL_PRIMARY_HOST fi if [[ ! -z $_PGPOOL_PRIMARY_HOST ]]; then PGPOOL_PRIMARY_HOST=$_PGPOOL_PRIMARY_HOST fi if [[ ! -z $_PGSQL_STANDBY_HOST ]]; then PGSQL_STANDBY_HOST=$_PGSQL_STANDBY_HOST fi if [[ ! -z $_STANDBY_HOST ]]; then STANDBY_HOST=$_STANDBY_HOST if [[ ! -z $_PGPOOL_STANDBY_HOST ]]; then PGPOOL_STANDBY_HOST=$_PGPOOL_STANDBY_HOST fi sed -i 's/__PRIMARY_HOST__/'$PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__STANDBY_HOST__/'$STANDBY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGSQL_PRIMARY_HOST__/'$PGSQL_PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGSQL_STANDBY_HOST__/'$PGSQL_STANDBY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGPOOL_PRIMARY_HOST__/'$PGPOOL_PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGPOOL_STANDBY_HOST__/'$PGPOOL_STANDBY_HOST'/g' /usr/local/bin/pg_replication pg_replication -c Loading
postgres/bin/pg_replication +9 −4 Original line number Diff line number Diff line Loading @@ -5,8 +5,11 @@ if [[ "$(whoami)" != "root" ]]; then exit -1 fi PRIMARY_HOST=__PRIMARY_HOST__ STANDBY_HOST=__STANDBY_HOST__ PGSQL_PRIMARY_HOST=__PGSQL_PRIMARY_HOST__ PGSQL_STANDBY_HOST=__PGSQL_STANDBY_HOST__ PGPOOL_PRIMARY_HOST=__PGPOOL_PRIMARY_HOST__ PGPOOL_STANDBY_HOST=__PGPOOL_STANDBY_HOST__ PG_CONNECTIONS=2000 Loading Loading @@ -36,8 +39,8 @@ function add_pg_host () { } # Prepare hosts add_pg_host "$PRIMARY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$STANDBY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$PGSQL_PRIMARY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" add_pg_host "$PGSQL_STANDBY_HOST" "5433" "postgres" "/var/lib/pgsql/data" "/var/lib/pgsql/backups" "/var/lib/pgsql/data/postgresql.conf" "/var/lib/pgsql/data/pg_hba.conf" # Configure postgres users access via ssh by RSA keys function exchange_rsa_keys () { Loading Loading @@ -113,6 +116,8 @@ archive_command = '$archive_command'" >> ${PG_CONFS[0]} echo "#REPLICATION BEGIN local all all trust host all all $PGPOOL_PRIMARY_HOST trust host all all $PGPOOL_STANDBY_HOST trust host all all 127.0.0.1/32 trust" >> ${PG_HBAS[0]} for (( i = 0; i < ${#PG_HOSTS[*]}; i++ )); do echo "host all all ${PG_HOSTS[$i]}/32 trust Loading
postgres/configure.sh +23 −11 Original line number Diff line number Diff line Loading @@ -20,19 +20,31 @@ fi cp bin/pg_* /usr/local/bin/ # Configure listen ip address echo -n "Please, enter a ip address of PRIMARY server(Default: $PRIMARY_HOST): " read _PRIMARY_HOST echo -n "Please, enter a ip address of STANDBY server(Default: $STANDBY_HOST) " read _STANDBY_HOST if [[ ! -z $_PRIMARY_HOST ]]; then PRIMARY_HOST=$_PRIMARY_HOST echo -n "Please, enter a ip address of PRIMARY PostgreSQL server(Default: $PGSQL_PRIMARY_HOST): " read _PGSQL_PRIMARY_HOST echo -n "Please, enter a ip address of PRIMARY PgPool server(Default: $PGPOOL_PRIMARY_HOST): " read _PGPOOL_PRIMARY_HOST echo -n "Please, enter a ip address of STANDBY PostgreSQL server(Default: $PGSQL_STANDBY_HOST): " read _PGSQL_STANDBY_HOST echo -n "Please, enter a ip address of STANDBY PgPool server(Default: $PGPOOL_STANDBY_HOST): " read _PGPOOL_STANDBY_HOST if [[ ! -z $_PGSQL_PRIMARY_HOST ]]; then PGSQL_PRIMARY_HOST=$_PGSQL_PRIMARY_HOST fi if [[ ! -z $_PGPOOL_PRIMARY_HOST ]]; then PGPOOL_PRIMARY_HOST=$_PGPOOL_PRIMARY_HOST fi if [[ ! -z $_PGSQL_STANDBY_HOST ]]; then PGSQL_STANDBY_HOST=$_PGSQL_STANDBY_HOST fi if [[ ! -z $_STANDBY_HOST ]]; then STANDBY_HOST=$_STANDBY_HOST if [[ ! -z $_PGPOOL_STANDBY_HOST ]]; then PGPOOL_STANDBY_HOST=$_PGPOOL_STANDBY_HOST fi sed -i 's/__PRIMARY_HOST__/'$PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__STANDBY_HOST__/'$STANDBY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGSQL_PRIMARY_HOST__/'$PGSQL_PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGSQL_STANDBY_HOST__/'$PGSQL_STANDBY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGPOOL_PRIMARY_HOST__/'$PGPOOL_PRIMARY_HOST'/g' /usr/local/bin/pg_replication sed -i 's/__PGPOOL_STANDBY_HOST__/'$PGPOOL_STANDBY_HOST'/g' /usr/local/bin/pg_replication pg_replication -c