适合CCCV操作的Fabric 1.4.6部署方案

Fabric 1.4.6部署方案
配置CentOS的系统
查看Linux 发行版
cat /etc/*-release
修改为多用户状态
执行:

systemctl set-default multi-user.target

设置yum源并升级系统

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum update

在 CentOS 7.× 上启用 ELRepo 仓库,运行:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

仓库启用后,使用下面的命令列出可用的系统内核相关包:

yum --disablerepo="*" --enablerepo=“elrepo-kernel” list available

安装最新的主线稳定内核:

yum --enablerepo=elrepo-kernel install kernel-ml

设置启动顺序

grub2-set-default “Linux (5.5.3-1.el7.elrepo.x86_64) 7 (Core)”

grub2-set-default “Linux (5.6.7-1.el7.elrepo.x86_64) 7 (Core)”

grub2-set-default “Linux (3.10.0-1062.9.1.el7.x86_64)”

grub2-editenv list

reboot

创建用户组和用户

/usr/sbin/groupadd fabric

/usr/sbin/groupadd dba

/usr/sbin/useradd -m -g fabric -G dba fabric

passwd fabric

允许fabric用户su –
编辑:

vi /etc/sudoers

添加
fabric ALL=(ALL) NOPASSWD: /bin/su
fabric用户互认
解决Bad owner or permissions on /home/fabric/.ssh/config

chmod 600 /home/fabric/.ssh/config

sshUserSetup.sh
$ ./sshUserSetup.sh -user fabric -hosts “10.11.2.34 10.11.2.35 10.11.2.36 10.11.2.37” -advanced -noPromptPassphrase
修改每台机器的/etc/hosts
10.11.2.34
10.11.2.35
10.11.2.36
10.11.2.37
linux 系统参数调整和网络参数调整
echo “kernel.shmmni = 4096” >> /etc/sysctl.conf
echo “kernel.sem = 250 32000 100 128” >> /etc/sysctl.conf
echo “fs.file-max = 65536” >> /etc/sysctl.conf
echo “net.ipv4.ip_local_port_range = 1024 65000” >> /etc/sysctl.conf
echo “net.core.rmem_default = 262144” >> /etc/sysctl.conf
echo “net.core.rmem_max = 262144” >> /etc/sysctl.conf
echo “net.core.wmem_default = 262144” >> /etc/sysctl.conf
echo “net.core.wmem_max = 262144” >>/etc/sysctl.conf
echo “net.bridge.bridge-nf-call-ip6tables=1” >>/etc/sysctl.conf
echo “net.bridge.bridge-nf-call-iptables=1” >>/etc/sysctl.conf
echo “net.bridge.bridge-nf-call-arptables=1” >>/etc/sysctl.conf
echo “net.ipv4.ip_forward=1” >>/etc/sysctl.conf
生效
sysctl -p
展示
sysctl -a
安装NODEJS
wget https://nodejs.org/download/release/v8.9.4/node-v8.9.4-linux-x64.tar.gz

下载后解压:
tar -zxf node-v8.9.4-linux-x64.tar.gz

安装目录/opt/
sudo mv node-v8.9.4-linux-x64 /opt

安装npm和node:
ln -s /opt/node-v8.9.4-linux-x64/bin/node /usr/local/bin/node
ln -s /opt/node-v8.9.4-linux-x64/bin/npm /usr/local/bin/npm
安装golang
下载的软件包

wget -c https://studygolang.com/dl/golang/go1.13.7.linux-amd64.tar.gz

wget -c https://studygolang.com/dl/golang/go1.14.2.linux-amd64.tar.gz
解压到指定目录

tar -C /opt/ -xzf go*.linux-amd64.tar.gz

配置环境变量
修改~/.bash_profile
export GOROOT=/opt/go
export GOPATH=~/go
export GOARCH=amd64
export GOOS=linux
export GOBIN= G O P A T H / b i n e x p o r t P A T H = GOPATH/bin export PATH= GOPATH/binexportPATH=PATH: G O R O O T / b i n : GOROOT/bin: GOROOT/bin:GOBIN:./
export LANG=zh_CN.UTF-8

环境变量生效

source ~/.bash_profile

安装goimports
$ mkdir -p $GOPATH/src/golang.org/x
$ cd $GOPATH/src/golang.org/x
$ git clone https://github.com/golang/tools.git
$ go get golang.org/x/tools/cmd/goimports
$ go get -u github.com/client9/misspell/cmd/misspell
go get -u github.com/golang/dep/cmd/dep
go get github.com/axw/gocov/gocov
go get github.com/vektra/mockery/cmd/mockery
安装docker

yum install libtool-ltdl

yum install libcgroup*

yum install container-selinux

yum install pigz

yum install glibc*

扩展yum功能

yum install -y yum-utils

添加软件源信息

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

自动选择最快yum仓库源

yum makecache fast

查看所有仓库中所有docker版本,并选择特定版本安装

yum list docker-ce --showduplicates | sort -r

安装docker

yum install -y docker-ce

docker version

Docker version 19.03.5, build 633a0ea
启动docker

systemctl status docker.service

systemctl start docker.service

systemctl enable docker

开发环境下:解决错误dial unix /var/run/docker.sock: connect: permission denied

  1. 将当前用户加入到docker组中

    sudo gpasswd -a fabric docker

  2. 将当前用户切换到docker组中
    $ newgrp docker
    另有临时方法:docker服务重启, 需要重新设置一次

    cd /var/run

    sudo chmod 666 docker.sock

安装docker compose

curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

sha256sum /usr/local/bin/docker-compose

常用LINUX命令
查看linux 端口信息

lsof -i

netstat -ano

netstat -tunlp

清理证书文件
linux 下用find命令查找文件,rm命令删除文件。
删除指定目录下指定文件
find ./. -name *.tx | xargs rm -rf
find ./. -name genesisblock | xargs rm -rf
find ./. -name *.block | xargs rm -rf

删除指定名称的文件或文件夹:
find -type d | grep channel-artifacts$ | xargs rm -r
rm -rf /var/hyperledger/production
同步时间
ntpdate -u ntp.api.bz

编译安装hyperledger fabric
下载fabric源代码
在下列网址下载最新的主线版本的zip文件
https://github.com/hyperledger/fabric
$ wget -c https://github.com/hyperledger/fabric/archive/master.zip
$ mkdir -p ~/go/src/github.com/hyperledger/
$ unzip -d ~/go/src/github.com/hyperledger/master.zip
进入工作目录
$ cd ~/go/src/github.com/hyperledger/
$ ln -s fabric-master fabric
编译fabric
hyperledger fabric工程概况
Go项目的Makefile文件的部分注释

- all (default) - builds all targets and runs all non-integration tests/checks

- checks - runs all non-integration tests/checks

- desk-check - runs linters and verify to test changed packages

- configtxgen - builds a native configtxgen binary

- configtxlator - builds a native configtxlator binary

- cryptogen - builds a native cryptogen binary

- idemixgen - builds a native idemixgen binary

- peer - builds a native fabric peer binary

- orderer - builds a native fabric orderer binary

- release - builds release packages for the host platform

- release-all - builds release packages for all target platforms

- publish-images - publishes release docker images to nexus3 or docker hub.

- unit-test - runs the go-test based unit tests

- verify - runs unit tests for only the changed package tree

- profile - runs unit tests for all packages in coverprofile mode (slow)

- gotools - installs go tools like golint

- linter - runs all code checks

- check-deps - check for vendored dependencies that are no longer used

- license - checks go source files for Apache license header

- native - ensures all native binaries are available

- docker[-clean] - ensures all docker images are available[/cleaned]

- docker-list - generates a list of docker images that ‘make docker’ produces

- peer-docker[-clean] - ensures the peer container is available[/cleaned]

- orderer-docker[-clean] - ensures the orderer container is available[/cleaned]

- tools-docker[-clean] - ensures the tools container is available[/cleaned]

- protos - generate all protobuf artifacts based on .proto files

- clean - cleans the build area

- clean-all - superset of ‘clean’ that also removes persistent state

- dist-clean - clean release packages for all target platforms

- unit-test-clean - cleans unit test state (particularly from docker)

- basic-checks - performs basic checks like license, spelling, trailing spaces and linter

- docker-thirdparty - pulls thirdparty images (kafka,zookeeper,couchdb)

- docker-tag-latest - re-tags the images made by ‘make docker’ with the :latest tag

- docker-tag-stable - re-tags the images made by ‘make docker’ with the :stable tag

- help-docs - generate the command reference docs

$ cd fabric
$ make all
编译完成后
在build/bin文件夹里会出现如下可执行文件
configtxgen configtxlator cryptogen discover idemixgen orderer peer
查看文件版本:
[fabric@localhost bin]$ ./peer version
peer:
Version: 2.0.0
Commit SHA:
Go version: go1.13.7
OS/Arch: linux/amd64
Chaincode:
Base Docker Namespace: hyperledger
Base Docker Label: org.hyperledger.fabric
Docker Namespace: hyperledger

[fabric@localhost bin]$ ./orderer version
orderer:
Version: 2.0.0
Commit SHA:
Go version: go1.13.7
OS/Arch: linux/amd64
体验Hyperledger Fabric1.4.6的first-network
git clone https://github.com/hyperledger/fabric-samples
byfn.sh generate
[fabric@localhost 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/github.com/hyperledger/fabric-samples/bin/cryptogen

##########################################################

Generate certificates using cryptogen tool

##########################################################

  • cryptogen generate --config=./crypto-config.yaml
    org1.example.com
    org2.example.com
  • res=0
  • set +x

/home/fabric/github.com/hyperledger/fabric-samples/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo

  • ‘[’ solo == solo ‘]’
  • configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
    2020-04-28 19:42:52.822 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-28 19:42:52.861 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
    2020-04-28 19:42:52.861 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:52.905 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
    2020-04-28 19:42:52.906 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:52.907 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
    2020-04-28 19:42:52.907 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
    2020-04-28 19:42:52.946 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-28 19:42:52.985 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.026 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
    2020-04-28 19:42:53.026 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.026 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
    2020-04-28 19:42:53.028 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
    2020-04-28 19:42:53.073 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-28 19:42:53.111 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.154 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
    2020-04-28 19:42:53.154 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.154 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
    2020-04-28 19:42:53.154 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
    2020-04-28 19:42:53.194 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-28 19:42:53.232 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.273 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
    2020-04-28 19:42:53.273 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-28 19:42:53.273 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
    2020-04-28 19:42:53.274 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
  • res=0
  • set +x
    byfn.sh up
    [fabric@localhost 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.0
    DOCKER_IMAGE_VERSION=1.4.6
    =================== WARNING ===================
    Local fabric binaries and docker images are
    out of sync. This may cause problems.
    ===============================================
    Starting peer0.org1.example.com …
    peer1.org1.example.com is up-to-date
    peer0.org2.example.com is up-to-date
    Starting peer0.org1.example.com … done
    Starting orderer.example.com … done
    Creating cli … done

/ | | | / \ | _ \ | |
_
\ | | / _ \ | |
) | | |
) | | | / ___ \ | _ < | |
|
/ || // _\ || _\ |_|

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-04-28 08:04:29.062 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:29.109 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
    2020-04-28 08:04:29.186 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:29.289 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-04-28 08:04:32.369 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:32.480 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-04-28 08:04:35.563 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:35.683 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-04-28 08:04:38.757 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:38.937 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-04-28 08:04:42.020 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:42.038 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-04-28 08:04:45.116 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-28 08:04:45.133 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-04-28 08:04:48.217 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2020-04-28 08:04:48.217 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2020-04-28 08:04:48.510 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-04-28 08:04:48.588 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2020-04-28 08:04:48.588 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2020-04-28 08:04:48.899 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-04-28 08:04:48.984 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2020-04-28 08:04:48.984 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:7051 --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-04-28 08:05:14.851 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-04-28 08:05:14.932 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2020-04-28 08:05:14.932 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2020-04-28 08:05:15.211 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 ===========


| | | \ | | | _ \
| | | | | | | | |
| |
| |\ | | |
| |
|_____| |
| _| |____/
运行时的docker
[fabric@localhost first-network]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b35bada43a01 dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab “chaincode -peer.add…” 6 seconds ago Up 4 seconds dev-peer1.org2.example.com-mycc-1.0
f6c6ca8dcad0 dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 “chaincode -peer.add…” 20 seconds ago Up 19 seconds dev-peer0.org1.example.com-mycc-1.0
8a26d8338496 dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b “chaincode -peer.add…” 35 seconds ago Up 33 seconds dev-peer0.org2.example.com-mycc-1.0
1278e6ba3fba hyperledger/fabric-tools:latest “/bin/bash” About a minute ago Up About a minute cli
f005b19b7387 hyperledger/fabric-peer:latest “peer node start” About a minute ago Up About a minute 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com
198125658d9a hyperledger/fabric-orderer:latest “orderer” About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com
8e8f5d6ccf38 hyperledger/fabric-peer:latest “peer node start” About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
0f24d0c92bc0 hyperledger/fabric-peer:latest “peer node start” About a minute ago Up About a minute 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
d2cf8f303b51 hyperledger/fabric-peer:latest “peer node start” About a minute ago Up About a minute 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
体验Hyperledger Fabric2.1.0的first-network
git clone https://github.com/hyperledger/fabric-samples
byfn.sh generate

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=2.1.0
DOCKER_IMAGE_VERSION=2.1.0
/home/fabric/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/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################

  • configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
    2020-04-29 17:32:34.380 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-29 17:32:34.424 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
    2020-04-29 17:32:34.424 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:“500ms” election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
    2020-04-29 17:32:34.424 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-29 17:32:34.428 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
    2020-04-29 17:32:34.428 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
  • res=0
  • set +x

#################################################################

Generating channel configuration transaction ‘channel.tx’

#################################################################

  • configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
    2020-04-29 17:32:34.457 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-29 17:32:34.500 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-29 17:32:34.500 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
    2020-04-29 17:32:34.505 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 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-04-29 17:32:34.536 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-29 17:32:34.579 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-29 17:32:34.579 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
    2020-04-29 17:32:34.582 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 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-04-29 17:32:34.613 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-29 17:32:34.656 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
    2020-04-29 17:32:34.656 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
    2020-04-29 17:32:34.658 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
  • res=0
  • set +x

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 volume “net_orderer2.example.com” with default driver
Creating volume “net_orderer3.example.com” with default driver
Creating volume “net_orderer4.example.com” with default driver
Creating volume “net_orderer5.example.com” with default driver
Creating orderer.example.com … done
Creating peer0.org2.example.com … done
Creating peer0.org1.example.com … done
Creating peer1.org2.example.com … done
Creating orderer4.example.com … done
Creating orderer3.example.com … done
Creating orderer5.example.com … done
Creating orderer2.example.com … done
Creating peer1.org1.example.com … done
Creating cli … done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
349c041f0c0c hyperledger/fabric-tools:latest “/bin/bash” 1 second ago Up Less than a second cli
a2df5320585a hyperledger/fabric-orderer:latest “orderer” 3 seconds ago Up Less than a second 7050/tcp, 0.0.0.0:8050->8050/tcp orderer2.example.com
58c2f4235fdf hyperledger/fabric-peer:latest “peer node start” 3 seconds ago Up 1 second 7051/tcp, 0.0.0.0:8051->8051/tcp peer1.org1.example.com
5d6f7caa898c hyperledger/fabric-orderer:latest “orderer” 4 seconds ago Up 1 second 7050/tcp, 0.0.0.0:9050->9050/tcp orderer3.example.com
38e08fd50036 hyperledger/fabric-orderer:latest “orderer” 4 seconds ago Up 1 second 7050/tcp, 0.0.0.0:11050->11050/tcp orderer5.example.com
23d3aeaf46c8 hyperledger/fabric-orderer:latest “orderer” 4 seconds ago Up 1 second 7050/tcp, 0.0.0.0:10150->10150/tcp orderer4.example.com
87d0d0e679a2 hyperledger/fabric-peer:latest “peer node start” 4 seconds ago Up 2 seconds 7051/tcp, 0.0.0.0:10051->10051/tcp peer1.org2.example.com
301a0248c68e hyperledger/fabric-peer:latest “peer node start” 4 seconds ago Up 1 second 0.0.0.0:7051->7051/tcp peer0.org1.example.com
3de5715c8176 hyperledger/fabric-peer:latest “peer node start” 4 seconds ago Up 1 second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
253132600be2 hyperledger/fabric-orderer:latest “orderer” 4 seconds ago Up 2 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
491f9d058442 hyperledger/fabric-tools:latest “/bin/bash” About an hour ago Exited (0) About an hour ago peer0_cli
f4cca2322248 hyperledger/fabric-tools:latest “/bin/bash” About an hour ago Exited (0) About an hour ago ordererCli
252da3dad606 hyperledger/fabric-peer:latest “peer node start” About an hour ago Exited (2) About an hour ago peer0.org1.xinyuan0316.com
01fb8ed9686c hyperledger/fabric-couchdb “tini – /docker-ent…” About an hour ago Exited (143) About an hour ago couchdb0
3b9ca1989584 hyperledger/fabric-orderer:latest “orderer” About an hour ago Exited (0) About an hour ago orderer.xinyuan0316.com
Sleeping 15s to allow Raft cluster to complete booting
Vendoring Go dependencies …
~/github.com/hyperledger/fabric-samples/chaincode/abstore/go ~/github.com/hyperledger/fabric-samples/first-network
~/github.com/hyperledger/fabric-samples/first-network
Finished vendoring Go dependencies


/ | | | / \ | _ \ | |
_
\ | | / _ \ | |
) | | |
) | | | / ___ \ | _ < | |
|
/ || // _\ || _\ |_|

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-04-29 09:32:55.055 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:32:55.080 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
    2020-04-29 09:32:55.084 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
    2020-04-29 09:32:55.286 UTC [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-29 09:32:55.290 UTC [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
    2020-04-29 09:32:55.491 UTC [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-29 09:32:55.496 UTC [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
    2020-04-29 09:32:55.697 UTC [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-29 09:32:55.701 UTC [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
    2020-04-29 09:32:55.902 UTC [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-29 09:32:55.907 UTC [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
    2020-04-29 09:32:56.108 UTC [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-29 09:32:56.112 UTC [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
    2020-04-29 09:32:56.316 UTC [cli.common] readBlock -> INFO 00e Received block: 0
    ===================== Channel ‘mychannel’ created =====================

Having all peers join the channel…

  • peer channel join -b mychannel.block

  • res=0

  • set +x
    2020-04-29 09:32:56.383 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:32:56.446 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-04-29 09:32:59.510 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:32:59.607 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-04-29 09:33:02.673 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:33:02.764 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-04-29 09:33:05.831 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:33:05.920 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-04-29 09:33:08.983 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:33:09.000 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-04-29 09:33:12.058 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:33:12.077 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
    ===================== Anchor peers updated for org ‘Org2MSP’ on channel ‘mychannel’ =====================

  • peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1

  • res=0

  • set +x
    ===================== Chaincode is packaged on peer0.org1 =====================

Installing chaincode on peer0.org1…

  • peer lifecycle chaincode install mycc.tar.gz
  • res=0
  • set +x
    2020-04-29 09:33:25.994 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-29 09:33:25.994 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== Chaincode is installed on peer0.org1 =====================

Install chaincode on peer0.org2…

  • peer lifecycle chaincode install mycc.tar.gz

  • res=0

  • set +x
    2020-04-29 09:33:35.567 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-29 09:33:35.567 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== Chaincode is installed on peer0.org2 =====================

  • peer lifecycle chaincode queryinstalled

  • res=0

  • set +x
    Installed chaincodes on peer:
    Package ID: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f, Label: mycc_1
    PackageID is mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== Query installed successful on peer0.org1 on channel =====================

  • peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f --sequence 1 --waitForEvent

  • set +x
    2020-04-29 09:33:35.715 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
    2020-04-29 09:33:37.905 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [5a8660aef7adbe24f156ac67978641a9b043c5e9be9a63155f7a69d5e31d19b4] committed with status (VALID) at
    ===================== Chaincode definition approved on peer0.org1 on channel ‘mychannel’ =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org1 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: false
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org2 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: false
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f --sequence 1 --waitForEvent
  • set +x
    2020-04-29 09:33:44.153 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
    2020-04-29 09:33:46.414 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [948b8b62731c763c59cf28f9205c4baa61617291df393a0bd44da829b6f2b995] committed with status (VALID) at
    ===================== Chaincode definition approved on peer0.org2 on channel ‘mychannel’ =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org1 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: true
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org2 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: true
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • peer lifecycle chaincode commit -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 --channelID mychannel --name 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 --version 1 --sequence 1 --init-required
  • res=0
  • set +x
    2020-04-29 09:33:54.919 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [641f48c115b9de7e81b07a8c673264caaabbab69756e156e1a8c430e0830233a] committed with status (VALID) at peer0.org1.example.com:7051
    2020-04-29 09:33:54.932 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [641f48c115b9de7e81b07a8c673264caaabbab69756e156e1a8c430e0830233a] committed with status (VALID) at peer0.org2.example.com:9051
    ===================== Chaincode definition committed on channel ‘mychannel’ =====================

===================== Querying chaincode definition on peer0.org1 on channel ‘mychannel’… =====================
Attempting to Query committed status on peer0.org1 …3 secs

  • peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
  • res=0
  • set +x

Committed chaincode definition for chaincode ‘mycc’ on channel ‘mychannel’:
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Querying chaincode definition on peer0.org2 on channel ‘mychannel’… =====================
Attempting to Query committed status on peer0.org2 …3 secs

  • peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
  • res=0
  • set +x

Committed chaincode definition for chaincode ‘mycc’ on channel ‘mychannel’:
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • 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 --isInit -c ‘{“Args”:[“Init”,“a”,“100”,“b”,“100”]}’
  • res=0
  • set +x
    2020-04-29 09:34:01.192 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 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
    2020-04-29 09:34:04.376 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 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

90
===================== Query successful on peer0.org1 on channel ‘mychannel’ =====================
Installing chaincode on peer1.org2…

  • peer lifecycle chaincode install mycc.tar.gz
  • res=0
  • set +x
    2020-04-29 09:34:17.139 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-29 09:34:17.139 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== 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 ===========


| | | \ | | | _ \
| | | | | | | | |
| |
| |\ | | |
| |
|_____| |
| _| |____/

eyfn.sh up
[fabric@localhost first-network]$ ./eyfn.sh up
Starting with channel ‘mychannel’ and CLI timeout of ‘10’ seconds and CLI delay of ‘3’ seconds
Continue? [Y/n] y
proceeding …
/home/fabric/bin/cryptogen

###############################################################

Generate Org3 certificates using cryptogen tool

###############################################################

  • cryptogen generate --config=./org3-crypto.yaml
    org3.example.com
  • res=0
  • set +x

/home/fabric/bin/configtxgen
##########################################################
######### Generating Org3 config material ###############
##########################################################

  • configtxgen -printOrg Org3MSP
    2020-04-29 17:34:58.113 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-29 17:34:58.114 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 002 Loaded configuration: /home/fabric/github.com/hyperledger/fabric-samples/first-network/org3-artifacts/configtx.yaml
  • res=0
  • set +x

###############################################################
####### Generate and submit config tx to add Org3 #############
###############################################################

========= Creating config transaction to add org3 to network ===========

Fetching the most recent configuration block for the channel

  • peer channel fetch config config_block.pb -o orderer.example.com:7050 -c mychannel --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
    2020-04-29 09:34:58.319 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:34:58.323 UTC [cli.common] readBlock -> INFO 002 Received block: 7
    2020-04-29 09:34:58.323 UTC [channelCmd] fetch -> INFO 003 Retrieving last config block: 2
    2020-04-29 09:34:58.325 UTC [cli.common] readBlock -> INFO 004 Received block: 2
  • set +x
    Decoding config block to JSON and isolating config to config.json
  • configtxlator proto_decode --input config_block.pb --type common.Block
  • jq ‘.data.data[0].payload.data.config’
  • set +x
  • jq -s ‘.[0] * {“channel_group”:{“groups”:{“Application”:{“groups”: {“Org3MSP”:.[1]}}}}}’ config.json ./channel-artifacts/org3.json
  • set +x
  • configtxlator proto_encode --input config.json --type common.Config
  • configtxlator proto_encode --input modified_config.json --type common.Config
  • configtxlator compute_update --channel_id mychannel --original original_config.pb --updated modified_config.pb
  • configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate
  • jq .
    ++ cat config_update.json
  • echo ‘{“payload”:{“header”:{“channel_header”:{“channel_id”:“mychannel”, “type”:2}},“data”:{“config_update”:{’ ‘“channel_id”:’ ‘“mychannel”,’ ‘“isolated_data”:’ ‘{},’ ‘“read_set”:’ ‘{’ ‘“groups”:’ ‘{’ ‘“Application”:’ ‘{’ ‘“groups”:’ ‘{’ ‘“Org1MSP”:’ ‘{’ ‘“groups”:’ ‘{},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“1”’ ‘},’ ‘“Org2MSP”:’ ‘{’ ‘“groups”:’ ‘{},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“1”’ ‘}’ ‘},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{’ ‘“Admins”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Endorsement”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“LifecycleEndorsement”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Readers”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Writers”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“values”:’ ‘{’ ‘“Capabilities”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“value”:’ null, ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“version”:’ ‘“1”’ ‘}’ ‘},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“0”’ ‘},’ ‘“write_set”:’ ‘{’ ‘“groups”:’ ‘{’ ‘“Application”:’ ‘{’ ‘“groups”:’ ‘{’ ‘“Org1MSP”:’ ‘{’ ‘“groups”:’ ‘{},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“1”’ ‘},’ ‘“Org2MSP”:’ ‘{’ ‘“groups”:’ ‘{},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“1”’ ‘},’ ‘“Org3MSP”:’ ‘{’ ‘“groups”:’ ‘{},’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policies”:’ ‘{’ ‘“Admins”:’ ‘{’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policy”:’ ‘{’ ‘“type”:’ 1, ‘“value”:’ ‘{’ ‘“identities”:’ ‘[’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“ADMIN”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘}’ ‘],’ ‘“rule”:’ ‘{’ ‘“n_out_of”:’ ‘{’ ‘“n”:’ 1, ‘“rules”:’ ‘[’ ‘{’ ‘“signed_by”:’ 0 ‘}’ ‘]’ ‘}’ ‘},’ ‘“version”:’ 0 ‘}’ ‘},’ ‘“version”:’ ‘“0”’ ‘},’ ‘“Endorsement”:’ ‘{’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policy”:’ ‘{’ ‘“type”:’ 1, ‘“value”:’ ‘{’ ‘“identities”:’ ‘[’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“PEER”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘}’ ‘],’ ‘“rule”:’ ‘{’ ‘“n_out_of”:’ ‘{’ ‘“n”:’ 1, ‘“rules”:’ ‘[’ ‘{’ ‘“signed_by”:’ 0 ‘}’ ‘]’ ‘}’ ‘},’ ‘“version”:’ 0 ‘}’ ‘},’ ‘“version”:’ ‘“0”’ ‘},’ ‘“Readers”:’ ‘{’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policy”:’ ‘{’ ‘“type”:’ 1, ‘“value”:’ ‘{’ ‘“identities”:’ ‘[’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“ADMIN”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘},’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“PEER”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘},’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“CLIENT”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘}’ ‘],’ ‘“rule”:’ ‘{’ ‘“n_out_of”:’ ‘{’ ‘“n”:’ 1, ‘“rules”:’ ‘[’ ‘{’ ‘“signed_by”:’ 0 ‘},’ ‘{’ ‘“signed_by”:’ 1 ‘},’ ‘{’ ‘“signed_by”:’ 2 ‘}’ ‘]’ ‘}’ ‘},’ ‘“version”:’ 0 ‘}’ ‘},’ ‘“version”:’ ‘“0”’ ‘},’ ‘“Writers”:’ ‘{’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policy”:’ ‘{’ ‘“type”:’ 1, ‘“value”:’ ‘{’ ‘“identities”:’ ‘[’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“ADMIN”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘},’ ‘{’ ‘“principal”:’ ‘{’ ‘“msp_identifier”:’ ‘“Org3MSP”,’ ‘“role”:’ ‘“CLIENT”’ ‘},’ ‘“principal_classification”:’ ‘“ROLE”’ ‘}’ ‘],’ ‘“rule”:’ ‘{’ ‘“n_out_of”:’ ‘{’ ‘“n”:’ 1, ‘“rules”:’ ‘[’ ‘{’ ‘“signed_by”:’ 0 ‘},’ ‘{’ ‘“signed_by”:’ 1 ‘}’ ‘]’ ‘}’ ‘},’ ‘“version”:’ 0 ‘}’ ‘},’ ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“values”:’ ‘{’ ‘“MSP”:’ ‘{’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“value”:’ ‘{’ ‘“config”:’ ‘{’ ‘“admins”:’ ‘[],’ ‘“crypto_config”:’ ‘{’ ‘“identity_identifier_hash_function”:’ ‘“SHA256”,’ ‘“signature_hash_family”:’ ‘“SHA2”’ ‘},’ ‘“fabric_node_ous”:’ ‘{’ ‘“admin_ou_identifier”:’ ‘{’ ‘“certificate”:’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVRENDQWZlZ0F3SUJBZ0lRRE1hMWtZZUN6MjRCUWQzeTllazd1VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NeTVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEwTWprd09UTXdNREJhRncwek1EQTBNamN3T1RNd01EQmEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3pMbVY0WVcxd2JHVXVZMjl0TVJ3d0dnWURWUVFECkV4TmpZUzV2Y21jekxtVjRZVzF3YkdVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUKN3VFM1NFVmdxTWIzN0gxcGovT0xBbytEbW9tK1Zrc2prYkpON0xacnFuQkJoRVdXVnV4cTBFbE5uK0xTdkIxYQozckw3VTk0aFZxTXV5Mm1SajN0dHNLTnRNR3N3RGdZRFZSMFBBUUgvQkFRREFnR21NQjBHQTFVZEpRUVdNQlFHCkNDc0dBUVVGQndNQ0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01Da0dBMVVkRGdRaUJDRGwKZGRmeVkwMU0wNDZUSFN6cTJlL2hUbW0zZk5oVXRlVHk1S2E3S25nT2VEQUtCZ2dxaGtqT1BRUURBZ05IQURCRQpBaUJGc25HOVA2UENoZGtOdlBGWDlKTFhENWQrZ0t2b0JuZ1lBQlhXSk9lQlJnSWdDNzg4cG8vQUN4UGczaVhTCmxyR1EzRGpXMzRPR3diSXhXUVBpcHFWSisrRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”,’ ‘“organizational_unit_identifier”:’ ‘“admin”’ ‘},’ ‘“client_ou_identifier”:’ ‘{’ ‘“certificate”:’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVRENDQWZlZ0F3SUJBZ0lRRE1hMWtZZUN6MjRCUWQzeTllazd1VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NeTVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEwTWprd09UTXdNREJhRncwek1EQTBNamN3T1RNd01EQmEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3pMbVY0WVcxd2JHVXVZMjl0TVJ3d0dnWURWUVFECkV4TmpZUzV2Y21jekxtVjRZVzF3YkdVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUKN3VFM1NFVmdxTWIzN0gxcGovT0xBbytEbW9tK1Zrc2prYkpON0xacnFuQkJoRVdXVnV4cTBFbE5uK0xTdkIxYQozckw3VTk0aFZxTXV5Mm1SajN0dHNLTnRNR3N3RGdZRFZSMFBBUUgvQkFRREFnR21NQjBHQTFVZEpRUVdNQlFHCkNDc0dBUVVGQndNQ0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01Da0dBMVVkRGdRaUJDRGwKZGRmeVkwMU0wNDZUSFN6cTJlL2hUbW0zZk5oVXRlVHk1S2E3S25nT2VEQUtCZ2dxaGtqT1BRUURBZ05IQURCRQpBaUJGc25HOVA2UENoZGtOdlBGWDlKTFhENWQrZ0t2b0JuZ1lBQlhXSk9lQlJnSWdDNzg4cG8vQUN4UGczaVhTCmxyR1EzRGpXMzRPR3diSXhXUVBpcHFWSisrRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”,’ ‘“organizational_unit_identifier”:’ ‘“client”’ ‘},’ ‘“enable”:’ true, ‘“orderer_ou_identifier”:’ ‘{’ ‘“certificate”:’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVRENDQWZlZ0F3SUJBZ0lRRE1hMWtZZUN6MjRCUWQzeTllazd1VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NeTVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEwTWprd09UTXdNREJhRncwek1EQTBNamN3T1RNd01EQmEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3pMbVY0WVcxd2JHVXVZMjl0TVJ3d0dnWURWUVFECkV4TmpZUzV2Y21jekxtVjRZVzF3YkdVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUKN3VFM1NFVmdxTWIzN0gxcGovT0xBbytEbW9tK1Zrc2prYkpON0xacnFuQkJoRVdXVnV4cTBFbE5uK0xTdkIxYQozckw3VTk0aFZxTXV5Mm1SajN0dHNLTnRNR3N3RGdZRFZSMFBBUUgvQkFRREFnR21NQjBHQTFVZEpRUVdNQlFHCkNDc0dBUVVGQndNQ0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01Da0dBMVVkRGdRaUJDRGwKZGRmeVkwMU0wNDZUSFN6cTJlL2hUbW0zZk5oVXRlVHk1S2E3S25nT2VEQUtCZ2dxaGtqT1BRUURBZ05IQURCRQpBaUJGc25HOVA2UENoZGtOdlBGWDlKTFhENWQrZ0t2b0JuZ1lBQlhXSk9lQlJnSWdDNzg4cG8vQUN4UGczaVhTCmxyR1EzRGpXMzRPR3diSXhXUVBpcHFWSisrRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”,’ ‘“organizational_unit_identifier”:’ ‘“orderer”’ ‘},’ ‘“peer_ou_identifier”:’ ‘{’ ‘“certificate”:’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVRENDQWZlZ0F3SUJBZ0lRRE1hMWtZZUN6MjRCUWQzeTllazd1VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NeTVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEwTWprd09UTXdNREJhRncwek1EQTBNamN3T1RNd01EQmEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3pMbVY0WVcxd2JHVXVZMjl0TVJ3d0dnWURWUVFECkV4TmpZUzV2Y21jekxtVjRZVzF3YkdVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUKN3VFM1NFVmdxTWIzN0gxcGovT0xBbytEbW9tK1Zrc2prYkpON0xacnFuQkJoRVdXVnV4cTBFbE5uK0xTdkIxYQozckw3VTk0aFZxTXV5Mm1SajN0dHNLTnRNR3N3RGdZRFZSMFBBUUgvQkFRREFnR21NQjBHQTFVZEpRUVdNQlFHCkNDc0dBUVVGQndNQ0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01Da0dBMVVkRGdRaUJDRGwKZGRmeVkwMU0wNDZUSFN6cTJlL2hUbW0zZk5oVXRlVHk1S2E3S25nT2VEQUtCZ2dxaGtqT1BRUURBZ05IQURCRQpBaUJGc25HOVA2UENoZGtOdlBGWDlKTFhENWQrZ0t2b0JuZ1lBQlhXSk9lQlJnSWdDNzg4cG8vQUN4UGczaVhTCmxyR1EzRGpXMzRPR3diSXhXUVBpcHFWSisrRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”,’ ‘“organizational_unit_identifier”:’ ‘“peer”’ ‘}’ ‘},’ ‘“intermediate_certs”:’ ‘[],’ ‘“name”:’ ‘“Org3MSP”,’ ‘“organizational_unit_identifiers”:’ ‘[],’ ‘“revocation_list”:’ ‘[],’ ‘“root_certs”:’ ‘[’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNVRENDQWZlZ0F3SUJBZ0lRRE1hMWtZZUN6MjRCUWQzeTllazd1VEFLQmdncWhrak9QUVFEQWpCek1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWNNQm9HQTFVRUF4TVRZMkV1CmIzSm5NeTVsZUdGdGNHeGxMbU52YlRBZUZ3MHlNREEwTWprd09UTXdNREJhRncwek1EQTBNamN3T1RNd01EQmEKTUhNeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxVApZVzRnUm5KaGJtTnBjMk52TVJrd0Z3WURWUVFLRXhCdmNtY3pMbVY0WVcxd2JHVXVZMjl0TVJ3d0dnWURWUVFECkV4TmpZUzV2Y21jekxtVjRZVzF3YkdVdVkyOXRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUUKN3VFM1NFVmdxTWIzN0gxcGovT0xBbytEbW9tK1Zrc2prYkpON0xacnFuQkJoRVdXVnV4cTBFbE5uK0xTdkIxYQozckw3VTk0aFZxTXV5Mm1SajN0dHNLTnRNR3N3RGdZRFZSMFBBUUgvQkFRREFnR21NQjBHQTFVZEpRUVdNQlFHCkNDc0dBUVVGQndNQ0JnZ3JCZ0VGQlFjREFUQVBCZ05WSFJNQkFmOEVCVEFEQVFIL01Da0dBMVVkRGdRaUJDRGwKZGRmeVkwMU0wNDZUSFN6cTJlL2hUbW0zZk5oVXRlVHk1S2E3S25nT2VEQUtCZ2dxaGtqT1BRUURBZ05IQURCRQpBaUJGc25HOVA2UENoZGtOdlBGWDlKTFhENWQrZ0t2b0JuZ1lBQlhXSk9lQlJnSWdDNzg4cG8vQUN4UGczaVhTCmxyR1EzRGpXMzRPR3diSXhXUVBpcHFWSisrRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”’ ‘],’ ‘“signing_identity”:’ null, ‘“tls_intermediate_certs”:’ ‘[],’ ‘“tls_root_certs”:’ ‘[’ ‘“LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNXRENDQWYyZ0F3SUJBZ0lRUnVGczFiQlNIZ1pUbzBDcHRkd3RFREFLQmdncWhrak9QUVFEQWpCMk1Rc3cKQ1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0JNS1EyRnNhV1p2Y201cFlURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeQpZVzVqYVhOamJ6RVpNQmNHQTFVRUNoTVFiM0puTXk1bGVHRnRjR3hsTG1OdmJURWZNQjBHQTFVRUF4TVdkR3h6ClkyRXViM0puTXk1bGVHRnRjR3hsTG1OdmJUQWVGdzB5TURBME1qa3dPVE13TURCYUZ3MHpNREEwTWpjd09UTXcKTURCYU1IWXhDekFKQmdOVkJBWVRBbFZUTVJNd0VRWURWUVFJRXdwRFlXeHBabTl5Ym1saE1SWXdGQVlEVlFRSApFdzFUWVc0Z1JuSmhibU5wYzJOdk1Sa3dGd1lEVlFRS0V4QnZjbWN6TG1WNFlXMXdiR1V1WTI5dE1SOHdIUVlEClZRUURFeFowYkhOallTNXZjbWN6TG1WNFlXMXdiR1V1WTI5dE1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMEQKQVFjRFFnQUVuQURnOHllaFd1VGd3SEdYSGdPb3Vwams5VHBSYjc4c2YvQ21HWHhQYUF5VnBEanZYeE9zU1lpbApwRG9uMGFNMk1PNVhUdnFpMlhMNCt6OUhldXJBL0tOdE1Hc3dEZ1lEVlIwUEFRSC9CQVFEQWdHbU1CMEdBMVVkCkpRUVdNQlFHQ0NzR0FRVUZCd01DQmdnckJnRUZCUWNEQVRBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUNrR0ExVWQKRGdRaUJDQ1ZhWFpOejNRS3JvdDJlQkp3UGRBZXdJRmhvaU1ldXczbHA2eUFvWXJLa2pBS0JnZ3Foa2pPUFFRRApBZ05KQURCR0FpRUF1UmxlNXMyYnN1MHR1ejB3djdsZFNOQW96dVVGeGo0MTFBcGxqaDRuSG9VQ0lRRENteXRVCnFuQndzay9FSUZ0MjNlR3hNcTNiOUFMaUNpRFVXaVArMXJiaXF3PT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=”’ ‘]’ ‘},’ ‘“type”:’ 0 ‘},’ ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“mod_policy”:’ ‘“Admins”,’ ‘“policies”:’ ‘{’ ‘“Admins”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Endorsement”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“LifecycleEndorsement”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Readers”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘},’ ‘“Writers”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“policy”:’ null, ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“values”:’ ‘{’ ‘“Capabilities”:’ ‘{’ ‘“mod_policy”:’ ‘"",’ ‘“value”:’ null, ‘“version”:’ ‘“0”’ ‘}’ ‘},’ ‘“version”:’ ‘“2”’ ‘}’ ‘},’ ‘“mod_policy”:’ ‘"",’ ‘“policies”:’ ‘{},’ ‘“values”:’ ‘{},’ ‘“version”:’ ‘“0”’ ‘}’ ‘}}}}’
  • configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope
  • set +x

========= Config transaction to add org3 to network created =====

Signing config transaction

  • peer channel signconfigtx -f org3_update_in_envelope.pb
    2020-04-29 09:34:58.621 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
  • set +x

========= Submitting transaction from a different peer (peer0.org2) which also signs it =========

  • peer channel update -f org3_update_in_envelope.pb -c mychannel -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
    2020-04-29 09:34:58.674 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:34:58.695 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
  • set +x

========= Config transaction to add org3 to network submitted! ===========

Creating volume “net_peer0.org3.example.com” with default driver
Creating volume “net_peer1.org3.example.com” with default driver
WARNING: Found orphan containers (cli, orderer2.example.com, peer1.org1.example.com, orderer3.example.com, orderer5.example.com, orderer4.example.com, peer1.org2.example.com, peer0.org1.example.com, peer0.org2.example.com, orderer.example.com) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating peer1.org3.example.com … done
Creating peer0.org3.example.com … done
Creating Org3cli … done

###############################################################
############### Have Org3 peers join network ##################
###############################################################

========= Getting Org3 on to your first network =========

Fetching channel config block from orderer…

  • peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c mychannel --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
  • res=0
  • set +x
    2020-04-29 09:35:01.857 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:35:01.860 UTC [cli.common] readBlock -> INFO 002 Received block: 0
  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2020-04-29 09:35:01.919 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:35:02.007 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer0.org3 joined channel ‘mychannel’ =====================
  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2020-04-29 09:35:02.074 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-29 09:35:02.157 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer1.org3 joined channel ‘mychannel’ =====================
  • peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1
  • res=0
  • set +x
    ===================== Chaincode is packaged on peer0.org3 =====================

Installing chaincode on peer0.org3…

  • peer lifecycle chaincode install mycc.tar.gz

  • res=0

  • set +x
    2020-04-29 09:35:13.364 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-29 09:35:13.365 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== Chaincode is installed on peer0.org3 =====================

  • peer lifecycle chaincode queryinstalled

  • res=0

  • set +x
    Installed chaincodes on peer:
    Package ID: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f, Label: mycc_1
    PackageID is mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
    ===================== Query installed successful on peer0.org3 on channel =====================

===================== Querying chaincode definition on peer0.org3 on channel ‘mychannel’… =====================
Attempting to Query committed status on peer0.org3 …3 secs

  • peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
  • res=0
  • set +x

Committed chaincode definition for chaincode ‘mycc’ on channel ‘mychannel’:
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true, Org3MSP: false]
===================== Query chaincode definition successful on peer0.org3 on channel ‘mychannel’ =====================

  • peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f --sequence 1 --waitForEvent
  • set +x
    2020-04-29 09:35:16.606 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
    2020-04-29 09:35:18.856 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [c1fec135dd265cf90a0df618787debe7d44c55466d307b59182d9ebaab93320a] committed with status (VALID) at
    ===================== Chaincode definition approved on peer0.org3 on channel ‘mychannel’ =====================

Querying chaincode on peer0.org3…
===================== Querying on peer0.org3 on channel ‘mychannel’… =====================
Attempting to Query peer0.org3 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

90
===================== Query successful on peer0.org3 on channel ‘mychannel’ =====================

========= Finished adding Org3 to your first network! =========


/ | | | / \ | _ \ | |
_
\ | | / _ \ | |
) | | |
) | | | / ___ \ | _ < | |
|
/ || // _\ || _\ |_|

Extend your first network (EYFN) test

Channel name : mychannel
Querying chaincode on peer0.org3…
===================== Querying on peer0.org3 on channel ‘mychannel’… =====================
Attempting to Query peer0.org3 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

90
===================== Query successful on peer0.org3 on channel ‘mychannel’ =====================
Sending invoke transaction on peer0.org1 peer0.org3…

  • 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.org3.example.com:11051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt -c ‘{“Args”:[“invoke”,“a”,“b”,“10”]}’
  • res=0
  • set +x
    2020-04-29 09:35:25.300 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 peer0.org3 on channel ‘mychannel’ =====================

Querying chaincode on peer0.org3…
===================== Querying on peer0.org3 on channel ‘mychannel’… =====================
Attempting to Query peer0.org3 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

80
===================== Query successful on peer0.org3 on channel ‘mychannel’ =====================
Querying chaincode on peer0.org2…
===================== Querying on peer0.org2 on channel ‘mychannel’… =====================
Attempting to Query peer0.org2 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

80
===================== Query successful 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

80
===================== Query successful on peer0.org1 on channel ‘mychannel’ =====================

========= All GOOD, EYFN test execution completed ===========


| | | \ | | | _ \
| | | | | | | | |
| |
| |\ | | |
| |
|_____| |
| _| |____/
运行时的docker
[fabric@localhost first-network]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f119e5c827bf dev-peer0.org3.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-39b61abe1a8f555cadfb83425bd0882b260de50e773a2278fb96e1453b04457a “chaincode -peer.add…” 21 seconds ago Up 20 seconds dev-peer0.org3.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
b50de5474caa hyperledger/fabric-tools:latest “/bin/bash” 39 seconds ago Up 38 seconds Org3cli
c6dbaab0a20c hyperledger/fabric-peer:latest “peer node start” 40 seconds ago Up 39 seconds 7051/tcp, 0.0.0.0:11051->11051/tcp peer0.org3.example.com
396e7a5b91eb hyperledger/fabric-peer:latest “peer node start” 40 seconds ago Up 39 seconds 7051/tcp, 0.0.0.0:12051->12051/tcp peer1.org3.example.com
5f54831b6871 dev-peer1.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-861731f1fb7a4568b5c4b97482e41ca66bb213f7eb7dd7215635fd371dbc2745 “chaincode -peer.add…” About a minute ago Up About a minute dev-peer1.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
c522a316dbd8 dev-peer0.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-667281c6b976fdf7176d974a284355bf1ff337baaab300e5129540a948115e2c “chaincode -peer.add…” About a minute ago Up About a minute dev-peer0.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
df999523a53f dev-peer0.org1.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-4c20bb52326acfebc71426bf7ea2fb83967081e00ca3fe383d464a100bc1177f “chaincode -peer.add…” About a minute ago Up About a minute dev-peer0.org1.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
349c041f0c0c hyperledger/fabric-tools:latest “/bin/bash” 3 minutes ago Up 3 minutes cli
a2df5320585a hyperledger/fabric-orderer:latest “orderer” 3 minutes ago Up 3 minutes 7050/tcp, 0.0.0.0:8050->8050/tcp orderer2.example.com
58c2f4235fdf hyperledger/fabric-peer:latest “peer node start” 3 minutes ago Up 3 minutes 7051/tcp, 0.0.0.0:8051->8051/tcp peer1.org1.example.com
5d6f7caa898c hyperledger/fabric-orderer:latest “orderer” 3 minutes ago Up 3 minutes 7050/tcp, 0.0.0.0:9050->9050/tcp orderer3.example.com
38e08fd50036 hyperledger/fabric-orderer:latest “orderer” 3 minutes ago Up 3 minutes 7050/tcp, 0.0.0.0:11050->11050/tcp orderer5.example.com
23d3aeaf46c8 hyperledger/fabric-orderer:latest “orderer” 3 minutes ago Up 3 minutes 7050/tcp, 0.0.0.0:10150->10150/tcp orderer4.example.com
87d0d0e679a2 hyperledger/fabric-peer:latest “peer node start” 3 minutes ago Up 3 minutes 7051/tcp, 0.0.0.0:10051->10051/tcp peer1.org2.example.com
301a0248c68e hyperledger/fabric-peer:latest “peer node start” 3 minutes ago Up 3 minutes 0.0.0.0:7051->7051/tcp peer0.org1.example.com
3de5715c8176 hyperledger/fabric-peer:latest “peer node start” 3 minutes ago Up 3 minutes 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
253132600be2 hyperledger/fabric-orderer:latest “orderer” 3 minutes ago Up 3 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
docker-compose部署Fabric1.4.6集群
获取docker image
更新docker mirror
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://e523f129.m.daocloud.io
sudo systemctl restart docker
orderer
hyperledger/fabric-tools 1.4.6 0f9743ac0662 2 months ago 1.49GB
hyperledger/fabric-tools latest 0f9743ac0662 2 months ago 1.49GB
hyperledger/fabric-ccenv 1.4.6 191911f4454f 2 months ago 1.36GB
hyperledger/fabric-ccenv latest 191911f4454f 2 months ago 1.36GB
hyperledger/fabric-orderer 1.4.6 84eaba5388e7 2 months ago 120MB
hyperledger/fabric-orderer latest 84eaba5388e7 2 months ago 120MB
hyperledger/fabric-peer 1.4.6 5a52faa5d8c2 2 months ago 128MB
hyperledger/fabric-peer latest 5a52faa5d8c2 2 months ago 128MB
hyperledger/fabric-couchdb latest d369d4eaa0fd 5 months ago 261MB
hyperledger/fabric-baseos amd64-0.4.18 c256a6aad46f 5 months ago 80.8MB
peer
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-tools 1.4.6 0f9743ac0662 2 months ago 1.49GB
hyperledger/fabric-tools latest 0f9743ac0662 2 months ago 1.49GB
hyperledger/fabric-ccenv 1.4.6 191911f4454f 2 months ago 1.36GB
hyperledger/fabric-orderer 1.4.6 84eaba5388e7 2 months ago 120MB
hyperledger/fabric-peer 1.4.6 5a52faa5d8c2 2 months ago 128MB
hyperledger/fabric-peer latest 5a52faa5d8c2 2 months ago 128MB
hyperledger/fabric-couchdb latest d369d4eaa0fd 5 months ago 261MB
拉取docker image
docker pull hyperledger/fabric-ca:1.4.6
docker pull hyperledger/fabric-orderer:1.4.6
docker pull hyperledger/fabric-ccenv:1.4.6
docker pull hyperledger/fabric-peer:1.4.6
docker pull hyperledger/fabric-tools:1.4.6
docker pull hyperledger/fabric-couchdb

标记tag
docker tag 0f9743ac0662 hyperledger/fabric-tools:latest
docker tag 191911f4454f hyperledger/fabric-ccenv:latest
docker tag 84eaba5388e7 hyperledger/fabric-orderer:latest
docker tag 5a52faa5d8c2 hyperledger/fabric-peer:latest
docker image备份
docker save -o fabric-tools.1.4.6.tar.gz hyperledger/fabric-tools:1.4.6
docker save -o fabric-ccenv.1.4.6.tar.gz hyperledger/fabric-ccenv:1.4.6
docker save -o fabric-orderer.1.4.6.tar.gz hyperledger/fabric-orderer:1.4.6
docker save -o fabric-peer.1.4.6.tar.gz hyperledger/fabric-peer:1.4.6
docker save -o fabric-couchdb.tar.gz hyperledger/fabric-couchdb
docker image恢复
docker load < ./fabric-tools.1.4.6.tar.gz
docker load < ./fabric-ccenv.1.4.6.tar.gz
docker load < ./fabric-orderer.1.4.6.tar.gz
docker load < ./fabric-peer.1.4.6.tar.gz
docker load < ./fabric-couchdb.tar.gz

docker image ls

REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-tools 1.4.6 0f9743ac0662 2 months ago 1.49GB
hyperledger/fabric-ccenv 1.4.6 191911f4454f 2 months ago 1.36GB
hyperledger/fabric-orderer 1.4.6 84eaba5388e7 2 months ago 120MB
hyperledger/fabric-peer 1.4.6 5a52faa5d8c2 2 months ago 128MB
order-peer0部署
10.11.2.8机器上执行
cd /usr/local/gopath/src/github.com/hyperledger/fabric-samples/xinyuanchain_0316_order_peer0/
docker-compose-cli-xinyuan-order-peer0.yaml
version: ‘2’

volumes:
orderer.xinyuan0316.com:
peer0.org1.xinyuan0316.com:

peer0.org2.xinyuan0316.com:

peer1.org2.xinyuan0316.com:

networks:
byfn:

services:

orderer.xinyuan0316.com:
extends:
file: base/docker-compose-base.yaml
service: orderer.xinyuan0316.com
container_name: orderer.xinyuan0316.com
networks:
- byfn

peer0.org1.xinyuan0316.com:
container_name: peer0.org1.xinyuan0316.com
extends:
file: base/docker-compose-base.yaml
service: peer0.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- peer1.org1.xinyuan0316.com:10.11.2.35
ordererCli:
container_name: ordererCli
image: hyperledger/fabric-tools:$IMAGE_TAG
restart: always
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=DEBUG
#- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=ordererCli
- CORE_PEER_ADDRESS=orderer.xinyuan0316.com:7050
- CORE_PEER_LOCALMSPID=Orderer0316MSP
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/users/[email protected]/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
- ./…/chaincode:/opt/gopath/src/github.com/chaincode
depends_on:
- orderer.xinyuan0316.com
networks:
- byfn

cli_peer0:
container_name: peer0_cli
image: hyperledger/fabric-tools:$IMAGE_TAG
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
#- FABRIC_LOGGING_SPEC=DEBUG
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=peer0cli
- CORE_PEER_ADDRESS=peer0.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/users/[email protected]/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./…/chaincode/:/opt/gopath/src/github.com/chaincode
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
depends_on:
- peer0.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- orderer.xinyuan0316.com:10.11.2.36
- peer0.org1.xinyuan0316.com:10.11.2.36
- peer1.org1.xinyuan0316.com:10.11.2.35
docker-compose-xinyuan-peer0-couchdb0.yaml
version: ‘2’
networks:
byfn:

services:
couchdb0:
container_name: couchdb0
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=
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
# for example map it to utilize Fauxton User Interface in dev environments.
ports:
- “5984:5984”
networks:
- byfn

peer0.org1.xinyuan0316.com:
environment:
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0: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=
depends_on:
- couchdb0
base/docker-compose-base.yaml
version: ‘2’

services:

orderer.xinyuan0316.com:
container_name: orderer.xinyuan0316.com
image: hyperledger/fabric-orderer:$IMAGE_TAG
environment:
- FABRIC_LOGGING_SPEC=INFO
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis0316.block
- ORDERER_GENERAL_LOCALMSPID=Orderer0316MSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
# enabled TLS
- ORDERER_GENERAL_TLS_ENABLED=true
- 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]
- ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1
- ORDERER_KAFKA_VERBOSE=true
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
- …/channel-artifacts/genesis0316.block:/var/hyperledger/orderer/orderer.genesis0316.block
- …/crypto-config/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/msp:/var/hyperledger/orderer/msp
- …/crypto-config/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/tls/:/var/hyperledger/orderer/tls
- orderer.xinyuan0316.com:/var/hyperledger/production/orderer
ports:
- 7050:7050

peer0.org1.xinyuan0316.com:
container_name: peer0.org1.xinyuan0316.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org1.xinyuan0316.com
- CORE_PEER_ADDRESS=peer0.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer0.org1.xinyuan0316.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
volumes:
- /var/run/:/host/var/run/
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/msp:/etc/hyperledger/fabric/msp
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/tls:/etc/hyperledger/fabric/tls
- peer0.org1.xinyuan0316.com:/var/hyperledger/production
ports:
- 7051:7051
- 7053:7053

peer1.org1.xinyuan0316.com:
container_name: peer1.org1.xinyuan0316.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org1.xinyuan0316.com
- CORE_PEER_ADDRESS=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer1.org1.xinyuan0316.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
volumes:
- /var/run/:/host/var/run/
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/msp:/etc/hyperledger/fabric/msp
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/tls:/etc/hyperledger/fabric/tls
- peer1.org1.xinyuan0316.com:/var/hyperledger/production

ports:
  - 7051:7051
  - 7053:7053

启动orderer-peer0节点
export IMAGE_TAG=1.4.6
export COMPOSE_PROJECT_NAME=xinyuan0316
docker-compose -f docker-compose-cli-xinyuan-order-peer0.yaml -f docker-compose-xinyuan-peer0-couchdb0.yaml up
docker exec -it peer0_cli bash
创建channel
在peer0上执行
peer channel create -o orderer.xinyuan0316.com:7050 -c org1channel0316 -f ./channel-artifacts/org1channel0316.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/msp/tlscacerts/tlsca.xinyuan0316.com-cert.pem
加入channel
在peer0、peer1上执行
peer channel join -b ./channel-artifacts/org1channel0316.block
更新channel
在Anchor peer锚节点上执行,目前是peer0,由configtx.yaml的AnchorPeers字段决定
peer channel update -o orderer.xinyuan0316.com:7050 -c org1channel0316 -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/msp/tlscacerts/tlsca.xinyuan0316.com-cert.pem
peer1部署
10.11.2.10机器上执行
cd /usr/local/gopath/src/github.com/hyperledger/fabric-samples/xinyuanchain_0316_peer1
docker-compose-cli-xinyuan-peer1.yaml
version: ‘2’
volumes:

orderer.xinyuan0316.com:

peer0.org1.xinyuan0316.com:

peer1.org1.xinyuan0316.com:

peer0.org2.xinyuan0316.com:

peer1.org2.xinyuan0316.com:

networks:
byfn:

services:

peer1.org1.xinyuan0316.com:
container_name: peer1.org1.xinyuan0316.com
extends:
file: base/docker-compose-base.yaml
service: peer1.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- orderer.xinyuan0316.com:10.11.2.36
- peer0.org1.xinyuan0316.com:10.11.2.36

cli_peer1:
container_name: peer1_cli
image: hyperledger/fabric-tools:$IMAGE_TAG
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
#- FABRIC_LOGGING_SPEC=DEBUG
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=peer1cli
- CORE_PEER_ADDRESS=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/users/[email protected]/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./…/chaincode/:/opt/gopath/src/github.com/chaincode
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
depends_on:
- peer1.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- orderer.xinyuan0316.com:10.11.2.36
- peer0.org1.xinyuan0316.com:10.11.2.36
- peer1.org1.xinyuan0316.com:10.11.2.35
docker-compose-xinyuan-peer1-couchdb1.yaml
version: ‘2’
networks:
byfn:

services:
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=
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
# for example map it to utilize Fauxton User Interface in dev environments.
ports:
- “5984:5984”
networks:
- byfn

peer1.org1.xinyuan0316.com:
environment:
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1: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=
depends_on:
- couchdb1
base/docker-compose-base.yaml
version: ‘2’
services:

peer1.org1.xinyuan0316.com:
container_name: peer1.org1.xinyuan0316.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org1.xinyuan0316.com
- CORE_PEER_ADDRESS=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.xinyuan0316.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_CHAINCODEADDRESS=peer1.org1.xinyuan0316.com:7052
- CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
volumes:
- /var/run/:/host/var/run/
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/msp:/etc/hyperledger/fabric/msp
- …/crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer1.org1.xinyuan0316.com/tls:/etc/hyperledger/fabric/tls
- peer1.org1.xinyuan0316.com:/var/hyperledger/production
ports:
- 7051:7051
- 7053:7053
启动peer1节点
export IMAGE_TAG=1.4.6
export CHANNEL_NAME=org1channel0316
export COMPOSE_PROJECT_NAME=xinyuan0316
docker-compose -f docker-compose-cli-xinyuan-peer1.yaml -f docker-compose-xinyuan-peer1-couchdb1.yaml up
docker exec -it peer1_cli bash
加入channel
peer channel join -b ./channel-artifacts/org1channel0316.block
peer channel list
peer channel getinfo -c org1channel0316
peer channel getinfo -c org1channel0316
智能合约chaincode fabric 1.4.6
挂载智能合约的发布目录
mount --bind /home/fabric/go/src/github.com/hyperledger/fabric-samples/chaincode /tmp/20200316/chaincode
安装智能合约
peer0节点上
peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
实例化智能合约
peer0节点上
peer chaincode instantiate -o orderer.xinyuan0316.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/msp/tlscacerts/tlsca.xinyuan0316.com-cert.pem -C org1channel0316 -n mycc -l golang -v 1.0 -c ‘{“Args”:[“init”,“a”,“100”,“b”,“200”]}’ -P ‘AND (’’‘Org1MSP.peer’’’)’
peer0节点
产生新的docker container
[fabric@localhost ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
649c60b14ac1 dev-peer0.org1.xinyuan0316.com-mycc-1.0-8020e3e92b62ef43fac7309e3ef2937e8e6dab5487e694fec54ada36471677c3 “chaincode -peer.add…” 11 hours ago Up 11 hours dev-peer0.org1.xinyuan0316.com-mycc-1.0
c67417f82f29 hyperledger/fabric-tools:latest “/bin/bash” 12 hours ago Up 11 hours ordererCli
5b3e7b81deef hyperledger/fabric-tools:latest “/bin/bash” 12 hours ago Up 11 hours peer0_cli
eb5806974ebc hyperledger/fabric-peer:latest “peer node start” 12 hours ago Up 11 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.xinyuan0316.com
8215898aaa45 hyperledger/fabric-couchdb “tini – /docker-ent…” 12 hours ago Up 11 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
73ae56619bf2 hyperledger/fabric-orderer:latest “orderer” 12 hours ago Up 11 hours 0.0.0.0:7050->7050/tcp orderer.xinyuan0316.com
peer1节点
[fabric@localhost ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76d389f70c52 dev-peer1.org1.xinyuan0316.com-mycc-1.0-c23dce685e8badc4c3703e0cba0436a3ced30c341f4a98bbb5e9df8d032f3fb2 “chaincode -peer.add…” About an hour ago Up About an hour dev-peer1.org1.xinyuan0316.com-mycc-1.0
d736661d48d1 hyperledger/fabric-tools:latest “/bin/bash” 14 hours ago Up 12 hours peer1_cli
f2e0b7f3168a hyperledger/fabric-peer:latest “peer node start” 14 hours ago Up 12 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer1.org1.xinyuan0316.com
b9acd289112c hyperledger/fabric-couchdb “tini – /docker-ent…” 14 hours ago Up 12 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb1
其余节点安装智能合约
peer1节点上
peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
2020-04-30 03:25:23.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-04-30 03:25:23.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-04-30 03:25:23.342 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
执行智能合约
peer0、peer1节点上
peer chaincode invoke -o orderer.xinyuan0316.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xinyuan0316.com/orderers/orderer.xinyuan0316.com/msp/tlscacerts/tlsca.xinyuan0316.com-cert.pem -C org1channel0316 -n mycc --peerAddresses peer0.org1.xinyuan0316.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer0.org1.xinyuan0316.com/tls/ca.crt -c ‘{“Args”:[“invoke”,“a”,“b”,“10”]}’
查询智能合约
peer0、peer1节点上
peer chaincode query -C org1channel0316 -n mycc -c ‘{“Args”:[“query”,“a”]}’
peer chaincode query -C org1channel0316 -n mycc -c ‘{“Args”:[“query”,“b”]}’
管理Fabric集群
Fabric中加入已有节点peer1
docker exec -it peer1_cli bash
在root@e03f1c39cd90:/opt/gopath/src/github.com/hyperledger/fabric/peer# 提示符下,执行
查看区块
peer channel fetch oldest -c org1channel0316
peer channel fetch newest -c org1channel0316
加入channel
peer channel join -b /opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts/org1channel0316.block
peer channel getinfo -c org1channel0316
2020-04-27 05:50:58.232 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Blockchain info: {“height”:1,“currentBlockHash”:“s2/5iqd0d/rN0zUfiUixpCHSkucAuCf7CVrBTUHXF1w=”}
查看智能合约
peer chaincode list --installed
peer chaincode list --instantiated -C org1channel0316
查询数据
peer chaincode query -C org1channel0316 -n mycc -c ‘{“Args”:[“query”,“a”]}’
Fabric中动态添加节点peer2
生成新节点的证书
修改crypto-config.yaml
Template:
Count: 3
生成:
cryptogen extend --config=./crypto-config.yaml
crypto-config/peerOrganizations/org1.xinyuan0316.com/peers/peer2.org1.xinyuan0316.com/msp/signcerts/peer2.org1.xinyuan0316.com-cert.pem
peer2部署
10.11.2.36机器上执行
cd /usr/local/gopath/src/github.com/hyperledger/fabric-samples/xinyuanchain_0316_peer2
docker-compose-cli-xinyuan-peer2.yaml
version: ‘2’

volumes:

orderer.xinyuan0316.com:

peer0.org1.xinyuan0316.com:

peer1.org1.xinyuan0316.com:

peer2.org1.xinyuan0316.com:

peer3.org1.xinyuan0316.com:

networks:
byfn:

services:

peer2.org1.xinyuan0316.com:
container_name: peer2.org1.xinyuan0316.com
extends:
file: base/docker-compose-base.yaml
service: peer2.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- orderer.xinyuan0316.com:10.11.2.34
- peer0.org1.xinyuan0316.com:10.11.2.34
- peer1.org1.xinyuan0316.com:10.11.2.35
- peer2.org1.xinyuan0316.com:10.11.2.36
- peer0.org2.xinyuan0316.com:10.11.2.37

cli_peer2:
container_name: peer2_cli
image: hyperledger/fabric-tools:$IMAGE_TAG
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
#- FABRIC_LOGGING_SPEC=DEBUG
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=peer2cli
- CORE_PEER_ADDRESS=peer2.org1.xinyuan0316.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer2.org1.xinyuan0316.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer2.org1.xinyuan0316.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/peers/peer2.org1.xinyuan0316.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xinyuan0316.com/users/[email protected]/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./…/chaincode/:/opt/gopath/src/github.com/chaincode
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
depends_on:
- peer2.org1.xinyuan0316.com
networks:
- byfn
extra_hosts:
- orderer.xinyuan0316.com:10.11.2.34
- peer0.org1.xinyuan0316.com:10.11.2.34
- peer1.org1.xinyuan0316.com:10.11.2.35
- peer2.org1.xinyuan0316.com:10.11.2.36
- peer0.org2.xinyuan0316.com:10.11.2.37
docker-compose-xinyuan-peer2-couchdb2.yaml
version: ‘2’

networks:
byfn:

services:
couchdb2:
container_name: couchdb2
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=
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
# for example map it to utilize Fauxton User Interface in dev environments.
ports:
- “5984:5984”
networks:
- byfn

peer2.org1.xinyuan0316.com:
environment:
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2: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=
depends_on:
- couchdb2
启动peer1节点
export IMAGE_TAG=latest
export CHANNEL_NAME=org1channel0316
export COMPOSE_PROJECT_NAME=xinyuan0316
docker-compose -f docker-compose-cli-xinyuan-peer2.yaml -f docker-compose-xinyuan-peer2-couchdb2.yaml up

增加用户 cryptogen
# ---------------------------------------------------------------------------
# “Users”
# ---------------------------------------------------------------------------
# Count: The number of user accounts in addition to Admin
# ---------------------------------------------------------------------------
Users:
Count: 10
cryptogen extend --config=./crypto-config.yaml
crypto-config/peerOrganizations/org1.xinyuan0316.com/users/
[email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected] [email protected]
[email protected] [email protected] [email protected]

清理docker下的 Hyperledger Fabric安装
清理证书及文件
linux 下用find命令查找文件,rm命令删除文件。
删除指定目录下指定文件
find ./. -name *.tx | xargs rm -rf
find ./. -name genesisblock | xargs rm -rf
find ./. -name .block | xargs rm -rf
删除指定名称的文件或文件夹:
find -type d | grep channel-artifacts$ | xargs rm -r
rm -rf /var/hyperledger/production
org1channel.block的说明
org1channel.block是由建立通道时创建的(peer channel create命令),和当前通道相关。
在重新建立通道时需要重新生成,执行加入通道(peer channel join)时,需要使用新的文件
orderer.genesis.block的说明
在base/docker-compose-base.yaml里需要挂载创世区块
channel-artifacts/genesis0316.block:/var/hyperledger/orderer/orderer.genesis0316.block
生成创世区块的文件名称要和配置文件里一致。
清理Fabric的运行文件
1、停止服务
systemctl stop docker
2、清理/var/lib/docker/volumes/
rm -rf /var/lib/docker/volumes/

3、删除docker container
docker container prune
4、删除docker image
docker rmi hyperledger/fabric-tools:latest hyperledger/fabric-ccenv:latest hyperledger/fabric-orderer:latest hyperledger/fabric-peer:latest hyperledger/fabric-couchdb:latest
docker rmi 0f9743ac0662 191911f4454f 84eaba5388e7 5a52faa5d8c2 c256a6aad46f
5、重启docker服务
systemctl restart docker
6、重新建立缺失的目录
缺省在 /var/lib/docker/volumes/
mkdir -p /var/lib/docker/volumes/xinyuan0316_peer0.org1.xinyuan0316.com/_data
mkdir -p /var/lib/docker/volumes/xinyuan0316_orderer.xinyuan0316.com/_data

mkdir -p /var/lib/docker/volumes/xinyuan0316_peer1.org1.xinyuan0316.com/_data

ERROR: for orderer.xinyuan0316.com Cannot start service orderer.xinyuan0316.com: b’OCI runtime create failed: container_linux.go:349: starting container process caused “process_linux.go:449: container init caused \“rootfs_linux.go:58: mounting \\\”/var/lib/docker/volumes/xinyuan0316_orderer.xinyuan0316.com/_data\\\” to rootfs \\\"/var/lib/docker/overlay2/b5b9487fd20f6efe244104521752d2a20dd1508f58c4d2fc9d48ad5b28c713f9/merged\\\" at \\\"/var/hyperledger/production/orderer\\\" caused \\\“stat /var/lib/docker/volumes/xinyuan0316_orderer.xinyuan0316.com/_data: no such file or directory\\\”\"": unknCreating couchdb0 … done
Creating peer0.org1.xinyuan0316.com … error

ERROR: for peer0.org1.xinyuan0316.com Cannot create container for service peer0.org1.xinyuan0316.com: b’open /var/lib/docker/volumes/xinyuan0316_peer0.org1.xinyuan0316.com/_data: no such file or directory’

ERROR: for orderer.xinyuan0316.com Cannot start service orderer.xinyuan0316.com: b’OCI runtime create failed: container_linux.go:349: starting container process caused “process_linux.go:449: container init caused \“rootfs_linux.go:58: mounting \\\”/var/lib/docker/volumes/xinyuan0316_orderer.xinyuan0316.com/_data\\\” to rootfs \\\"/var/lib/docker/overlay2/b5b9487fd20f6efe244104521752d2a20dd1508f58c4d2fc9d48ad5b28c713f9/merged\\\" at \\\"/var/hyperledger/production/orderer\\\" caused \\\“stat /var/lib/docker/volumes/xinyuan0316_orderer.xinyuan0316.com/_data: no such file or directory\\\”\"": unknown’

ERROR: for peer0.org1.xinyuan0316.com Cannot create container for service peer0.org1.xinyuan0316.com: b’open /var/lib/docker/volumes/xinyuan0316_peer0.org1.xinyuan0316.com/_data: no such file or directory’
ERROR: Encountered errors while bringing up the project.
强制重新启动docker容器
–force-recreate
couchdb的查询
访问 http://127.0.0.1:5984/
管理http://127.0.0.1:5984/_utils/
手动部署Fabric 单机
确定部署目录
$ mkdir -p $GOPATH/fabric-deploy/
$ mkdir -p $GOPATH/fabric-deploy/config

$ cd $GOPATH/fabric-deploy/
部署可执行文件
cp -r $GOPATH/src/github.com/hyperledger/fabric/build/bin
准备证书 cryptogen
crypto-config.yaml内容:
一个Orderer节点,两个Peer节点
OrdererOrgs:

  • Name: Orderer
    Domain: bitnei.cn
    Specs:
    • Hostname: orderer
      PeerOrgs:
  • Name: Org1
    Domain: org1.bitnei.cn
    Template:
    Count: 2
    Users:
    Count: 1
    $ ./bin/cryptogen generate --config=./config/crypto-config.yaml --output ./certs
    证书目录列表
    [fabric@localhost fabric-deploy]$ tree certs/
    certs/
    ├── ordererOrganizations
    │?? └── bitnei.cn
    │?? ├── ca
    │?? │?? ├── ca.bitnei.cn-cert.pem
    │?? │?? └── priv_sk
    │?? ├── msp
    │?? │?? ├── admincerts
    │?? │?? │?? └── [email protected]
    │?? │?? ├── cacerts
    │?? │?? │?? └── ca.bitnei.cn-cert.pem
    │?? │?? └── tlscacerts
    │?? │?? └── tlsca.bitnei.cn-cert.pem
    │?? ├── orderers
    │?? │?? └── orderer.bitnei.cn
    │?? │?? ├── msp
    │?? │?? │?? ├── admincerts
    │?? │?? │?? │?? └── [email protected]
    │?? │?? │?? ├── cacerts
    │?? │?? │?? │?? └── ca.bitnei.cn-cert.pem
    │?? │?? │?? ├── keystore
    │?? │?? │?? │?? └── priv_sk
    │?? │?? │?? ├── signcerts
    │?? │?? │?? │?? └── orderer.bitnei.cn-cert.pem
    │?? │?? │?? └── tlscacerts
    │?? │?? │?? └── tlsca.bitnei.cn-cert.pem
    │?? │?? └── tls
    │?? │?? ├── ca.crt
    │?? │?? ├── server.crt
    │?? │?? └── server.key
    │?? ├── tlsca
    │?? │?? ├── priv_sk
    │?? │?? └── tlsca.bitnei.cn-cert.pem
    │?? └── users
    │?? └── [email protected]
    │?? ├── msp
    │?? │?? ├── admincerts
    │?? │?? │?? └── [email protected]
    │?? │?? ├── cacerts
    │?? │?? │?? └── ca.bitnei.cn-cert.pem
    │?? │?? ├── keystore
    │?? │?? │?? └── priv_sk
    │?? │?? ├── signcerts
    │?? │?? │?? └── [email protected]
    │?? │?? └── tlscacerts
    │?? │?? └── tlsca.bitnei.cn-cert.pem
    │?? └── tls
    │?? ├── ca.crt
    │?? ├── client.crt
    │?? └── client.key
    └── peerOrganizations
    └── org1.bitnei.cn
    ├── ca
    │?? ├── ca.org1.bitnei.cn-cert.pem
    │?? └── priv_sk
    ├── msp
    │?? ├── admincerts
    │?? │?? └── [email protected]
    │?? ├── cacerts
    │?? │?? └── ca.org1.bitnei.cn-cert.pem
    │?? └── tlscacerts
    │?? └── tlsca.org1.bitnei.cn-cert.pem
    ├── peers
    │?? ├── peer0.org1.bitnei.cn
    │?? │?? ├── msp
    │?? │?? │?? ├── admincerts
    │?? │?? │?? │?? └── [email protected]
    │?? │?? │?? ├── cacerts
    │?? │?? │?? │?? └── ca.org1.bitnei.cn-cert.pem
    │?? │?? │?? ├── keystore
    │?? │?? │?? │?? └── priv_sk
    │?? │?? │?? ├── signcerts
    │?? │?? │?? │?? └── peer0.org1.bitnei.cn-cert.pem
    │?? │?? │?? └── tlscacerts
    │?? │?? │?? └── tlsca.org1.bitnei.cn-cert.pem
    │?? │?? └── tls
    │?? │?? ├── ca.crt
    │?? │?? ├── server.crt
    │?? │?? └── server.key
    │?? └── peer1.org1.bitnei.cn
    │?? ├── msp
    │?? │?? ├── admincerts
    │?? │?? │?? └── [email protected]
    │?? │?? ├── cacerts
    │?? │?? │?? └── ca.org1.bitnei.cn-cert.pem
    │?? │?? ├── keystore
    │?? │?? │?? └── priv_sk
    │?? │?? ├── signcerts
    │?? │?? │?? └── peer1.org1.bitnei.cn-cert.pem
    │?? │?? └── tlscacerts
    │?? │?? └── tlsca.org1.bitnei.cn-cert.pem
    │?? └── tls
    │?? ├── ca.crt
    │?? ├── server.crt
    │?? └── server.key
    ├── tlsca
    │?? ├── priv_sk
    │?? └── tlsca.org1.bitnei.cn-cert.pem
    └── users
    ├── [email protected]
    │?? ├── msp
    │?? │?? ├── admincerts
    │?? │?? │?? └── [email protected]
    │?? │?? ├── cacerts
    │?? │?? │?? └── ca.org1.bitnei.cn-cert.pem
    │?? │?? ├── keystore
    │?? │?? │?? └── priv_sk
    │?? │?? ├── signcerts
    │?? │?? │?? └── [email protected]
    │?? │?? └── tlscacerts
    │?? │?? └── tlsca.org1.bitnei.cn-cert.pem
    │?? └── tls
    │?? ├── ca.crt
    │?? ├── client.crt
    │?? └── client.key
    └── [email protected]
    ├── msp
    │?? ├── admincerts
    │?? │?? └── [email protected]
    │?? ├── cacerts
    │?? │?? └── ca.org1.bitnei.cn-cert.pem
    │?? ├── keystore
    │?? │?? └── priv_sk
    │?? ├── signcerts
    │?? │?? └── [email protected]
    │?? └── tlscacerts
    │?? └── tlsca.org1.bitnei.cn-cert.pem
    └── tls
    ├── ca.crt
    ├── client.crt
    └── client.key

68 directories, 62 files

通过cryptogen生成所有证书文件后,以peerOrgannizations的第一个组织树org1为例,每个目录和对应文件的功能如下:
ca:
存放组织的根证书和对应的私钥文件,默认采用EC算法,证书为自签名。组织内的实体将基于该证书作为证书根。
tlsca:
存放组织tls连接用的根证书和私钥文件。(TLS是传输层安全协议,原为SSL)
msp:
存放代表该组织的身份信息。
admincerts:组织管理员的身份验证证书,被根证书签名。
cacerts:组织的根证书,同ca目录下文件。
tlscacerts:用于TLS的ca证书,自签名。
peers:
存放属于该组织的所有peer节点。
peer0:
第一个peer的信息,包括其msp证书和TLS证书两类。
msp:
admincerts:组织管理员的身份验证证书。peer将基于这些证书来认证
交易签署这是否为管理员身份。
cacerts:组织的根证书.
keystore:本节点的身份私钥,用来签名。
signcerts:验证本节点签名的证书,被组织根证书签名。
tlscacerts:TLS连接用的身份证书,即组织TLS证书。
tls:
存放tls相关的证书和私钥
ca.crt:组织的根证书
server.crt:验证本节点签名的证书,被组织根证书签名。
server.key:本节点的身份私钥,用来签名。
peer1:
第二个peer的信息,结构类似。

users:
存放属于该组织的用户的实体。
Admin:
管理员用户的信息,包括其msp证书和tls证书两类。
msp:
admincerts:组织根证书作为管理者身份验证证书。
cacerts:组织的根证书.
keystore:本用户的身份私钥,用来签名。
signcerts:管理员用户的身份验证证书,被组织根证书签名。要被某个Peer
认可,则必须放到该peer的msp/admincerts下。
tlscacerts:TLS连接用的身份证书,即组织TLS证书。
tls:存放tls相关的证书和私钥
ca.crt:组织的根证书
server.crt:管理员的用户身份验证证书,被组织根证书签名。
server.key:管理员用户的身份私钥,用来签名。
User1:
第一个用户的信息,包括msp证书和tls证书两类。
msp:
admincerts:组织根证书作为管理者身份验证证书。
cacerts:组织的根证书.
keystore:本用户的身份私钥,用来签名。
signcerts:验证本用户签名的身份证书,被组织根证书签名。
tlscacerts:TLS连接用的身份证书,即组织TLS证书。
tls:
存放tls相关的证书和私钥
ca.crt:组织的根证书
server.crt:验证用户签名的身份证书,被组织根证书签名。
server.key:用户的身份私钥,用来签名。
部署orderer.bitnei.cn
orderer.bitnei.cn所属文件:
建立目录
$ mkdir orderer.bitnei.cn
将bin/orderer以及证书复制到orderer.bitnei.cn目录中。
$ cp bin/orderer orderer.bitnei.cn/
$ cp -rf certs/ordererOrganizations/bitnei.cn/orderers/orderer.bitnei.cn/* orderer.bitnei.cn/
orderer的配置文件orderer.bitnei.cn/orderer.yaml:
可以使用官方提供的样例,路径如下:
fabric/sampleconfig| orderer.yaml

General:
# Listen address: The IP on which to bind to listen.
ListenAddress: orderer.bitnei.cn

# Listen port: The port on which to bind to listen.
ListenPort: 7050

# TLS: TLS settings for the GRPC server.
TLS:
    Enabled: false
    # PrivateKey governs the file location of the private key of the TLS certificate.
    PrivateKey: tls/server.key
    # Certificate governs the file location of the server TLS certificate.
    Certificate: tls/server.crt
    RootCAs:
      - tls/ca.crt
    ClientAuthRequired: false
    ClientRootCAs:
# Keepalive settings for the GRPC server.
Keepalive:
    # ServerMinInterval is the minimum permitted time between client pings.
    # If clients send pings more frequently, the server will
    # disconnect them.
    ServerMinInterval: 60s
    # ServerInterval is the time between pings to clients.
    ServerInterval: 7200s
    # ServerTimeout is the duration the server waits for a response from
    # a client before closing the connection.
    ServerTimeout: 20s
# Cluster settings for ordering service nodes that communicate with other ordering service nodes
# such as Raft based ordering service.
Cluster:
    # SendBufferSize is the maximum number of messages in the egress buffer.
    # Consensus messages are dropped if the buffer is full, and transaction
    # messages are waiting for space to be freed.
    SendBufferSize: 10
    # ClientCertificate governs the file location of the client TLS certificate
    # used to establish mutual TLS connections with other ordering service nodes.
    ClientCertificate:
    # ClientPrivateKey governs the file location of the private key of the client TLS certificate.
    ClientPrivateKey:
    # The below 4 properties should be either set together, or be unset together.
    # If they are set, then the orderer node uses a separate listener for intra-cluster
    # communication. If they are unset, then the general orderer listener is used.
    # This is useful if you want to use a different TLS server certificates on the
    # client-facing and the intra-cluster listeners.

    # ListenPort defines the port on which the cluster listens to connections.
    ListenPort:
    # ListenAddress defines the IP on which to listen to intra-cluster communication.
    ListenAddress:
    # ServerCertificate defines the file location of the server TLS certificate used for intra-cluster
    # communication.
    ServerCertificate:
    # ServerPrivateKey defines the file location of the private key of the TLS certificate.
    ServerPrivateKey:

# Bootstrap method: The method by which to obtain the bootstrap block
# system channel is specified. The option can be one of:
#   "file" - path to a faile containing the genesis block or config block of system channel
#   "none" - allows an orderer to start without a system channel configuration
BootstrapMethod: file

# Bootstrap file: The file containing the bootstrap block to use when
# initializing the orderer system channel and BootstrapMethod is set to
# "file".  The bootstrap file can be the genesis block, and it can also be
# a config block for late bootstrap of some consensus methods like Raft.
# Generate a genesis block by updating $FABRIC_CFG_PATH/configtx.yaml and
# using configtxgen command with "-outputBlock" option.
# Defaults to file "genesisblock" (in $FABRIC_CFG_PATH directory) if not specified.
BootstrapFile:

# LocalMSPDir is where to find the private crypto material needed by the
# orderer. It is set relative here as a default for dev environments but
# should be changed to the real location in production.
LocalMSPDir: msp

# LocalMSPID is the identity to register the local MSP material with the MSP
# manager. IMPORTANT: The local MSP ID of an orderer needs to match the MSP
# ID of one of the organizations defined in the orderer system channel's
# /Channel/Orderer configuration. The sample organization defined in the
# sample configuration provided has an MSP ID of "SampleOrg".
LocalMSPID: Org1MSP

# Enable an HTTP service for Go "pprof" profiling as documented at:
# https://golang.org/pkg/net/http/pprof
Profile:
    Enabled: false
    Address: 0.0.0.0:6060

# BCCSP configures the blockchain crypto service providers.
BCCSP:
    # Default specifies the preferred blockchain crypto service provider
    # to use. If the preferred provider is not available, the software
    # based provider ("SW") will be used.
    # Valid providers are:
    #  - SW: a software based crypto provider
    #  - PKCS11: a CA hardware security module crypto provider.
    Default: SW

    # SW configures the software based blockchain crypto provider.
    SW:
        # TODO: The default Hash and Security level needs refactoring to be
        # fully configurable. Changing these defaults requires coordination
        # SHA2 is hardcoded in several places, not only BCCSP
        Hash: SHA2
        Security: 256
        # Location of key store. If this is unset, a location will be
        # chosen using: 'LocalMSPDir'/keystore
        FileKeyStore:
            KeyStore:

    # Settings for the PKCS#11 crypto provider (i.e. when DEFAULT: PKCS11)
    PKCS11:
        # Location of the PKCS11 module library
        Library:
        # Token Label
        Label:
        # User PIN
        Pin:
        Hash:
        Security:
        FileKeyStore:
            KeyStore:

# Authentication contains configuration parameters related to authenticating
# client messages
Authentication:
    # the acceptable difference between the current server time and the
    # client's time as specified in a client request message
    TimeWindow: 15m

################################################################################

SECTION: File Ledger

- This section applies to the configuration of the file or json ledgers.

################################################################################
FileLedger:

# Location: The directory to store the blocks in.
# NOTE: If this is unset, a new temporary location will be chosen every time
# the orderer is restarted, using the prefix specified by Prefix.
Location: /var/hyperledger/production/orderer

# The prefix to use when generating a ledger directory in temporary space.
# Otherwise, this value is ignored.
Prefix: hyperledger-fabric-ordererledger

################################################################################

SECTION: Kafka

- This section applies to the configuration of the Kafka-based orderer, and

its interaction with the Kafka cluster.

################################################################################
Kafka:

# Retry: What do if a connection to the Kafka cluster cannot be established,
# or if a metadata request to the Kafka cluster needs to be repeated.
Retry:
    # When a new channel is created, or when an existing channel is reloaded
    # (in case of a just-restarted orderer), the orderer interacts with the
    # Kafka cluster in the following ways:
    # 1. It creates a Kafka producer (writer) for the Kafka partition that
    # corresponds to the channel.
    # 2. It uses that producer to post a no-op CONNECT message to that
    # partition
    # 3. It creates a Kafka consumer (reader) for that partition.
    # If any of these steps fail, they will be re-attempted every
    #  for a total of , and then every
    #  for a total of  until they succeed.
    # Note that the orderer will be unable to write to or read from a
    # channel until all of the steps above have been completed successfully.
    ShortInterval: 5s
    ShortTotal: 10m
    LongInterval: 5m
    LongTotal: 12h
    # Affects the socket timeouts when waiting for an initial connection, a
    # response, or a transmission. See Config.Net for more info:
    # https://godoc.org/github.com/Shopify/sarama#Config
    NetworkTimeouts:
        DialTimeout: 10s
        ReadTimeout: 10s
        WriteTimeout: 10s
    # Affects the metadata requests when the Kafka cluster is in the middle
    # of a leader election.See Config.Metadata for more info:
    # https://godoc.org/github.com/Shopify/sarama#Config
    Metadata:
        RetryBackoff: 250ms
        RetryMax: 3
    # What to do if posting a message to the Kafka cluster fails. See
    # Config.Producer for more info:
    # https://godoc.org/github.com/Shopify/sarama#Config
    Producer:
        RetryBackoff: 100ms
        RetryMax: 3
    # What to do if reading from the Kafka cluster fails. See
    # Config.Consumer for more info:
    # https://godoc.org/github.com/Shopify/sarama#Config
    Consumer:
        RetryBackoff: 2s
# Settings to use when creating Kafka topics.  Only applies when
# Kafka.Version is v0.10.1.0 or higher
Topic:
    # The number of Kafka brokers across which to replicate the topic
    ReplicationFactor: 3
# Verbose: Enable logging for interactions with the Kafka cluster.
Verbose: false

# TLS: TLS settings for the orderer's connection to the Kafka cluster.
TLS:

  # Enabled: Use TLS when connecting to the Kafka cluster.
  Enabled: false

  # PrivateKey: PEM-encoded private key the orderer will use for
  # authentication.
  PrivateKey:
    # As an alternative to specifying the PrivateKey here, uncomment the
    # following "File" key and specify the file name from which to load the
    # value of PrivateKey.
    #File: path/to/PrivateKey

  # Certificate: PEM-encoded signed public key certificate the orderer will
  # use for authentication.
  Certificate:
    # As an alternative to specifying the Certificate here, uncomment the
    # following "File" key and specify the file name from which to load the
    # value of Certificate.
    #File: path/to/Certificate

  # RootCAs: PEM-encoded trusted root certificates used to validate
  # certificates from the Kafka cluster.
  RootCAs:
    # As an alternative to specifying the RootCAs here, uncomment the
    # following "File" key and specify the file name from which to load the
    # value of RootCAs.
    #File: path/to/RootCAs

# SASLPlain: Settings for using SASL/PLAIN authentication with Kafka brokers
SASLPlain:
  # Enabled: Use SASL/PLAIN to authenticate with Kafka brokers
  Enabled: false
  # User: Required when Enabled is set to true
  User:
  # Password: Required when Enabled is set to true
  Password:

# Kafka protocol version used to communicate with the Kafka cluster brokers
# (defaults to 0.10.2.0 if not specified)
Version:

################################################################################

Debug Configuration

- This controls the debugging options for the orderer

################################################################################
Debug:

# BroadcastTraceDir when set will cause each request to the Broadcast service
# for this orderer to be written to a file in this directory
BroadcastTraceDir:

# DeliverTraceDir when set will cause each request to the Deliver service
# for this orderer to be written to a file in this directory
DeliverTraceDir:

################################################################################

Operations Configuration

- This configures the operations server endpoint for the orderer

################################################################################
Operations:
# host and port for the operations server
ListenAddress: 127.0.0.1:8443

# TLS configuration for the operations endpoint
TLS:
    # TLS enabled
    Enabled: false

    # Certificate is the location of the PEM encoded TLS certificate
    Certificate:

    # PrivateKey points to the location of the PEM-encoded key
    PrivateKey:

    # Most operations service endpoints require client authentication when TLS
    # is enabled. ClientAuthRequired requires client certificate authentication
    # at the TLS layer to access all resources.
    ClientAuthRequired: false

    # Paths to PEM encoded ca certificates to trust for client authentication
    ClientRootCAs: []

################################################################################

Metrics Configuration

- This configures metrics collection for the orderer

################################################################################
Metrics:
# The metrics provider is one of statsd, prometheus, or disabled
Provider: disabled

# The statsd configuration
Statsd:
  # network type: tcp or udp
  Network: udp

  # the statsd server address
  Address: 127.0.0.1:8125

  # The interval at which locally cached counters and gauges are pushed
  # to statsd; timings are pushed immediately
  WriteInterval: 30s

  # The prefix is prepended to all emitted statsd metrics
  Prefix:

################################################################################

Consensus Configuration

- This section contains config options for a consensus plugin. It is opaque

to orderer, and completely up to consensus implementation to make use of.

################################################################################
Consensus:
# The allowed key-value pairs here depend on consensus plugin. For etcd/raft,
# we use following options:

# WALDir specifies the location at which Write Ahead Logs for etcd/raft are
# stored. Each channel will have its own subdir named after channel ID.
WALDir: /var/hyperledger/production/orderer/etcdraft/wal

# SnapDir specifies the location at which snapshots for etcd/raft are
# stored. Each channel will have its own subdir named after channel ID.
SnapDir: /var/hyperledger/production/orderer/etcdraft/snapshot

存放orderer数据的目录
$ mkdir orderer.bitnei.cn/data
部署peer0.org1.bitnei.cn
peer0.org1.bitnei.cn所属文件:
建立目录
$ mkdir peer0.org1.bitnei.cn
将bin/peer以及证书复制到peer0.org1.bitnei.cn目录中。
$ cp bin/peer peer0.org1.bitnei.cn/
$ cp -rf certs/peerOrganizations/org1.bitnei.cn/peers/peer0.org1.bitnei.cn/* peer0.org1.bitnei.cn/
peer0.org1.bitnei.cn的配置文件core.yaml:
orderer的配置文件orderer.bitnei.cn/core.yaml:
可以使用官方提供的样例,路径如下:

存放peer数据的目录:
$ mkdir peer0.org1.bitnei.cn/data
部署peer1.org1.bitnei.cn
过程与peer0.org1.bitnei.cn类似,注意将配置文件中的名称修改为peer1。
复制peer0.org1.exampl.com目录,然后替换其中的文件。
cp -rf peer0.org1.bitnei.cn/ peer1.org1.bitnei.cn/
rm -rf peer1.org1.bitnei.cn/msp/
rm -rf peer1.org1.bitnei.cn/tls/
cp -rf certs/peerOrganizations/org1.bitnei.cn/peers/peer1.org1.bitnei.cn/* peer1.org1.bitnei.cn/
最后修改peer1.org1.bitnei.cn/core.yml,将peer0.org1.exampl.com修改为peer1.org1.bitnei.cn,
直接用sed命令替换:
sed -i “s/peer0.org1.bitnei.cn/peer1.org1.bitnei.cn/g” peer1.org1.bitnei.cn/core.yaml

开始部署
本例为多机部署
部署之前,先确保已经在每台机器的/etc/hosts文件中添加下列的记录:
192.168.21.88 orderer.bitnei.cn
192.168.21.221 peer0.org1.bitnei.cn
192.168.21.222 peer1.org1.bitnei.cn

在部署机上创建目录:
mkdir -p fabric-deploy/{orderer,peer}

创建configtx.yaml的文件
可以使用官方提供的样例,路径如下:
fabric/sampleconfig|configtx.yaml
在fabric-deploy目录中,编辑configtx.yaml,采用SOLO方式

Organizations:

# SampleOrg defines an MSP using the sampleconfig.  It should never be used
# in production but may be used as a template for other definitions
- &OrdererOrg
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: OrdererOrg

    # ID to load the MSP definition as
    ID: OrdererMSP

    # MSPDir is the filesystem path which contains the MSP configuration
    MSPDir: msp

    # Policies defines the set of policies at this level of the config tree
    # For organization policies, their canonical path is usually
    #   /Channel///
    Policies:
        Readers:
            Type: Signature
            Rule: "OR('OrdererMSP.member')"
        Writers:
            Type: Signature
            Rule: "OR('OrdererMSP.member')"
        Admins:
            Type: Signature
            Rule: "OR('OrdererMSP.admin')"

- &Org1
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Org1MSP

    # ID to load the MSP definition as
    ID: Org1MSP

    MSPDir: orderer.bitnei.cn/msp

    # Policies defines the set of policies at this level of the config tree
    # For organization policies, their canonical path is usually
    #   /Channel///
    Policies:
        Readers:
            Type: Signature
            Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
        Writers:
            Type: Signature
            Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
        Admins:
            Type: Signature
            Rule: "OR('Org1MSP.admin')"
        Endorsement:
            Type: Signature
            Rule: "OR('Org1MSP.peer')"

    # leave this flag set to true.
    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org1.bitnei.cn
          Port: 7051

################################################################################

SECTION: Capabilities

- This section defines the capabilities of fabric network. This is a new

concept as of v1.1.0 and should not be utilized in mixed networks with

v1.0.x peers and orderers. Capabilities define features which must be

present in a fabric binary for that binary to safely participate in the

fabric network. For instance, if a new MSP type is added, newer binaries

might recognize and validate the signatures from this type, while older

binaries without this support would be unable to validate those

transactions. This could lead to different versions of the fabric binaries

having different world states. Instead, defining a capability for a channel

informs those binaries without this capability that they must cease

processing transactions until they have been upgraded. For v1.0.x if any

capabilities are defined (including a map with all capabilities turned off)

then the v1.0.x peer will deliberately crash.

################################################################################
Capabilities:
# Channel capabilities apply to both the orderers and the peers and must be
# supported by both.
# Set the value of the capability to true to require it.
Channel: &ChannelCapabilities
# V2_0 capability ensures that orderers and peers behave according
# to v2.0 channel capabilities. Orderers and peers from
# prior releases would behave in an incompatible way, and are therefore
# not able to participate in channels at v2.0 capability.
# Prior to enabling V2.0 channel capabilities, ensure that all
# orderers and peers on a channel are at v2.0.0 or later.
V2_0: true

# Orderer capabilities apply only to the orderers, and may be safely
# used with prior release peers.
# Set the value of the capability to true to require it.
Orderer: &OrdererCapabilities
    # V2_0 orderer capability ensures that orderers behave according
    # to v2.0 orderer capabilities. Orderers from
    # prior releases would behave in an incompatible way, and are therefore
    # not able to participate in channels at v2.0 orderer capability.
    # Prior to enabling V2.0 orderer capabilities, ensure that all
    # orderers on channel are at v2.0.0 or later.
    V2_0: true

# Application capabilities apply only to the peer network, and may be safely
# used with prior release orderers.
# Set the value of the capability to true to require it.
Application: &ApplicationCapabilities
    # V2_0 application capability ensures that peers behave according
    # to v2.0 application capabilities. Peers from
    # prior releases would behave in an incompatible way, and are therefore
    # not able to participate in channels at v2.0 application capability.
    # Prior to enabling V2.0 application capabilities, ensure that all
    # peers on channel are at v2.0.0 or later.
    V2_0: true

################################################################################

SECTION: Application

- This section defines the values to encode into a config transaction or

genesis block for application related parameters

################################################################################
Application: &ApplicationDefaults

# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:

# Policies defines the set of policies at this level of the config tree
# For Application policies, their canonical path is
#   /Channel/Application/
Policies:
    Readers:
        Type: ImplicitMeta
        Rule: "ANY Readers"
    Writers:
        Type: ImplicitMeta
        Rule: "ANY Writers"
    Admins:
        Type: ImplicitMeta
        Rule: "MAJORITY Admins"
    LifecycleEndorsement:
        Type: ImplicitMeta
        Rule: "MAJORITY Endorsement"
    Endorsement:
        Type: ImplicitMeta
        Rule: "MAJORITY Endorsement"

Capabilities:
    <<: *ApplicationCapabilities

################################################################################

SECTION: Orderer

- This section defines the values to encode into a config transaction or

genesis block for orderer related parameters

################################################################################
Orderer: &OrdererDefaults

OrdererType: solo
Addresses:
    - orderer.bitnei.cn:7050
BatchTimeout: 2s
BatchSize:
    MaxMessageCount: 10
    AbsoluteMaxBytes: 98 MB
    PreferredMaxBytes: 512 KB
Kafka:
    Brokers:
        - 127.0.0.1:9092

# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:

# Policies defines the set of policies at this level of the config tree
# For Orderer policies, their canonical path is
#   /Channel/Orderer/
Policies:
    Readers:
        Type: ImplicitMeta
        Rule: "ANY Readers"
    Writers:
        Type: ImplicitMeta
        Rule: "ANY Writers"
    Admins:
        Type: ImplicitMeta
        Rule: "MAJORITY Admins"
    # BlockValidation specifies what signatures must be included in the block
    # from the orderer for the peer to validate it.
    BlockValidation:
        Type: ImplicitMeta
        Rule: "ANY Writers"

################################################################################

CHANNEL

This section defines the values to encode into a config transaction or

genesis block for channel related parameters.

################################################################################
Channel: &ChannelDefaults
# Policies defines the set of policies at this level of the config tree
# For Channel policies, their canonical path is
# /Channel/
Policies:
# Who may invoke the ‘Deliver’ API
Readers:
Type: ImplicitMeta
Rule: “ANY Readers”
# Who may invoke the ‘Broadcast’ API
Writers:
Type: ImplicitMeta
Rule: “ANY Writers”
# By default, who may modify elements at this config level
Admins:
Type: ImplicitMeta
Rule: “MAJORITY Admins”

# Capabilities describes the channel level capabilities, see the
# dedicated Capabilities section elsewhere in this file for a full
# description
Capabilities:
    <<: *ChannelCapabilities

################################################################################

Profile

- Different configuration profiles may be encoded here to be specified

as parameters to the configtxgen tool

################################################################################
Profiles:

OneOrgsSoloChannel:
    Consortium: SampleConsortium
    <<: *ChannelDefaults
    Capabilities:
        <<: *ChannelCapabilities
    Orderer:
        <<: *OrdererDefaults
        Capabilities:
            <<: *OrdererCapabilities
    Application:
        <<: *ApplicationDefaults
        Organizations:
            - *Org1
        Capabilities:
            <<: *ApplicationCapabilities
    Consortiums:
        SampleConsortium:
            Organizations:
            - *Org1

生成创世块文件
$ ./bin/configtxgen -profile OneOrgsSoloChannel -outputBlock ./channel-artifacts/genesisblock -channelID channel
将./genesisblock文件复制到orderer节点的fabric-deploy/orderer.bitnei.cn目录中:
cp ./channel-artifacts/genesisblock orderer.bitnei.cn
启动节点
Creating new file ledger directory
$ chgrp -R fabric /var/hyperledger
$ chown -R fabric /var/hyperledger
分别在部署机器的orderer、peer目录中启动:
$./orderer
$./peer node start
设置[email protected]
在fabric-deploy中创建目录[email protected],在其中存放该用户的所有资料。
$ mkdir [email protected]
将用户证书复制到其中:
$ cp -rf certs/peerOrganizations/org1.bitnei.cn/users/[email protected]/* [email protected]/
将core.yaml复制到用户目录下:
$ cp peer0.org1.bitnei.cn/core.yaml [email protected]/
为了方便使用,创建一个脚本[email protected]/peer.sh:
$ chmod +x peer.sh
#!/bin/bash
PATH=pwd/…/bin:$PATH
export FABRIC_CFG_PATH=pwd
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_TLS_CERT_FILE=./tls/client.crt
export CORE_PEER_TLS_KEY_FILE=./tls/client.key
export CORE_PEER_MSPCONFIGPATH=./msp
export CORE_PEER_ADDRESS=peer0.org1.bitnei.cn:7051
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_TLS_ROOTCERT_FILE=./tls/ca.crt
export CORE_PEER_ID=cli
export CORE_LOGGING_LEVEL=INFO
peer $*
设置[email protected]
User1与Admin1使用相同的peer,因此只需要替换用户证书即可:
$ cp -rf [email protected]/ [email protected]/
$ rm -rf [email protected]/msp
$ rm -rf [email protected]/tls
$ cp -rf certs/peerOrganizations/org1.bitnei.cn/users/[email protected]/* [email protected]/
创建channel与peer的设置
准备channel文件
进入fabric-deploy目录中,用configtxgen生成channel文件:
$ ./bin/configtxgen -profile OneOrgsSoloChannel -outputCreateChannelTx ./channel-artifacts/testchannel.tx -channelID testchannel
channel名字为testchannel,生成的testchannel.tx备用。
还需要为每个组织的peer生成一个anchor文件,每个组织只需要一个
$ ./bin/configtxgen -profile OneOrgsSoloChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

$ scp channel-artifacts/testchannel.tx [email protected]:/home/fabric/go/fabric-deploy/[email protected]/
$ scp channel-artifacts/testchannel.tx [email protected]:/home/fabric/go/fabric-deploy/[email protected]/
将验证orderer.bitnei.cn的根证书复制到用户目录中:
$ cp certs/ordererOrganizations/bitnei.cn/tlsca/tlsca.bitnei.cn-cert.pem [email protected]/
$ cp certs/ordererOrganizations/bitnei.cn/tlsca/tlsca.bitnei.cn-cert.pem [email protected]/
创建channel
[email protected]目录中执行下面的命令,:
$ cd [email protected]
$ ./peer.sh channel create -o orderer.bitnei.cn:7050 -c testchannel -f ./testchannel.tx --tls true --cafile tlsca.bitnei.cn-cert.pem

你可能感兴趣的:(区块链)