Timescaledb is an open-source database built for analyzing time-series data which is built on top of PostgreSQL.
Timescaledb allows installation on OS X via two mechanisms - via Source and via Homebrew. If we are using PostgreSQL managed by Homebrew then we can install Timescaledb also via Homebrew. But if we want to use Timescaledb along with Postgres.app then we have to install it via Source as per Timescaledb documentation.
Before starting the installation make sure that the
pg_config path is using the path of
pg_config utility installed by Postgres.app. This can be verified by running following command.
> which pg_config /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
If the output is something else, then follow the instructions here to setup the CLI utilities installed by Postgres.app properly.
Now it is time to start installing Timescaledb. First we need to download the source code and switch to appropriate stable release tag for installation.
git clone https://github.com/timescale/timescaledb.git cd timescaledb git checkout <release_tag> # e.g., git checkout 1.7.1 ./bootstap
This results in following error.
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR) CMake Error at CMakeLists.txt:336 (message): TimescaleDB requires OpenSSL but it wasn't found. If you want to continue without OpenSSL, re-run bootstrap with `-DUSE_OPENSSL=0
We can resolve it as follows.
Running this shows up another error.
CMake Error at test/CMakeLists.txt:83 (message): Program 'pg_isolation_regress' not found, but regressions checks were required. Skip regression checks using -DREGRESS_CHECKS=OFF -- Configuring incomplete, errors occurred!
pg_isolation_regress is a binary from PostgreSQL which does not get built in a normal PostgreSQL build. We have to build it ourself if we want to run the isolation regression tests. As we don't want to do that we can skip it as mentioned in the above error message.
OPENSSL_ROOT_DIR=/usr/local/opt/openssl ./bootstrap -DREGRESS_CHECKS=OFF
If it runs successfully then it will print following at the end.
-- Build files have been written to: /Users/prathamesh/Projects/sources/timescaledb/build TimescaleDB build system initialized in ./build. To compile, do: cd ./build && make
We can go ahead and run the next command.
cd ./build && make make install
After this, we need to edit the
postgresql.conf to add
> psql -d postgres -c "SHOW config_file;" config_file ------------------------------------------------------------------------------- /Users/prathamesh/Library/Application Support/Postgres/var-11/postgresql.conf (1 row)
Then uncomment the line with
shared_preload_libraries and change it to following.
shared_preload_libraries = 'timescaledb'
After that we have to restart PostgreSQL. If it restarts successfully, the installation is successful. If not we can check the errors as follows.
tail -f /Users/prathamesh/Library/Application\ Support/Postgres/var-11/postgresql.log
After successful restart, we can start
psql and add the
timescaledb extension to our database.
prathamesh=# CREATE EXTENSION IF NOT EXISTS "timescaledb" CASCADE; WARNING: WELCOME TO _____ _ _ ____________ |_ _(_) | | | _ \ ___ \ | | _ _ __ ___ ___ ___ ___ __ _| | ___| | | | |_/ / | | | | _ ` _ \ / _ \/ __|/ __/ _` | |/ _ \ | | | ___ \ | | | | | | | | | __/\__ \ (_| (_| | | __/ |/ /| |_/ / |_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/ Running version 1.7.1 For more information on TimescaleDB, please visit the following links: 1. Getting started: https://docs.timescale.com/getting-started 2. API reference documentation: https://docs.timescale.com/api 3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture Note: TimescaleDB collects anonymous reports to better understand and assist our users. For more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry. CREATE EXTENSION prathamesh=#
And that's all. Timescaledb is setup properly running with PostgreSQL managed by Postgres.app.