执行./network.sh up createChannel命令出错:Hyperledger Fabric v2.2示例>test-network通道创建失败
./network.sh up createChannel Error in Hyperledger Fabric v2.2 Test-Network Hey there, let's troubleshoot this error you're facing when creating a channel with the Fabric v2.2 test-network. Since you've confirmed all binaries and module versions are up to spec, let's walk through the most common fixes and checks:
Verify Docker Container Health
First, check if all required Fabric containers are running properly. Run this command:docker ps -aLook for containers like
orderer.example.com,peer0.org1.example.com,peer0.org2.example.com, andcli. If any container has exited, pull its logs to pinpoint the issue:docker logs <container-name>A frequent culprit here is port conflicts (e.g., ports 7050/7051 being used by other processes). If that's the case, either kill the conflicting process or adjust port mappings in the test-network's docker-compose files.
Validate Channel Artifacts
Thenetwork.shscript generates critical channel files in thechannel-artifactsdirectory, includingchannel.txandgenesis.block. If these files are missing or corrupted, channel creation will fail.
Regenerate these artifacts manually and retry:./network.sh generate ./network.sh up createChannelMake sure the
generatestep completes without errors.Debug with Direct CLI Commands
The wrapper script can sometimes mask detailed error messages. Try creating the channel manually inside the CLI container to get a clearer picture:- Enter the CLI container:
docker exec -it cli bash - Run the channel creation command directly:
peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
The output here will give you specific details about why the channel creation is failing (e.g., TLS certificate issues, connection timeouts to orderer).
- Enter the CLI container:
Clean Up Residual Resources
Old network artifacts, containers, or chaincode images can cause unexpected conflicts. Do a full cleanup before restarting:./network.sh down rm -rf channel-artifacts organizationsThen re-run the network setup command:
./network.sh up createChannelThis ensures you're starting with a fresh state, eliminating any leftover issues from previous tests.
Check TLS Certificate Generation
Fabric v2.2 uses TLS by default, so invalid or missing TLS certificates will break peer-orderer communication. Verify that certificates exist in theorganizationsdirectory:- For orderer:
organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem - For peers:
organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem
If certificates are missing, regenerate them manually:
cryptogen generate --config=./organizations/cryptogen/crypto-config.yamlThen retry the network setup.
- For orderer:
内容的提问来源于stack exchange,提问作者Charchit Dhawan

