使用 fabric-samples 文件夹启动 Hyperledger Fabric 测试网络时的端口冲突

Port conflicts in starting test-network of Hyperledger Fabric using fabric-samples folder

我是新手,为这些端口错误苦苦挣扎了一段时间 当我在运行./network.sh目录下:fabric-samples/test-network 发生以下端口错误:

    yujindeMBP:test-network yujin$ ./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.3.0
DOCKER_IMAGE_VERSION=2.3.0
/Users/yujin/fabric-samples-with-bis/test-network/../bin/cryptogen
Generating certificates using cryptogen tool
Creating Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Creating Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Creating Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generating CCP files for Org1 and Org2
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating orderer.example.com    ... error
Creating peer0.org2.example.com ... 
Creating peer0.org1.example.com ... 

Creating peer0.org1.example.com ... error
Creating peer0.org2.example.com ... done
ERROR: for peer0.org1.example.com  Cannot start service peer0.org1.example.com: Ports are not available: listen tcp 0.0.0.0:7051: bind: address already in use

ERROR: for orderer.example.com  Cannot start service orderer.example.com: Ports are not available: listen tcp 0.0.0.0:7050: bind: address already in use

ERROR: for peer0.org1.example.com  Cannot start service peer0.org1.example.com: Ports are not available: listen tcp 0.0.0.0:7051: bind: address already in use
ERROR: Encountered errors while bringing up the project.
CONTAINER ID   IMAGE                               COMMAND             CREATED        STATUS                  PORTS                              NAMES
6feb86580f43   hyperledger/fabric-orderer:latest   "orderer"           1 second ago   Created                                                    orderer.example.com
dbfae1aa4c11   hyperledger/fabric-peer:latest      "peer node start"   1 second ago   Created                                                    peer0.org1.example.com
d0367a0d6089   hyperledger/fabric-peer:latest      "peer node start"   1 second ago   Up Less than a second   7051/tcp, 0.0.0.0:9051->9051/tcp   peer0.org2.example.com

似乎订购者、org1 和 org2 使用相同的端口 7050 和 7051,它们相互冲突。我想我可以通过 运行ning docker 来避免这些端口错误。但是,看来我错了。我在 运行 ./network.sh 之前检查了 docker 环境,我确定没有其他进程同时 运行ning。

yujindeMBP:test-network yujin$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

在我尝试启动测试网络之前,docker 的进程 table 是清楚的。

我真的很困惑,需要你的帮助。非常感谢!

尝试docker ps -a 这会列出所有活动容器。 使用命令 docker rm -f [container_id/container_name] 删除容器 删除所有容器后,恢复您的网络。

如果问题仍然存在,请转到 crypto-config-org1.yamlcrypto-config-org2.yamlcrypto-config-orderer.yaml 编辑和更改端口。您也可以在 https://chat.hyperledger.org/

上提问