From 8194c1eacb5574a1fdf28baa9422698c6f411db7 Mon Sep 17 00:00:00 2001 From: Pavlo Golub Date: Mon, 18 Mar 2024 16:56:15 +0100 Subject: [PATCH] [*] move ansible playbooks to `cybertec-postgresql/pgwatch2-charts` (#758) --- .../config-db-test-hosts-multiplied.sql | 39 -------- ansible/perftest/hosts | 10 -- ...ll-postgres-and-prepare-for-monitoring.yml | 91 ------------------- 3 files changed, 140 deletions(-) delete mode 100644 ansible/perftest/config-db-test-hosts-multiplied.sql delete mode 100644 ansible/perftest/hosts delete mode 100644 ansible/perftest/install-postgres-and-prepare-for-monitoring.yml diff --git a/ansible/perftest/config-db-test-hosts-multiplied.sql b/ansible/perftest/config-db-test-hosts-multiplied.sql deleted file mode 100644 index 954cc69b..00000000 --- a/ansible/perftest/config-db-test-hosts-multiplied.sql +++ /dev/null @@ -1,39 +0,0 @@ -/* To be executed on the Config DB */ - -SET ROLE TO pgwatch2; - -CREATE TABLE pgwatch2.test_hosts( - id SERIAL PRIMARY KEY, - host text NOT NULL, - cpus int NOT NULL DEFAULT 1 -- to use "weights", better machines get more config entries -); - -INSERT INTO pgwatch2.test_hosts (host, cpus) VALUES -('172.31.28.14', 2), -('172.31.20.71', 2), -('172.31.22.229', 2), -('172.31.31.84', 2), -('172.31.22.82', 2), -('172.31.23.128', 2), -('172.31.17.254', 2), -('172.31.26.8', 2), -('172.31.29.134', 2), -('172.31.18.118', 2) -; - -CREATE OR REPLACE FUNCTION get_entries_count_by_group(group_id text) RETURNS bigint AS -$$ - select count(*) from pgwatch2.monitored_db where md_group = group_id -$$ LANGUAGE sql; - --- Need to get rid of the "duplicate hosts guard", that's normally desired -DROP INDEX pgwatch2.monitored_db_md_hostname_md_port_md_dbname_md_is_enabled_idx; - -INSERT INTO pgwatch2.monitored_db (md_unique_name, md_preset_config_name, md_config, md_hostname, md_port, md_dbname, md_user, md_password, md_group, md_statement_timeout_seconds, md_is_superuser) -SELECT - 'test_host_'||id||'_'|| get_entries_count_by_group(id::text) + 1, 'exhaustive', null, host, '5432', 'postgres', 'pgwatch2', 'perftesting', id, 10, true -FROM - pgwatch2.test_hosts, - generate_series(1, cpus * 10) i - /* 10x multiplier for each host is pretty conservative...but monitor load and re-run the insert gradually until the gatherer or DB nodes choke */ -; diff --git a/ansible/perftest/hosts b/ansible/perftest/hosts deleted file mode 100644 index 950edde4..00000000 --- a/ansible/perftest/hosts +++ /dev/null @@ -1,10 +0,0 @@ -[pg] -ubuntu@13.48.190.34 -ubuntu@13.49.222.37 -ubuntu@13.49.74.199 -ubuntu@13.48.26.59 -ubuntu@13.48.135.34 -ubuntu@13.51.13.117 -ubuntu@13.53.37.0 -ubuntu@13.48.135.46 -ubuntu@13.48.5.228 diff --git a/ansible/perftest/install-postgres-and-prepare-for-monitoring.yml b/ansible/perftest/install-postgres-and-prepare-for-monitoring.yml deleted file mode 100644 index a5c5dd28..00000000 --- a/ansible/perftest/install-postgres-and-prepare-for-monitoring.yml +++ /dev/null @@ -1,91 +0,0 @@ -# Sets up a standard v12 Postgres cluster from PGDG repos + ensure a pgwatch2 monitoring role -# NB! Expects Ubuntu / Debian hosts currently! -# NB2! Although a trusted environment is assumed a password (perftesting) for the pgwatch2 (superuser!) user is set. Change accordingly - -- hosts: all - become: yes - gather_facts: false - - tasks: - - - name: Configure postgresql.org official APT repo - block: - - shell: 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' - - shell: 'wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -' - - - name: Install default Postgres + PL/Python - apt: - pkg: - - postgresql-12 - - postgresql-plpython3-12 - - python3-psutil - state: present - update_cache: yes - - - name: Enable * access - lineinfile: - path: /etc/postgresql/12/main/postgresql.conf - line: | - listen_addresses='*' - state: present - - - name: Enable pg_stat_statements extension - lineinfile: - path: /etc/postgresql/12/main/postgresql.conf - line: | - shared_preload_libraries='pg_stat_statements' - state: present - - - name: Enable local trust access - remove default entry - lineinfile: - path: /etc/postgresql/12/main/pg_hba.conf - regexp: '^local\s+all\s+postgres\s+peer$' - state: absent - - - name: Enable local trust access - lineinfile: - path: /etc/postgresql/12/main/pg_hba.conf - regexp: '^local\s+all\s+all\s+peer$' - line: 'local all all trust' - - - name: Enable remote password access - lineinfile: - path: /etc/postgresql/12/main/pg_hba.conf - line: 'host all all 0.0.0.0/0 md5' - - - name: Restart postgres - systemd: - name: postgresql - state: restarted - - - name: Ensure pgwatch2 role. NB! Using superuser here which is not of course recommended generally for remote monitoring - shell: 'createuser -U postgres --superuser -g pg_monitor pgwatch2' - ignore_errors: yes - - - name: Set pgwatch2 password to "perftesting" - shell: - cmd: | - psql -U postgres -c "alter role pgwatch2 password 'md56d9f217af43ed7b01c23fd48bfa3bb3f'" - - - name: Create the pg_stat_statements extension - shell: - cmd: | - psql -U postgres -c "create extension if not exists pg_stat_statements" - - - name: Initialize a pgbench schema - shell: - cmd: | - psql -U postgres -c "select count(*) from pgbench_branches" || pgbench -U postgres -i -s 10 - - - name: Create a bunch of dummy tables to be more realistic - shell: - cmd: | - for x in {1..100}; do PGOPTIONS="-c synchronous_commit=off" psql -U postgres -c "create table if not exists test_table_${x}(LIKE pgbench_accounts INCLUDING INDEXES)" ; done - executable: /bin/bash - - - name: Ensure a background Cronjob that generates some light Postgres load so that one could even look a graphs - cron: - name: "pgbench" - minute: "*/10" - job: | - pgbench -U postgres -R 1 -T 500 -N postgres >/dev/null