TimescaleDB
TimescaleDB 是基于postgres的时序数据库,安装TimescaleDB需要先安装postgres,然后将postgres转成TimescaleDB.
参考前文安装 postgres-15
.
安装TimescaleDB
- 安装yum源
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- 安装TimescaleDB资源库
sudo 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
- 更新
sudo yum update
- YUM安装TimescaleDB
sudo yum install timescaledb-2-postgresql-15
- 初始化数据库(已经安装过了就跳过)
sudo /usr/pgsql-16/bin/postgresql-15-setup initdb
- 将PostgreSQL调成TimescaleDB
sudo timescaledb-tune --pg-config=/usr/pgsql-15/bin/pg_config -conf-path=/home/pgsql/data/postgresql.conf
- 重启数据库
systemctl restart postgresql-15
- 添加数据库拓展
psql -U postgres -h 127.0.0.1 -p 5432
CREATE EXTENSION IF NOT EXISTS timescaledb;
postgres=
List of installed extensions
Name | Version | Schema | Description
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | 2.15.2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
(2 rows)