最近在工作中使用postgresql 和 timescaledb 的time_bucket_gapfill()函数 报错,让更换license,在网上找了一大圈,没有找到,最后解决了这个问题,这篇文章记录我的解决办法
错误: function “time_bucket_gapfill” is not supported under the current “apache” license
HINT: Upgrade your license to ‘timescale’ to use this free community feature.
查看timescaledb.license参数命令:
show timescaledb.license;
修改命令:
alter system set timescaledb.license='timescale';
结果不行,报错如下:
lter system set timescaledb.license=‘timescale’;
错误: 无法访问文件 “$libdir/timescaledb-tsl-2.5.2”: 没有那个文件或目录
那只能换包了
如果出现上面那种情况,那我们只能
先从官网上下载带 'timescale’版本的yum 包
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum update timescaledb_14
下载rpm包
yumdownloader --resolve --destdir=/u01 timescaledb-2-postgresql-14.x86_64
下载所缺的依赖包
yumdownloader --resolve --destdir=/u01 timescaledb-2-loader-postgresql-14.x86_64
yumdownloader --resolve --destdir=/u01 timescaledb-tools-0.12.0-0.el7.x86_64
由于timescaledb的版本不一致,不能直接使用pg_dump 命令来备份数据库的数据
在这里我采用单表数据进行备份的方式:
psql --host "0.0.0.0" --port "5432" --dbname "原数据库名" --username "postgres" \
-c "\COPY (SELECT * FROM 超级表名 {后面可以跟where 加限制条件}) TO /u01/data.csv DELIMITER ',' CSV"
这里可以使用pg_dump等命令导出表结构的sql。
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = '原库名'
;
查看
rpm -qa |grep timescaledb
卸载
yum remove timescaledb_14-2.6.0-1.rhel7.x86_64
[root@AQSF-DB tjuser]# yum remove timescaledb_14-2.6.0-1.rhel7.x86_64
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package timescaledb_14.x86_64 0:2.6.0-1.rhel7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================
Removing:
timescaledb_14 x86_64 2.6.0-1.rhel7 installed 8.5 M
Transaction Summary
=======================================================================================================================================================
Remove 1 Package
Installed size: 8.5 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : timescaledb_14-2.6.0-1.rhel7.x86_64 1/1
Verifying : timescaledb_14-2.6.0-1.rhel7.x86_64 1/1
Removed:
timescaledb_14.x86_64 0:2.6.0-1.rhel7
Complete!
我这里是用最新的2.7.0版本的timescaledb,还有2个依赖包
yum install timescaledb-2-loader-postgresql-14-2.7.0-0.el7.x86_64.rpm
yum install timescaledb-tools-0.12.0-0.el7.x86_64.rpm
yum install timescaledb-2-postgresql-14-2.7.0-0.el7.x86_64.rpm
安装timescaledb
CREATE EXTENSION timescaledb;
安装原本需要的插件(比如:postgis 等)
Create extension postgis;
Create extension “uuid-ossp”;
Create extension “postgres_fdw”
我是有之前的表结构的sql,就直接执行了。
psql --host “10.12.105.150” --port “5432” --dbname “timescaledb” --username “postgres” -c “\COPY 模式名.表名 FROM /u01/data-target.csv CSV”
show timescaledb.license;
如果本文章有何错误,请您评论中指出,或联系我,我会改正,如果您觉得这篇文章有用,请帮忙一键三连,让更多的人看见,谢谢
作者 yang_z_1 csdn博客地址: https://blog.csdn.net/yang_z_1?type=blog