우분투 16.04 LTS 설치 직 후 테스트
1. apt update & upgrade
fabric@fabric:~$ sudo apt update
fabric@fabric:~$ sudo apt upgrade -y
2. Install git, cURL, wget
(1) git
fabric@fabric:~$ sudo apt-get install -y git
fabric@fabric:~$ git version
git version 2.7.4
(2) curl
fabric@fabric:~$ sudo apt-get install -y curl
fabric@fabric:~$ curl --version
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
(3) wget
fabric@fabric:~$ sudo apt-get install wget
fabric@fabric:~$ wget --version
GNU Wget 1.17.1 built on linux-gnu.
3. Install docker and docker-compose
* install docker document: https://docs.docker.com/install/linux/docker-ce/ubuntu/
* docker repository: https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
[required] Docker Engine: Version 17.06.2-ce or higher
[required] Docker Compose: Version 1.14.0 or greater installed
(1) Install Docker
fabric@fabric:~$ sudo apt-get install -y apt-transport-https ca-certificates gnupg-agent software-properties-common
fabric@fabric:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
fabric@fabric:~$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <docker@docker.com>
sub 4096R/F273FCD8 2017-02-22
fabric@fabric:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
fabric@fabric:~$ sudo apt-get update
fabric@fabric:~$ apt-cache madison docker-ce
docker-ce | 5:19.03.5~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 5:19.03.4~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 5:19.03.3~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
...
fabric@fabric:~$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
fabric@fabric:~$ docker --version
Docker version 19.03.5, build 633a0ea838
fabric@fabric:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
(2) Install Docker Compose
fabric@fabric:~$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 1193 0 --:--:-- --:--:-- --:--:-- 1193
100 16.4M 100 16.4M 0 0 3314k 0 0:00:05 0:00:05 --:--:-- 4153k
fabric@fabric:~$ sudo chmod +x /usr/local/bin/docker-compose
fabric@fabric:~$ docker-compose --version
bash: /usr/bin/docker-compose: 그런 파일이나 디렉터리가 없습니다
* 위와 같은 문제가 발생하면 아래 명령어 수행
fabric@fabric:~$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fabric@fabric:~$ docker-compose --version
docker-compose version 1.25.3, build d4d1b42b
4. Go Lang Download (1.12.x)
* Go version 1.12.x is required.
* Download reference: https://golang.org/dl/
fabric@fabric:~$ wget https://dl.google.com/go/go1.12.16.linux-amd64.tar.gz
fabric@fabric:~$ sudo tar -C /usr/local -xzf go1.12.16.linux-amd64.tar.gz
fabric@fabric:~$ sudo vim /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
# Go Path 추가
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
fabric@fabric:~$ source /etc/profile
fabric@fabric:~$ echo $GOROOT
/usr/local/go
fabric@fabric:~$ echo $PATH
/home/fabric/bin:/home/fabric/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin
fabric@fabric:~$ go version
go version go1.12.16 linux/amd64
5. Install Node.js
Node.js version 10 is supported from 10.15.3 and higher.
fabric@fabric:~$ sudo curl -sL http://deb.nodesource.com/setup_10.x | sudo -E bash --
fabric@fabric:~$ sudo apt install -y nodejs
fabric@fabric:~$ node -v
v10.19.0
fabric@fabric:~$ npm -v
6.13.4
6. Install Python (2.7.x)
fabric@fabric:~$ sudo apt-get install python
fabric@fabric:~$ python --version
Python 2.7.12
7. Install Hyperledger Fabric 1.4
fabric@fabric:~$ curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.4 1.4.4 0.4.18
Clone hyperledger/fabric-samples repo
...
...
===> List out hyperledger docker images
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/json: dial unix /var/run/docker.sock: connect: permission denied
(permission denied 문제 해결)
https://stackoverflow.com/questions/48957195/how-to-fix-docker-got-permission-denied-issue
fabric@fabric:~$ curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.4 1.4.4 0.4.18
...
...
===> List out hyperledger docker images
hyperledger/fabric-javaenv 1.4 4648059d209e 2 months ago 1.7GB
hyperledger/fabric-javaenv 1.4.4 4648059d209e 2 months ago 1.7GB
hyperledger/fabric-javaenv latest 4648059d209e 2 months ago 1.7GB
hyperledger/fabric-ca 1.4 62a60c5459ae 2 months ago 150MB
hyperledger/fabric-ca 1.4.4 62a60c5459ae 2 months ago 150MB
hyperledger/fabric-ca latest 62a60c5459ae 2 months ago 150MB
hyperledger/fabric-tools 1.4 7552e1968c0b 2 months ago 1.49GB
hyperledger/fabric-tools 1.4.4 7552e1968c0b 2 months ago 1.49GB
hyperledger/fabric-tools latest 7552e1968c0b 2 months ago 1.49GB
hyperledger/fabric-ccenv 1.4 ca4780293e4c 2 months ago 1.37GB
hyperledger/fabric-ccenv 1.4.4 ca4780293e4c 2 months ago 1.37GB
hyperledger/fabric-ccenv latest ca4780293e4c 2 months ago 1.37GB
hyperledger/fabric-orderer 1.4 dbc9f65443aa 2 months ago 120MB
hyperledger/fabric-orderer 1.4.4 dbc9f65443aa 2 months ago 120MB
hyperledger/fabric-orderer latest dbc9f65443aa 2 months ago 120MB
hyperledger/fabric-peer 1.4 9756aed98c6b 2 months ago 128MB
hyperledger/fabric-peer 1.4.4 9756aed98c6b 2 months ago 128MB
hyperledger/fabric-peer latest 9756aed98c6b 2 months ago 128MB
hyperledger/fabric-zookeeper 0.4 ede9389347db 3 months ago 276MB
hyperledger/fabric-zookeeper 0.4.18 ede9389347db 3 months ago 276MB
hyperledger/fabric-zookeeper latest ede9389347db 3 months ago 276MB
hyperledger/fabric-kafka 0.4 caaae0474ef2 3 months ago 270MB
hyperledger/fabric-kafka 0.4.18 caaae0474ef2 3 months ago 270MB
hyperledger/fabric-kafka latest caaae0474ef2 3 months ago 270MB
hyperledger/fabric-couchdb 0.4 d369d4eaa0fd 3 months ago 261MB
hyperledger/fabric-couchdb 0.4.18 d369d4eaa0fd 3 months ago 261MB
hyperledger/fabric-couchdb latest d369d4eaa0fd 3 months ago 261MB
fabric@fabric:~$ sudo vim /etc/profile
...
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
# Fabric 환경변수 설정
export FABRIC_HOME=/home/fabric/fabric-samples
export PATH=$PATH:$FABRIC_HOME/bin
fabric@fabric:~$ source /etc/profile
fabric@fabric:~$ cd $FABRIC_HOME/
fabric@fabric:~/fabric-samples$ ls
fabric@fabric:~/fabric-samples$ cd first-network/
fabric@fabric:~/fabric-samples/first-network$ ls
README.md
ccp-template.yaml
crypto-config.yaml
docker-compose-e2e-template.yaml
org3-artifacts base
channel-artifacts
docker-compose-ca.yaml
docker-compose-etcdraft2.yaml
scripts byfn.sh
configtx.yaml
docker-compose-cli.yaml
docker-compose-kafka.yaml ccp-generate.sh
connection-org3.json
docker-compose-couch-org3.yaml
docker-compose-org3.yaml ccp-template.json
connection-org3.yaml
docker-compose-couch.yaml
eyfn.sh
fabric@fabric:~/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/fabric/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
/home/fabric/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
2020-02-07 06:52:03.372 KST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-02-07 06:52:03.449 KST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2020-02-07 06:52:03.449 KST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.525 KST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2020-02-07 06:52:03.525 KST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.527 KST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2020-02-07 06:52:03.527 KST [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
2020-02-07 06:52:03.550 KST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-02-07 06:52:03.629 KST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.706 KST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2020-02-07 06:52:03.706 KST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.706 KST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2020-02-07 06:52:03.707 KST [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
2020-02-07 06:52:03.731 KST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-02-07 06:52:03.817 KST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.902 KST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2020-02-07 06:52:03.902 KST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:03.902 KST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2020-02-07 06:52:03.902 KST [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
2020-02-07 06:52:03.935 KST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-02-07 06:52:04.018 KST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:04.104 KST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2020-02-07 06:52:04.104 KST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/fabric-samples/first-network/configtx.yaml
2020-02-07 06:52:04.104 KST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2020-02-07 06:52:04.104 KST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
fabric@fabric:~/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.4
DOCKER_IMAGE_VERSION=1.4.4
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer0.org1.example.com ... done
Creating orderer.example.com ... done
Creating peer0.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80ab1a74473b hyperledger/fabric-tools:latest "/bin/bash" 1 second ago Up Less than a second cli
768a7b690e09 hyperledger/fabric-peer:latest "peer node start" 6 seconds ago Up 2 seconds 0.0.0.0:10051->10051/tcp peer1.org2.example.com
eae1421a981c hyperledger/fabric-peer:latest "peer node start" 6 seconds ago Up 3 seconds 0.0.0.0:8051->8051/tcp peer1.org1.example.com
b7bd23622c1c hyperledger/fabric-peer:latest "peer node start" 6 seconds ago Up 4 seconds 0.0.0.0:9051->9051/tcp peer0.org2.example.com
d56c746cf04c hyperledger/fabric-orderer:latest "orderer" 6 seconds ago Up 1 second 0.0.0.0:7050->7050/tcp orderer.example.com
a099b769ced5 hyperledger/fabric-peer:latest "peer node start" 6 seconds ago Up 4 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
b4dbc08936a5 hello-world "/hello" 9 minutes ago Exited (0) 9 minutes ago wonderful_johnson
da4107116ad4 hello-world "/hello" 11 hours ago Exited (0) 11 hours ago kind_shannon
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
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
2020-02-06 21:52:35.846 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:35.918 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
+ peer channel join -b mychannel.block
Having all peers join the channel...
+ res=0
+ set +x
2020-02-06 21:52:35.977 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:36.098 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
2020-02-06 21:52:39.154 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:39.267 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
2020-02-06 21:52:42.317 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:42.440 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
2020-02-06 21:52:45.495 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:45.601 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
2020-02-06 21:52:48.651 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:48.659 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
2020-02-06 21:52:51.716 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-02-06 21:52:51.724 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
2020-02-06 21:52:54.778 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-02-06 21:52:54.778 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-02-06 21:52:55.104 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== Chaincode is installed on peer0.org1 =====================
Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-02-06 21:52:55.156 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-02-06 21:52:55.156 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-02-06 21:52:55.307 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== Chaincode is installed on peer0.org2 =====================
Instantiating chaincode on peer0.org2...
+ 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'\'')'
+ res=0
+ set +x
2020-02-06 21:52:55.368 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-02-06 21:52:55.368 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'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer0.org1 ...3 secs
+ 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
2020-02-06 21:53:35.720 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...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-02-06 21:53:35.776 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-02-06 21:53:35.776 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-02-06 21:53:35.943 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
===================== 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 ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
fabric@fabric:~/fabric-samples/first-network$ ./byfn.sh down
Stopping for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
WARNING: The BYFN_CA1_PRIVATE_KEY variable is not set. Defaulting to a blank string.
WARNING: The BYFN_CA2_PRIVATE_KEY variable is not set. Defaulting to a blank string.
Stopping cli ... done
Stopping peer1.org2.example.com ... done
Stopping peer1.org1.example.com ... done
...
...
Deleted: sha256:9756ec14da6a2db311be0e417e8d46c7c94ea9a15e33c155d6135e887cc2a8cc
Deleted: sha256:a8b72d4a6d81530815da03be3ffe1be505058766596643be85abdf76133f7f12
fabric@fabric:~/fabric-samples/first-network$ sudo vim /etc/profile
...
export FABRIC_HOME=/home/fabric/fabric-samples
export PATH=$PATH:$FABRIC_HOME/bin
# first-network path 추가
export FABRIC_CFG_PATH=$FABRIC_HOME/first-network
fabric@fabric:~/fabric-samples/first-network$ source /etc/profile
fabric@fabric:~$ cd $FABRIC_HOME/
fabric@fabric:~/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 ...
fabric@fabric:~/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 ...
fabric@fabric:~/fabric-samples/first-network$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b0e5c187b3df dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.add…" 2 minutes ago Up 2 minutes dev-peer1.org2.example.com-mycc-1.0
...
fabric@fabric:~/fabric-samples/first-network$ ./byfn.sh down
Stopping for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
fabric@fabric:~/fabric-samples/first-network$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fabric@fabric:~/fabric-samples/first-network$ ./byfn.sh up
fabric@fabric:~/fabric-samples/first-network$ docker exec -it cli bash
root@c12bbe44fc9c:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer version
peer:
Version: 1.4.4
Commit SHA: 7917a40ff
Go version: go1.12.12
OS/Arch: linux/amd64
Chaincode:
Base Image Version: 0.4.18
Base Docker Namespace: hyperledger
Base Docker Label: org.hyperledger.fabric
Docker Namespace: hyperledger
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# echo $CHANNEL_NAME
mychannel
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
90
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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 $CHANNEL_NAME -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"]}'
2020-02-07 00:01:48.074 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
80
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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 $CHANNEL_NAME -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","b","a","50"]}'
2020-02-07 00:02:36.463 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
root@1479d2693812:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
130
reference
[1] https://hyperledger-fabric.readthedocs.io/en/release-1.4/getting_started.html
[2] https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html