10

我尝试将plpython3扩展名添加到我的timescaledb/ postgres(基于 linux alpine)图像:

FROM timescale/timescaledb:0.9.0-pg10

RUN set -ex \
    && apk add --no-cache --virtual .plpython3-deps --repository http://nl.alpinelinux.org/alpine/edge/testing \
    postgresql-plpython3

当我尝试创建扩展时,出现以下错误:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not open extension control file "/usr/local/share/postgresql/extension/plpython3u.control": No such file or directory

但是当我在容器中搜索文件时,我可以在不同的目录中找到它们:

/ # find / -name '*plpy*'
/usr/lib/postgresql/plpython3.so
/usr/share/postgresql/extension/plpython3u.control
/usr/share/postgresql/extension/plpython3u--1.0.sql
/usr/share/postgresql/extension/plpython3u--unpackaged--1.0.sql

如何安装postgresql-plpython3到不同的目录或配置postgres以识别我添加的扩展?

更新

当我只是mv文件时,/usr/local/share/postgresql/extension我得到了错误:

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not access file "$libdir/plpython3": No such file or directory

更新 2

所以问题$libdirpg_config --pkglibdir指向/usr/local/lib/postgresqlplpython3.so在里面/usr/lib/postgresql。当我将所有内容移动到相应的/usr/local目录时,我可以成功创建扩展。

这就引出了我希望在哪里找到答案的问题。我怎样才能安装postgresql-plpython3/usr/local/...而不是/usr/...

4

1 回答 1

7

我相当肯定,如果您使用预构建的软件包,您会被硬编码的安装路径所困。

解决问题的最简单方法是在安装后创建符号链接:

FROM timescale/timescaledb:0.9.0-pg10

RUN set -ex \
    && apk add --no-cache --virtual .plpython3-deps --repository http://nl.alpinelinux.org/alpine/edge/testing \
    postgresql-plpython3 \
    && ln -s /usr/lib/postgresql/plpython3.so /usr/local/lib/postgresql/plpython3.so \
    && ln -s /usr/share/postgresql/extension/plpython3u.control /usr/local/share/postgresql/extension/plpython3u.control \
    && ln -s /usr/share/postgresql/extension/plpython3u--1.0.sql /usr/local/share/postgresql/extension/plpython3u--1.0.sql \
    && ln -s /usr/share/postgresql/extension/plpython3u--unpackaged--1.0.sql /usr/local/share/postgresql/extension/plpython3u--unpackaged--1.0.sql
于 2019-04-04T11:45:52.150 回答