ZabbixからTimescaleDBへの移行を高速化する方法

画像







前回の記事「ダウンタイムを最小限に抑えてZabbixをMySQLからPostgreSQLに移行する方法」ZabbixをMySQLからPostgreSQLに正常に移行した、次のステップを実行する必要がありました。データベースをTimescaleDBに移行するためです。彼女のためにすべてが始まった。







読者は疑問に思うかもしれません:シンプルで理解しやすいマニュアルがあるのに、なぜこの記事が必要なのですか?

しかし、前の記事のように、問題はダウンタイムに隠されています。マニュアルには明確に記載されています。







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.



:









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.








All Articles