这是我的第一篇文章,因此,我将尽可能详细,并说明重现这些错误的步骤。我想用其他对等扩展给定的Fabcar示例,但是我无法查询/调用扩展的系统。如果我尝试查询系统,则会出现以下错误:
Query has completed, checking results error from query = Error: make sure the chaincode fabcar has been successfully instantiated and try again: getccdata mychannel/fabcar responded with error: could not find chaincode with name 'fabcar' at /home/hyperledger/Dokumente/Hyperledger_test/Fabric-SamplesV4/fabric-samples/fabcar/node_modules/fabric-client/lib/Channel.js:2638:24 at <anonymous>
如果我运行docker ps -a命令,它将显示以下内容:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7eabee4c4eb2 hyperledger/fabric-peer "peer node start" 39 minutes ago Up 38 minutes 0.0.0.0:8151->7051/tcp, 0.0.0.0:8153->7053/tcp peer1.org1.example.com 4aaf1b4c063b hyperledger/fabric-couchdb "tini -- /docker-ent…" 39 minutes ago Up 39 minutes 4369/tcp, 9100/tcp, 0.0.0.0:9984->5984/tcp couchdb1 831facf5abad hyperledger/fabric-peer "peer node start" 39 minutes ago Up 39 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com 1a9cd9b9f3fb hyperledger/fabric-orderer "orderer" 39 minutes ago Up 39 minutes 0.0.0.0:7050->7050/tcp orderer.example.com e33bfb4374eb hyperledger/fabric-couchdb "tini -- /docker-ent…" 39 minutes ago Up 39 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb 2cfb85e6aa9e hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 39 minutes ago Up 39 minutes 0.0.0.0:7054->7054/tcp ca.example.com
如您所见,开发人员不见了,如果您构建原始的Fabcar示例,则会显示此同行。
如果我为peer0运行docker logs命令,它将显示以下内容:
2018-08-16 07:21:29.804 UTC [ledgermgmt] CreateLedger -> INFO 023 Creating ledger [mychannel] with genesis block 2018-08-16 07:21:29.838 UTC [fsblkstorage] newBlockfileMgr -> INFO 024 Getting block information from block storage 2018-08-16 07:21:30.246 UTC [couchdb] CreateDatabaseIfNotExist -> INFO 025 Created state database mychannel_ 2018-08-16 07:21:30.421 UTC [kvledger] CommitWithPvtData -> INFO 026 Channel [mychannel]: Committed block [0] with 1 transaction(s) 2018-08-16 07:21:30.422 UTC [pvtdatastorage] func1 -> INFO 027 Purger started: Purging expired private data till block number [0] 2018-08-16 07:21:30.422 UTC [pvtdatastorage] func1 -> INFO 028 Purger finished 2018-08-16 07:21:30.577 UTC [ledgermgmt] CreateLedger -> INFO 029 Created ledger [mychannel] with genesis block 2018-08-16 07:21:30.726 UTC [cscc] Init -> INFO 02a Init CSCC 2018-08-16 07:21:30.726 UTC [sccapi] deploySysCC -> INFO 02b system chaincode cscc/mychannel(github.com/hyperledger/fabric/core/scc/cscc) deployed 2018-08-16 07:21:30.726 UTC [sccapi] deploySysCC -> INFO 02c system chaincode lscc/mychannel(github.com/hyperledger/fabric/core/scc/lscc) deployed 2018-08-16 07:21:30.727 UTC [qscc] Init -> INFO 02d Init QSCC 2018-08-16 07:21:30.727 UTC [sccapi] deploySysCC -> INFO 02e system chaincode qscc/mychannel(github.com/hyperledger/fabric/core/scc/qscc) deployed 2018-08-16 07:21:36.730 UTC [gossip/election] beLeader -> INFO 02f [60 150 184 106 152 137 128 154 149 235 201 184 164 27 185 56 26 64 112 155 28 70 77 95 96 101 28 51 209 225 187 117] : Becoming a leader 2018-08-16 07:22:57.514 UTC [couchdb] CreateDatabaseIfNotExist -> INFO 030 Created state database mychannel_lscc 2018-08-16 07:22:57.519 UTC [lscc] Invoke -> ERRO 031 error getting chaincode fabcar on channel [mychannel]: could not find chaincode with name 'fabcar'
重现此结果的步骤:
在基本网络文件夹中进行了更改:
Crypto-config.yaml-将模板计数值更改为2
Docker-compose.yml-复制了peer0和benchdb,并更改了端口/名称
peer1.org1.example.com: container_name: peer1.org1.example.com image: hyperledger/fabric-peer environment: - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - CORE_PEER_ID=peer1.org1.example.com - CORE_LOGGING_PEER=info - CORE_CHAINCODE_LOGGING_LEVEL=info - CORE_PEER_LOCALMSPID=Org1MSP - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/ - CORE_PEER_ADDRESS=peer1.org1.example.com:7051 # # 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=${COMPOSE_PROJECT_NAME}_basic # - CORE_PEER_TLS_ENABLED=true - 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 - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984 # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD # provide the credentials for ledger to connect to CouchDB. The username and password must # match the username and password set for the associated CouchDB. - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME= - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD= working_dir: /opt/gopath/src/github.com/hyperledger/fabric command: peer node start # command: peer node start --peer-chaincodedev=true ports: - 8151:7051 - 8153:7053 volumes: - /var/run/:/host/var/run/ - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.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 - couchdb1 networks: - basic couchdb1: container_name: couchdb1 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: - 9984:5984 networks: - basic
运行generate.sh文件以创建所需的加密材料
扩展start.sh文件以在整个系统中创建新对等项
# don't rewrite paths for Windows Git Bash users export MSYS_NO_PATHCONV=1 docker-compose -f docker-compose.yml down docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb sleep 0.2 docker-compose -f docker-compose.yml up -d peer1.org1.example.com couchdb1 # wait for Hyperledger Fabric to start # incase of errors when running later commands, issue export FABRIC_START_TIMEOUT= export FABRIC_START_TIMEOUT=10 #echo ${FABRIC_START_TIMEOUT} sleep ${FABRIC_START_TIMEOUT} # Create the channel docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx # Join peer0.org1.example.com to the channel. docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel join -b mychannel.block
运行start.sh文件以启动系统
运行docker log ca.example以获取新的ca.example私钥,并在docker-compose.yml文件中更改旧的私钥
再次运行start.sh文件,现在您应该可以在Docker环境中看到新的对等项
peer1的docker exec命令出错:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel join -b mychannel.block 2018-08-16 08:06:35.608 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized Error: genesis block file not found open mychannel.block: no such file or directory
为什么第二个对等方的创世块丢失了,这个对等方是否可能无法访问该块?
切换到fabcar文件夹并运行startFabric.sh文件
注册管理员并注册用户
尝试查询新系统,您将收到上面显示的查询错误
问题:这些步骤中是否缺少某些内容,或者为什么无法在对等方上安装链码并正确运行网络?
答案 0 :(得分:0)
mychannel.block是在运行以下命令时创建的:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
mychannel.block在peer0.org1.example.com泊坞容器中创建。
当您运行此命令时,它是从peer1.org1.example.com泊坞容器运行的,因此它将没有mychannel.block文件,因此您必须获取该文件,然后运行第二个对等连接命令。
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel join -b mychannel.block
获取命令是:
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel
因此,在加入第二个对等方(peer1.org1.example.com)之前添加此提取命令
赞:
# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer1.org1.example.com peer channel join -b mychannel.block