fix: automatic column additions, permissions grants and docs updates for seamless upgrades
This commit is contained in:
@@ -53,32 +53,34 @@ Once inside `psql`, connect to your Zabbix database (usually named `zabbix`):
|
||||
|
||||
## Step 3: Execute Installation Scripts
|
||||
|
||||
Run the scripts in the following exact order. You can use the `\i` command in `psql` if you are in the `procedures` directory, or specify the full path.
|
||||
Run the scripts in the following exact order. You can execute them directly from your bash terminal, from within the interactive `psql` console, or by pasting their contents into a GUI tool (like pgAdmin).
|
||||
|
||||
**1. Create the partitioning schema and config tables:**
|
||||
> [!NOTE]
|
||||
> **Zabbix 8.0+ Users:** Zabbix 8.0 introduced a new `history_json` table. Before running the script below, open `00_schema_create.sql` in a text editor and uncomment the lines specifically marked for Zabbix 8.0 at the end of the history tables block.
|
||||
> **Zabbix 8.0+ Users:** Zabbix 8.0 introduced a new `history_json` table. Before running the first script, open `00_schema_create.sql` in a text editor and uncomment the lines specifically marked for Zabbix 8.0 at the end of the history tables block.
|
||||
|
||||
### Option A: From bash terminal (Recommended)
|
||||
If you are in your normal Linux terminal, run these commands one by one:
|
||||
```bash
|
||||
psql -U postgres -d zabbix -f 00_schema_create.sql
|
||||
psql -U postgres -d zabbix -f 01_maintenance.sql
|
||||
# MIGRATION STEP: The next script renames your existing large tables to `_old`
|
||||
# and instantly creates new partitioned tables. This might take a few moments.
|
||||
psql -U postgres -d zabbix -f 02_enable_partitioning.sql
|
||||
psql -U postgres -d zabbix -f 03_monitoring_view.sql
|
||||
```
|
||||
|
||||
### Option B: Inside interactive `psql`
|
||||
If you already connected via `psql` (as in Step 2), use the `\i` command:
|
||||
```sql
|
||||
\i 00_schema_create.sql
|
||||
```
|
||||
|
||||
**2. Install the maintenance logic and functions:**
|
||||
```sql
|
||||
\i 01_maintenance.sql
|
||||
```
|
||||
|
||||
**3. Enable Partitioning (MIGRATION STEP):**
|
||||
*This step renames your existing large tables to `_old` and instantly creates new partitioned tables. This might take a few moments.*
|
||||
```sql
|
||||
\i 02_enable_partitioning.sql
|
||||
```
|
||||
|
||||
**4. Create the Monitoring View:**
|
||||
```sql
|
||||
\i 03_monitoring_view.sql
|
||||
```
|
||||
|
||||
### Option C: GUI Tools (pgAdmin, DBeaver, etc.)
|
||||
If you use a visual database manager, simply open each file in your query editor and execute them one by one in the exact order (00, 01, 02, 03).
|
||||
|
||||
---
|
||||
|
||||
## Step 4: Schedule Automated Maintenance
|
||||
@@ -127,6 +129,7 @@ SELECT
|
||||
FROM partitions.monitoring;
|
||||
EOF
|
||||
```
|
||||
*(Note: If your Zabbix Agent is configured to look for custom queries in a different directory like `/etc/zabbix/postgresql/sql/`, modify the destination path above).*
|
||||
|
||||
2. Configure the PostgreSQL Plugin by editing `/etc/zabbix/zabbix_agent2.d/plugins.d/postgresql.conf`. Ensure you have defined a session (e.g., `MY_DB`) and enabled custom queries:
|
||||
|
||||
@@ -159,3 +162,20 @@ sudo systemctl restart zabbix-agent2
|
||||
8. Click **Update**.
|
||||
|
||||
**Congratulations!** Your Zabbix database is now fully partitioned, optimized, and monitored.
|
||||
|
||||
---
|
||||
|
||||
## Step 8: Upgrades & Updates
|
||||
|
||||
To apply future updates or fixes to the partitioning logic, the scripts are fully idempotent and safe to re-run on a live database.
|
||||
Simply connect to `psql` and re-execute the updated scripts in order:
|
||||
|
||||
```bash
|
||||
psql -U postgres -d zabbix -f 00_schema_create.sql
|
||||
psql -U postgres -d zabbix -f 01_maintenance.sql
|
||||
psql -U postgres -d zabbix -f 02_enable_partitioning.sql
|
||||
psql -U postgres -d zabbix -f 03_monitoring_view.sql
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> If you update the agent SQL query, always remember to restart the agent (`sudo systemctl restart zabbix-agent2`) so it flushes its cache!
|
||||
|
||||
Reference in New Issue
Block a user