diff --git a/postgresql/README.md b/postgresql/README.md new file mode 100644 index 0000000..14ec183 --- /dev/null +++ b/postgresql/README.md @@ -0,0 +1,8 @@ +# PostgreSQL Partitioning for Zabbix + +This directory contains solutions for partitioning a Zabbix database running on PostgreSQL. Partitioning is essential for large Zabbix environments as it eliminates the need for the built-in Zabbix Housekeeper to aggressively delete old data row-by-row, replacing it with instant DDL operations that drop entire daily or monthly chunks. + +## Implementations + +- **[procedures](procedures/)**: The recommended Declarative (SQL-based) implementation. It uses native PostgreSQL procedures and features like `pg_cron` for entirely self-contained maintenance. +- **[script](script/)**: External script-based management solution. (Coming soon) diff --git a/postgresql/script/README.md b/postgresql/script/README.md new file mode 100644 index 0000000..2c38b68 --- /dev/null +++ b/postgresql/script/README.md @@ -0,0 +1,3 @@ +# Script-based Partitioning + +(Coming soon) diff --git a/template/README.md b/postgresql/template/README.md similarity index 100% rename from template/README.md rename to postgresql/template/README.md diff --git a/template/partitions.get_all.sql b/postgresql/template/partitions.get_all.sql similarity index 100% rename from template/partitions.get_all.sql rename to postgresql/template/partitions.get_all.sql diff --git a/template/zbx_pg_partitions_monitor_agent2.yaml b/postgresql/template/zbx_pg_partitions_monitor_agent2.yaml similarity index 100% rename from template/zbx_pg_partitions_monitor_agent2.yaml rename to postgresql/template/zbx_pg_partitions_monitor_agent2.yaml diff --git a/ARCHITECTURE.md b/postgresql/tests/ARCHITECTURE.md similarity index 100% rename from ARCHITECTURE.md rename to postgresql/tests/ARCHITECTURE.md diff --git a/QUICKSTART.md b/postgresql/tests/QUICKSTART.md similarity index 100% rename from QUICKSTART.md rename to postgresql/tests/QUICKSTART.md diff --git a/postgresql/docker/docker-compose.yml b/postgresql/tests/docker/docker-compose.yml similarity index 100% rename from postgresql/docker/docker-compose.yml rename to postgresql/tests/docker/docker-compose.yml diff --git a/postgresql/docker/init_scripts/00_init_extra_users.sql b/postgresql/tests/docker/init_scripts/00_init_extra_users.sql similarity index 100% rename from postgresql/docker/init_scripts/00_init_extra_users.sql rename to postgresql/tests/docker/init_scripts/00_init_extra_users.sql diff --git a/postgresql/docker/init_scripts/01_00_schema.sql b/postgresql/tests/docker/init_scripts/01_00_schema.sql similarity index 100% rename from postgresql/docker/init_scripts/01_00_schema.sql rename to postgresql/tests/docker/init_scripts/01_00_schema.sql diff --git a/postgresql/docker/init_scripts/01_10_partitions_init.sql b/postgresql/tests/docker/init_scripts/01_10_partitions_init.sql similarity index 100% rename from postgresql/docker/init_scripts/01_10_partitions_init.sql rename to postgresql/tests/docker/init_scripts/01_10_partitions_init.sql diff --git a/postgresql/docker/init_scripts/01_30_maintenance.sql b/postgresql/tests/docker/init_scripts/01_30_maintenance.sql similarity index 100% rename from postgresql/docker/init_scripts/01_30_maintenance.sql rename to postgresql/tests/docker/init_scripts/01_30_maintenance.sql diff --git a/postgresql/docker/init_scripts/01_40_enable.sql b/postgresql/tests/docker/init_scripts/01_40_enable.sql similarity index 100% rename from postgresql/docker/init_scripts/01_40_enable.sql rename to postgresql/tests/docker/init_scripts/01_40_enable.sql diff --git a/postgresql/docker/init_scripts/01_50_monitoring.sql b/postgresql/tests/docker/init_scripts/01_50_monitoring.sql similarity index 100% rename from postgresql/docker/init_scripts/01_50_monitoring.sql rename to postgresql/tests/docker/init_scripts/01_50_monitoring.sql diff --git a/postgresql/docker/init_scripts/02_images.sql b/postgresql/tests/docker/init_scripts/02_images.sql similarity index 100% rename from postgresql/docker/init_scripts/02_images.sql rename to postgresql/tests/docker/init_scripts/02_images.sql diff --git a/postgresql/docker/init_scripts/03_data.sql b/postgresql/tests/docker/init_scripts/03_data.sql similarity index 100% rename from postgresql/docker/init_scripts/03_data.sql rename to postgresql/tests/docker/init_scripts/03_data.sql diff --git a/postgresql/docker/init_scripts/04_gen_data.sql b/postgresql/tests/docker/init_scripts/04_gen_data.sql similarity index 100% rename from postgresql/docker/init_scripts/04_gen_data.sql rename to postgresql/tests/docker/init_scripts/04_gen_data.sql diff --git a/postgresql/docker/run_test_env.sh b/postgresql/tests/docker/run_test_env.sh similarity index 88% rename from postgresql/docker/run_test_env.sh rename to postgresql/tests/docker/run_test_env.sh index d225144..de6d50e 100755 --- a/postgresql/docker/run_test_env.sh +++ b/postgresql/tests/docker/run_test_env.sh @@ -67,17 +67,17 @@ if [[ -f "$SQL_DIR/schema.sql" ]]; then cp "$SQL_DIR/schema.sql" ./init_scripts/01_00_schema.sql # 1.1 Partitioning Infrastructure - if [[ -f "../procedures/00_schema_create.sql" ]]; then - cp "../procedures/00_schema_create.sql" ./init_scripts/01_10_schema_create.sql + if [[ -f "../../procedures/00_schema_create.sql" ]]; then + cp "../../procedures/00_schema_create.sql" ./init_scripts/01_10_schema_create.sql fi - if [[ -f "../procedures/01_maintenance.sql" ]]; then - cp "../procedures/01_maintenance.sql" ./init_scripts/01_30_maintenance.sql + if [[ -f "../../procedures/01_maintenance.sql" ]]; then + cp "../../procedures/01_maintenance.sql" ./init_scripts/01_30_maintenance.sql fi - if [[ -f "../procedures/02_enable_partitioning.sql" ]]; then - cp "../procedures/02_enable_partitioning.sql" ./init_scripts/01_40_enable.sql + if [[ -f "../../procedures/02_enable_partitioning.sql" ]]; then + cp "../../procedures/02_enable_partitioning.sql" ./init_scripts/01_40_enable.sql fi - if [[ -f "../procedures/03_monitoring_view.sql" ]]; then - cp "../procedures/03_monitoring_view.sql" ./init_scripts/01_50_monitoring.sql + if [[ -f "../../procedures/03_monitoring_view.sql" ]]; then + cp "../../procedures/03_monitoring_view.sql" ./init_scripts/01_50_monitoring.sql fi else echo -e "${RED}Error: schema.sql not found in $SQL_DIR${NC}" diff --git a/postgresql/init_extra_users.sql b/postgresql/tests/init_extra_users.sql similarity index 100% rename from postgresql/init_extra_users.sql rename to postgresql/tests/init_extra_users.sql diff --git a/postgresql/setup_rds.sh b/postgresql/tests/setup_rds.sh similarity index 100% rename from postgresql/setup_rds.sh rename to postgresql/tests/setup_rds.sh diff --git a/postgresql/sql-scripts-70/data.sql b/postgresql/tests/sql-scripts-70/data.sql similarity index 100% rename from postgresql/sql-scripts-70/data.sql rename to postgresql/tests/sql-scripts-70/data.sql diff --git a/postgresql/sql-scripts-70/images.sql b/postgresql/tests/sql-scripts-70/images.sql similarity index 100% rename from postgresql/sql-scripts-70/images.sql rename to postgresql/tests/sql-scripts-70/images.sql diff --git a/postgresql/sql-scripts-70/option-patches/history_upgrade_prepare.sql b/postgresql/tests/sql-scripts-70/option-patches/history_upgrade_prepare.sql similarity index 100% rename from postgresql/sql-scripts-70/option-patches/history_upgrade_prepare.sql rename to postgresql/tests/sql-scripts-70/option-patches/history_upgrade_prepare.sql diff --git a/postgresql/sql-scripts-70/schema.sql b/postgresql/tests/sql-scripts-70/schema.sql similarity index 100% rename from postgresql/sql-scripts-70/schema.sql rename to postgresql/tests/sql-scripts-70/schema.sql diff --git a/postgresql/sql-scripts-74/data.sql b/postgresql/tests/sql-scripts-74/data.sql similarity index 100% rename from postgresql/sql-scripts-74/data.sql rename to postgresql/tests/sql-scripts-74/data.sql diff --git a/postgresql/sql-scripts-74/images.sql b/postgresql/tests/sql-scripts-74/images.sql similarity index 100% rename from postgresql/sql-scripts-74/images.sql rename to postgresql/tests/sql-scripts-74/images.sql diff --git a/postgresql/sql-scripts-74/option-patches/history_upgrade_prepare.sql b/postgresql/tests/sql-scripts-74/option-patches/history_upgrade_prepare.sql similarity index 100% rename from postgresql/sql-scripts-74/option-patches/history_upgrade_prepare.sql rename to postgresql/tests/sql-scripts-74/option-patches/history_upgrade_prepare.sql diff --git a/postgresql/sql-scripts-74/schema.sql b/postgresql/tests/sql-scripts-74/schema.sql similarity index 100% rename from postgresql/sql-scripts-74/schema.sql rename to postgresql/tests/sql-scripts-74/schema.sql diff --git a/postgresql/sql-scripts-80/data.sql b/postgresql/tests/sql-scripts-80/data.sql similarity index 100% rename from postgresql/sql-scripts-80/data.sql rename to postgresql/tests/sql-scripts-80/data.sql diff --git a/postgresql/sql-scripts-80/images.sql b/postgresql/tests/sql-scripts-80/images.sql similarity index 100% rename from postgresql/sql-scripts-80/images.sql rename to postgresql/tests/sql-scripts-80/images.sql diff --git a/postgresql/sql-scripts-80/option-patches/history_upgrade_prepare.sql b/postgresql/tests/sql-scripts-80/option-patches/history_upgrade_prepare.sql similarity index 100% rename from postgresql/sql-scripts-80/option-patches/history_upgrade_prepare.sql rename to postgresql/tests/sql-scripts-80/option-patches/history_upgrade_prepare.sql diff --git a/postgresql/sql-scripts-80/schema.sql b/postgresql/tests/sql-scripts-80/schema.sql similarity index 100% rename from postgresql/sql-scripts-80/schema.sql rename to postgresql/tests/sql-scripts-80/schema.sql diff --git a/postgresql/z_gen_history_data.sql b/postgresql/tests/z_gen_history_data.sql similarity index 100% rename from postgresql/z_gen_history_data.sql rename to postgresql/tests/z_gen_history_data.sql