【问题标题】:How to install a PostgreSQL terminal client using microdnf install?如何使用 microdnf install 安装 PostgreSQL 终端客户端?
【发布时间】:2021-12-10 21:53:42
【问题描述】:

通过 microdnf 安装可以使用哪些 PostgreSQL 客户端? 我正在尝试通过我的 Dockerfile 安装客户端。

我尝试了多个我看到推荐的命令和几个猜测,但没有一个对我有用:

microdnf install -y postgresql-client
microdnf install -y postgresql
microdnf install -y psql
etc.

正在使用的图像: https://hub.docker.com/r/jboss/keycloak/

sh-4.4$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.3 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.3 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.3:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.3"

PS = 有没有可以访问的网站查看可用软件包的完整列表?

【问题讨论】:

    标签: linux postgresql keycloak dnf


    【解决方案1】:

    我也有同样的问题,但使用了maven docker 镜像(它基于 OracleLinux 8)。

    Oracle Linux 8 和 Postgresql13 客户端

    在上面安装postgresql客户端是非常不寻常的,所以,让我们考虑一下我的步骤:

    1. https://www.postgresql.org/download/linux/redhat/
      选择RHEL 8,接收rpm包链接

    2. 使用rpm手动安装

    microdnf install -y wget
    wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm
    rpm -i /tmp/pg_repo.rpm
    
    1. 确定没有postgresql13 包。点击direct download链接并选择RHEL 8:https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/

    2. 下载postgresql13-13.x.x...包(最新)

    wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm
    

    该 rpm 的依赖项列表:

    libicu is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
            libpq.so.5()(64bit) is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
            postgresql13-libs(x86-64) = 13.3-2PGDG.rhel8 is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
            systemd is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
            systemd-sysv is needed by postgresql13-13.3-2PGDG.rhel8.x86_64
    
    1. 安装依赖项
    microdnf install -y systemd postgresql13-libs libicu
    
    1. 最后,安装客户端
    rpm -i /tmp/pgql.rpm
    

    现在您可以清除缓存并测试客户端,例如pg_dump 命令。

    结果 Dockerfile 命令:

    RUN microdnf install -y wget && \
        wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm -O /tmp/pg_repo.rpm && \
        rpm -i /tmp/pg_repo.rpm && \
        microdnf install -y systemd postgresql13-libs libicu && \
        wget https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-8-x86_64/postgresql13-13.3-2PGDG.rhel8.x86_64.rpm -O /tmp/pgql.rpm && \
        rpm -i /tmp/pgql.rpm && \
        rm -f /tmp/pg_repo.rpm /tmp/pgql.rpm && \
        microdnf remove -y wget
    

    RHEL 8 和 Postgresql13 客户端(您的情况)

    现在让我们考虑一下您的情况,图像 jboss/keycloak:14.0.0 基于 RHEL 8。

    警告:如果您收到错误消息 error: Failed to create: /var/cache/yum/metadata,请以 root 用户身份运行,然后将用户切换回 jboss。

    所有步骤和 Dockerfile 命令都是一样的。

    如果有任何错误或没有很好地描述,请告诉我。

    【讨论】:

    • @Tliak - 我尝试了几种以 root 身份运行的方法(sudo 等),但命令不存在。我将如何在标准 keycloak 容器中以 root 身份执行。
    【解决方案2】:

    使用基于 openjdk:15 的 Dockerfile 对我有用。

    FROM openjdk:15.0.1-oracle
    ...
    RUN microdnf update
    RUN microdnf module enable postgresql:13
    RUN microdnf install postgresql.x86_64
    

    【讨论】:

    • 我没有使用那个图片。
    猜你喜欢
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-24
    • 2016-11-29
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多