{"id":262,"date":"2025-03-19T16:32:02","date_gmt":"2025-03-19T15:32:02","guid":{"rendered":"https:\/\/tillnet.se\/?p=262"},"modified":"2025-04-01T15:17:12","modified_gmt":"2025-04-01T13:17:12","slug":"timescaledb-add-to-existing-postgresql-zabbix-7-0-lts-and-ubuntu-24-04-lts","status":"publish","type":"post","link":"https:\/\/www.tillnet.se\/index.php\/2025\/03\/19\/timescaledb-add-to-existing-postgresql-zabbix-7-0-lts-and-ubuntu-24-04-lts\/","title":{"rendered":"TimescaleDB add to existing PostgreSQL, Zabbix 7.0 LTS and Ubuntu 24.04 LTS"},"content":{"rendered":"\n<p>This is how I added TimescaleDB to my PostgreSQL-server and enabled it on my existing Zabbix database. I found alot of helpful artikels and reference material at initMAX ( <a href=\"https:\/\/www.initmax.com\/\">https:\/\/www.initmax.com\/<\/a> ), which made everything easier.<\/p>\n\n\n\n<p>In short this is my setup. Three servers running Ubuntu 24.04 LTS, one for Zabbix server, another for Zabbix frontend and lastly a PostgreSQL(v16) server.<\/p>\n\n\n\n<p>We will be working almost exclusively on the Postgres server and the other two just to stop and start the services when we enable TimescaleDB.<\/p>\n\n\n\n<p>Open a terminal or connect via SSH to your PostgreSQL server. For convenience you could run &#8220;<code>sudo su -<\/code>&#8221; or prefix all commands with &#8220;<code>sudo<\/code>&#8220;.<\/p>\n\n\n\n<p>Make temporary directory where we can download source code and store other files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/tmp\/zabbix-db-migration\/ &amp;&amp; cd $_<\/code><\/pre>\n\n\n\n<p>Check exact version of Zabbix server and download that source code. My Zabbix server version is 7.0.10.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/cdn.zabbix.com\/zabbix\/sources\/stable\/7.0\/zabbix-7.0.10.tar.gz\n\ntar -zxvf zabbix-7.0.10.tar.gz<\/code><\/pre>\n\n\n\n<p>Add TimescaleDB repo.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb https:\/\/packagecloud.io\/timescale\/timescaledb\/ubuntu\/ $(lsb_release -c -s) main\" | sudo tee \/etc\/apt\/sources.list.d\/timescaledb.list\n\nwget --quiet -O - https:\/\/packagecloud.io\/timescale\/timescaledb\/gpgkey | sudo gpg --dearmor -o \/etc\/apt\/trusted.gpg.d\/timescaledb.gpg<\/code><\/pre>\n\n\n\n<p>Install TimeScaleDB. Check your PostgreSQL version first, mine is 16. Two different alternatives:<br><strong>Alt. 1<\/strong> &#8211; install latest release, change config ( <code>nano \/etc\/zabbix\/zabbix_server.conf<\/code> ) look for ( <code>AllowUnsupportedDBVersions=1<\/code> ).<br><strong>Alt. 2<\/strong> &#8211; install latest supported TimeScaleDB (2.18), no need to change Zabbix config.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update\n(Alt.1)\napt install timescaledb-2-postgresql-16 timescaledb-2-loader-postgresql-16 postgresql-client-16 -y\n(Alt.2)\napt install timescaledb-2-postgresql-16='2.18.0*' timescaledb-2-loader-postgresql-16='2.18.0*' postgresql-client-16<\/code><\/pre>\n\n\n\n<p>Run the tuning utility, if you like you can pass arguments like max connections. Also possible to edit the configuration file afterwards for further tuning. When running the utility it&#8217;s recommended to answer Yes on all questions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timescaledb-tune --max-conns=125<\/code><\/pre>\n\n\n\n<p>Now we need to stop the Zabbix server. Go to that machine and run &#8220;<code>systemctl stop zabbix-server<\/code>&#8220;.<\/p>\n\n\n\n<p>Restart the service PostgreSQL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart postgresql<\/code><\/pre>\n\n\n\n<p>Activate TimescaleDB for the Zabbix database.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;\" | sudo -u postgres psql --dbname=zabbix<\/code><\/pre>\n\n\n\n<p>Now we need to load data from the extracted source code, the schema for TimescaleDB. <em>Migration might take a while depending on the amount of data.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql --host=127.0.0.1 --dbname=zabbix --username=zabbix -f \/tmp\/zabbix-db-migration\/zabbix-7.0.10\/database\/postgresql\/timescaledb\/schema.sql<\/code><\/pre>\n\n\n\n<p>Now we can start the Zabbix server again. Go to that machine and run &#8220;<code>systemctl start zabbix-server<\/code>&#8220;.<\/p>\n\n\n\n<p>All done. Remove the tmp files to clean up afterwards.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is how I added TimescaleDB to my PostgreSQL-server and enabled it on my existing Zabbix database. I found alot of helpful artikels and reference &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-262","post","type-post","status-publish","format-standard","hentry","category-it"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":11,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/262\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}