Commit 50ac3c60 authored by Gabriel Mazetto's avatar Gabriel Mazetto 🚀

Fix using postgresql with different ports for Geo

parent ea62cd80
......@@ -240,6 +240,9 @@ postgresql/data:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql/data
support/bootstrap-rails
postgresql/port:
./support/postgres-port ${postgres_dir} ${postgresql_port}
postgresql-sensible-defaults:
./support/postgresql-sensible-defaults ${postgres_dir}
......@@ -256,19 +259,26 @@ postgresql-replication/access:
cat support/pg_hba.conf.add >> postgresql/data/pg_hba.conf
postgresql-replication/role:
${postgres_bin_dir}/psql -h ${postgres_dir} -d postgres -c "CREATE ROLE ${postgres_replication_user} WITH REPLICATION LOGIN;"
${postgres_bin_dir}/psql -h ${postgres_dir} -p ${postgresql_port} -d postgres -c "CREATE ROLE ${postgres_replication_user} WITH REPLICATION LOGIN;"
postgresql-replication/backup:
$(eval postgres_primary_dir := $(realpath postgresql-primary))
$(eval postgres_primary_port := $(shell cat ${postgres_primary_dir}/postgresql_port 2>/dev/null || echo '5432'))
$(eval postgres_primary_port := $(shell cat ${postgres_primary_dir}/../postgresql_port 2>/dev/null || echo '5432'))
psql -h ${postgres_primary_dir} -p ${postgres_primary_port} -d postgres -c "select pg_start_backup('base backup for streaming rep')"
rsync -cva --inplace --exclude="*pg_xlog*" --exclude="*.pid" ${postgres_primary_dir}/data postgresql
psql -h ${postgres_primary_dir} -p ${postgres_primary_port} -d postgres -c "select pg_stop_backup(), current_timestamp"
./support/recovery.conf ${postgres_primary_dir} > postgresql/data/recovery.conf
./support/recovery.conf ${postgres_primary_dir} ${postgres_primary_port} > postgresql/data/recovery.conf
$(MAKE) postgresql/port
postgresql-replication/slot:
${postgres_bin_dir}/psql -h ${postgres_dir} -d postgres -c "SELECT * FROM pg_create_physical_replication_slot('gitlab_gdk_replication_slot');"
${postgres_bin_dir}/psql -h ${postgres_dir} -p ${postgresql_port} -d postgres -c "SELECT * FROM pg_create_physical_replication_slot('gitlab_gdk_replication_slot');"
postgresql-replication/list-slots:
${postgres_bin_dir}/psql -h ${postgres_dir} -p ${postgresql_port} -d postgres -c "SELECT * FROM pg_replication_slots;"
postgresql-replication/drop-slot:
${postgres_bin_dir}/psql -h ${postgres_dir} -p ${postgresql_port} -d postgres -c "SELECT * FROM pg_drop_replication_slot('gitlab_gdk_replication_slot');"
postgresql-replication/config:
./support/postgres-replication ${postgres_dir}
......
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
exit 1
fi
postgres_dir="$( cd "$1" && pwd )"
postgres_port=$2
timestamp="$(date +"%s")"
sed -E -i ".{$timestamp}.bak" "s/(port[ \t]=[ \t])([0-9]{4,6})/\1${postgres_port}/g" $postgres_dir/data/postgresql.conf
#!/bin/bash
# this script will output a recovery.conf file using first parameter as host/socket path
socket_path=$1
pg_port=$2
cat <<EOF
standby_mode = 'on'
primary_conninfo = 'host=${socket_path} port=5432 user=gitlab_replication'
primary_conninfo = 'host=${socket_path} port=${pg_port} user=gitlab_replication'
primary_slot_name = 'gitlab_gdk_replication_slot'
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment