我应该如何在laravel homestead中配置TimescaleDBPostgres

问题描述

我正在尝试使用laravel生态系统中的宅基地。

我可以使其与Postgresql DB一起使用,但是我没有TimescaleDB功能

我在homestead.yaml中用这些行安装了postgres 12

services:
    - enabled:
        - "postgresql@12-main"

我尝试按照timescaleDB docs中所述手动安装,但我认为它安装了不同的版本:

postgres  9188  0.0  1.3 353756 28068 ?        S    08:11   0:00 /usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf
postgres  9191  0.0  2.3 757760 48108 ?        Ss   08:11   0:00 /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf
postgres  9193  0.0  1.3 353396 27716 ?        S    08:11   0:00 /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
postgres  9196  0.0  0.3 353884  6916 ?        Ss   08:11   0:00 postgres: 11/main: checkpointer   
postgres  9197  0.0  0.2 353756  4172 ?        Ss   08:11   0:00 postgres: 11/main: background writer   
postgres  9198  0.0  0.4 353756  9056 ?        Ss   08:11   0:00 postgres: 11/main: walwriter   
postgres  9199  0.0  0.3 354160  6696 ?        Ss   08:11   0:00 postgres: 11/main: autovacuum launcher   
postgres  9200  0.0  0.1 208672  3560 ?        Ss   08:11   0:00 postgres: 11/main: stats collector   
postgres  9201  0.0  0.2 354160  4996 ?        Ss   08:11   0:00 postgres: 11/main: logical replication launcher   
postgres  9203  0.0  0.3 353508  7092 ?        Ss   08:11   0:00 postgres: 10/main: checkpointer process   
postgres  9204  0.0  0.2 353396  4216 ?        Ss   08:11   0:00 postgres: 10/main: writer process   
postgres  9205  0.0  0.4 353396  9232 ?        Ss   08:11   0:00 postgres: 10/main: wal writer process   
postgres  9206  0.0  0.3 353804  6940 ?        Ss   08:11   0:00 postgres: 10/main: autovacuum launcher process   
postgres  9207  0.0  0.1 208452  3660 ?        Ss   08:11   0:00 postgres: 10/main: stats collector process   
postgres  9208  0.0  0.2 353680  5044 ?        Ss   08:11   0:00 postgres: 10/main: bgworker: logical replication launcher   
postgres  9209  0.0  0.5 757864 10380 ?        Ss   08:11   0:00 postgres: 12/main: checkpointer   
postgres  9210  0.0  0.3 757760  6672 ?        Ss   08:11   0:00 postgres: 12/main: background writer   
postgres  9211  0.0  1.0 757760 21068 ?        Ss   08:11   0:00 postgres: 12/main: walwriter   
postgres  9212  0.0  0.3 758436  7128 ?        Ss   08:11   0:00 postgres: 12/main: autovacuum launcher   
postgres  9213  0.0  0.2 211220  5108 ?        Ss   08:11   0:00 postgres: 12/main: stats collector   
postgres  9214  0.0  0.3 758320  7588 ?        Ss   08:11   0:00 postgres: 12/main: TimescaleDB Background Worker Launcher   
postgres  9215  0.0  0.3 758308  7072 ?        Ss   08:11   0:00 postgres: 12/main: logical replication launcher   
postgres  9223  0.6  1.9 781872 39828 ?        Ss   08:11   0:02 postgres: 12/main: homestead mydb 10.0.2.2(41896) idle
postgres  9228  0.0  1.2 315744 26120 ?        S    08:11   0:00 /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
postgres  9230  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: checkpointer process   
postgres  9231  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: writer process   
postgres  9232  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: wal writer process   
postgres  9233  0.0  0.3 316156  6844 ?        Ss   08:11   0:00 postgres: 9.6/main: autovacuum launcher process   
postgres  9234  0.0  0.1 170744  3356 ?        Ss   08:11   0:00 postgres: 9.6/main: stats collector process   
postgres  9408  0.0  0.8 759028 17224 ?        Ss   08:13   0:00 postgres: 12/main: homestead mydb 10.0.2.2(42982) idle
postgres  9450  0.0  1.0 759640 21604 ?        Ss   08:14   0:00 postgres: 12/main: homestead mydb 10.0.2.2(43680) idle
postgres  9485  0.0  0.8 759028 17220 ?        Ss   08:15   0:00 postgres: 12/main: homestead mydb 10.0.2.2(44028) idle
postgres  9486  0.0  1.9 778188 39540 ?        Ss   08:15   0:00 postgres: 12/main: homestead postgres 10.0.2.2(44052) idle
postgres  9490  0.0  0.8 759028 17228 ?        Ss   08:15   0:00 postgres: 12/main: homestead mydb 10.0.2.2(44150) idle
postgres  9523  0.1  1.4 769688 30464 ?        Ss   08:16   0:00 postgres: 12/main: homestead homestead 10.0.2.2(44612) idle

在PGAdmin中,在本地,我可以看到几个以timescaledb为前缀的模式:

_timescaledb_cache
_timescaledb_catalog
_timescaledb_config
_timescaledb_internal

但是我看不到它。

此外,当我尝试使用以下方法创建超表时:

SELECT create_hypertable('measures','time');

我得到:

ERROR:  function create_hypertable(unkNown,unkNown) does not exist
LINE 1: SELECT create_hypertable('measures','time');
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
sql state: 42883
Character: 8

我可以看到git repo中有一个名为timescaledb的功能,但是没有关于如何调用它的文档。

有没有一种对时间刻度的内置支持,或者我应该怎么做?

编辑:我可以使用宅基功能安装timescaledb:

features:
    - mariadb: false
    - MysqL: false
    - timescaledb: true

但是它仍然给我同样的错误...

解决方法

解决方案在docs中:

一旦安装了时间表,就必须安装扩展程序:

CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

警告: 实际上,这是TimescaleDB OSS版本。您会在communit版本中找到很多缺少的功能,这些功能也免费

功能不受支持:7错误:当前许可证“ ApacheOnly”不支持功能“ time_bucket_gapfill”

提示:升级到获得Timescale许可的二进制文件以访问此免费社区功能

因此,对我来说,我必须卸载Homestead版本,然后重新安装社区版本。不确定为什么Homestead使用OSS版本。