我所做的修改不是三个组织,而是我仅创建一个。 我能够创建和启动Docker容器,创建通道并加入该通道。然后安装链代码,但是在尝试实例化链代码时遇到问题。该错误通常是: 错误:批注链码错误:rpc错误:代码=未知desc =访问被拒绝:频道[mychannel]创建者单位[Org1Msp]
当我查看docker日志中的peer0.org1.example.com时,我遇到了 2018-10-29 01:22:43.494 UTC [protoutils] ValidateProposalMessage-> WARN 228通道[mychannel]:MSP错误:提供的身份无效:x509:证书由未知授权机构签名(可能由于“ x509:ECDSA验证”失败”,同时尝试验证候选授权证书“ ca.org1.example.com”) 我也用类似的禁用TLS或类似的问题来运行它。
我能够成功地从fab-car,基本网络和edX课程中的tuna-app示例等结构示例中运行示例。当我自己做事情时,我必须忽略一些事情。感谢您提供任何帮助,即使只是告诉我要去哪里看看。
我觉得值得一提。 我的目标是能够创建一个有许多同行的单一组织,并且现在就可以创建SOLO进行订购。欢迎任何建议。
除了更改组织数目之外,所有内容都将严格遵循。 我将包括我正在使用的所有文件,希望对您有所帮助。
peer-base.yaml
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'
services:
peer-base:
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=example_basic_network
#- CORE_LOGGING_LEVEL=INFO
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=false
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
docker-compose-base.yaml
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
version: '2'
services:
orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
- ORDERER_GENERAL_LOGLEVEL=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=false
- 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]
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/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
#- orderer.example.com:/var/hyperledger/production/orderer
ports:
- 7050:7050
peer0.org1.example.com:
container_name: peer0.org1.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer0.org1.example.com:/var/hyperledger/production
ports:
- 7051:7051
- 7053:7053
peer1.org1.example.com:
container_name: peer1.org1.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org1.example.com
- CORE_PEER_ADDRESS=peer1.org1.example.com:8051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:8051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer1.org1.example.com:/var/hyperledger/production
ports:
- 8051:7051
- 8053:7053
peer2.org1.example.com:
container_name: peer2.org1.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer2.org1.example.com
- CORE_PEER_ADDRESS=peer2.org1.example.com:9051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer2.org1.example.com:9051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer2.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer2.org1.example.com/tls:/etc/hyperledger/fabric/tls
- peer2.org1.example.com:/var/hyperledger/production
ports:
- 9051:7051
- 9053:7053
我用来自动化的bash脚本 build.sh 运行的命令是: ./build.sh -g ./build.sh -l </ p>
#!/bin/bash
# define some things up here
export CHANNEL_NAME=mychannel
CHANNEL_NAME=mychannel
function generate_material()
{
echo -e "======\n Generating Crypto material \n======="
cryptogen generate --config=./crypto-config.yaml
echo -e "======\n Creating channel artifacts \n======="
export FABRIC_CFG_PATH=$PWD
mkdir channel-artifacts
configtxgen -profile NsolOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
echo "Should say Writing genesis block above"
configtxgen -profile NsolChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
echo "Should say writing new channel tx above"
configtxgen -profile NsolChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
echo "Should say writing anchor peer update above"
}
function launch_dockers()
{
echo "Starting up docker containers"
CHANNEL_NAME=$CHANNEL_NAME docker-compose -f docker-compose-cli.yaml up -d
echo "going to display the containers"
docker ps
}
function run_cli()
{
echo "entering docker container ' cli '"
docker exec -it cli bash
}
function clean()
{
rm -rf crypto-config
rm -rf channel-artifacts
docker rm -f $(docker ps -aq)
echo "cleaned"
exit
}
if [ "$1" == '-c' ]; then
clean
elif [ "$1" == '-g' ]; then
generate_material
elif [ "$1" == '-l' ]; then
launch_dockers
elif [ "$1" == '-t' ]; then
run_cli
else
echo "usage:"
echo "-c : clean note, may need to run as root"
echo "-g : generate materials"
echo "-l : launch dockers"
echo "-t : run cli with script"
fi
最后,为了方便起见,在脚本中包含的cli docker容器上运行的代码。 cli.sh
#!/bin/bash
# ! This script is run inside the cli container
# this script is meant to be carried over to the cli container.
# from there it will run at start up and execute the commands to create the
# channel
cd ..
export CHANNEL_NAME=mychannel
CHANNEL_NAME=mychannel
#peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx
#peer channel join -b mychannel.block
#peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx
#peer chaincode install -n chaincodez -v 1.0 -p github.com/chaincode/chaincode_example02/go/
#peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n chaincodez -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.member')"
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
#
peer channel join -b mychannel.block
#
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
#
peer chaincode install -n nncc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
#
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n nncc -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member')"
#
echo "FINISHED??"
# run this to keep the container alive
/bin/bash
答案 0 :(得分:0)
那么,您的cli.sh在cli容器中运行了吗?
您确定MSP和证书的环境路径如下:
CORE_PEER_MSPCONFIGPATH
CORE_PEER_TLS_ROOTCERT_FILE
cli容器的指向admin或org1的证书吗?