Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:monitoring:zabbix:database:postgresql:partitioning [2020/03/30 20:21] – jlucas | linux:monitoring:zabbix:database:postgresql:partitioning [2020/04/02 15:20] (current) – [Dump individual Zabbix database tables for testing] jlucas | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ======Adding DB table partitioning to Zabbix DB====== | ||
| - | The current development Zabbix monitoring server that I've been building has filled | + | ===Note from the Author=== |
| - | What I'm going to attempt here is to retain | + | First off, the servers that I'm using in my setup are OpenBSD. |
| + | |||
| + | ===Summary=== | ||
| + | |||
| + | The current Zabbix monitoring server I'm working on is a development server that I have been working on to build for a client. | ||
| + | |||
| + | What I'm going to attempt here is to retain the history collected thus far. | ||
| + | |||
| + | I will dump the entire zabbix database, drop the zabbix database, " | ||
| + | |||
| + | =====Getting things ready to perform the work===== | ||
| + | |||
| + | ====Shutdown the Zabbix server data collection processes==== | ||
| + | |||
| + | I happen to be working with two different servers. | ||
| + | |||
| + | Issue the following command to shutdown your Zabbix server data collection processes. | ||
| + | |||
| + | doas rcctl stop zabbix_server | ||
| + | |||
| + | ====Delete older data [optional]==== | ||
| If you have a large amount of historical data that isn't relevant, you can delete some of it by issuing these SQL commands: | If you have a large amount of historical data that isn't relevant, you can delete some of it by issuing these SQL commands: | ||
| Line 18: | Line 39: | ||
| DELETE FROM trends WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | DELETE FROM trends WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | ||
| - | Use this to dump the entire Zabbix database | + | ====Dump the entire Zabbix DB==== |
| + | |||
| + | dump the entire Zabbix database | ||
| pg_dump -U zabbix zabbix | gzip -1 > ./ | pg_dump -U zabbix zabbix | gzip -1 > ./ | ||
| - | Testing... | ||
| - | The history table is by far the largest | + | |
| - | pg_dump -U zabbix -t history_uint | + | pg_dump -U postgres postgres | psql -U zabbix zabbix |
| + | |||
| + | ====Dump individual Zabbix database tables for testing==== | ||
| + | |||
| + | The following use of pg_dump and pg_restore performs a data-only backup using the custom-form output option and using INSERTs instead of COPY statements: | ||
| + | pg_dump -U zabbix | ||
| + | |||
| + | Once the backup is done, drop all data from the table: | ||
| + | psql -U zabbix -c ' | ||
| + | |||
| + | Now restore the data to the table: | ||
| + | gunzip -c zabdb.zabbix.history_str.Pg.gz | pg_restore -U zabbix -d zabbix | ||