Installing Timescaledb on Mac OS X with Postgres.app
Tags: postgres, timescaledb
Published: 2020-07-30 06:57:30

---
title: Installing Timescaledb on Mac OS X with Postgres.app
published: true
date: 2020-07-22 18:35:00 UTC
tags: postgresql,timescaledb
canonical_url: https://prathamesh.tech/2020/07/23/installing-timescaledb-on-mac-os-x-with-postgres-app/
---

I use [Postgres.app](https://postgresapp.com/) to manage PostgreSQL on my Mac. I wanted to install [Timescaledb](https://www.timescale.com/) locally and ran into few issues while installing it which are discussed in this post.

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](https://docs.timescale.com/latest/getting-started/installation).

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.

<!--kg-card-begin: code-->
```
> which pg_config                                                           
/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
```
<!--kg-card-end: code-->

If the output is something else, then follow the instructions here to [setup the CLI utilities installed by Postgres.app](https://postgresapp.com/documentation/cli-tools.html) 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.

<!--kg-card-begin: code-->
```
git clone https://github.com/timescale/timescaledb.git
cd timescaledb
git checkout <release_tag> # e.g., git checkout 1.7.1
./bootstap
```
<!--kg-card-end: code-->

This results in following error.

<!--kg-card-begin: code-->
```
-- 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
```
<!--kg-card-end: code-->

We can resolve it as follows.

<!--kg-card-begin: code-->
```
OPENSSL_ROOT_DIR=/usr/local/opt/openssl ./bootstrap
```
<!--kg-card-end: code-->

Running this shows up another error.

<!--kg-card-begin: code-->
```
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!
```
<!--kg-card-end: code-->

The `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.

<!--kg-card-begin: code-->
```
OPENSSL_ROOT_DIR=/usr/local/opt/openssl ./bootstrap -DREGRESS_CHECKS=OFF
```
<!--kg-card-end: code-->

If it runs successfully then it will print following at the end.

<!--kg-card-begin: code-->
```
-- Build files have been written to: /Users/prathamesh/Projects/sources/timescaledb/build
TimescaleDB build system initialized in ./build. To compile, do:
cd ./build && make
```
<!--kg-card-end: code-->

We can go ahead and run the next command.

<!--kg-card-begin: code-->
```
cd ./build && make
make install
```
<!--kg-card-end: code-->

After this, we need to edit the `postgresql.conf` to add `timescaledb` to `shared_preload_libraries`.

<!--kg-card-begin: code-->
```
> psql -d postgres -c "SHOW config_file;"                                          
                                  config_file
-------------------------------------------------------------------------------
 /Users/prathamesh/Library/Application Support/Postgres/var-11/postgresql.conf
(1 row)
```
<!--kg-card-end: code-->

Then uncomment the line with `shared_preload_libraries` and change it to following.

<!--kg-card-begin: code-->
```
shared_preload_libraries = 'timescaledb'
```
<!--kg-card-end: code-->

After that we have to restart PostgreSQL. If it restarts successfully, the installation is successful. If not we can check the errors as follows.

<!--kg-card-begin: code-->
```
tail -f /Users/prathamesh/Library/Application\ Support/Postgres/var-11/postgresql.log
```
<!--kg-card-end: code-->

After successful restart, we can start `psql` and add the `timescaledb` extension to our database.

<!--kg-card-begin: code-->
```
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=#
```
<!--kg-card-end: code-->

And that's all. Timescaledb is setup properly now running with PostgreSQL managed by Postgres.app.