我正在尝试建立一个包含2个组织(每个组织1个对等体)的网络,并尝试将它们加入一个公共渠道。所有加密原伪像均按预期生成。请在下面找到yaml文件,
crypto-config.yaml
OrdererOrgs:
- Name: "Orderer"
Domain: "example.com"
Specs:
- Hostname: "orderer"
PeerOrgs:
- Name: "Org1"
Domain: "org1.example.com"
Template:
Count: 1
Users:
Count: 1
- Name: "org2"
Domain: "org2.example.com"
Template:
Count: 1
Users:
Count: 1
configtx.yaml
Organizations:
- Name: "OrdererOrg"
ID: "OrdererMSP"
MSPDir: "crypto-config/ordererOrganizations/example.com/msp"
- Name: "Org1MSP"
ID: "Org1MSP"
MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
AnchorPeers:
- Host: "peer0.org1.example.com"
Port: 7051
- Name: "org2MSP"
ID: "org2MSP"
MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
AnchorPeers:
- Host: "peer0.org2.example.com"
Port: 10201
Application:
Organizations: null
Orderer:
OrdererType: "solo"
Addresses:
- "orderer.example.com:7050"
BatchTimeout: "2s"
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: "99 MB"
PreferredMaxBytes: "512 KB"
Kafka:
Brokers:
- "127.0.0.1:9092"
Organizations: null
Profiles:
OneOrgOrdererGenesis:
Orderer:
OrdererType: "solo"
Addresses:
- "orderer.example.com:7050"
BatchTimeout: "2s"
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: "99 MB"
PreferredMaxBytes: "512 KB"
Kafka:
Brokers:
- "127.0.0.1:9092"
Organizations:
- Name: "OrdererOrg"
ID: "OrdererMSP"
MSPDir: "crypto-config/ordererOrganizations/example.com/msp"
Consortiums:
SampleConsortium:
Organizations:
- Name: "Org1MSP"
ID: "Org1MSP"
MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
AnchorPeers:
- Host: "peer0.org1.example.com"
Port: 7051
- Name: "org2MSP"
ID: "org2MSP"
MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
AnchorPeers:
- Host: "peer0.org2.example.com"
Port: 10201
OneOrgChannel:
Consortium: "SampleConsortium"
Application:
Organizations:
- Name: "Org1MSP"
ID: "Org1MSP"
MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
AnchorPeers:
- Host: "peer0.org1.example.com"
Port: 7051
- Name: "org2MSP"
ID: "org2MSP"
MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
AnchorPeers:
- Host: "peer0.org2.example.com"
Port: 10201
docker-compose.yaml
version: "2"
networks:
basic: null
services:
ca.org1.example.com:
image: "hyperledger/fabric-ca"
environment:
- "FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server"
- "FABRIC_CA_SERVER_CA_NAME=ca-org1"
- "FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem"
- "FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/692b679f21458a2283135a063617ebbcca9537e6e025754c34fd573b1bc07ce3_sk"
ports:
- "7054:7054"
command: "sh -c 'fabric-ca-server start -b admin:adminpw'"
volumes:
- "./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config"
container_name: "ca.org1.example.com"
networks:
- "basic"
ca.org2.example.com:
image: "hyperledger/fabric-ca"
environment:
- "FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server"
- "FABRIC_CA_SERVER_CA_NAME=ca-org2"
- "FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem"
- "FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/f19ec77442abb428ab593933bca9e4c61b86f460d40c342ecb74540068190318_sk"
ports:
- "8054:8054"
command: "sh -c 'fabric-ca-server start -b admin:adminpw'"
volumes:
- "./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config"
container_name: "ca.org2.example.com"
networks:
- "basic"
orderer.example.com:
container_name: "orderer.example.com"
image: "hyperledger/fabric-orderer"
environment:
- "FABRIC_LOGGING_SPEC=info"
- "ORDERER_GENERAL_LISTENADDRESS=0.0.0.0"
- "ORDERER_GENERAL_GENESISMETHOD=file"
- "ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block"
- "ORDERER_GENERAL_LOCALMSPID=OrdererMSP"
- "ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp"
working_dir: "/opt/gopath/src/github.com/hyperledger/fabric/orderer"
command: "orderer"
ports:
- "7050:7050"
volumes:
- "./config/:/etc/hyperledger/configtx"
- "./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer"
- "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1"
- "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/msp/peerOrg2"
networks:
- "basic"
peer0.org1.example.com:
container_name: "peer0.org1.example.com"
image: "hyperledger/fabric-peer"
environment:
- "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
- "CORE_PEER_ID=peer0.org1.example.com"
- "FABRIC_LOGGING_SPEC=info"
- "CORE_CHAINCODE_LOGGING_LEVEL=info"
- "CORE_PEER_LOCALMSPID=Org1MSP"
- "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/"
- "CORE_PEER_ADDRESS=peer0.org1.example.com:7051"
- "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic"
- "CORE_LEDGER_STATE_STATEDATABASE=CouchDB"
- "CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984"
- "CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME="
- "CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD="
working_dir: "/opt/gopath/src/github.com/hyperledger/fabric"
command: "peer node start"
ports:
- "7051:7051"
volumes:
- "/var/run/:/host/var/run/"
- "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer"
- "./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users"
- "./config:/etc/hyperledger/configtx"
depends_on:
- "orderer.example.com"
- "couchdb"
networks:
- "basic"
peer0.org2.example.com:
container_name: "peer0.org2.example.com"
image: "hyperledger/fabric-peer"
environment:
- "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
- "CORE_PEER_ID=peer0.org2.example.com"
- "FABRIC_LOGGING_SPEC=info"
- "CORE_CHAINCODE_LOGGING_LEVEL=info"
- "CORE_PEER_LOCALMSPID=org2MSP"
- "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/"
- "CORE_PEER_ADDRESS=peer0.org2.example.com:10201"
- "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic"
- "CORE_LEDGER_STATE_STATEDATABASE=CouchDB"
- "CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984"
- "CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME="
- "CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD="
working_dir: "/opt/gopath/src/github.com/hyperledger/fabric"
command: "peer node start"
ports:
- "10201:10201"
volumes:
- "/var/run/:/host/var/run/"
- "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/msp/peer"
- "./crypto-config/peerOrganizations/org2.example.com/users:/etc/hyperledger/msp/users"
- "./config:/etc/hyperledger/configtx"
depends_on:
- "orderer.example.com"
- "couchdb"
networks:
- "basic"
couchdb:
container_name: "couchdb"
image: "hyperledger/fabric-couchdb"
environment:
- "COUCHDB_USER="
- "COUCHDB_PASSWORD="
ports:
- "5984:5984"
networks:
- "basic"
cli:
container_name: "cli"
image: "hyperledger/fabric-tools"
tty: true
environment:
- "GOPATH=/opt/gopath"
- "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
- "FABRIC_LOGGING_SPEC=info"
- "CORE_PEER_ID=cli"
- "CORE_PEER_ADDRESS=peer0.org1.example.com:7051"
- "CORE_PEER_LOCALMSPID=Org1MSP"
- "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp"
- "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
- "CORE_CHAINCODE_KEEPALIVE=10"
working_dir: "/opt/gopath/src/github.com/hyperledger/fabric/peer"
command: "/bin/bash"
volumes:
- "/var/run/:/host/var/run/"
- "./../chaincode/:/opt/gopath/src/github.com/"
- "./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/"
- "./config:/opt/gopath/src/github.com/hyperledger/fabric/peer/config/"
depends_on:
- "orderer.example.com"
- "peer0.org1.example.com"
- "peer0.org2.example.com"
networks:
- "basic"
所有docker容器均已成功创建,
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
614685a858c0 hyperledger/fabric-tools "/bin/bash" 18 hours ago Up 18 hours cli
cead74ff3acf hyperledger/fabric-peer "peer node start" 18 hours ago Up 18 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
abd07c877081 hyperledger/fabric-peer "peer node start" 18 hours ago Up 18 hours 0.0.0.0:10201->10201/tcp peer0.org2.example.com
70ac639b1b7a hyperledger/fabric-couchdb "tini -- /docker-ent…" 18 hours ago Up 18 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
e8d04f5cac45 hyperledger/fabric-orderer "orderer" 18 hours ago Up 18 hours 0.0.0.0:7050->7050/tcp orderer.example.com
3fafc99fe92d hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 18 hours ago Up 18 hours 0.0.0.0:7054->7054/tcp ca.org1.example.com
c9b830eecf8a hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 18 hours ago Up 18 hours 7054/tcp, 0.0.0.0:8054->8054/tcp ca.org2.example.com
当我进入peer0.org1.example.com或cli容器并运行“ peer channel ..”命令时,它可以正常工作而没有问题...
root@cead74ff3acf:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
2020-03-04 07:55:39.000 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Channels peers has joined:
但是当我进入peer0.org2.example.com容器并运行它们时,出现以下错误,
root@abd07c877081:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org2.example.com:10201: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.23.0.6:10201: connect: connection refused"
peer0.org2日志中显示的一些警告是
[gossip.gossip] NewGossipService -> WARN 017 External endpoint is empty, peer will not be accessible outside of its organization
[gossip.comm] sendToEndpoint -> WARN 103 Failed obtaining connection for , PKIid:1fff29d8bd80fe1df86bbd7b23f14059a0ad1ac10fd0e790b133d6f84433087d reason: context deadline exceeded
[comm.grpc.server] 1 -> INFO 122 unary call completed grpc.service=gossip.Gossip grpc.method=Ping grpc.request_deadline=2020-03-03T14:50:08.415Z grpc.peer_address=127.0.0.1:40334 grpc.code=OK grpc.call_duration=160.19µs
[gossip.comm] func1 -> WARN 123 127.0.0.1:7051, PKIid:1fff29d8bd80fe1df86bbd7b23f14059a0ad1ac10fd0e790b133d6f84433087d isn't responsive: EOF
您能找出问题所在吗?
答案 0 :(得分:1)
您在同级上缺少CORE_PEER_LISTENADDRESS
,以使其实际上在端口10201
上监听。
自定义端口时,您需要确保覆盖所有相关配置,请参阅:https://github.com/hyperledger/fabric/blob/master/sampleconfig/core.yaml