我学习使用超级账本结构创建应用程序。
这是我的参考资料-> https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html?highlight=script.sh
创建和加入频道时出现错误。
当我运行Attributes latestValue = results.keySet().stream()
.max(Element::compareTo)
.map(results::get)
.get()
运行这些命令后,我得到了peer channel create -o orderer.medrecnet.com:7050 -c medrecnetChannel -f ./channel-artifacts/channel.tx --tls –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/medrecnet.com/orderers/orderer.medrecnet.com/msp/tlscacerts/tlsca.medrecnet.com-cert.pem
这是我的docker-compose-base.yaml:
error 2019-02-20 09:33:25.905 UTC [main] InitCmd -> ERRO 001 Cannot run peer because error when setting up MSP of type bccsp from directory /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/msp: Setup error: nil conf reference
这是我的docker-compose-cli.yaml:
version: '2'
services:
orderer.medrecnet.com:
container_name: orderer.medrecnet.com
image: hyperledger/fabric-orderer:$IMAGE_TAG
environment:
- FABRIC_LOGGING_SPEC=INFO
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
# enabled TLS
- ORDERER_GENERAL_TLS_ENABLED=true
- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
- ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
- ORDERER_KAFKA_VERBOSE=true
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
- ../crypto-config/ordererOrganizations/medrecnet.com/orderers/orderer.medrecnet.com/msp:/var/hyperledger/orderer/msp
- ../crypto-config/ordererOrganizations/medrecnet.com/orderers/orderer.medrecnet.com/tls/:/var/hyperledger/orderer/tls
- orderer.medrecnet.com:/var/hyperledger/production/orderer
ports:
- 7050:7050
peer0.hospital.medrecnet.com:
container_name: peer0.hospital.medrecnet.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.hospital.medrecnet.com
- CORE_PEER_ADDRESS=peer0.hospital.medrecnet.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.hospital.medrecnet.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.hospital.medrecnet.com:7051
- CORE_PEER_LOCALMSPID=HospitalMSP
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/users/Admin@hospital.medrecnet.com/msp
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/tls:/etc/hyperledger/fabric/tls
- ../crypto-config/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/msp:/etc/hyperledger/fabric/msp/signcerts
- peer0.hospital.medrecnet.com:/var/hyperledger/production
ports:
- 7051:7051
- 7053:7053
peer1.doctor.medrecnet.com:
container_name: peer1.doctor.medrecnet.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.doctor.medrecnet.com
- CORE_PEER_ADDRESS=peer1.doctor.medrecnet.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.doctor.medrecnet.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.doctor.medrecnet.com:7051
- CORE_PEER_LOCALMSPID=doctorMSP
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/doctor.medrecnet.com/peers/peer1.doctor.medrecnet.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/doctor.medrecnet.com/peers/peer1.doctor.medrecnet.com/tls:/etc/hyperledger/fabric/tls
- peer1.doctor.medrecnet.com:/var/hyperledger/production
ports:
- 9051:7051
- 9053:7053
这是我的configtx.yaml:
version: '2'
volumes:
orderer.medrecnet.com:
peer0.hospital.medrecnet.com:
peer1.doctor.medrecnet.com:
networks:
byfn:
services:
orderer.medrecnet.com:
extends:
file: base/docker-compose-base.yaml
service: orderer.medrecnet.com
container_name: orderer.medrecnet.com
networks:
- byfn
peer0.hospital.medrecnet.com:
container_name: peer0.hospital.medrecnet.com
extends:
file: base/docker-compose-base.yaml
service: peer0.hospital.medrecnet.com
networks:
- byfn
peer1.doctor.medrecnet.com:
container_name: peer1.doctor.medrecnet.com
extends:
file: base/docker-compose-base.yaml
service: peer1.doctor.medrecnet.com
networks:
- byfn
cli:
container_name: cli
image: hyperledger/fabric-tools:$IMAGE_TAG
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
#- FABRIC_LOGGING_SPEC=DEBUG
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.hospital.medrecnet.com:7051
- CORE_PEER_LOCALMSPID=HospitalMSP
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/peers/peer0.hospital.medrecnet.com/msp
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/chaincode
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
depends_on:
- orderer.medrecnet.com
- peer0.hospital.medrecnet.com
- peer1.doctor.medrecnet.com
networks:
- byfn
这是我的crypto-config.yaml:
---
################################################################################
#
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:
# SampleOrg defines an MSP using the sampleconfig. It should never be used
# in production but may be used as a template for other definitions
- &OrdererOrg
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: OrdererOrg
# ID to load the MSP definition as
ID: OrdererMSP
# MSPDir is the filesystem path which contains the MSP configuration
MSPDir: crypto-config/ordererOrganizations/medrecnet.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
- &Hospital
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: HospitalMSP
# ID to load the MSP definition as
ID: HospitalMSP
MSPDir: crypto-config/peerOrganizations/hospital.medrecnet.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('HospitalMSP.admin', 'HospitalMSP.peer', 'HospitalMSP.client')"
Writers:
Type: Signature
Rule: "OR('HospitalMSP.admin', 'HospitalMSP.client')"
Admins:
Type: Signature
Rule: "OR('HospitalMSP.admin')"
# leave this flag set to true.
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.hospital.medrecnet.com
Port: 7051
- &Doctor
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: DoctorMSP
# ID to load the MSP definition as
ID: DoctorMSP
MSPDir: crypto-config/peerOrganizations/doctor.medrecnet.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('DoctorMSP.admin', 'DoctorMSP.peer', 'DoctorMSP.client')"
Writers:
Type: Signature
Rule: "OR('DoctorMSP.admin', 'DoctorMSP.client')"
Admins:
Type: Signature
Rule: "OR('DoctorMSP.admin')"
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer1.doctor.medrecnet.com
Port: 7052
################################################################################
#
# SECTION: Capabilities
#
# - This section defines the capabilities of fabric network. This is a new
# concept as of v1.1.0 and should not be utilized in mixed networks with
# v1.0.x peers and orderers. Capabilities define features which must be
# present in a fabric binary for that binary to safely participate in the
# fabric network. For instance, if a new MSP type is added, newer binaries
# might recognize and validate the signatures from this type, while older
# binaries without this support would be unable to validate those
# transactions. This could lead to different versions of the fabric binaries
# having different world states. Instead, defining a capability for a channel
# informs those binaries without this capability that they must cease
# processing transactions until they have been upgraded. For v1.0.x if any
# capabilities are defined (including a map with all capabilities turned off)
# then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
# Channel capabilities apply to both the orderers and the peers and must be
# supported by both.
# Set the value of the capability to true to require it.
Channel: &ChannelCapabilities
# V1.3 for Channel is a catchall flag for behavior which has been
# determined to be desired for all orderers and peers running at the v1.3.x
# level, but which would be incompatible with orderers and peers from
# prior releases.
# Prior to enabling V1.3 channel capabilities, ensure that all
# orderers and peers on a channel are at v1.3.0 or later.
V1_3: true
# Orderer capabilities apply only to the orderers, and may be safely
# used with prior release peers.
# Set the value of the capability to true to require it.
Orderer: &OrdererCapabilities
# V1.1 for Orderer is a catchall flag for behavior which has been
# determined to be desired for all orderers running at the v1.1.x
# level, but which would be incompatible with orderers from prior releases.
# Prior to enabling V1.1 orderer capabilities, ensure that all
# orderers on a channel are at v1.1.0 or later.
V1_1: true
# Application capabilities apply only to the peer network, and may be safely
# used with prior release orderers.
# Set the value of the capability to true to require it.
Application: &ApplicationCapabilities
# V1.3 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.3.
V1_3: true
# V1.2 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.2 (note, this need not be set if
# later version capabilities are set)
V1_2: false
# V1.1 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.1 (note, this need not be set if
# later version capabilities are set).
V1_1: false
################################################################################
#
# SECTION: Application
#
# - This section defines the values to encode into a config transaction or
# genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults
# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:
# Policies defines the set of policies at this level of the config tree
# For Application policies, their canonical path is
# /Channel/Application/<PolicyName>
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ApplicationCapabilities
################################################################################
#
# SECTION: Orderer
#
# - This section defines the values to encode into a config transaction or
# genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults
# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: kafka
Addresses:
- orderer.medrecnet.com:7050
# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s
# Batch Size: Controls the number of messages batched into a block
BatchSize:
# Max Message Count: The maximum number of messages to permit in a batch
MaxMessageCount: 10
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
# the serialized messages in a batch.
AbsoluteMaxBytes: 99 MB
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
# the serialized messages in a batch. A message larger than the preferred
# max bytes will result in a batch larger than preferred max bytes.
PreferredMaxBytes: 512 KB
Kafka:
# Brokers: A list of Kafka brokers to which the orderer connects
# NOTE: Use IP:port notation
Brokers:
- 127.0.0.1:9092
# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:
# Policies defines the set of policies at this level of the config tree
# For Orderer policies, their canonical path is
# /Channel/Orderer/<PolicyName>
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# BlockValidation specifies what signatures must be included in the block
# from the orderer for the peer to validate it.
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
################################################################################
#
# CHANNEL
#
# This section defines the values to encode into a config transaction or
# genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
# Policies defines the set of policies at this level of the config tree
# For Channel policies, their canonical path is
# /Channel/<PolicyName>
Policies:
# Who may invoke the 'Deliver' API
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
# Who may invoke the 'Broadcast' API
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
# By default, who may modify elements at this config level
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# Capabilities describes the channel level capabilities, see the
# dedicated Capabilities section elsewhere in this file for a full
# description
Capabilities:
<<: *ChannelCapabilities
################################################################################
#
# Profile
#
# - Different configuration profiles may be encoded here to be specified
# as parameters to the configtxgen tool
#
################################################################################
Profiles:
MedrecNetOrdererGenesis:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
SampleConsortium:
Organizations:
- *Hospital
- *Doctor
MedrecNetChannel:
Consortium: MedrecNetConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Hospital
- *Doctor
Capabilities:
<<: *ApplicationCapabilities
SampleDevModeKafka:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: kafka
Kafka:
Brokers:
- kafka.medrecnet.com:9092
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Hospital
- *Doctor
请帮助我...
答案 0 :(得分:2)
我认为此问题是由于本地结构二进制文件和Docker映像引起的
不同步。这可能会引起问题。
因此建议您重新下载具有匹配版本的本地软件包。
例如,
curl -sSL {Link) | bash -s -- <fabric_version> <fabric-ca_version> <thirdparty_version>
curl -sSL (link) | bash -s -- 1.4.4 1.4.4 0.4.18
答案 1 :(得分:1)
您需要在CORE_PEER_MSPCONFIGPATH
内的/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/users/Admin@hospital.medrecnet.com/msp
服务中将cli
设置为docker-compose-cli.yaml
答案 2 :(得分:0)
要解决这个问题,我只需删除docker- /中的/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/hospital.medrecnet.com/users/Admin@hospital.medrecnet.com/msp compose-cli.yaml和docker-compose-base.yaml,然后错误消失并且对等方正在运行。