Postgresql 12 集成 TimescaleDB

2022-05-12 00:00:00 专区 订阅 是一个 扩展 启用

TimescaleDB 是一个流行的时序数据库,可以用来做日志存储或者物联网数据库,它并不是一个独立的应用,而是以扩展插件的方式集成到 PostgreSQL 中。

在 PostgreSQL 12 中集成 TimescaleDB ,首先安装对应的版本:

yum install timescaledb_12

登录 pg,选择数据库, 启用扩展:

tsdb=# CREATE EXTENSION IF NOT EXISTS timescaledb;
FATAL: extension "timescaledb" must be preloaded
提示: Please preload the timescaledb library via shared_preload_libraries.

This can be done by editing the config file at: var/lib/pgsql/12/data/postgresql.conf
and adding 'timescaledb' to the list in the shared_preload_libraries config.
# Modify postgresql.conf:
shared_preload_libraries = 'timescaledb'

Another way to do this, if not preloading other libraries, is with the command:
echo "shared_preload_libraries = 'timescaledb'" >> var/lib/pgsql/12/data/postgresql.conf

(Will require a database restart.)

If you REALLY know what you are doing and would like to load the library without preloading, you can disable this check with:
SET timescaledb.allow_install_without_preload = 'on';
服务器意外地关闭了联接
这种现象通常意味着服务器在处理请求之前
或者正在处理请求的时候意外中止
与服务器的连接已断开,正在试图重置: 完成。

在次启用扩展的时候就会提示扩展未预加载,需要修改配置文件,并且需要重启。

修改配置文件:

# - Shared Library Preloading -

shared_preload_libraries = 'pg_stat_statements,timescaledb' # (change requires restart)
pg_stat_statements.max = 10000
pg_stat_statements.track = all

重启之后,重新链接 PG,启用扩展:

tsdb=# CREATE EXTENSION IF NOT EXISTS timescaledb;
WARNING:
WELCOME TO
_____ _ _ ____________
|_ _(_) | | | _ \ ___ \
| | _ _ __ ___ ___ ___ ___ __ _| | ___| | | | |_/
| | | | _ ` _ \ _ \/ __|/ __/ _` | |/ _ \ | | | ___ \
| | | | | | | | | __/\__ \ (_| (_| | | __/ |/ | |_/
|_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/
Running version 1.7.4
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: Please enable telemetry to help us improve our product by running: ALTER DATABASE "tsdb" SET timescaledb.telemetry_level = 'basic';

看到上面信息即表示创建成功了。

来源 https://www.modb.pro/db/49972

相关文章