From 19afe3a5e79ab02603bbe0e46f073ff0974231d1 Mon Sep 17 00:00:00 2001 From: NikolayS Date: Tue, 17 Aug 2021 19:42:03 +0000 Subject: [PATCH 1/7] 2-node env for tests-and-benchmarks#20 --- inventory | 22 ++++++++-------------- vars/Debian.yml | 7 +++++++ vars/main.yml | 15 ++++++++------- vars/system.yml | 4 ++-- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/inventory b/inventory index 76faf9f7a..14ddd8fc3 100644 --- a/inventory +++ b/inventory @@ -7,25 +7,19 @@ # if dcs_exists: false and dcs_type: "etcd" (in vars/main.yml) [etcd_cluster] # recommendation: 3 or 5-7 nodes -10.128.64.140 -10.128.64.142 -10.128.64.143 - +172.31.14.220 +172.31.1.229 # if with_haproxy_load_balancing: true (in vars/main.yml) [balancers] -10.128.64.140 -10.128.64.142 -10.128.64.143 # PostgreSQL nodes [master] -10.128.64.140 hostname=pgnode01 postgresql_exists='false' +172.31.14.220 hostname=pgnode01 postgresql_exists='false' [replica] -10.128.64.142 hostname=pgnode02 postgresql_exists='false' -10.128.64.143 hostname=pgnode03 postgresql_exists='false' +172.31.1.229 hostname=pgnode02 postgresql_exists='false' [postgres_cluster:children] master @@ -44,12 +38,12 @@ replica [all:vars] ansible_connection='ssh' ansible_ssh_port='22' -ansible_user='root' -ansible_ssh_pass='secretpassword' # "sshpass" package is required for use "ansible_ssh_pass" +ansible_user='ubuntu' +#ansible_ssh_pass='secretpassword' # "sshpass" package is required for use "ansible_ssh_pass" # ansible_ssh_private_key_file= # ansible_python_interpreter='/usr/bin/python3' # is required for use python3 [pgbackrest:vars] -ansible_user='postgres' -ansible_ssh_pass='secretpassword' +#ansible_user='postgres' +#ansible_ssh_pass='postgres' diff --git a/vars/Debian.yml b/vars/Debian.yml index e4c2de185..f337af28f 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -48,12 +48,19 @@ system_packages: - jq - iptables - acl + - moreutils + - libpq-dev + - linux-tools-common + - linux-tools-5.4.0-1045-aws # ubuntu 20.04 postgresql_packages: - postgresql-{{ postgresql_version }} - postgresql-client-{{ postgresql_version }} - postgresql-server-dev-{{ postgresql_version }} - postgresql-contrib-{{ postgresql_version }} + - postgresql-{{ postgresql_version }}-pg-wait-sampling + - postgresql-{{ postgresql_version }}-pg-stat-kcache + - postgresql-{{ postgresql_version }}-dbgsym # - postgresql-{{ postgresql_version }}-repack" # Extra packages diff --git a/vars/main.yml b/vars/main.yml index b1b26859e..a54448d9d 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -101,19 +101,19 @@ postgresql_extensions: [] # postgresql parameters to bootstrap dcs (are parameters for example) postgresql_parameters: - - {option: "max_connections", value: "100"} + - {option: "max_connections", value: "300"} - {option: "superuser_reserved_connections", value: "5"} - {option: "max_locks_per_transaction", value: "64"} # raise this value (ex. 512) if you have queries that touch many different tables (partitioning) - {option: "max_prepared_transactions", value: "0"} - {option: "huge_pages", value: "try"} # or "on" if you set "vm_nr_hugepages" in kernel parameters - - {option: "shared_buffers", value: "512MB"} # please change this value + - {option: "shared_buffers", value: "20GB"} # please change this value - {option: "work_mem", value: "128MB"} # please change this value - {option: "maintenance_work_mem", value: "256MB"} # please change this value - - {option: "effective_cache_size", value: "4GB"} # please change this value - - {option: "checkpoint_timeout", value: "15min"} + - {option: "effective_cache_size", value: "40GB"} # please change this value + - {option: "checkpoint_timeout", value: "30min"} - {option: "checkpoint_completion_target", value: "0.9"} - {option: "min_wal_size", value: "2GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") - - {option: "max_wal_size", value: "4GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") + - {option: "max_wal_size", value: "64GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") - {option: "wal_buffers", value: "32MB"} - {option: "default_statistics_target", value: "1000"} - {option: "seq_page_cost", value: "1"} @@ -133,13 +133,14 @@ postgresql_parameters: - {option: "archive_command", value: "cd ."} # not doing anything yet with WAL-s # - {option: "archive_command", value: "wal-g wal-push %p"} # archive WAL-s using WAL-G # - {option: "archive_command", value: "pgbackrest --stanza={{ pgbackrest_stanza }} archive-push %p"} # archive WAL-s using pgbackrest - - {option: "wal_level", value: "replica"} # "replica" for PostgreSQL 9.6 and above (for 9.4, 9.5 use "hot_standby") + - {option: "wal_level", value: "logical"} # "replica" for PostgreSQL 9.6 and above (for 9.4, 9.5 use "hot_standby") - {option: "wal_keep_segments", value: "130"} + - {option: "wal_compression", value: "on"} - {option: "max_wal_senders", value: "10"} - {option: "max_replication_slots", value: "10"} - {option: "hot_standby", value: "on"} - {option: "wal_log_hints", value: "on"} - - {option: "shared_preload_libraries", value: "pg_stat_statements,auto_explain"} + - {option: "shared_preload_libraries", value: "pg_stat_statements,pg_stat_kcache,pg_wait_sampling"} - {option: "pg_stat_statements.max", value: "10000"} - {option: "pg_stat_statements.track", value: "all"} - {option: "pg_stat_statements.save", value: "off"} diff --git a/vars/system.yml b/vars/system.yml index 685e24944..9a4cb8381 100644 --- a/vars/system.yml +++ b/vars/system.yml @@ -32,7 +32,7 @@ locale: "en_US.utf-8" # Kernel parameters -sysctl_set: true # or 'false' +sysctl_set: false # or 'false' # these parameters for example! Specify kernel options for your system sysctl_conf: etcd_cluster: [] @@ -117,7 +117,7 @@ sudo_users: # Firewall (ansible-role-firewall) -firewall_enabled_at_boot: true +firewall_enabled_at_boot: false firewall_allowed_tcp_ports_for: master: [] From b0722c551b8aa376ee27db2dc9919bb738d9410d Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Wed, 18 Aug 2021 21:29:25 -0700 Subject: [PATCH 2/7] Apply suggestions from code review --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index a54448d9d..c7cf5a7a6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -140,7 +140,7 @@ postgresql_parameters: - {option: "max_replication_slots", value: "10"} - {option: "hot_standby", value: "on"} - {option: "wal_log_hints", value: "on"} - - {option: "shared_preload_libraries", value: "pg_stat_statements,pg_stat_kcache,pg_wait_sampling"} + - {option: "shared_preload_libraries", value: "pg_stat_statements,pg_wait_sampling"} - {option: "pg_stat_statements.max", value: "10000"} - {option: "pg_stat_statements.track", value: "all"} - {option: "pg_stat_statements.save", value: "off"} From db13239b7c41f5a0d6b8f2801baa300a36a152ed Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Thu, 19 Aug 2021 11:35:00 -0700 Subject: [PATCH 3/7] Update vars/main.yml --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index c7cf5a7a6..159bbf468 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -113,7 +113,7 @@ postgresql_parameters: - {option: "checkpoint_timeout", value: "30min"} - {option: "checkpoint_completion_target", value: "0.9"} - {option: "min_wal_size", value: "2GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") - - {option: "max_wal_size", value: "64GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") + - {option: "max_wal_size", value: "4GB"} # for PostgreSQL 9.5 and above (for 9.4 use "checkpoint_segments") - {option: "wal_buffers", value: "32MB"} - {option: "default_statistics_target", value: "1000"} - {option: "seq_page_cost", value: "1"} From 3d4fb7c43a60b3216048d895771ff55adfd54110 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Thu, 19 Aug 2021 17:15:04 -0700 Subject: [PATCH 4/7] Update main.yml --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index 159bbf468..9ecc3c2eb 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -171,7 +171,7 @@ postgresql_parameters: # - {option: "max_parallel_workers_per_gather", value: "4"} # for PostgreSQL 9.6 and above # - {option: "max_parallel_maintenance_workers", value: "2"} # for PostgreSQL 11 and above # - {option: "hot_standby_feedback", value: "on"} # allows feedback from a hot standby to the primary that will avoid query conflicts -# - {option: "max_standby_streaming_delay", value: "30s"} + - {option: "max_standby_streaming_delay", value: "300s"} # - {option: "wal_receiver_status_interval", value: "10s"} # - {option: "old_snapshot_threshold", value: "60min"} # for PostgreSQL 9.6 and above (1min-60d) # - {option: "", value: ""} From d8ae93eaa275506f461ccf2b9c2c362a874db620 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Fri, 20 Aug 2021 08:43:04 -0700 Subject: [PATCH 5/7] Update vars/main.yml --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index 9ecc3c2eb..7f8f5b54c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -171,7 +171,7 @@ postgresql_parameters: # - {option: "max_parallel_workers_per_gather", value: "4"} # for PostgreSQL 9.6 and above # - {option: "max_parallel_maintenance_workers", value: "2"} # for PostgreSQL 11 and above # - {option: "hot_standby_feedback", value: "on"} # allows feedback from a hot standby to the primary that will avoid query conflicts - - {option: "max_standby_streaming_delay", value: "300s"} + - {option: "max_standby_streaming_delay", value: "1800s"} # - {option: "wal_receiver_status_interval", value: "10s"} # - {option: "old_snapshot_threshold", value: "60min"} # for PostgreSQL 9.6 and above (1min-60d) # - {option: "", value: ""} From ea16e59f20f67228ccfc4aee3e7376d8f032d736 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Fri, 27 Aug 2021 19:11:09 -0700 Subject: [PATCH 6/7] Automate installation of pgcenter, etc --- vars/Debian.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vars/Debian.yml b/vars/Debian.yml index f337af28f..df6f22fa3 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -22,6 +22,7 @@ apt_repository_keys: - key: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" # postgresql repository apt key apt_repository: - repo: "deb https://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" # postgresql apt repository + - repo: "deb https://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main 14" # to install 14beta3 or later # - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }} main" # debian repo (optional) # - repo: "deb https://deb.debian.org/debian/ {{ ansible_distribution_release }}-updates main" # debian repo (optional) # - repo: "deb https://security.debian.org/debian-security/ {{ ansible_distribution_release }}/updates main" # debian repo (optional) @@ -135,6 +136,8 @@ patroni_pip_package_repo: [] patroni_deb_package_repo: [] # - "https://apt.postgresql.org/pub/repos/apt/pool/main/p/patroni/patroni_1.6.5-2.pgdg100%2B1_all.deb" # (package for Debian 10) +# pgcenter +pgcenter_deb_package_file: "https://github.com/lesovsky/pgcenter/releases/download/v0.9.2/pgcenter_0.9.2_linux_amd64.deb" # ================================================================================================= # # (optional) if installation_method: "file" @@ -184,7 +187,8 @@ haproxy_src_file: "haproxy-1.8.20.tar.gz" # http://www.haproxy.org/download/1.8 # ------------------------------------------------------------------------------------------------- # # (optional) Specify additional deb packages if required (for any installation_method) # this packages will be installed before all other packages. -packages_from_file: [] +packages_from_file: + - "pgcenter_0.9.2_linux_amd64.deb" # - "my-package-name_1_amd64.deb" # - "my-package-name_2_amd64.deb" # - "" From 2700c9e587c1f5f325f1df5ea666ae7a1186aee0 Mon Sep 17 00:00:00 2001 From: Nikolay Samokhvalov Date: Sun, 5 Sep 2021 15:25:49 -0700 Subject: [PATCH 7/7] hot_standby_feedback = on --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index 7f8f5b54c..762e0234d 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -170,7 +170,7 @@ postgresql_parameters: # - {option: "max_parallel_workers", value: "24"} # for PostgreSQL 10 and above # - {option: "max_parallel_workers_per_gather", value: "4"} # for PostgreSQL 9.6 and above # - {option: "max_parallel_maintenance_workers", value: "2"} # for PostgreSQL 11 and above -# - {option: "hot_standby_feedback", value: "on"} # allows feedback from a hot standby to the primary that will avoid query conflicts + - {option: "hot_standby_feedback", value: "on"} # allows feedback from a hot standby to the primary that will avoid query conflicts - {option: "max_standby_streaming_delay", value: "1800s"} # - {option: "wal_receiver_status_interval", value: "10s"} # - {option: "old_snapshot_threshold", value: "60min"} # for PostgreSQL 9.6 and above (1min-60d)