Skip to content

Instantly share code, notes, and snippets.

@mwrites
Last active January 25, 2022 08:52
Show Gist options
  • Save mwrites/a1eae3fe51d7b6379458f521d79e77de to your computer and use it in GitHub Desktop.
Save mwrites/a1eae3fe51d7b6379458f521d79e77de to your computer and use it in GitHub Desktop.
Install TimescaleDB on CentOS8
#!/usr/bin/env bash
# ------------------------------------------ HELP
# https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
# (NOT PRECISE): https://docs.timescale.com/install/latest/self-hosted/installation-redhat/#setting-up-the-timescaledb-extension
# export SYSTEMD_EDITOR=vim
# Logs:
# journalctl -xeu postgresql-14
# Check postgres service:
# systemd-analyze verify /usr/lib/systemd/system/postgresql-14.service
# systemctl cat postgresql-14.service
# ------------------------------------------ Start Script
info () {
echo -e "\n$1"
}
text="
************************
Installing timescaledb-2-postgresql-14
************************
"
info $text
set -ueo pipefail
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{centos})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Values from: https://docs.timescale.com/install/latest/self-hosted/installation-redhat/#installing-self-hosted-timescaledb-on-red-hat-based-systems
tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
dnf update -y
# https://github.com/timescale/timescaledb/issues/2691
dnf -qy module disable postgresql
dnf install -y timescaledb-2-postgresql-14
text="
************************
Initializing DB
************************
"
info $text
/usr/pgsql-14/bin/postgresql-14-setup initdb
text="
************************
Checking if PGSQL can run
************************
"
info $text
systemctl restart postgresql-14.service
systemctl stop postgresql-14.service
systemctl enable postgresql-14.service
text="
************************
Tuning
************************
"
info $text
timescaledb-tune --yes --pg-config=/usr/pgsql-14/bin/pg_config
systemctl restart postgresql-14.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment