hyperledger-fabric - 无法连接到 Postgres 数据库 Postgres 需要连接到特定数据库,尝试了以下数据库:
问题描述
当我尝试连接我的 fabric-ca 以使用 postgres 作为数据库时出现此错误。
Using postgres database, connecting to database...
2019/10/22 09:21:16 [DEBUG] Database Name: fabriccaserver
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=fabriccaserver sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'fabriccaserver'
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=postgres sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'postgres'
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=template1 sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'template1'
2019/10/22 09:21:16 [ERROR] Error occurred initializing database: Failed to connect to Postgres database. Postgres requires connecting to a specific database, the following databases were tried: [fabriccaserver postgres template1]. Please create one of these database before continuing
解决方案
我通过将 container_name 放在主机中解决了这个错误,即
db:
db:
type: postgres
datasource: host=db-postgres port=5432 user=postgres password=caDbPass12345 dbname=fabriccaserver sslmode=disable
tls:
enabled: false
certfiles:
client:
certfile:
keyfile:
以前,我输入 localhost 并尝试使用 127.0.0.1 之后我看到在我的 docker-compose.yaml 中我的 postgres 服务位于不同的网络下,而 ica.org1.example.com 位于不同的网络下,我已修复并且在杀死并删除所有 docker 进程后,必须执行 docker network prune。
推荐阅读
- flutter - Flutter Dart:更新两个不同 StreamBuilder 中数据的 BLoC 模式
- assembly - 无法在 64 位 ARM (AArch64) Ubuntu 上交叉组装 ARM 32 位汇编程序
- node.js - 如何检查 mongodb 数据库中是否已存在相同名称或相同编号?
- python - 有什么方法可以让 Python 的函数更易读吗?
- python - Python Matplotlib LEGEND 自定义
- java - 具有动态匹配器和角色的 Spring Boot 安全配置
- c# - 一种从输入数组创建位图的更快方法,而不是使用 for 循环和 SetPixel()
- python - 增加帧数会减少opencv videowriter中视频的持续时间?
- python - 我需要一个 SQL 表来更新 Unit #,而不是在检测到 Unit 已存在时创建新条目
- r - 根据特定条件从两列制作频率表