Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux:monitoring:zabbix:database:postgresql:partitioning [2020/03/30 13:14] jlucas created |
linux:monitoring:zabbix:database:postgresql:partitioning [2020/04/02 08:20] (current) jlucas [Dump individual Zabbix database tables for testing] |
||
---|---|---|---|
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 13: | Line 34: | ||
Additional tables that get a little big that could have some: | Additional tables that get a little big that could have some: | ||
- | DELETE FROM events WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | ||
DELETE FROM alerts WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | DELETE FROM alerts WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | ||
- | DELETE FROM trends | + | DELETE FROM events |
DELETE FROM trends_uint WHERE to_timestamp(clock) < NOW() - INTERVAL '40 days'; | DELETE FROM trends_uint 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 |