安装条件:
Ubuntu18.04
virtualbox,忘了第几版了,这个不影响。
其实运行起来很简单,主要是!!!下载二进制文件和docker镜像实在是太!慢!了!每次下载到半截就卡住了,所以决定先下载好这些再运行
你要备好的东西:
1.安装docker
2.安装docker-compose
这俩安装相对简单就不说了,网上很多教程
ljm@ljm-VirtualBox:~$ docker -v
Docker version 18.09.2, build 6247962
ljm@ljm-VirtualBox:~$ docker-compose -v
docker-compose version 1.17.1, build unknown
ljm@ljm-VirtualBox:~$ go version
go version go1.12 linux/amd64
3.go语言和环境配置
下载go语言的tar包go1.12.linux-amd64.tar.gz
至少11以上,我选的12
命令行输入
sudo nautilus
其他位置->计算机
把你的go的安装包解压到user/local这个地方,看图
接着开始配置环境变量
命令行输入
sudo gedit /etc/profile
把这个加到文件末尾,注意,GOPATH的ljm是我的用户名,换成你自己的
export GOROOT=/usr/local/go
export GOARCH=amd64
export GOOS=linux
export GOPATH=/home/ljm
export GOBIN=$GOROOT/bin
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
接着保存退出,这个肯定会吧,按ESC键,接着:wq
命令行输入
source /etc/profile
就算成功了,可以用go version查看安装的版本
4.重点来了,按理说应该装Fabric Samples,二进制文件,docker镜像,从官网拉取实在是太慢了,所以我先提前在Windows下载好放在Ubuntu了,主要是一个bootstrap.sh,hyperledger-fabric-ca-linux-amd64-1.4.3.tar.gz和hyperledger-fabric-linux-amd64-1.4.3.tar.gz文件。运行
chmod 777 ./scripts/bootstrap.sh
./scripts/bootstrap.sh
会得到一个bin文件夹和一个config文件夹,我整理好了,可以直接下载。hyperledger fabric samples1.4.3
然后进入/first-network运行就行了,代码我放下面了。
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# ./byfn.sh generate
bash: ./byfn.sh: 权限不够
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# chmod 777 ./byfn.sh
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# ./byfn.sh generate
Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
/home/ljm/fabric-samples/first-network/../bin/cryptogen
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x
Generate CCP files for Org1 and Org2
./byfn.sh: line 371: ./ccp-generate.sh: Permission denied
/home/ljm/fabric-samples/first-network/../bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2019-11-04 10:19:25.086 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-04 10:19:25.464 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2019-11-04 10:19:25.464 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:25.683 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2019-11-04 10:19:25.683 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:25.685 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2019-11-04 10:19:25.685 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2019-11-04 10:19:25.766 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-04 10:19:25.998 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:26.218 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-04 10:19:26.219 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:26.219 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2019-11-04 10:19:26.221 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2019-11-04 10:19:26.301 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-04 10:19:26.499 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:26.737 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-04 10:19:26.737 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:26.737 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-11-04 10:19:26.737 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2019-11-04 10:19:26.813 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-04 10:19:27.022 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:27.242 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-04 10:19:27.242 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/ljm/fabric-samples/first-network/configtx.yaml
2019-11-04 10:19:27.242 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-11-04 10:19:27.242 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.3
DOCKER_IMAGE_VERSION=1.4.3
Creating network "net_byfn" with the default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
Creating peer0.org2.example.com ...
Creating orderer.example.com ...
Creating peer1.org1.example.com ...
Creating peer0.org1.example.com ...
Creating peer1.org2.example.com ...
Creating peer0.org2.example.com
Creating orderer.example.com
Creating peer1.org1.example.com
Creating peer0.org1.example.com
Creating peer0.org1.example.com ... done
Creating cli ...
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
520f50e0d7fc hyperledger/fabric-tools:latest "/bin/bash" 4 seconds ago Up Less than a second cli
a64198e580a9 hyperledger/fabric-peer:latest "peer node start" 13 seconds ago Up 5 seconds 0.0.0.0:10051->10051/tcp peer1.org2.example.com
480f3136d52b hyperledger/fabric-peer:latest "peer node start" 13 seconds ago Up 5 seconds 0.0.0.0:8051->8051/tcp peer1.org1.example.com
187396dd640a hyperledger/fabric-peer:latest "peer node start" 13 seconds ago Up 4 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
2001aec6150b hyperledger/fabric-orderer:latest "orderer" 13 seconds ago Up 4 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
18749b5a53b8 hyperledger/fabric-peer:latest "peer node start" 13 seconds ago Up 6 seconds 0.0.0.0:9051->9051/tcp peer0.org2.example.com
16907172c3c0 dev-peer0.org5.example.com-drugledger-1.0-656a087839edf0e8685024ed6cbb2ed480365d037cc2ff9cafea4dfe411fa8af "chaincode -peer.add…" 2 weeks ago Exited (0) 2 weeks ago dev-peer0.org5.example.com-drugledger-1.0
a24dbde88db7 dev-peer0.org4.example.com-drugledger-1.0-9e6d8350b92aaaa243632284e73ded070e83c913935537a5d2d3f43ba27d9d38 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org4.example.com-drugledger-1.0
076745a5e7d4 dev-peer0.org3.example.com-drugledger-1.0-c36e6bfe55251db653ae360681b357c99e4bd7d90d7c0294d9e81e354b2a25c5 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org3.example.com-drugledger-1.0
bbae648c793c dev-peer0.org2.example.com-drugledger-1.0-7e82332585de2c35508f69061126a6a856c12d16c4f27b72feaf7dcf04eac8d6 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org2.example.com-drugledger-1.0
341321633b7f dev-peer0.org1.example.com-drugledger-1.0-ae1a3106f95855644cbb6b960bd0524d5e6cc640080a36269091d52745833bb9 "chaincode -peer.add…" 2 weeks ago Exited (0) 2 weeks ago dev-peer0.org1.example.com-drugledger-1.0
7022db1b5c7f 304fac59b501 "peer node start" 2 weeks ago Exited (0) 2 weeks ago peer0.org5.example.com
d018636fe20c 304fac59b501 "peer node start" 2 weeks ago Exited (0) 2 weeks ago peer0.org4.example.com
ffb1843658b2 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7064->7054/tcp ca2.example.com
7d7ac395a7b1 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7054->7054/tcp ca.example.com
4034c635af05 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb5
61fda86a43f8 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7094->7054/tcp ca5.example.com
35d0aa87275a hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb
224cc79a1de9 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb4
d88bc7fb1713 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7074->7054/tcp ca3.example.com
5b00b828a14e 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7084->7054/tcp ca4.example.com
OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"scripts/script.sh\": permission denied": unknown
ERROR !!!! Test failed
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# cd scripts
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network/scripts# chmod 777 script.sh
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network/scripts# cd ..
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network# ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.3
DOCKER_IMAGE_VERSION=1.4.3
peer1.org2.example.com is up-to-date
peer0.org2.example.com is up-to-date
peer0.org1.example.com is up-to-date
orderer.example.com is up-to-date
peer1.org1.example.com is up-to-date
cli is up-to-date
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
520f50e0d7fc hyperledger/fabric-tools:latest "/bin/bash" About a minute ago Up About a minute cli
a64198e580a9 hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:10051->10051/tcp peer1.org2.example.com
480f3136d52b hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:8051->8051/tcp peer1.org1.example.com
187396dd640a hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp peer0.org1.example.com
2001aec6150b hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com
18749b5a53b8 hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:9051->9051/tcp peer0.org2.example.com
16907172c3c0 dev-peer0.org5.example.com-drugledger-1.0-656a087839edf0e8685024ed6cbb2ed480365d037cc2ff9cafea4dfe411fa8af "chaincode -peer.add…" 2 weeks ago Exited (0) 2 weeks ago dev-peer0.org5.example.com-drugledger-1.0
a24dbde88db7 dev-peer0.org4.example.com-drugledger-1.0-9e6d8350b92aaaa243632284e73ded070e83c913935537a5d2d3f43ba27d9d38 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org4.example.com-drugledger-1.0
076745a5e7d4 dev-peer0.org3.example.com-drugledger-1.0-c36e6bfe55251db653ae360681b357c99e4bd7d90d7c0294d9e81e354b2a25c5 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org3.example.com-drugledger-1.0
bbae648c793c dev-peer0.org2.example.com-drugledger-1.0-7e82332585de2c35508f69061126a6a856c12d16c4f27b72feaf7dcf04eac8d6 "chaincode -peer.add…" 2 weeks ago Exited (2) 2 weeks ago dev-peer0.org2.example.com-drugledger-1.0
341321633b7f dev-peer0.org1.example.com-drugledger-1.0-ae1a3106f95855644cbb6b960bd0524d5e6cc640080a36269091d52745833bb9 "chaincode -peer.add…" 2 weeks ago Exited (0) 2 weeks ago dev-peer0.org1.example.com-drugledger-1.0
7022db1b5c7f 304fac59b501 "peer node start" 2 weeks ago Exited (0) 2 weeks ago peer0.org5.example.com
d018636fe20c 304fac59b501 "peer node start" 2 weeks ago Exited (0) 2 weeks ago peer0.org4.example.com
ffb1843658b2 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7064->7054/tcp ca2.example.com
7d7ac395a7b1 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7054->7054/tcp ca.example.com
4034c635af05 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb5
61fda86a43f8 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7094->7054/tcp ca5.example.com
35d0aa87275a hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb
224cc79a1de9 hyperledger/fabric-couchdb "tini -- /docker-ent…" 2 weeks ago Exited (143) 2 weeks ago couchdb4
d88bc7fb1713 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7074->7054/tcp ca3.example.com
5b00b828a14e 1a804ab74f58 "sh -c 'fabric-ca-se…" 2 weeks ago Exited (255) 2 days ago 0.0.0.0:7084->7054/tcp ca4.example.com
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
Build your first network (BYFN) end-to-end test
Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-04 02:21:31.726 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:32.040 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-04 02:21:32.547 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:32.665 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-04 02:21:35.863 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:35.971 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-04 02:21:39.133 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:39.339 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-04 02:21:42.493 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:42.690 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' =====================
Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-04 02:21:45.853 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:45.903 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-04 02:21:49.064 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-04 02:21:49.102 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
2019-11-04 02:21:52.281 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-04 02:21:52.281 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-04 02:21:54.497 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:"OK" >
===================== Chaincode is installed on peer0.org1 =====================
Install chaincode on peer0.org2...
+ res=0
+ set +x
+ peer chaincode instantiate -o orderer.example.com:7050 --tls true --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 mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
2019-11-04 02:21:54.713 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-04 02:21:54.713 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-04 02:21:55.052 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:"OK" >
===================== Chaincode is installed on peer0.org2 =====================
Instantiating chaincode on peer0.org2...
+ res=0
+ set +x
2019-11-04 02:21:55.235 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-04 02:21:55.235 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
===================== Chaincode is instantiated on peer0.org2 on channel 'mychannel' =====================
Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x
100
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --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 mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
2019-11-04 02:24:21.108 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================
Installing chaincode on peer1.org2...
+ res=0
+ set +x
2019-11-04 02:24:21.282 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-04 02:24:21.282 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-04 02:24:21.614 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:"OK" >
===================== Chaincode is installed on peer1.org2 =====================
Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... =====================
Attempting to Query peer1.org2 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x
90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
root@ljm-VirtualBox:/home/ljm/fabric-samples/first-network#
结束
曾经遇到的错误
1:Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
ERROR !!! Test failed
解决:时延问题,15改成90,或者多等一会
2:Error: got unexpected status: BAD_REQUEST – error authorizing update: error validating ReadSet: readset expected key [Group] /Channel/Application at version 0, but got version 1
ERROR !!! Test failed
解决:已经有容器在运行,先关闭,./byfn.sh down //不同的程序关闭代码不一样
3.在终端执行shell脚本后,出现问题如下:
[root]# ./start.sh
bash: ./start.sh: 权限不够
解决方法是先使用chmod命令对shell脚本赋予权限,再执行
[root]# chmod 777 ./start.sh
[root]# ./start.sh
4.ERROR: Couldn’t connect to Docker daemon - you might need to run docker-machine start default
.
Error! Not able to start up the network
解决:切换为root用户
5.OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused “exec: “scripts/script.sh”: permission denied”: unknown
ERROR !!! Test failed
改时延10-》90