Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql cluster (patroni) with timescaledb. #31

Closed
vitabaks opened this issue Mar 14, 2020 · 20 comments
Closed

postgresql cluster (patroni) with timescaledb. #31

vitabaks opened this issue Mar 14, 2020 · 20 comments
Labels
question Further information is requested

Comments

@vitabaks
Copy link
Owner

vitabaks commented Mar 14, 2020

Timescale

Question:

Could you please send across, or the changes that i need to make on postgresql cluster to make it work for timescaledb.

Answer:

Everything is very simple!
And I myself use timescaledb in production in this cluster scheme.

Please read the documentation to get started: https://docs.timescale.com/latest/getting-started/installation/

Example for:
Installation on: Debian
Install method: apt
PostgreSQL version: 15

  1. Add timescaledb repository to download packages (in the /vars/Debian.yml variable file):
apt_repository_keys:
  - key: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" # postgresql repository apt key
  - key: "https://packagecloud.io/timescale/timescaledb/gpgkey" # timescaledb repository apt key

apt_repository:
  - repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" # postgresql apt repository
  - repo: "deb https://packagecloud.io/timescale/timescaledb/debian/ {{ ansible_distribution_release }} main" # timescaledb apt repository
  1. Add timescaledb packages for automatic installation in the postgresql_packages variable (in the /vars/Debian.yml variable file):
postgresql_packages:
  - postgresql-{{ postgresql_version }}
  - postgresql-client-{{ postgresql_version }}
  - postgresql-server-dev-{{ postgresql_version }}
  - postgresql-contrib-{{ postgresql_version }}
  - timescaledb-2-postgresql-{{ postgresql_version }}
  1. Add/edit the necessary PostgreSQL parameters for timescaledb (in the /vars/main.yml variable file):
postgresql_version: "15"

postgresql_users: # this is optional
postgresql_databases: # this is optional
postgresql_extensions:
  - {ext: "timescaledb", db: "postgres"} # or my database name

postgresql_parameters:
  - {option: "max_locks_per_transaction", value: "512"}
  - {option: "shared_preload_libraries", value: "timescaledb"}

Specify all other variables according to your personal requirements for the database cluster.

Deployment: quick start

@vitabaks vitabaks added the question Further information is requested label Mar 14, 2020
@vitabaks
Copy link
Owner Author

timescaledb repository for RHEL/CentOS 7/8 (in the /vars/RedHat.yml variable file)

yum_repository:
  - name: "timescale_timescaledb"
    description: "timescaledb repo"
    baseurl: "https://packagecloud.io/timescale/timescaledb/el/{{ ansible_distribution_major_version }}/x86_64"
    gpgkey: "https://packagecloud.io/timescale/timescaledb/gpgkey"
    gpgcheck: "no"

@vitabaks
Copy link
Owner Author

timescaledb repository for Ubuntu (in the /vars/Debian.yml variable file):

apt_repository_keys:
  - key: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" # postgresql repository apt key
  - key: "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x55ee6bf7698e3d58d72c0dd9ecb3980cc59e610b" # timescaledb PPA repository key

apt_repository:
  - repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" # postgresql apt repository
  - repo: "deb http://ppa.launchpad.net/timescale/timescaledb-ppa/ubuntu {{ ansible_distribution_release }} main" # timescaledb PPA repository

@vitabaks
Copy link
Owner Author

vitabaks commented Apr 17, 2020

PostgreSQL 12 support added in TimescaleDB since version 1.7.0 (2020-04-16)

Deprecation Notice:
Please note that with the release of Timescale 1.7, are deprecating support for PostgreSQL 9.6.x and 10.x.

@marcusteixeira
Copy link

Great Work!
One thing we can put in the role, is when timescaledb_install is set to true, already running timescaledb-tune.

Ref: https://docs.timescale.com/latest/getting-started/configuring

@vitabaks
Copy link
Owner Author

@marcusteixeira Thanks for your feedback!

One thing we can put in the role, is when timescaledb_install is set to true, already running timescaledb-tune.

That is unnecessary.
You can specify all the necessary parameters in the variable postgresql_parameters (ex. max_locks_per_transaction) in vars/main.yml variable file.

@valentin-fischer
Copy link

Hmmm....very interesting this TimescaleDB.
I've been using influxdb for the last 2 years, maybe I can do a switch ...

Thanks!

@vitabaks
Copy link
Owner Author

vitabaks commented Mar 4, 2021

PostgreSQL 13 support added in TimescaleDB since version 2.1.0 (2021-02-22)

@vitabaks
Copy link
Owner Author

vitabaks commented Aug 6, 2021

PostgreSQL 11 is not supported with TimescaleDB 2.4.

@vitabaks
Copy link
Owner Author

PostgreSQL 14 support added in TimescaleDB since version 2.5.0 (2021-10-28)

@vitabaks vitabaks pinned this issue Jan 27, 2022
@sojjan1337
Copy link

+1 for implementation

@vitabaks
Copy link
Owner Author

+1 for implementation

@sojjan1337 what do you mean by implementation?

After all, this has already been implemented, just specify the necessary variables as indicated above.

@sojjan1337
Copy link

Can i enable timescale from start in a configuration-file?
The same way as you enable ha-proxy?

enable_timscale = True

Thanks!

@vitabaks
Copy link
Owner Author

@sojjan1337 ok, I'll look for time to implement this functionality

@sojjan1337
Copy link

sojjan1337 commented May 30, 2022

Big thanks! I'm using this for a Zabbix 6 HA setup. Would be great to have a ansible-playbook to set this up with both zabbix and postgres. Have a nice evening. :)

@vitabaks
Copy link
Owner Author

PostgreSQL 15 support added in TimescaleDB since version 2.10.0 (2023-02-21)

@sojjan1337
Copy link

sojjan1337 commented Feb 22, 2023

PostgreSQL 15 support added in TimescaleDB since version 2.10.0 (2023-02-21)

YoYo! Does this mean that when i run your latest ansible-playbook with postgres15, timescale is installed by default?
Or maybe you have a "enable - timescale" feature now? I haven't looked for a while.

Big thanks man!

@vitabaks
Copy link
Owner Author

Does this mean that when i run your latest ansible-playbook with postgres15, timescale is installed by default?

Please see the instructions: #31 (comment)

Or maybe you have a "enable - timescale" feature now? I haven't looked for a while.

TODO - #235

@vitabaks
Copy link
Owner Author

Now, to deploy a PostgreSQL High-Availability Cluster (based on "Patroni") with the TimescaleDB extension, you just need to specify only one variable enable_timescale=true

Example:

ansible-playbook deploy_pgcluster.yml -e "enable_timescale=true"

@vitabaks vitabaks unpinned this issue May 21, 2023
@vitabaks
Copy link
Owner Author

PostgreSQL 12 is not supported starting with TimescaleDB 2.12.

@vitabaks
Copy link
Owner Author

PostgreSQL 16 support added in TimescaleDB since version 2.13.0 (2023-11-28)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants