测试环境:
- 多机环境:1 个 ubuntu18 + 5台centos 7,其中ubuntu作为client机器.在6台机器上,修改/etc/hosts:
192.168.64.136 peer0.org1.ping40.net
192.168.64.225 peer1.org1.ping40.net
192.168.64.243 peer0.org2.ping40.net
192.168.64.249 peer1.org2.ping40.net
192.168.64.69 orderer.ping40.net
多机环境下,要保证所有机器的时间一样。在 core.yaml, orderer.yaml配置文件要求时间相处不能超过15分钟:
authentication:
# the acceptable difference between the current server time and the
# client's time as specified in a client request message
timewindow: 15m
理论上也可以使用2~5台机器进行测试
- 单机环境:1 个 ubuntu18,/etc/hosts 修改配置:
127.0.0.1 peer0.org1.ping40.net
127.0.0.1 peer1.org1.ping40.net
127.0.0.1 peer0.org2.ping40.net
127.0.0.1 peer1.org2.ping40.net
127.0.0.1 orderer.ping40.net
- 本测试生成的二进制程序是fabric 1.4.0版本。
commit b2ea980d57b2ff50240049b2feef69adaa44a2e3
测试例子中没有启用tls,且 是一个orderer,solo模式
docker环境准备
peer0.org1,peer0.org2的机器需要docker环境和二个镜像:
hyperledger/fabric-baseos:amd64-0.4.14
hyperledger/fabric-ccenv:latest
[root@c243 tmp]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-baseos amd64-0.4.14 75f5fb1a0e0c 4 weeks ago 124MB
hyperledger/fabric-ccenv amd64-1.3.0 953124d80237 5 weeks ago 1.38GB
hyperledger/fabric-ccenv latest 953124d80237 5 weeks ago 1.38GB
[root@c243 tmp]# docker version
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
步骤1:下载脚本
在client机器上下载 https://github.com/ping40/fabric_install.git
fabric@me:~$ git clone https://github.com/ping40/fabric_install.git
正克隆到 'fabric_install'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 20 (delta 6), reused 20 (delta 6), pack-reused 0
展开对象中: 100% (20/20), 完成.
fabric@me:~$ cd fabric_install/
fabric@me:~/fabric_install$ pwd
fabric@me:~/fabric_install$ ls -hl
总用量 96M
-rwxrwxr-x 1 fabric fabric 14K 11月 16 10:28 byfn.sh
-rwxrwxr-x 1 fabric fabric 19M 11月 16 10:28 configtxgen
-rw-rw-r-- 1 fabric fabric 12K 11月 16 10:28 configtx.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 16 10:28 core.yaml
-rw-rw-r-- 1 fabric fabric 3.9K 11月 16 10:28 crypto-config.yaml
-rwxrwxr-x 1 fabric fabric 13M 11月 16 10:28 cryptogen
-rw-rw-r-- 1 fabric fabric 3 11月 16 10:28 log.txt
-rwxrwxr-x 1 fabric fabric 28M 11月 16 10:28 orderer
-rw-rw-r-- 1 fabric fabric 14K 11月 16 10:28 orderer.yaml
-rwxrwxr-x 1 fabric fabric 36M 11月 16 10:28 peer
-rw-rw-r-- 1 fabric fabric 28K 11月 16 10:28 peer0-org1.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 16 10:28 peer0-org2.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 16 10:28 peer1-org1.core.yaml
-rw-rw-r-- 1 fabric fabric 28K 11月 16 10:28 peer1-org2.core.yaml
-rw-rw-r-- 1 fabric fabric 16 11月 16 10:28 README.md
drwxrwxr-x 3 fabric fabric 4.0K 11月 16 10:28 src
下面的所有操作当前目录是:/home/fabric/fabric_install。
client机器上需要安装golang
fabric@me:~/fabric_install$ go version
go version go1.11 linux/amd64
步骤2:生成msp相关文件,genesis block,channel.tx, anchor.tx
fabric@me:~/fabric_install$ ./byfn.sh generate
CURRENTDIR = /home/fabric/fabric_install
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ ./cryptogen generate --config=./crypto-config.yaml
org1.ping40.net
org2.ping40.net
+ res=0
+ set +x
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
+ ./configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/mygenesis.block
2018-11-16 11:02:14.849 CST [common.tools.configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen for output operations is deprecated. Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.
2018-11-16 11:02:14.849 CST [common.tools.configtxgen] main -> INFO 002 Loading configuration
2018-11-16 11:02:14.876 CST [common.tools.configtxgen] doOutputBlock -> INFO 003 Generating genesis block
2018-11-16 11:02:14.876 CST [common.tools.configtxgen] doOutputBlock -> INFO 004 Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ping40channel
2018-11-16 11:02:14.909 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-16 11:02:14.931 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-11-16 11:02:14.932 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ping40channel -asOrg Org1MSP
2018-11-16 11:02:14.968 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-16 11:02:14.989 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-16 11:02:14.990 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ ./configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ping40channel -asOrg Org2MSP
2018-11-16 11:02:15.023 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2018-11-16 11:02:15.045 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-16 11:02:15.045 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x
步骤3:为orderer,peer运行准备程序,配置文件
fabric@me:~/fabric_install$ ./byfn.sh dispatch
CURRENTDIR = /home/fabric/fabric_install
##########################################################
##### copy files to run-orderer, run-peer0-org1 #########
##### run-peer1-org1, run-peer0-org2,run-peer1-org2######
##########################################################
run-orderer/
run-orderer/msp/
run-orderer/msp/tlscacerts/
run-orderer/msp/tlscacerts/tlsca.ping40.net-cert.pem
run-orderer/msp/admincerts/
run-orderer/msp/admincerts/Admin@ping40.net-cert.pem
run-orderer/msp/signcerts/
run-orderer/msp/signcerts/orderer.ping40.net-cert.pem
run-orderer/msp/keystore/
run-orderer/msp/keystore/a4bd8fcb673d31141fd34016db02f86e7e4172b111382b513bce084616910b3f_sk
run-orderer/msp/cacerts/
run-orderer/msp/cacerts/ca.ping40.net-cert.pem
run-orderer/orderer.yaml
run-orderer/orderer
run-orderer/mygenesis.block
run-peer0-org1/
run-peer0-org1/msp/
run-peer0-org1/msp/tlscacerts/
run-peer0-org1/msp/tlscacerts/tlsca.org1.ping40.net-cert.pem
run-peer0-org1/msp/admincerts/
run-peer0-org1/msp/admincerts/Admin@org1.ping40.net-cert.pem
run-peer0-org1/msp/signcerts/
run-peer0-org1/msp/signcerts/peer0.org1.ping40.net-cert.pem
run-peer0-org1/msp/keystore/
run-peer0-org1/msp/keystore/e91ac45bff00c72c6c328380fedbbcbd3980b971922617fdb1c5eb00ce12998e_sk
run-peer0-org1/msp/cacerts/
run-peer0-org1/msp/cacerts/ca.org1.ping40.net-cert.pem
run-peer0-org1/msp/config.yaml
run-peer0-org1/peer
run-peer0-org1/core.yaml
run-peer1-org1/
run-peer1-org1/msp/
run-peer1-org1/msp/tlscacerts/
run-peer1-org1/msp/tlscacerts/tlsca.org1.ping40.net-cert.pem
run-peer1-org1/msp/admincerts/
run-peer1-org1/msp/admincerts/Admin@org1.ping40.net-cert.pem
run-peer1-org1/msp/signcerts/
run-peer1-org1/msp/signcerts/peer1.org1.ping40.net-cert.pem
run-peer1-org1/msp/keystore/
run-peer1-org1/msp/keystore/801cab394608c18f3103b934312db1d38de12af6583b716be46fe81862683026_sk
run-peer1-org1/msp/cacerts/
run-peer1-org1/msp/cacerts/ca.org1.ping40.net-cert.pem
run-peer1-org1/msp/config.yaml
run-peer1-org1/peer
run-peer1-org1/core.yaml
run-peer0-org2/
run-peer0-org2/msp/
run-peer0-org2/msp/tlscacerts/
run-peer0-org2/msp/tlscacerts/tlsca.org2.ping40.net-cert.pem
run-peer0-org2/msp/admincerts/
run-peer0-org2/msp/admincerts/Admin@org2.ping40.net-cert.pem
run-peer0-org2/msp/signcerts/
run-peer0-org2/msp/signcerts/peer0.org2.ping40.net-cert.pem
run-peer0-org2/msp/keystore/
run-peer0-org2/msp/keystore/60b8537a807cb75558a489f7370f8fb1a77c6a722bad7bc1ecf672c3c4e03df5_sk
run-peer0-org2/msp/cacerts/
run-peer0-org2/msp/cacerts/ca.org2.ping40.net-cert.pem
run-peer0-org2/msp/config.yaml
run-peer0-org2/peer
run-peer0-org2/core.yaml
run-peer1-org2/
run-peer1-org2/msp/
run-peer1-org2/msp/tlscacerts/
run-peer1-org2/msp/tlscacerts/tlsca.org2.ping40.net-cert.pem
run-peer1-org2/msp/admincerts/
run-peer1-org2/msp/admincerts/Admin@org2.ping40.net-cert.pem
run-peer1-org2/msp/signcerts/
run-peer1-org2/msp/signcerts/peer1.org2.ping40.net-cert.pem
run-peer1-org2/msp/keystore/
run-peer1-org2/msp/keystore/2e3473ee76be82329d62b975467d23aebe23baa99c1d5ff4025ae0ab632695da_sk
run-peer1-org2/msp/cacerts/
run-peer1-org2/msp/cacerts/ca.org2.ping40.net-cert.pem
run-peer1-org2/msp/config.yaml
run-peer1-org2/peer
run-peer1-org2/core.yaml
一:多机环境下程序分发
fabric@me:~/fabric_install$ cd multimachine/
fabric@me:~/fabric_install/multimachine$ ll
总用量 58444
drwxrwxr-x 2 fabric fabric 4096 11月 16 11:05 ./
drwxrwxr-x 12 fabric fabric 4096 11月 16 11:05 ../
-rw-rw-r-- 1 fabric fabric 9749482 11月 16 11:05 run-orderer.tar.gz -->这个文件复制到orderer的机器上
-rw-rw-r-- 1 fabric fabric 12521375 11月 16 11:05 run-peer0-org1.tar.gz -->这个文件复制到peer0-org1的机器上
-rw-rw-r-- 1 fabric fabric 12521356 11月 16 11:05 run-peer0-org2.tar.gz
-rw-rw-r-- 1 fabric fabric 12521335 11月 16 11:05 run-peer1-org1.tar.gz
-rw-rw-r-- 1 fabric fabric 12520864 11月 16 11:05 run-peer1-org2.tar.gz
步骤4: 启动orderer,peer程序
一:多机环境下
启动orderer
[root@c69 run-orderer]# ls -lh
总用量 28M
drwxr-xr-x 7 1001 1001 85 11月 16 11:05 msp
-rw-r--r-- 1 1001 1001 13K 11月 16 11:05 mygenesis.block
-rwxrwxr-x 1 1001 1001 28M 11月 16 11:05 orderer
-rw-rw-r-- 1 1001 1001 14K 11月 16 11:05 orderer.yaml
[root@c69 run-orderer]#
[root@c69 run-orderer]# ./orderer start
......
5e38af704638328bfac205bd953153359bcb9d949daf4b6aa771cc8eac7e47b9 and orderer type solo
2018-11-16 11:29:01.247 CST [orderer.common.server] Start -> INFO 005 Starting orderer:
Version: 1.4.0
Commit SHA: b2ea980d5
Go version: go1.11
OS/Arch: linux/amd64
2018-11-16 11:29:01.247 CST [orderer.common.server] Start -> INFO 006 Beginning to serve requests
启动4个peer节点
ll
总用量 36124
-rw-rw-r-- 1 1001 1001 28267 11月 16 11:05 core.yaml
drwxr-xr-x 7 1001 1001 103 11月 16 11:05 msp
-rwxrwxr-x 1 1001 1001 36961288 11月 16 11:05 peer
[root@c249 run-peer1-org2]# pwd
/root/run-peer1-org2
[root@c249 run-peer1-org2]# ./peer node start
2018-11-16 11:33:47.335 CST [nodeCmd] serve -> INFO 001 Starting peer:
Version: 1.4.0
Commit SHA: b2ea980d5
Go version: go1.11
OS/Arch: linux/amd64
Chaincode:
Base Image Version: 0.4.14
Base Docker Namespace: hyperledger
Base Docker Label: org.hyperledger.fabric
Docker Namespace: hyperledger
2018-11-16 11:33:47.336 CST [ledgermgmt] initialize -> INFO 002 Initializing ledger mgmt
.....
二:单机环境环境下
drwxrwxr-x 3 fabric fabric 4096 11月 16 11:05 run-orderer/
drwxrwxr-x 3 fabric fabric 4096 11月 16 11:05 run-peer0-org1/
drwxrwxr-x 3 fabric fabric 4096 11月 16 11:05 run-peer0-org2/
drwxrwxr-x 3 fabric fabric 4096 11月 16 11:05 run-peer1-org1/
drwxrwxr-x 3 fabric fabric 4096 11月 16 11:05 run-peer1-org2/
请到上面5个目录下,启动对应的服务
步骤5: 创建通道
步骤5.1: 创建通道
fabric@me:~/fabric_install$ ./byfn.sh createChannel
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel create -o orderer.ping40.net:51000 -c ping40channel -f ./channel-artifacts/channel.tx --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:41:55.284 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:41:55.298 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:41:55.300 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:41:55.421 CST [cli.common] readBlock -> INFO 004 Received block: 0
===================== Channel 'ping40channel' created =====================
步骤5.2: peer节点加入通道
fabric@me:~/fabric_install$ ./byfn.sh joinChannel
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:42:47.689 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:47.705 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:47.707 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:42:47.984 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer0-org1.ping40.net success to join channel =====================
00 setGlobals 1, 1
02 setGlobals 1, 1
CORE_PEER_ADDRESS: peer1.org1.ping40.net:51110
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer1.org1.ping40.net:51110
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:42:48.034 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.049 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.051 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:42:48.369 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer1-org1.ping40.net success to join channel =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:42:48.420 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.436 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.437 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:42:48.683 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer0-org2.ping40.net success to join channel =====================
00 setGlobals 1, 2
CORE_PEER_ADDRESS: peer1.org2.ping40.net:51210
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer1.org2.ping40.net:51210
+ ./peer channel join -b ping40channel.block --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:42:48.738 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.752 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:42:48.753 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:42:49.058 CST [channelCmd] executeJoin -> INFO 004 Successfully submitted proposal to join channel
===================== peer1-org2.ping40.net success to join channel =====================
步骤5.3: 更新锚节点
fabric@me:~/fabric_install$ ./byfn.sh updateAnchor
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer channel update -o orderer.ping40.net:51000 -c ping40channel -f channel-artifacts/Org1MSPanchors.tx --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:48:18.368 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:48:18.385 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:48:18.386 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:48:18.410 CST [channelCmd] update -> INFO 004 Successfully submitted channel update
===================== peer0-org1.ping40.net success to updateAnchor =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer channel update -o orderer.ping40.net:51000 -c ping40channel -f channel-artifacts/Org2MSPanchors.tx --logging-level=debug
+ res=0
+ set +x
2018-11-16 11:48:18.459 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:48:18.474 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 11:48:18.475 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-16 11:48:18.487 CST [channelCmd] update -> INFO 004 Successfully submitted channel update
===================== peer0-org2.ping40.net success to updateAnchor =====================
步骤6: Chaincode的部署和调用
步骤6.1: 部署Chaincode代码
fabric@me:~/fabric_install$ ./byfn.sh installChaincode
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ GOPATH=/home/fabric/fabric_install
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode install -n chaincodeName -v 3.1 -p chaincode/ --logging-level=debug
+ res=0
+ set +x
2018-11-16 12:05:53.642 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 12:05:53.657 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 12:05:53.664 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-16 12:05:53.664 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-16 12:05:54.028 CST [chaincodeCmd] install -> INFO 005 Installed remotely response:<status:200 payload:"OK" >
===================== peer0-org1.ping40.net success to installChaincode =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ GOPATH=/home/fabric/fabric_install
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode install -n chaincodeName -v 3.1 -p chaincode/ --logging-level=debug
+ res=0
+ set +x
2018-11-16 12:05:54.076 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 12:05:54.090 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 12:05:54.094 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-16 12:05:54.094 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-16 12:05:54.292 CST [chaincodeCmd] install -> INFO 005 Installed remotely response:<status:200 payload:"OK" >
===================== peer0-org2.ping40.net success to installChaincode =====================
如果client机器没有 golang环境,会有如下错误
Error: error getting chaincode code chaincodeName: <go, [env]>: failed with error: "exec: not started"
步骤6.2: 实例化Chaincode代码
fabric@me:~/fabric_install$ ./byfn.sh instantiateChaincode
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode instantiate -o orderer.ping40.net:51000 -C ping40channel -n chaincodeName -v 3.1 -c '{"Args":["init","a","100","b","200"]}' -P 'OR ('\''Org1MSP.member'\'', '\''Org2MSP.member'\'')' --logging-level=debug
+ res=0
+ set +x
2018-11-16 13:48:16.484 CST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 13:48:16.498 CST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2018-11-16 13:48:16.502 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-16 13:48:16.502 CST [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
===================== peer0-org2.ping40.net success to instantiateChaincode =====================
步骤6.3: 通过Chaincode写入数据
fabric@me:~/fabric_install$ ./byfn.sh invokeChaincode
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode invoke -o orderer.ping40.net:51000 -C ping40channel -n chaincodeName -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2018-11-16 13:54:08.347 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on on channel 'ping40channel' =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode invoke -o orderer.ping40.net:51000 -C ping40channel -n chaincodeName -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2018-11-16 13:54:08.423 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on on channel 'ping40channel' =====================
几乎同时触发二个transaction,其中一个会失败的
步骤6.4: 通过Chaincode查询数据
fabric@me:~/fabric_install$ ./byfn.sh queryChaincode
CURRENTDIR = /home/fabric/fabric_install
00 setGlobals 0, 1
02 setGlobals 0, 1
CORE_PEER_ADDRESS: peer0.org1.ping40.net:51100
CORE_PEER_LOCALMSPID: Org1MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org1MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org1.ping40.net/users/Admin@org1.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org1.ping40.net:51100
+ ./peer chaincode query -C ping40channel -n chaincodeName -c '{"Args":["query","a"]}'
+ res=0
+ set +x
90
========= Query successful on peer0.org1 on channel 'ping40channel' =====================
00 setGlobals 0, 2
CORE_PEER_ADDRESS: peer0.org2.ping40.net:51200
CORE_PEER_LOCALMSPID: Org2MSP
CORE_PEER_MSPCONFIGPATH: /home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
environment variables: begin
environment variables: end
+ CORE_PEER_LOCALMSPID=Org2MSP
+ CORE_PEER_MSPCONFIGPATH=/home/fabric/fabric_install/crypto-config/peerOrganizations/org2.ping40.net/users/Admin@org2.ping40.net/msp
+ CORE_PEER_ADDRESS=peer0.org2.ping40.net:51200
+ ./peer chaincode query -C ping40channel -n chaincodeName -c '{"Args":["query","a"]}'
+ res=0
+ set +x
90
========= Query successful on peer0.org2 on channel 'ping40channel' =====================
有疑问加站长微信联系(非本文作者)