diff --git a/role_scripts/10/primary/start.sh b/role_scripts/10/primary/start.sh index 6a1d344..350e5b8 100755 --- a/role_scripts/10/primary/start.sh +++ b/role_scripts/10/primary/start.sh @@ -24,7 +24,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/10/standby/ha_backup_job.sh b/role_scripts/10/standby/ha_backup_job.sh index f754665..5fd4afd 100755 --- a/role_scripts/10/standby/ha_backup_job.sh +++ b/role_scripts/10/standby/ha_backup_job.sh @@ -81,7 +81,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "shared_preload_libraries = 'pg_stat_statements'" >>/tmp/postgresql.conf diff --git a/role_scripts/10/standby/run.sh b/role_scripts/10/standby/run.sh index ec71e58..4b64ab1 100755 --- a/role_scripts/10/standby/run.sh +++ b/role_scripts/10/standby/run.sh @@ -119,7 +119,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/10/standby/warm_stanby.sh b/role_scripts/10/standby/warm_stanby.sh index 598ad68..d49edf2 100755 --- a/role_scripts/10/standby/warm_stanby.sh +++ b/role_scripts/10/standby/warm_stanby.sh @@ -26,7 +26,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/11/primary/start.sh b/role_scripts/11/primary/start.sh index dde2bfa..e54cb96 100755 --- a/role_scripts/11/primary/start.sh +++ b/role_scripts/11/primary/start.sh @@ -24,7 +24,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/11/standby/ha_backup_job.sh b/role_scripts/11/standby/ha_backup_job.sh index d337953..9270734 100755 --- a/role_scripts/11/standby/ha_backup_job.sh +++ b/role_scripts/11/standby/ha_backup_job.sh @@ -81,7 +81,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/11/standby/run.sh b/role_scripts/11/standby/run.sh index c2396f5..af88ae5 100755 --- a/role_scripts/11/standby/run.sh +++ b/role_scripts/11/standby/run.sh @@ -118,7 +118,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/11/standby/warm_stanby.sh b/role_scripts/11/standby/warm_stanby.sh index b29d984..9d36fcb 100755 --- a/role_scripts/11/standby/warm_stanby.sh +++ b/role_scripts/11/standby/warm_stanby.sh @@ -26,7 +26,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/12/primary/start.sh b/role_scripts/12/primary/start.sh index e85c9c9..ca93987 100755 --- a/role_scripts/12/primary/start.sh +++ b/role_scripts/12/primary/start.sh @@ -24,7 +24,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/12/standby/ha_backup_job.sh b/role_scripts/12/standby/ha_backup_job.sh index def35a0..0b6e85d 100755 --- a/role_scripts/12/standby/ha_backup_job.sh +++ b/role_scripts/12/standby/ha_backup_job.sh @@ -76,7 +76,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then diff --git a/role_scripts/12/standby/run.sh b/role_scripts/12/standby/run.sh index 958c671..974e320 100755 --- a/role_scripts/12/standby/run.sh +++ b/role_scripts/12/standby/run.sh @@ -114,7 +114,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then diff --git a/role_scripts/12/standby/warm_stanby.sh b/role_scripts/12/standby/warm_stanby.sh index 56c1f2a..6f7ab49 100755 --- a/role_scripts/12/standby/warm_stanby.sh +++ b/role_scripts/12/standby/warm_stanby.sh @@ -24,7 +24,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/13/primary/start.sh b/role_scripts/13/primary/start.sh index eebe9f1..fe23779 100755 --- a/role_scripts/13/primary/start.sh +++ b/role_scripts/13/primary/start.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/13/standby/ha_backup_job.sh b/role_scripts/13/standby/ha_backup_job.sh index 88692a1..da4b8f0 100755 --- a/role_scripts/13/standby/ha_backup_job.sh +++ b/role_scripts/13/standby/ha_backup_job.sh @@ -72,11 +72,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/13/standby/remote-replica.sh b/role_scripts/13/standby/remote-replica.sh index 8931eef..6b16989 100755 --- a/role_scripts/13/standby/remote-replica.sh +++ b/role_scripts/13/standby/remote-replica.sh @@ -67,7 +67,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/13/standby/run.sh b/role_scripts/13/standby/run.sh index a4ca167..dfa75ce 100755 --- a/role_scripts/13/standby/run.sh +++ b/role_scripts/13/standby/run.sh @@ -110,11 +110,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/13/standby/warm_stanby.sh b/role_scripts/13/standby/warm_stanby.sh index 4cac11b..d1d7ec2 100755 --- a/role_scripts/13/standby/warm_stanby.sh +++ b/role_scripts/13/standby/warm_stanby.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/14/primary/start.sh b/role_scripts/14/primary/start.sh index 7155ca9..ca49b17 100755 --- a/role_scripts/14/primary/start.sh +++ b/role_scripts/14/primary/start.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/14/standby/ha_backup_job.sh b/role_scripts/14/standby/ha_backup_job.sh index ed26ce3..c538e00 100755 --- a/role_scripts/14/standby/ha_backup_job.sh +++ b/role_scripts/14/standby/ha_backup_job.sh @@ -72,11 +72,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/14/standby/remote-replica.sh b/role_scripts/14/standby/remote-replica.sh index 8931eef..6b16989 100755 --- a/role_scripts/14/standby/remote-replica.sh +++ b/role_scripts/14/standby/remote-replica.sh @@ -67,7 +67,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/14/standby/run.sh b/role_scripts/14/standby/run.sh index 4f7482e..db2ac8f 100755 --- a/role_scripts/14/standby/run.sh +++ b/role_scripts/14/standby/run.sh @@ -110,11 +110,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/14/standby/warm_stanby.sh b/role_scripts/14/standby/warm_stanby.sh index 4c5196c..d6c4d45 100755 --- a/role_scripts/14/standby/warm_stanby.sh +++ b/role_scripts/14/standby/warm_stanby.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/15/primary/start.sh b/role_scripts/15/primary/start.sh index e1e15d9..d1c4e35 100755 --- a/role_scripts/15/primary/start.sh +++ b/role_scripts/15/primary/start.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/15/standby/ha_backup_job.sh b/role_scripts/15/standby/ha_backup_job.sh index 21dfbea..5124f8f 100755 --- a/role_scripts/15/standby/ha_backup_job.sh +++ b/role_scripts/15/standby/ha_backup_job.sh @@ -74,11 +74,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/15/standby/remote-replica.sh b/role_scripts/15/standby/remote-replica.sh index 8931eef..6b16989 100755 --- a/role_scripts/15/standby/remote-replica.sh +++ b/role_scripts/15/standby/remote-replica.sh @@ -67,7 +67,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/15/standby/run.sh b/role_scripts/15/standby/run.sh index 1a3e7d5..f12e066 100755 --- a/role_scripts/15/standby/run.sh +++ b/role_scripts/15/standby/run.sh @@ -110,11 +110,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/15/standby/warm_stanby.sh b/role_scripts/15/standby/warm_stanby.sh index ed0c6a1..d7565c7 100755 --- a/role_scripts/15/standby/warm_stanby.sh +++ b/role_scripts/15/standby/warm_stanby.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/16/primary/start.sh b/role_scripts/16/primary/start.sh index eeabe9e..bc9f727 100755 --- a/role_scripts/16/primary/start.sh +++ b/role_scripts/16/primary/start.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/16/standby/ha_backup_job.sh b/role_scripts/16/standby/ha_backup_job.sh index 05abab8..1dcb299 100755 --- a/role_scripts/16/standby/ha_backup_job.sh +++ b/role_scripts/16/standby/ha_backup_job.sh @@ -74,11 +74,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/16/standby/remote-replica.sh b/role_scripts/16/standby/remote-replica.sh index f016308..8ad33b3 100755 --- a/role_scripts/16/standby/remote-replica.sh +++ b/role_scripts/16/standby/remote-replica.sh @@ -67,7 +67,7 @@ echo "max_replication_slots = 90" >>/tmp/postgresql.conf if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/16/standby/run.sh b/role_scripts/16/standby/run.sh index cc96d72..38f312e 100755 --- a/role_scripts/16/standby/run.sh +++ b/role_scripts/16/standby/run.sh @@ -111,11 +111,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/16/standby/warm_stanby.sh b/role_scripts/16/standby/warm_stanby.sh index 538c854..0c173bb 100755 --- a/role_scripts/16/standby/warm_stanby.sh +++ b/role_scripts/16/standby/warm_stanby.sh @@ -20,11 +20,11 @@ echo "wal_level = replica" >>/tmp/postgresql.conf echo "shared_buffers = $SHARED_BUFFERS" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS -# echo "wal_keep_size = 1024" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 +# echo "wal_keep_size = 2560" >>/tmp/postgresql.conf #it was "wal_keep_segments" in earlier version. changed in version 13 if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf fi if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then CLEAN_HOSTNAME="${HOSTNAME//[^[:alnum:]]/}" diff --git a/role_scripts/9/primary/start.sh b/role_scripts/9/primary/start.sh index 63ecbec..f79ad23 100755 --- a/role_scripts/9/primary/start.sh +++ b/role_scripts/9/primary/start.sh @@ -24,7 +24,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "wal_log_hints = on" >>/tmp/postgresql.conf echo "archive_mode = always" >>/tmp/postgresql.conf diff --git a/role_scripts/9/standby/ha_backup_job.sh b/role_scripts/9/standby/ha_backup_job.sh index b94ae61..35c3924 100755 --- a/role_scripts/9/standby/ha_backup_job.sh +++ b/role_scripts/9/standby/ha_backup_job.sh @@ -81,7 +81,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi diff --git a/role_scripts/9/standby/run.sh b/role_scripts/9/standby/run.sh index 74788c5..6ae9e4f 100755 --- a/role_scripts/9/standby/run.sh +++ b/role_scripts/9/standby/run.sh @@ -118,7 +118,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf diff --git a/role_scripts/9/standby/warm_stanby.sh b/role_scripts/9/standby/warm_stanby.sh index 73a8305..139112a 100755 --- a/role_scripts/9/standby/warm_stanby.sh +++ b/role_scripts/9/standby/warm_stanby.sh @@ -26,7 +26,7 @@ echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must if [ ! -z "${WAL_RETAIN_PARAM:-}" ] && [ ! -z "${WAL_RETAIN_AMOUNT:-}" ]; then echo "${WAL_RETAIN_PARAM}=${WAL_RETAIN_AMOUNT}" >>/tmp/postgresql.conf else - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf fi echo "max_replication_slots = 90" >>/tmp/postgresql.conf diff --git a/scripts/restore.sh b/scripts/restore.sh index 5af8f5c..3666d87 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -1,5 +1,13 @@ #!/bin/bash +DONE_FILE="var/pv/done.txt" +LOG_DIR="$PGDATA"/log +PATTERN1="recovery stopping before commit of transaction" +PATTERN2="pausing at the end of recovery" +PATTERN3="Execute pg_wal_replay_resume()" +PATTERN4="recovery has paused" +LOG_FILE_PATTERN="postgresql-*.log" +RECOVERY_FILE="$PGDATA"/recovery.signal mkdir -p $PGDATA chmod 0700 "$PGDATA" @@ -13,8 +21,9 @@ fi # check postgresql veriosn -if [[ "$PG_MAJOR" == "11" ]]; then +if [[ "$PG_MAJOR" == "11" ]]; then + RECOVERY_FILE="$PGDATA"/recovery.conf # ****************** Recovery config 11 ************************** touch /tmp/recovery.conf echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/recovery.conf @@ -25,7 +34,7 @@ if [[ "$PG_MAJOR" == "11" ]]; then else echo "recovery_target_timeline = 'latest'" >>/tmp/recovery.conf fi - echo "recovery_target_action = 'promote'" >>/tmp/recovery.conf + echo "recovery_target_action = 'pause'" >>/tmp/recovery.conf mv /tmp/recovery.conf "$PGDATA/recovery.conf" # setup postgresql.conf @@ -33,8 +42,7 @@ if [[ "$PG_MAJOR" == "11" ]]; then echo "wal_level = replica" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS - # echo "wal_keep_segments = 64" >>/tmp/postgresql.conf - echo "wal_keep_segments = 64" >>/tmp/postgresql.conf + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf else # ****************** Recovery config 12, 13, 14 ************************** @@ -43,18 +51,20 @@ else # setup postgresql.conf touch /tmp/postgresql.conf echo "restore_command = 'wal-g wal-fetch %f %p'" >>/tmp/postgresql.conf - #echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf if [[ "${PITR_TIME:-0}" != "latest" ]]; then echo "recovery_target_time = '$PITR_TIME'" >>/tmp/postgresql.conf else echo "recovery_target_timeline = 'latest'" >>/tmp/postgresql.conf fi - echo "recovery_target_action = 'promote'" >>/tmp/postgresql.conf + echo "recovery_target_action = 'pause'" >>/tmp/postgresql.conf echo "wal_level = replica" >>/tmp/postgresql.conf echo "max_wal_senders = 90" >>/tmp/postgresql.conf # default is 10. value must be less than max_connections minus superuser_reserved_connections. ref: https://www.postgresql.org/docs/11/runtime-config-replication.html#GUC-MAX-WAL-SENDERS - # echo "wal_keep_size = 64" >>/tmp/postgresql.conf - echo "wal_keep_size = 1024" >>/tmp/postgresql.conf + if [[ "$PG_MAJOR" == "12" ]]; then + echo "wal_keep_segments = 160" >>/tmp/postgresql.conf + else + echo "wal_keep_size = 2560" >>/tmp/postgresql.conf + fi echo "hot_standby = on" >>/tmp/postgresql.conf echo "wal_log_hints = on" >>/tmp/postgresql.conf @@ -64,7 +74,7 @@ fi # we are not doing any archiving by default but it's better to have this config in our postgresql.conf file in case of customization. echo "archive_mode = always" >>/tmp/postgresql.conf echo "archive_command = '/bin/true'" >>/tmp/postgresql.conf - +echo "logging_collector = on" >>/tmp/postgresql.conf cat /run_scripts/role/postgresql.conf >>/tmp/postgresql.conf mv /tmp/postgresql.conf "$PGDATA/postgresql.conf" echo "max_replication_slots = 90" >>/tmp/postgresql.conf @@ -81,19 +91,39 @@ mv /tmp/pg_hba.conf "$PGDATA/pg_hba.conf" pg_ctl -D "$PGDATA" -w start & sleep 10 # | [[ ! -e /var/pv/data/restore.done]] -while [[ -e /var/pv/data/recovery.signal && -e /var/pv/data/postmaster.pid ]]; do +while [[ -e "$RECOVERY_FILE" && -e /var/pv/data/postmaster.pid ]]; do echo "restoring..." cluster_state=$(pg_controldata | grep "Database cluster state" | awk '{print $4, $5}') if [[ $cluster_state == "in production" ]]; then - echo "database succefully recovered...." - rm -rf /var/pv/data/recovery.signal + rm -rf "$RECOVERY_FILE" + fi + + if grep -rq "$PATTERN1" "$LOG_DIR" && (grep -rq "$PATTERN2" "$LOG_DIR" || grep -rq "$PATTERN4" "$LOG_DIR") && grep -rq "$PATTERN3" "$LOG_DIR"; then + echo "Recovery was paused." + rm -rf "$RECOVERY_FILE" fi + + if [[ -e "$DONE_FILE" ]]; then + echo "Recovery was Stopped in the presence of $DONE_FILE file." + rm -rf "$RECOVERY_FILE" + fi + sleep 1 done -sleep 10 -if [[ ! -e /var/pv/data/recovery.signal ]]; then +sleep 8 +# Find and output all log files matching the pattern +for log_file in "$LOG_DIR"/$LOG_FILE_PATTERN; do + echo "---------------------------------------" + echo "Outputting contents of: $log_file" + cat "$log_file" + echo "---------------------------------------" +done + + +if [[ ! -e "$RECOVERY_FILE" ]]; then + echo "database successfully recovered...." exit 0 else exit 1