Skip to main content

Installing PostgreSQL and TimescaleDB in Ubuntu

To follow the latest instructions, view the instructions on the PostgreSQL and TimescaleDB sites here where the following summarized instructions were taken from:

https://www.postgresql.org/download/linux/ubuntu/

https://docs.timescale.com/self-hosted/latest/install/installation-linux/

Install PostgreSQL

To install PostgreSQL, use the following script:

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
sudo apt install -y postgresql-17

To set the password for the default PostgreSQL user run the following command:

sudo -u postgres psql

Then in the PSQL console, enter to set a new password:

\password postgres

Then enter this to exit the console:

\quit

Edit the Postgres configuration with the following command:

sudo nano /etc/postgresql/17/main/postgresql.conf

Edit the line that reads:

listen_addresses = 'localhost'

Change it to read:

listen_addresses = '*'

Next, edit the security configuration file pg_hba.conf:

sudo nano /etc/postgresql/17/main/pg_hba.conf

After the line that reads:

host    replication     all             127.0.0.1/32            scram-sha-256

Add the following line to allow other IPs besides localhost to access the server:

host    replication     all             0.0.0.0/24              scram-sha-256

Install TimescaleDB

To install TimescaleDB, use the following script:

sudo apt install -y gnupg apt-transport-https lsb-release wget
echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg
sudo apt update
sudo apt install -y timescaledb-2-postgresql-17 postgresql-client-17

To tune TimescaleDB for the current server configuration and restart PostgreSQL, run the following commands:

sudo timescaledb-tune --quiet --yes
sudo systemctl restart postgresql
Configuring PostgreSQL, TimescaleDB and Ignition as your Historian

Follow the guide here to configure everything for Ignition: Using PostgreSQL and TimescaleDB with Ignition