将 plpython3 扩展添加到 Postgres/timescaledb Alpine Docker Image



我尝试将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

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

这就引出了我希望找到答案的问题。如何将postgresql-plpython3安装到/usr/local/...而不是/usr/...

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

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

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

只需配置您的postgresql.conf即可从预期路径加载扩展共享库。

plpython3u.library_path = '/usr/lib'

最新更新