我已经使用超级账本结构创建了一个应用程序。
创建和加入频道时出现错误。
"Fatal error when initializing core config : Could not find config file. Please make sure that FABRIC_CFG_PATH is set to a path which contains core.yaml"
这是我的docker-compose-base.yaml:
version: '2'
networks:
dfarm:
services:
# Orderer
orderer.dfarmadmin.com:
container_name: orderer.dfarmadmin.com
image: hyperledger/fabric-orderer:$IMAGE_TAG
environment:
- FABRIC_CFG_PATH=/var/hyperledger/config
# - ORDERER_GENERAL_LOGLEVEL=DEBUG
- FABRIC_LOGGING_SPEC=INFO
- ORDERER_GENERAL_LISTENADDRESS=orderer.dfarmadmin.com
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/genesis/dfarm-genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/msp
- ORDERER_FILELEDGER_LOCATION=/var/ledger
working_dir: $HOME
command: orderer
volumes:
# Folder with genesis block
- ${PWD}/config/orderer:/var/hyperledger/genesis
# Map the folder with MSP for orderer
- ${PWD}/client/orderer/orderer/msp:/var/hyperledger/msp
# Map the current folder to cfg
- ${PWD}/config/orderer:/var/hyperledger/config
- ${HOME}/ledgers/ca/orderer.dfarmadmin.com:/var/ledger
ports:
- 7050:7050
networks:
- dfarm
# Dfarmadmin peer1
dfarmadmin-peer1.dfarmadmin.com:
container_name: dfarmadmin-peer1.dfarmadmin.com
image: hyperledger/fabric-peer:$IMAGE_TAG
environment:
- FABRIC_CFG_PATH=/var/hyperledger/config
# - CORE_LOGGING_LEVEL=debug
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_dfarm
- CORE_PEER_ID=dfarmadmin-peer1.dfarmadmin.com
# - CORE_PEER_LISTENADDRESS=dfarmretail-peer1.dfarmretail.com:7051
- CORE_PEER_ADDRESS=dfarmadmin-peer1.dfarmadmin.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=dfarmadmin-peer1.dfarmadmin.com:7051
# - CORE_PEER_ADDRESS=0.0.0.0:7051
# - CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051
- CORE_PEER_LOCALMSPID=DfarmadminMSP
- CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp
- CORE_PEER_TLS_ENABLED=false
# - CORE_PEER_GOSSIP_USELEADERELECTION=true
# - CORE_PEER_GOSSIP_ORGLEADER=false
# - CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_FILESYSTEMPATH=/var/ledger
working_dir: $HOME
# command: peer node start --peer-chaincodedev=true
command: peer node start
volumes:
# Folder with channel create tx file
- ${PWD}/config:/var/hyperledger/channeltx
# Map the folder with MSP for Peer
- ${PWD}/client/dfarmadmin/peer1/msp:/var/hyperledger/msp
# Map the current folder to cfg
- ${PWD}/config:/var/hyperledger/config
- /var/run/:/host/var/run/
# Ledger folder for the peer
- ${HOME}/ledgers/ca/dfarmadmin-peer1.dfarmadmin.com/:/var/ledger
depends_on:
- orderer.dfarmadmin.com
ports:
- 7051:7051
- 7052:7052
- 7053:7053
networks:
- dfarm
# Dfarmretail peer1
dfarmretail-peer1.dfarmretail.com:
container_name: dfarmretail-peer1.dfarmretail.com
image: hyperledger/fabric-peer:$IMAGE_TAG
environment:
- FABRIC_CFG_PATH=/var/hyperledger/config
# - CORE_LOGGING_LEVEL=debug
- FABRIC_LOGGING_SPEC=INFO
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_dfarm
- CORE_PEER_ID=dfarmretail-peer1.dfarmretail.com
- CORE_PEER_ADDRESS=dfarmretail-peer1.dfarmretail.com:8051
# - CORE_PEER_LISTENADDRESS=dfarmretail-peer1.dfarmretail.com:8051
- CORE_PEER_LISTENADDRESS=dfarmretail-peer1.dfarmretail.com:8051
- CORE_PEER_CHAINCODELISTENADDRESS=dfarmretail-peer1.dfarmretail.com:8052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=dfarmretail-peer1.dfarmretail.com:8051
- CORE_PEER_LOCALMSPID=DfarmretailMSP
- CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp
- CORE_PEER_TLS_ENABLED=false
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
# - CORE_PEER_GOSSIP_USELEADERELECTION=true
# - CORE_PEER_GOSSIP_ORGLEADER=false
# - CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_FILESYSTEMPATH=/var/ledger
working_dir: $HOME
# command: peer node start --peer-chaincodedev=true
command: peer node start
volumes:
# Folder with channel create tx file
- ${PWD}/config:/var/hyperledger/channeltx
# Map the folder with MSP for Peer
- ${PWD}/client/dfarmretail/peer1/msp:/var/hyperledger/msp
# Map the current folder to cfg
- ${PWD}/config:/var/hyperledger/config
- /var/run/:/host/var/run/
# Ledger folder for the peer
- ${HOME}/ledgers/ca/dfarmretail-peer1.dfarmretail.com:/var/ledger
depends_on:
- orderer.dfarmadmin.com
ports:
- 8051:8051
- 8052:8052
- 8053:8053
networks:
- dfarm
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 5984:5984
networks:
- dfarm
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=dfarmadmin-peer1.dfarmadmin.com:7051
- CORE_PEER_LOCALMSPID=DfarmadminMSP
#- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
- CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp
- CORE_CHAINCODE_KEEPALIVE=10
working_dir: $HOME
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/
networks:
- dfarm
depends_on:
- orderer.dfarmadmin.com
- dfarmadmin-peer1.dfarmadmin.com
- couchdb
我的docker-compose-ca.yaml
# Docker compose for overriding the State DB setup for the peers
version: '2'
networks:
dfarm:
services:
root.caserver.com:
container_name: root.caserver.com
hostname: root
domainname: caserver.com
image: hyperledger/fabric-ca:$IMAGE_TAG
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=root.caserver
- FABRIC_CA_SERVER_TLS_ENABLED=false
# - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
# - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY
ports:
- "7054:7054"
command: sh -c 'fabric-ca-server start --cfg.identities.allowremove --cfg.affiliations.allowremove'
volumes:
- ${PWD}/server:/etc/hyperledger/fabric-ca-server
networks:
- dfarm
用于fabric-ca init的My Init.sh文件
docker-compose -f docker-compose-ca.yaml down
rm -rf ./server/*
rm -rf ./client/*
cp fabric-ca-server-config.yaml ./server
docker-compose -f docker-compose-ca.yaml up -d
sleep 3s
# Bootstrap enrollment
export FABRIC_CA_CLIENT_HOME=$PWD/client/caserver/admin
fabric-ca-client enroll -u http://admin:adminpw@localhost:7054
######################
# Admin registration #
######################
echo "Registering: dfarmadmin-admin"
ATTRIBUTES='"hf.Registrar.Roles=peer,user,client","hf.AffiliationMgr=true","hf.Revoker=true","hf.Registrar.Attributes=*"'
fabric-ca-client register --id.type client --id.name dfarmadmin-admin --id.secret adminpw --id.affiliation dfarmadmin --id.attrs $ATTRIBUTES
# 3. Register dfarmretail-admin
echo "Registering: dfarmretail-admin"
ATTRIBUTES='"hf.Registrar.Roles=peer,user,client","hf.AffiliationMgr=true","hf.Revoker=true","hf.Registrar.Attributes=*"'
fabric-ca-client register --id.type client --id.name dfarmretail-admin --id.secret adminpw --id.affiliation dfarmretail --id.attrs $ATTRIBUTES
# 4. Register orderer-admin
echo "Registering: orderer-admin"
ATTRIBUTES='"hf.Registrar.Roles=orderer"'
fabric-ca-client register --id.type client --id.name orderer-admin --id.secret adminpw --id.affiliation orderer --id.attrs $ATTRIBUTES
####################
# Admin Enrollment #
####################
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/admin
fabric-ca-client enroll -u http://dfarmadmin-admin:adminpw@localhost:7054
mkdir -p $FABRIC_CA_CLIENT_HOME/msp/admincerts
cp $FABRIC_CA_CLIENT_HOME/../../caserver/admin/msp/signcerts/* $FABRIC_CA_CLIENT_HOME/msp/admincerts
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmretail/admin
fabric-ca-client enroll -u http://dfarmretail-admin:adminpw@localhost:7054
mkdir -p $FABRIC_CA_CLIENT_HOME/msp/admincerts
cp $FABRIC_CA_CLIENT_HOME/../../caserver/admin/msp/signcerts/* $FABRIC_CA_CLIENT_HOME/msp/admincerts
export FABRIC_CA_CLIENT_HOME=$PWD/client/orderer/admin
fabric-ca-client enroll -u http://orderer-admin:adminpw@localhost:7054
mkdir -p $FABRIC_CA_CLIENT_HOME/msp/admincerts
cp $FABRIC_CA_CLIENT_HOME/../../caserver/admin/msp/signcerts/* $FABRIC_CA_CLIENT_HOME/msp/admincerts
#################
# Org MSP Setup #
#################
# Path to the CA certificate
ROOT_CA_CERTIFICATE=./server/ca-cert.pem
mkdir -p ./client/orderer/msp/admincerts
mkdir ./client/orderer/msp/cacerts
mkdir ./client/orderer/msp/keystore
cp $ROOT_CA_CERTIFICATE ./client/orderer/msp/cacerts
cp ./client/orderer/admin/msp/signcerts/* ./client/orderer/msp/admincerts
mkdir -p ./client/dfarmadmin/msp/admincerts
mkdir ./client/dfarmadmin/msp/cacerts
mkdir ./client/dfarmadmin/msp/keystore
cp $ROOT_CA_CERTIFICATE ./client/dfarmadmin/msp/cacerts
cp ./client/dfarmadmin/admin/msp/signcerts/* ./client/dfarmadmin/msp/admincerts
mkdir -p ./client/dfarmretail/msp/admincerts
mkdir ./client/dfarmretail/msp/cacerts
mkdir ./client/dfarmretail/msp/keystore
cp $ROOT_CA_CERTIFICATE ./client/dfarmretail/msp/cacerts
cp ./client/dfarmretail/admin/msp/signcerts/* ./client/dfarmretail/msp/admincerts
######################
# Orderer Enrollment #
######################
export FABRIC_CA_CLIENT_HOME=$PWD/client/orderer/admin
fabric-ca-client register --id.type orderer --id.name orderer --id.secret adminpw --id.affiliation orderer
export FABRIC_CA_CLIENT_HOME=$PWD/client/orderer/orderer
fabric-ca-client enroll -u http://orderer:adminpw@localhost:7054
cp -a $PWD/client/orderer/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
####################
# Peer Enrollments #
####################
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/admin
fabric-ca-client register --id.type peer --id.name dfarmadmin-peer1 --id.secret adminpw --id.affiliation dfarmadmin
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/peer1
fabric-ca-client enroll -u http://dfarmadmin-peer1:adminpw@localhost:7054
cp -a $PWD/client/dfarmadmin/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmretail/admin
fabric-ca-client register --id.type peer --id.name dfarmretail-peer1 --id.secret adminpw --id.affiliation dfarmretail
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmretail/peer1
fabric-ca-client enroll -u http://dfarmretail-peer1:adminpw@localhost:7054
cp -a $PWD/client/dfarmretail/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
##############################
# User Enrollments Dfarmadmin only #
##############################
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/admin
ATTRIBUTES='"hf.AffiliationMgr=false:ecert","hf.Revoker=false:ecert","app.accounting.role=manager:ecert","department=accounting:ecert"'
fabric-ca-client register --id.type user --id.name mary --id.secret pw --id.affiliation dfarmadmin --id.attrs $ATTRIBUTES
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/mary
fabric-ca-client enroll -u http://mary:pw@localhost:7054
cp -a $PWD/client/dfarmadmin/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/admin
ATTRIBUTES='"hf.AffiliationMgr=false:ecert","hf.Revoker=false:ecert","app.accounting.role=accountant:ecert","department=accounting:ecert"'
fabric-ca-client register --id.type user --id.name john --id.secret pw --id.affiliation dfarmadmin --id.attrs $ATTRIBUTES
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/john
fabric-ca-client enroll -u http://john:pw@localhost:7054
cp -a $PWD/client/dfarmadmin/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/admin
ATTRIBUTES='"hf.AffiliationMgr=false:ecert","hf.Revoker=false:ecert","department=logistics:ecert","app.logistics.role=specialis:ecert"'
fabric-ca-client register --id.type user --id.name anil --id.secret pw --id.affiliation dfarmadmin --id.attrs $ATTRIBUTES
export FABRIC_CA_CLIENT_HOME=$PWD/client/dfarmadmin/anil
fabric-ca-client enroll -u http://anil:pw@localhost:7054
cp -a $PWD/client/dfarmadmin/admin/msp/signcerts $FABRIC_CA_CLIENT_HOME/msp/admincerts
# Shutdown CA
# docker-compose -f docker-compose-ca.yaml down
# Setup network config
export FABRIC_CFG_PATH=$PWD/config
configtxgen -outputBlock ./config/orderer/dfarm-genesis.block -channelID ordererchannel -profile DfarmOrdererGenesis
configtxgen -outputCreateChannelTx ./config/dfarmchannel.tx -channelID dfarmchannel -profile DfarmChannel
ANCHOR_UPDATE_TX=./config/dfarm-anchor-update-dfarmadmin.tx
configtxgen -profile DfarmChannel -outputAnchorPeersUpdate $ANCHOR_UPDATE_TX -channelID dfarmchannel -asOrg DfarmadminMSP
ANCHOR_UPDATE_TX=./config/dfarm-anchor-update-dfarmretail.tx
configtxgen -profile DfarmChannel -outputAnchorPeersUpdate $ANCHOR_UPDATE_TX -channelID dfarmchannel -asOrg DfarmretailMSP
最后一个setup.sh文件用于初始化通道,并将对等方加入通道。
docker-compose down
# REMOVE the dev- container images also - TBD
docker rm $(docker ps -a -q) &> /dev/null
docker rmi $(docker images dev-* -q) &> /dev/null
sudo rm -rf $HOME/ledgers/ca &> /dev/null
docker-compose up -d
SLEEP_TIME=3s
echo '========= Submitting txn for channel creation as DfarmadminAdmin ============'
export CHANNEL_TX_FILE=./config/dfarm-channel.tx
export ORDERER_ADDRESS=orderer.dfarmadmin.com:7050
# export FABRIC_LOGGING_SPEC=DEBUG
export CORE_PEER_LOCALMSPID=DfarmadminMSP
export CORE_PEER_MSPCONFIGPATH=$PWD/client/dfarmadmin/admin/msp
export CORE_PEER_ADDRESS=dfarmadmin-peer.dfarmadmin.com:7051
peer channel create -o $ORDERER_ADDRESS -c dfarmchannel -f ./dfarmchannel.tx
echo '========= Joining the dfarmadmin-peer1 to Dfarm channel ============'
DFARM_CHANNEL_BLOCK=./dfarmchannel.block
export CORE_PEER_ADDRESS=dfarmadmin-peer.dfarmadmin.com:7051
peer channel join -o $ORDERER_ADDRESS -b $DFARM_CHANNEL_BLOCK
# Update anchor peer on channel for dfarmadmin
# sleep 3s
sleep $SLEEP_TIME
ANCHOR_UPDATE_TX=./config/dfarm-anchor-update-dfarmadmin.tx
peer channel update -o $ORDERER_ADDRESS -c dfarmchannel -f $ANCHOR_UPDATE_TX
echo '========= Joining the dfarmretail-peer1 to Dfarm channel ============'
# peer channel fetch config $DFARM_CHANNEL_BLOCK -o $ORDERER_ADDRESS -c dfarmchannel
export CORE_PEER_LOCALMSPID=DfarmretailMSP
ORG_NAME=dfarmretail.com
export CORE_PEER_ADDRESS=dfarmretail-peer.dfarmretail.com:8051
export CORE_PEER_MSPCONFIGPATH=$PWD/client/dfarmretail/admin/msp
peer channel join -o $ORDERER_ADDRESS -b $DFARM_CHANNEL_BLOCK
# Update anchor peer on channel for dfarmretail
sleep $SLEEP_TIME
ANCHOR_UPDATE_TX=./config/dfarm-anchor-update-dfarmretail.tx
peer channel update -o $ORDERER_ADDRESS -c dfarmchannel -f $ANCHOR_UPDATE_TX
请帮助我,我尝试了很多但很困惑
有关文件夹和文件https://github.com/abhisamant7/Hyperledger_project/tree/master/network
的更多详细信息答案 0 :(得分:0)
FABRIC_CFG_PATH该变量需要core.yaml的路径。文件
- FABRIC_CFG_PATH=/var/hyperledger/config
在/ var / hyperledger / config上,您尝试挂载不存在的目录,因此从技术上讲,您的/ var / hyperledger / config路径为空
- ${PWD}/config/orderer:/var/hyperledger/config
为此
- ${PWD}/config:/var/hyperledger/config
这将起作用,只需确保所有安装正确即可