如何解决使用fabric-samples文件夹启动Hyperledger Fabric的测试网络时的端口冲突
我是一个新手,已经为这些端口错误苦苦挣扎了一段时间 当我在目录中运行 ./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,它们相互冲突。我认为我可以通过运行 docker 来避免这些端口错误。不过,好像我错了。我在运行 ./network.sh 之前检查了 docker 环境,我确定没有其他进程同时运行。
yujindeMBP:test-network yujin$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
在我尝试启动测试网络之前,docker 的进程表很清楚。
我真的很困惑,需要你的帮助。非常感谢!
解决方法
Try docker ps -a
此列表列出所有活动容器。
使用命令 docker rm -f [container_id/container_name]
删除容器
移除所有容器后,再恢复您的网络。
如果您仍然遇到问题,请转到您的 crypto-config-org1.yaml、crypto-config-org2.yaml、crypto- config-orderer.yaml 编辑和更改端口。您也可以在 https://chat.hyperledger.org/
上提问