EkiXu / CTFm

CTFm
Mozilla Public License 2.0
30 stars 3 forks source link

数据库密码异常 #4

Closed sparrowhe closed 2 years ago

sparrowhe commented 2 years ago

如题,按readme配置了secrets目录下几个文件,ctfm和db容器内/run/secret/ctfm_db_password 均正常,在ctfm容器下执行 python manage.py migrate 报错 django.db.utils.OperationalError: connection to server at "db" (172.26.0.2), port 5432 failed: FATAL: password authentication failed for user "ctfm"

EkiXu commented 2 years ago

是git pull下来的最新版吗,又及密码是否符合postgresql的规范,可以查看下db容器的log

sparrowhe commented 2 years ago

是最新版,至于密码是否符合规范我没有找到相关的文档,使用的大小写+数字+特殊字符的随机字符串,log见下

PostgreSQL Database directory appears to contain a database; Skipping initialization

2022-08-01 02:20:07.867 UTC [1] LOG:  starting PostgreSQL 14.4 (Debian 14.4-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-08-01 02:20:07.867 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-08-01 02:20:07.868 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2022-08-01 02:20:07.875 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-08-01 02:20:07.886 UTC [30] LOG:  database system was shut down at 2022-08-01 02:19:50 UTC
2022-08-01 02:20:07.895 UTC [1] LOG:  database system is ready to accept connections
2022-08-01 02:20:10.260 UTC [37] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:10.260 UTC [37] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2022-08-01 02:20:10.312 UTC [38] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:10.312 UTC [38] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2022-08-01 02:20:10.485 UTC [39] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:10.485 UTC [39] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2022-08-01 02:20:12.116 UTC [40] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:12.116 UTC [40] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2022-08-01 02:20:12.116 UTC [41] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:12.116 UTC [41] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2022-08-01 02:20:14.747 UTC [42] FATAL:  password authentication failed for user "ctfm"
2022-08-01 02:20:14.747 UTC [42] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
EkiXu commented 2 years ago

会不会是docker版本的问题,可能没有配置上secret

sparrowhe commented 2 years ago

会不会是docker版本的问题,可能没有配置上secret

进相关目录都有密码的

EkiXu commented 2 years ago

docker-compose down清理下容器再docker-compose up -d --build试试吧,也许是初始化的时候就没给数据库配上环境。我这边测试是正常的。

sparrowhe commented 2 years ago

docker-compose down清理下容器再docker-compose up -d --build试试吧,也许是初始化的时候就没给数据库配上环境。我这边测试是正常的。

给容器网段在数据库配置里配了无需密码,强行解决问题(

现在还有问题是动态容器题目docker启动不起来,没有发现相关报错,配置均按照readme.md中编写

EkiXu commented 2 years ago

3 可以参考下这个issue

sparrowhe commented 2 years ago

3 可以参考下这个issue

刚才看过了,我这边的问题是无法建立题目容器,也参考过那边的配置检查过了

只有frps报错 do http proxy request error: EOF 猜测应该是因为访问不到题目

EkiXu commented 2 years ago

可能还是docker本身的问题 是最新版的docker吗

sparrowhe commented 2 years ago

可能还是docker本身的问题 是最新版的docker吗

似乎不是,我更新一下试试

sparrowhe commented 2 years ago

可能还是docker本身的问题 是最新版的docker吗

似乎不是,我更新一下试试

更到最新版本 依然无效

sparrowhe commented 2 years ago

image image 配置文件如上

EkiXu commented 2 years ago

如果这个配置文件/backend/script/frpc.ini 在启动容器有变化的话说明程序运行已经在数据库中注册了动态容器,没有容器生成的话大概率是docker swarm挂了或者题目镜像有问题

sparrowhe commented 2 years ago

如果这个配置文件�/backend/script/frpc.ini 在启动容器有变化的话说明程序运行已经在数据库中注册了动态容器,没有生成的话大概率是docker swarm挂了或者镜像有问题

image 有生成 但docker ps -a没有相关容器

EkiXu commented 2 years ago

对,我说的就是这个生成了,但是没有容器的情况

sparrowhe commented 2 years ago

对,我说的就是这个生成了,但是没有容器的情况

我再排查一下吧

sparrowhe commented 2 years ago

谢谢巨师,我这好了,原因是把network填错了 横线看成下划线了。。