将plpython3扩展添加到Postgres/timescaledb Alpine Docker Image [英] Add plpython3 Extension to Postgres/timescaledb Alpine Docker Image

查看:163
本文介绍了将plpython3扩展添加到Postgres/timescaledb Alpine Docker Image的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to add the plpython3 extension to my timescaledb/postgres (based on linux alpine) image:

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

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

When I try to create the extension I get the following error:

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

但是当我在容器内搜索文件时,可以在其他目录中找到它们:

But when I search for the files inside my container I can find them within a different 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 以识别添加的扩展名?

How can I install postgresql-plpython3 to a different directory or configure postgres to recognize my added extension?

更新

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

When I just mv the files to /usr/local/share/postgresql/extension I get the error:

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

更新2

所以 $ libdir 的问题是 pg_config --pkglibdir 指向/usr/local/lib/postgresql ,但是plpython3.so 位于/usr/lib/postgresql 中.当我将所有内容移到相应的/usr/local 目录中时,便可以成功创建扩展名.

So the issue with $libdir was that pg_config --pkglibdir points to /usr/local/lib/postgresql but plpython3.so is inside /usr/lib/postgresql. When I move everything to the according /usr/local directories I can successfully create the extension.

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

This leads to the question where I hope to find an answer. How can I install postgresql-plpython3 to /usr/local/... instead of /usr/...?

推荐答案

我相当确定,如果您使用预构建的软件包,则会陷入硬编码的安装路径.

I am fairly certain that if you use prebuilt packages you are stuck with hardcoded installation paths.

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

The easiest way around your problem is to create symlinks after installation:

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

这篇关于将plpython3扩展添加到Postgres/timescaledb Alpine Docker Image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆