diff --git a/postgresql/tasks/postgres_pgpool.yml b/postgresql/tasks/postgres_pgpool.yml index b506ac5f..8e79cc49 100644 --- a/postgresql/tasks/postgres_pgpool.yml +++ b/postgresql/tasks/postgres_pgpool.yml @@ -39,7 +39,7 @@ tags: [ 'postgresql', 'postgres', 'pgpool' ] - name: Install the pgpool recovery and remote restart scripts. They assume that the postgresql hosts can talk to each other - template: src={{ item.1 }}.j2 dest={{ item.0.backend_data_directory }}/{{ item.1 }} owner=postgres group=postgres mode=0500 + template: src={{ item.1 }}.j2 dest={{ item.0.backend_data_directory }}/main/{{ item.1 }} owner=postgres group=postgres mode=0500 with_nested: - '{{ pgpool_backends | default([]) }}' - [ '{{ pgpool_recovery_stage1_script }}', '{{ pgpool_recovery_stage2_script }}', '{{ pgpool_remote_start_script }}' ] diff --git a/postgresql/templates/pgpool_recovery_stage_1.j2 b/postgresql/templates/pgpool_recovery_stage_1.j2 index 27e57b2e..8b77ffa8 100644 --- a/postgresql/templates/pgpool_recovery_stage_1.j2 +++ b/postgresql/templates/pgpool_recovery_stage_1.j2 @@ -4,13 +4,16 @@ # TS=$(date +%Y-%m-%d_%H-%M-%S) MASTER_HOST=$(hostname -f) -# The variables $1 and $3 are {{ psql_data_dir }}/main +# $1 is {{ psql_data_dir }}/main while $3 is {{ psql_data_dir }} MASTER_DATA=$1 MASTER_DATA_BASE_DIR={{ psql_data_dir }} -RECOVERY_TARGET=$2 -RECOVERY_DATA=$3 +RECOVERY_TARGET=${2} +RECOVERY_DATA=${3}/main RECOVERY_DATA_BASE_DIR={{ psql_data_dir }} +logger "pgpool_recovery_1: MASTER_DATA=$MASTER_DATA" +logger "pgpool_recovery_1: RECOVERY_DATA=$RECOVERY_DATA" + archive_dir={{ psql_wal_archiving_log_dir }} # Ensure that postgres is shut down on the target node diff --git a/postgresql/templates/pgpool_recovery_stage_2.j2 b/postgresql/templates/pgpool_recovery_stage_2.j2 index e08dd43c..d9e037b4 100644 --- a/postgresql/templates/pgpool_recovery_stage_2.j2 +++ b/postgresql/templates/pgpool_recovery_stage_2.j2 @@ -2,14 +2,19 @@ # Online recovery 2nd stage script # MASTER_DATA_BASE_DIR={{ psql_data_dir }} -MASTER_DATA=$1 -RECOVERY_TARGET=$2 +MASTER_DATA=${1} +RECOVERY_TARGET=${2} RECOVERY_DATA_BASE_DIR={{ psql_data_dir }} -RECOVERY_DATA=$3 +RECOVERY_DATA=${3} port={{ psql_db_port }} # PostgreSQL port number archive_dir={{ psql_wal_archiving_log_dir }} +logger "pgpool_recovery_2: MASTER_DATA=$MASTER_DATA" +logger "pgpool_recovery_2: RECOVERY_DATA=$RECOVERY_DATA" +logger "pgpool_recovery_2: archive_dir=$archive_dir" + + # Force to flush current value of sequences to xlog psql -p $port -t -c 'SELECT datname FROM pg_database WHERE NOT datistemplate AND datallowconn' template1| while read i