
Après avoir migré avec succès Zabbix de MySQL vers PostgreSQL dans l'article précédent Comment migrer Zabbix de MySQL vers PostgreSQL avec un temps d'arrêt minimal , il est devenu nécessaire de passer à l'étape suivante - migrer la base de données vers TimescaleDB, car pour elle, tout a commencé.
Le lecteur peut se demander: pourquoi cet article est-il nécessaire s'il existe un manuel simple et compréhensible ?
Mais le problème, comme dans l'article précédent, est caché dans les temps d'arrêt. Le manuel indique clairement:
The migration of existing history and trend data may take a lot of time. Zabbix server and frontend must be down for the period of migration.
:
- Zabbix 5.0
- PostgreSQL 12
- ENABLING EXTENDED RANGE OF NUMERIC (FLOAT) VALUES
- TimescaleDB 1.7 ( 2.0 )
PostgreSQL, PostgreSQL. — 24 CPU, 64 GB RAM. , , . ~350 15 . .
TimescaleDB , "Faster Method":
- , . , history
- , ,
CREATE TABLE history_new (LIKE history INCLUDING DEFAULTS INCLUDING CONSTRAINTS EXCLUDING INDEXES);
-
SELECT create_hypertable('history_new', 'clock', chunk_interval => 86400);
- history history_new
INSERT INTO history_new SELECT * FROM history;
- history
DROP TABLE IF EXISTS history;
- history_new history
ALTER TABLE IF EXISTS history_new RENAME TO history;
- ( — schema.sql)
CREATE INDEX history_1 in history (itemid,clock);
:
- history
- history_log
- history_str
- history_text
- history_uint
- trends
- trends_uint
, .
github .
finish.sql .
TimescaleDB 5 , 15.
PROFIT.