gpt4 book ai didi

postgresql - Postgres,RHEL和Docker

转载 作者:行者123 更新时间:2023-12-02 21:31:32 30 4
gpt4 key购买 nike

在我生命的最后4天,我一直在与这个问题作斗争,这使我发疯。
我正在尝试在RHEL 8中部署使用postgres DB的服务。为此,我都使用docker-compose部署了它们。
问题是我可以从服务容器ping postgres容器,但是服务无法连接数据库...
我简化了用例,并使用了一个docker compose,它使用管理员docker镜像来连接任何列出的DB管理器,包括postgres。它在我的机器和使用ubuntu 20的测试服务器上都能很好地工作,但是当我在RHEL 8中尝试使用它时,我也无法访问数据库!
这是docker和docker-compose版本:
docker :

Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:36 2020
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:01:11 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Docker组成
docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
操作系统
Red Hat Enterprise Linux release 8.1 (Ootpa)
我正在使用的实际docker-compose是这样的:
version: '3.1'

services:

db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example

adminer:
image: adminer
restart: always
ports:
- 8080:8080
与我在其他两个系统中获得的日志相比,postgres容器的日志似乎很好:
db_1       | The files belonging to this database system will be owned by user "postgres".
db_1 | This user must also own the server process.
db_1 |
db_1 | The database cluster will be initialized with locale "en_US.utf8".
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
db_1 |
db_1 | Data page checksums are disabled.
db_1 |
db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1 | creating subdirectories ... ok
db_1 | selecting dynamic shared memory implementation ... posix
db_1 | selecting default max_connections ... 100
db_1 | selecting default shared_buffers ... 128MB
db_1 | selecting default time zone ... Etc/UTC
db_1 | creating configuration files ... ok
db_1 | running bootstrap script ... ok
db_1 | performing post-bootstrap initialization ... ok
db_1 | syncing data to disk ... ok
db_1 |
db_1 |
db_1 | Success. You can now start the database server using:
db_1 |
db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1 |
db_1 | initdb: warning: enabling "trust" authentication for local connections
db_1 | You can change this by editing pg_hba.conf or using the option -A, or
db_1 | --auth-local and --auth-host, the next time you run initdb.
db_1 | waiting for server to start....2020-10-12 08:18:28.489 UTC [46] LOG: starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2020-10-12 08:18:28.499 UTC [46] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-10-12 08:18:28.545 UTC [47] LOG: database system was shut down at 2020-10-12 08:18:25 UTC
db_1 | 2020-10-12 08:18:28.557 UTC [46] LOG: database system is ready to accept connections
db_1 | done
db_1 | server started
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
db_1 |
db_1 | waiting for server to shut down...2020-10-12 08:18:28.572 UTC [46] LOG: received fast shutdown request
db_1 | .2020-10-12 08:18:28.581 UTC [46] LOG: aborting any active transactions
db_1 | 2020-10-12 08:18:28.582 UTC [46] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
db_1 | 2020-10-12 08:18:28.583 UTC [48] LOG: shutting down
db_1 | 2020-10-12 08:18:28.648 UTC [46] LOG: database system is shut down
db_1 | done
db_1 | server stopped
db_1 |
db_1 | PostgreSQL init process complete; ready for start up.
db_1 |
db_1 | 2020-10-12 08:18:28.693 UTC [1] LOG: starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2020-10-12 08:18:28.694 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-10-12 08:18:28.694 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-10-12 08:18:28.712 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-10-12 08:18:28.751 UTC [55] LOG: database system was shut down at 2020-10-12 08:18:28 UTC
db_1 | 2020-10-12 08:18:28.764 UTC [1] LOG: database system is ready to accept connections

有人遇到过这个问题吗?您是否有我可以尝试的建议?
编辑:
管理员容器日志与其他计算机相同。他们只是在尝试连接时抛出此错误,而不是一条正常消息:
Is the server running on host "postgres" (10.10.10.2) and accepting TCP/IP connections on port 5432?

最佳答案

我猜您是从某个站点安装了docker。对于RHEL 8,请尝试使用Podman和Buildah-不需要守护程序的OCI兼容替代品。这个article对此进行了解释。这些是RHEL 8中的默认容器工具。

关于postgresql - Postgres,RHEL和Docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64314138/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com