Install self-hosted TimescaleDB from source

You can host TimescaleDB yourself, on any system, by downloading the source code and compiling it. These instructions do not require the use of a package manager or installation tool.

Before you start, make sure you have installed:

  • PostgreSQL 12 or later, with a development environment. For more information about PostgreSQL installation, including downloads and instructions, see the PostgreSQL documentation.
  • CMake version 3.11 or later. For more information about CMake installation, including downloads and instructions, see the CMake documentation.
  • C language compiler for your operating system, such as gcc or clang.

If you are installing from source on a Microsoft Windows system, you also need:

  • Visual Studio 2015 or later, packaged with CMake version 3.11 or later, and Git components.

Installing self-hosted TimescaleDB from source

  1. At the command prompt, clone the Timescale GitHub repository:

    1. git clone https://github.com/timescale/timescaledb.git
  2. Change into the cloned directory:

    1. cd timescaledb
  3. Checkout the latest release. You can find the latest release tag on our Releases page:

    1. git checkout 2.5.1
  4. Bootstrap the build system:

  5. Build the extension:

  6. Install TimescaleDB:

Configure PostgreSQL after installing from source

When you install TimescaleDB from source, you need to do some additional PostgreSQL configuration to add the TimescaleDB library.

important

If you have more than one version of PostgreSQL installed, TimescaleDB can only be associated with one of them. The TimescaleDB build scripts use pg_config to find out where PostgreSQL stores its extension files, so you can use pg_config to find out which PostgreSQL installation TimescaleDB is using.

Configuring PostgreSQL after installing from source

  1. Locate the postgresql.conf configuration file:

    1. psql -d postgres -c "SHOW config_file;"
  2. Open the postgresql.conf file in your preferred text editor, and locate the shared_preload_libraries parameter. Uncomment the line, and add timescaledb:

    1. shared_preload_libraries = 'timescaledb'

    If you use other preloaded libraries, make sure they are comma separated.

  3. Restart the PostgreSQL instance:

When you have completed the installation, you need to configure your database so that you can use it. The easiest way to do this is to run the timescaledb-tune script, which is included with the timescaledb-tools package. For more information, see the configuration section.

Set up the TimescaleDB extension

When you have PostgreSQL and TimescaleDB installed, you can connect to it from your local system using the psql command-line utility. This is the same tool you might have used to connect to PostgreSQL before, but if you haven’t installed it yet, check out our installing psql section.

Setting up the TimescaleDB extension

  1. On your local system, at the command prompt, connect to the PostgreSQL instance as the postgres superuser:

    1. psql -U postgres -h localhost

    If your connection is successful, you’ll see a message like this, followed by the psql prompt:

    1. psql (13.3, server 12.8 (Ubuntu 12.8-1.pgdg21.04+1))
    2. SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
    3. Type "help" for help.
    4. tsdb=>
  2. At the psql prompt, create an empty database. Our database is called example:

    1. CREATE database example;
  3. Connect to the database you created:

    1. \c example
  4. Add the TimescaleDB extension:

    1. CREATE EXTENSION IF NOT EXISTS timescaledb;
  5. You can now connect to your database using this command:

    1. psql -U postgres -h localhost -d example

You can check that the TimescaleDB extension is installed by using the \dx command at the psql prompt. It looks like this:

  1. tsdb=> \dx
  2. List of installed extensions
  3. -[ RECORD 1 ]------------------------------------------------------------------
  4. Name | pg_stat_statements
  5. Version | 1.7
  6. Schema | public
  7. Description | track execution statistics of all SQL statements executed
  8. -[ RECORD 2 ]------------------------------------------------------------------
  9. Name | plpgsql
  10. Version | 1.0
  11. Schema | pg_catalog
  12. Description | PL/pgSQL procedural language
  13. -[ RECORD 3 ]------------------------------------------------------------------
  14. Name | timescaledb
  15. Version | 2.5.1
  16. Schema | public
  17. Description | Enables scalable inserts and complex queries for time-series data
  18. -[ RECORD 4 ]------------------------------------------------------------------
  19. Name | timescaledb_toolkit
  20. Version | 1.3.1
  21. Schema | public
  22. Description | timescaledb_toolkit
  23. tsdb=>

Where to next

Now that you have your first TimescaleDB database up and running, you can check out the TimescaleDB section in our documentation, and find out what you can do with it.

If you want to work through some tutorials to help you get up and running with TimescaleDB and time-series data, check out our tutorials section.

You can always contact us if you need help working something out, or if you want to have a chat.