当前位置:网站首页>PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement

PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement

2022-07-07 06:19:00 yang_ z_ one

postgresql database timescaledb function time_bucket_gapfill() Report errors, solve and replace license

Preface

Recently, I used postgresql and timescaledb Of time_bucket_gapfill() function Report errors , Let replace license, I found a big circle on the Internet , Can't find , At last, the problem was solved , This article records my solutions

One Have a problem :

An error is as follows

error : function “time_bucket_gapfill” is not supported under the current “apache” license
HINT: Upgrade your license to ‘timescale’ to use this free community feature.

 Insert picture description here

Two terms of settlement :

Method 1 : Change directly timescaledb.license Parameters

see timescaledb.license Parameter command :

show timescaledb.license;

Modify the order :

alter system set timescaledb.license='timescale';

It doesn't work , An error is as follows :

lter system set timescaledb.license=‘timescale’;

error : Unable to access file “$libdir/timescaledb-tsl-2.5.2”: There is no file or directory

 Insert picture description here

Then I can only change my bag

Method 2 : Replace timescaledb edition ( Bring their own ’timescale’ license)

If the above situation occurs , Then we can only

1. download yum package

First download the tape from the official website 'timescale’ Version of yum package

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{
     rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2. Update the local package

yum update timescaledb_14

download rpm package
yumdownloader --resolve --destdir=/u01 timescaledb-2-postgresql-14.x86_64

Download the missing dependency package
yumdownloader --resolve --destdir=/u01 timescaledb-2-loader-postgresql-14.x86_64
yumdownloader --resolve --destdir=/u01 timescaledb-tools-0.12.0-0.el7.x86_64

3. Back up the original data

because timescaledb The versions of are inconsistent , Can't be used directly pg_dump Command to back up the data of the database

Here I use the method of single table data backup :

 psql --host "0.0.0.0"  --port "5432" --dbname " Original database name "  --username "postgres" \
-c "\COPY (SELECT * FROM  Super table name  { It can be followed by where  With restrictions }) TO /u01/data.csv DELIMITER ',' CSV"

4. Back up the original table structure

Here you can use pg_dump Wait for the command to export the table structure sql.

5. Kill the process connecting to the database :

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 = ' Original library name '
    ;

6. Uninstall the original timescaledb

see
rpm -qa |grep timescaledb

 Insert picture description here

uninstall

yum remove timescaledb_14-2.6.0-1.rhel7.x86_64

[[email protected] 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!

7. install timescaledb

I use the latest 2.7.0 Version of timescaledb, also 2 A dependent package
 Insert picture description here

7.1 Install dependency package first

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

7.2 In the installation timescaledb.

yum install timescaledb-2-postgresql-14-2.7.0-0.el7.x86_64.rpm

8. Installing a plug-in

  1. install timescaledb
    CREATE EXTENSION timescaledb;

  2. Install the required plug-ins ( such as :postgis etc. )

Create extension postgis;
Create extension “uuid-ossp”;
Create extension “postgres_fdw”

 Insert picture description here

9. Restore the previous table structure

I have the previous table structure sql, It's directly executed .

10. Restore table data

psql --host “10.12.105.150” --port “5432” --dbname “timescaledb” --username “postgres” -c “\COPY Schema name . Table name FROM /u01/data-target.csv CSV”

11. The verification results

11.1 see license

show timescaledb.license;

 Insert picture description here

11.2 see time_bucket_gapfill() Whether the report is wrong

 Insert picture description here
To this step , We have finished it all , The error reporting of this database has been solved .

Postscript

If there are any mistakes in this article , Please point out in your comment , Or contact me , I will correct it , If you find this article useful , Please do me a favor , Let more people see , thank you
author yang_z_1 csdn Blog address : https://blog.csdn.net/yang_z_1?type=blog

原网站

版权声明
本文为[yang_ z_ one]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070123376918.html