Fabric开发(五) Ubuntu20.04.1快速搭建Fabric2.2.0 (排雷版)

写在前面

看到题目,你可能会想,这个作者脑子抽吧,怎么又要出一篇关于环境搭建的。 emm,毕竟我是那种送佛送到西的人。(哈哈 其实是被小伙伴说了,现在都2.0时代了,怎么还搞1.0的东西,变化挺大的呢) 说来也对,截止当下北京时间2020年9月25号,Fabric github 已经更新到2.2版本,为了保证技术的新鲜热乎的赶脚,我决定就采用2.2版本了。e_e,感觉是给自己又开了个坑,本来想写2.0版本的,稳定版本他不香么。

嗯,他不香。FabricV2.2版本现在奉上。(1.4.3版本请点击这里)

1、切换到2.2版本

1cd ~/go/src/github.com/hyperledger/fabric/ 2git checkout v2.2.0 3 4Previous HEAD position was b8c4a6aa7 [FAB-16412] Release fabric v1.4.3 5HEAD is now at 5ea85bc54 Fabric v2.2.0 release commit

2、执行bootstrap.sh下载镜像和二进制文件

1cd scripts/ 2./bootstrap.sh

执行过程如下:
在这里插入图片描述
以上执行有点慢。。。我这边下载了20分钟左右。。。时间自行调整哈。emm ,我就说事情没有这么简单吧,又来一个,我就纳闷了下载1.4.7又是要作甚?(各位小伙伴有更好的办法请留言告知我,我这边也做一个记录和更新呀
在这里插入图片描述
这两个下载完应该可以了吧,不要还有啊。预计下载总时长30分钟。可以的,下载好了,结果如下。

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts$ ./bootstrap.sh 2 3Clone hyperledger/fabric-samples repo 4 5===> Checking out v2.2.0 of hyperledger/fabric-samples 6error: pathspec 'v2.2.0' did not match any file(s) known to git 7 8Pull Hyperledger Fabric binaries 9 10===> Downloading version 2.2.0 platform specific fabric binaries 11===> Downloading: https://github.com/hyperledger/fabric/releases/download/v2.2.0/hyperledger-fabric-linux-amd64-2.2.0.tar.gz 12 % Total % Received % Xferd Average Speed Time Time Time Current 13 Dload Upload Total Spent Left Speed 14100 667 100 667 0 0 1089 0 --:--:-- --:--:-- --:--:-- 1089 15100 72.7M 100 72.7M 0 0 66705 0 0:19:03 0:19:03 --:--:-- 48032 16==> Done. 17===> Downloading version 1.4.7 platform specific fabric-ca-client binary 18===> Downloading: https://github.com/hyperledger/fabric-ca/releases/download/v1.4.7/hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz 19 % Total % Received % Xferd Average Speed Time Time Time Current 20 Dload Upload Total Spent Left Speed 21100 670 100 670 0 0 240 0 0:00:02 0:00:02 --:--:-- 239 22100 23.6M 100 23.6M 0 0 49739 0 0:08:17 0:08:17 --:--:-- 106k 23==> Done. 24 25Pull Hyperledger Fabric docker images 26 27FABRIC_IMAGES: peer orderer ccenv tools nodeenv baseos javaenv 28===> Pulling fabric Images 29====> hyperledger/fabric-peer:2.2.0 302.2.0: Pulling from hyperledger/fabric-peer 31df20fa9351a1: Pull complete 322f32f83c5fab: Pull complete 339e46444d9bf3: Pull complete 34861b7a9f9840: Pull complete 35b4064bf05b0b: Pull complete 364ee14d1f801f: Pull complete 37Digest: sha256:81efaab943387820815c9b9bd3e3bec9d262365e635bac6f500a287fb3e873e7 38Status: Downloaded newer image for hyperledger/fabric-peer:2.2.0 39docker.io/hyperledger/fabric-peer:2.2.0 40====> hyperledger/fabric-orderer:2.2.0 412.2.0: Pulling from hyperledger/fabric-orderer 42df20fa9351a1: Already exists 432f32f83c5fab: Already exists 44894c488ba627: Pull complete 455bc2319b26e2: Pull complete 460d1a6ef2d9ec: Pull complete 4794c4e0cdcdfb: Pull complete 48cfb83833d872: Pull complete 49Digest: sha256:bb97a8e80b53d9f32c3b850ae3b55bab57bf3cc9483978a471a5bee0ac49728e 50Status: Downloaded newer image for hyperledger/fabric-orderer:2.2.0 51docker.io/hyperledger/fabric-orderer:2.2.0 52====> hyperledger/fabric-ccenv:2.2.0 532.2.0: Pulling from hyperledger/fabric-ccenv 54df20fa9351a1: Already exists 55ed8968b2872e: Pull complete 56a92cc7c5fd73: Pull complete 579e0cccf56431: Pull complete 58cbe0275821fc: Pull complete 59d8f39229024f: Pull complete 609fe2c7972d12: Pull complete 61050fa39404af: Pull complete 62ab61a9ef0e4b: Pull complete 63Digest: sha256:4ec2f71fbcd52a1e6717f5eb20f82452c24352faa2dcd08d3941e0bf2438610b 64Status: Downloaded newer image for hyperledger/fabric-ccenv:2.2.0 65docker.io/hyperledger/fabric-ccenv:2.2.0 66====> hyperledger/fabric-tools:2.2.0 672.2.0: Pulling from hyperledger/fabric-tools 68df20fa9351a1: Already exists 69ed8968b2872e: Already exists 70a92cc7c5fd73: Already exists 719e0cccf56431: Already exists 72cbe0275821fc: Already exists 7371ccef561004: Pull complete 74b6f489e17ff2: Pull complete 75c767f04d100e: Pull complete 76Digest: sha256:d328c63a5ca2e9d27e74ee43d17fcfada9937961d5e70433a1d66352f6e7b652 77Status: Downloaded newer image for hyperledger/fabric-tools:2.2.0 78docker.io/hyperledger/fabric-tools:2.2.0 79====> hyperledger/fabric-nodeenv:2.2.0 802.2.0: Pulling from hyperledger/fabric-nodeenv 81aad63a933944: Pull complete 82edd41271d385: Pull complete 83dd731a721451: Pull complete 84495807fcdd37: Pull complete 85ea7337a9c641: Pull complete 86500dc4d300c4: Pull complete 87288c5daaa0fb: Pull complete 88Digest: sha256:794194885581f59535d4c13b0e0ae8896f43d9333a42020eb35fdf8f28aba90e 89Status: Downloaded newer image for hyperledger/fabric-nodeenv:2.2.0 90docker.io/hyperledger/fabric-nodeenv:2.2.0 91====> hyperledger/fabric-baseos:2.2.0 922.2.0: Pulling from hyperledger/fabric-baseos 93df20fa9351a1: Already exists 942f32f83c5fab: Already exists 9555a6005882ed: Pull complete 96Digest: sha256:6584eb096bb3cf495e4c2ebf162ed7c1be45157b89662c0d407bfd9adc036d66 97Status: Downloaded newer image for hyperledger/fabric-baseos:2.2.0 98docker.io/hyperledger/fabric-baseos:2.2.0 99====> hyperledger/fabric-javaenv:2.2.0 1002.2.0: Pulling from hyperledger/fabric-javaenv 1019d48c3bd43c5: Pull complete 10215f4f2d99e41: Pull complete 10337cbb5ebfe5b: Pull complete 10498767d3f4b64: Pull complete 105c9c532b143b0: Pull complete 106ac32095a41c6: Pull complete 10723295c8e3cc2: Pull complete 108dd43e444d573: Pull complete 1098c3d7e276648: Pull complete 110a84723b6c2fc: Pull complete 111Digest: sha256:6c85b2fce9b9d0c4420d6131f2dea321be728142e3d2d494a4296b43d66afdfa 112Status: Downloaded newer image for hyperledger/fabric-javaenv:2.2.0 113docker.io/hyperledger/fabric-javaenv:2.2.0 114===> Pulling fabric ca Image 115====> hyperledger/fabric-ca:1.4.7 1161.4.7: Pulling from hyperledger/fabric-ca 117b8f262c62ec6: Pull complete 11856b16818f60b: Pull complete 119707812f2aa2d: Pull complete 120400ab1f52b57: Pull complete 1211e32346b61cd: Pull complete 122d1832ac8c002: Pull complete 123cb7ebebf613a: Pull complete 1246af9a3114ec8: Pull complete 125Digest: sha256:9418ea351bfbef4bf2bca34bcd77305bdb9a45d2c1aab3237c08c17da0b4d1dd 126Status: Downloaded newer image for hyperledger/fabric-ca:1.4.7 127docker.io/hyperledger/fabric-ca:1.4.7 128===> List out hyperledger docker images 129hyperledger/fabric-tools 2.2 5eb2356665e7 2 months ago 519MB 130hyperledger/fabric-tools 2.2.0 5eb2356665e7 2 months ago 519MB 131hyperledger/fabric-tools latest 5eb2356665e7 2 months ago 519MB 132hyperledger/fabric-peer 2.2 760f304a3282 2 months ago 54.9MB 133hyperledger/fabric-peer 2.2.0 760f304a3282 2 months ago 54.9MB 134hyperledger/fabric-peer latest 760f304a3282 2 months ago 54.9MB 135hyperledger/fabric-orderer 2.2 5fb8e97da88d 2 months ago 38.4MB 136hyperledger/fabric-orderer 2.2.0 5fb8e97da88d 2 months ago 38.4MB 137hyperledger/fabric-orderer latest 5fb8e97da88d 2 months ago 38.4MB 138hyperledger/fabric-ccenv 2.2 aac435a5d3f1 2 months ago 586MB 139hyperledger/fabric-ccenv 2.2.0 aac435a5d3f1 2 months ago 586MB 140hyperledger/fabric-ccenv latest aac435a5d3f1 2 months ago 586MB 141hyperledger/fabric-baseos 2.2 aa2bdf8013af 2 months ago 6.85MB 142hyperledger/fabric-baseos 2.2.0 aa2bdf8013af 2 months ago 6.85MB 143hyperledger/fabric-baseos latest aa2bdf8013af 2 months ago 6.85MB 144hyperledger/fabric-nodeenv 2.2 ab88fe4d29dd 2 months ago 293MB 145hyperledger/fabric-nodeenv 2.2.0 ab88fe4d29dd 2 months ago 293MB 146hyperledger/fabric-nodeenv latest ab88fe4d29dd 2 months ago 293MB 147hyperledger/fabric-javaenv 2.2 56c30f316b23 2 months ago 504MB 148hyperledger/fabric-javaenv 2.2.0 56c30f316b23 2 months ago 504MB 149hyperledger/fabric-javaenv latest 56c30f316b23 2 months ago 504MB 150hyperledger/fabric-ca 1.4 743a758fae29 4 months ago 154MB 151hyperledger/fabric-ca 1.4.7 743a758fae29 4 months ago 154MB 152hyperledger/fabric-ca latest 743a758fae29 4 months ago 154MB 153hyperledger/fabric-tools 1.4.3 18ed4db0cd57 13 months ago 1.55GB 154hyperledger/fabric-ca 1.4.3 c18a0d3cc958 13 months ago 253MB 155hyperledger/fabric-ccenv 1.4.3 3d31661a812a 13 months ago 1.45GB 156hyperledger/fabric-orderer 1.4.3 b666a6ebbe09 13 months ago 173MB 157hyperledger/fabric-peer 1.4.3 fa87ccaed0ef 13 months ago 179MB 158hyperledger/fabric-javaenv 1.4.3 5ba5ba09db8f 14 months ago 1.76GB 159hyperledger/fabric-zookeeper 0.4.15 20c6045930c8 18 months ago 1.43GB 160hyperledger/fabric-zookeeper latest 20c6045930c8 18 months ago 1.43GB 161hyperledger/fabric-kafka 0.4.15 b4ab82bbaf2f 18 months ago 1.44GB 162hyperledger/fabric-kafka latest b4ab82bbaf2f 18 months ago 1.44GB 163hyperledger/fabric-couchdb 0.4.15 8de128a55539 18 months ago 1.5GB 164hyperledger/fabric-couchdb latest 8de128a55539 18 months ago 1.5GB 165hyperledger/fabric-baseos amd64-0.4.15 9d6ec11c60ff 18 months ago 145MB 166hyperledger/fabric-tools x86_64-1.0.0 0403fd1c72c7 3 years ago 1.32GB 167hyperledger/fabric-couchdb x86_64-1.0.0 2fbdbf3ab945 3 years ago 1.48GB 168hyperledger/fabric-kafka x86_64-1.0.0 dbd3f94de4b5 3 years ago 1.3GB 169hyperledger/fabric-zookeeper x86_64-1.0.0 e545dbf1c6af 3 years ago 1.31GB 170hyperledger/fabric-orderer x86_64-1.0.0 e317ca5638ba 3 years ago 179MB 171hyperledger/fabric-peer x86_64-1.0.0 6830dcd7b9b5 3 years ago 182MB 172hyperledger/fabric-javaenv x86_64-1.0.0 8948126f0935 3 years ago 1.42GB 173hyperledger/fabric-ccenv x86_64-1.0.0 7182c260a5ca 3 years ago 1.29GB 174hyperledger/fabric-ca x86_64-1.0.0 a15c59ecda5b 3 years ago 238MB 175hyperledger/fabric-baseos x86_64-0.3.1 4b0cab202084 3 years ago 157MB 176halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts$

3、测试网络

1.启动test-network测试网络

(中间有一段排错过程,想跳过的直接点击右侧目录真正启动测试网络哦)

网上看教程都说有这么一个test-network的文件夹,但是我本地我是没有,网上说法如下:在这里插入图片描述
我自己本地环境如下:
在这里插入图片描述
查看docker镜像显示如下。

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples$ docker images 2REPOSITORY TAG IMAGE ID CREATED SIZE 3dev-peer1.org2.example.com-fabcar-1.0-a139c9f32bcd86b26c02c1cfecba01c235a9007e24c34b03cb1d82d000696338 latest 8a9b6a0e83af 47 hours ago 162MB 4dev-peer0.org2.example.com-fabcar-1.0-264b0a1cb5efbecaac5cf8990339c24474dc8435c6e10f10f2be565d555d0e94 latest f249485f4870 47 hours ago 162MB 5dev-peer1.org1.example.com-fabcar-1.0-791f4e9c59e5c5ae44b5e63c754aaf47cfa4757490019879665238e39ab45594 latest db02cd8473c1 47 hours ago 162MB 6dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba latest 402ec60c1200 47 hours ago 162MB 7hyperledger/fabric-tools 2.2 5eb2356665e7 2 months ago 519MB 8hyperledger/fabric-tools 2.2.0 5eb2356665e7 2 months ago 519MB 9hyperledger/fabric-tools latest 5eb2356665e7 2 months ago 519MB 10hyperledger/fabric-peer 2.2 760f304a3282 2 months ago 54.9MB 11hyperledger/fabric-peer 2.2.0 760f304a3282 2 months ago 54.9MB 12hyperledger/fabric-peer latest 760f304a3282 2 months ago 54.9MB 13hyperledger/fabric-orderer 2.2 5fb8e97da88d 2 months ago 38.4MB 14hyperledger/fabric-orderer 2.2.0 5fb8e97da88d 2 months ago 38.4MB 15hyperledger/fabric-orderer latest 5fb8e97da88d 2 months ago 38.4MB 16hyperledger/fabric-ccenv 2.2 aac435a5d3f1 2 months ago 586MB 17hyperledger/fabric-ccenv 2.2.0 aac435a5d3f1 2 months ago 586MB 18hyperledger/fabric-ccenv latest aac435a5d3f1 2 months ago 586MB 19hyperledger/fabric-baseos 2.2 aa2bdf8013af 2 months ago 6.85MB 20hyperledger/fabric-baseos 2.2.0 aa2bdf8013af 2 months ago 6.85MB 21hyperledger/fabric-baseos latest aa2bdf8013af 2 months ago 6.85MB 22hyperledger/fabric-nodeenv 2.2 ab88fe4d29dd 2 months ago 293MB 23hyperledger/fabric-nodeenv 2.2.0 ab88fe4d29dd 2 months ago 293MB 24hyperledger/fabric-nodeenv latest ab88fe4d29dd 2 months ago 293MB 25hyperledger/fabric-javaenv 2.2 56c30f316b23 2 months ago 504MB 26hyperledger/fabric-javaenv 2.2.0 56c30f316b23 2 months ago 504MB 27hyperledger/fabric-javaenv latest 56c30f316b23 2 months ago 504MB 28hyperledger/fabric-ca 1.4 743a758fae29 4 months ago 154MB 29hyperledger/fabric-ca 1.4.7 743a758fae29 4 months ago 154MB 30hyperledger/fabric-ca latest 743a758fae29 4 months ago 154MB 31hyperledger/fabric-tools 1.4.3 18ed4db0cd57 13 months ago 1.55GB 32hyperledger/fabric-ca 1.4.3 c18a0d3cc958 13 months ago 253MB 33hyperledger/fabric-ccenv 1.4.3 3d31661a812a 13 months ago 1.45GB 34hyperledger/fabric-orderer 1.4.3 b666a6ebbe09 13 months ago 173MB 35hyperledger/fabric-peer 1.4.3 fa87ccaed0ef 13 months ago 179MB 36hyperledger/fabric-javaenv 1.4.3 5ba5ba09db8f 14 months ago 1.76GB 37hyperledger/fabric-zookeeper 0.4.15 20c6045930c8 18 months ago 1.43GB 38hyperledger/fabric-zookeeper latest 20c6045930c8 18 months ago 1.43GB 39hyperledger/fabric-kafka 0.4.15 b4ab82bbaf2f 18 months ago 1.44GB 40hyperledger/fabric-kafka latest b4ab82bbaf2f 18 months ago 1.44GB 41hyperledger/fabric-couchdb 0.4.15 8de128a55539 18 months ago 1.5GB 42hyperledger/fabric-couchdb latest 8de128a55539 18 months ago 1.5GB 43hyperledger/fabric-baseos amd64-0.4.15 9d6ec11c60ff 18 months ago 145MB 44hyperledger/fabric-tools x86_64-1.0.0 0403fd1c72c7 3 years ago 1.32GB 45hyperledger/fabric-couchdb x86_64-1.0.0 2fbdbf3ab945 3 years ago 1.48GB 46hyperledger/fabric-kafka x86_64-1.0.0 dbd3f94de4b5 3 years ago 1.3GB 47hyperledger/fabric-zookeeper x86_64-1.0.0 e545dbf1c6af 3 years ago 1.31GB 48hyperledger/fabric-orderer x86_64-1.0.0 e317ca5638ba 3 years ago 179MB 49hyperledger/fabric-peer x86_64-1.0.0 6830dcd7b9b5 3 years ago 182MB 50hyperledger/fabric-javaenv x86_64-1.0.0 8948126f0935 3 years ago 1.42GB 51hyperledger/fabric-ccenv x86_64-1.0.0 7182c260a5ca 3 years ago 1.29GB 52hyperledger/fabric-ca x86_64-1.0.0 a15c59ecda5b 3 years ago 238MB 53hyperledger/fabric-baseos x86_64-0.3.1 4b0cab202084 3 years ago 157MB 54

我怀疑是我之前在下载V1.4.3的时候,带出了他这个版本的样例,然后V2.2.0的样例没有下载下来。所以删掉所有镜像在下载一遍。

11.停止所有的container,这样才能够删除其中的images: 2sudo docker stop $(docker ps -a -q) 32.删除全部image 4sudo docker rmi -f $(docker images -q) 53.删除掉fabirc-samples文件夹 6cd scripts/ 7sudo rm -rf ./fabirc-samples/ 84.重新下载镜像文件./ 9./bootstrap.sh

安装成功后,查看docker镜像如下:
在这里插入图片描述
好了,继续我们的表演,果然有了
在这里插入图片描述

1-1真正启动测试网络

1cd test-network 2./network.sh up

启动成功,会启动两个peer节点和一个order节点,启动成功代码如下:

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh up 2Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen' 3LOCAL_VERSION=2.2.0 4DOCKER_IMAGE_VERSION=2.2.0 5/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/cryptogen 6Generate certificates using cryptogen tool 7Create Org1 Identities 8+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations 9org1.example.com 10+ res=0 11Create Org2 Identities 12+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations 13org2.example.com 14+ res=0 15Create Orderer Org Identities 16+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations 17+ res=0 18Generate CCP files for Org1 and Org2 19/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/configtxgen 20Generating Orderer Genesis block 21+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block 222020-09-28 09:24:05.552 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 232020-09-28 09:24:05.597 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft 242020-09-28 09:24:05.598 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 252020-09-28 09:24:05.598 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 262020-09-28 09:24:05.600 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block 272020-09-28 09:24:05.601 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block 28+ res=0 29Creating network "net_test" with the default driver 30Creating peer0.org2.example.com ... 31Creating orderer.example.com ... 32Creating peer0.org1.example.com ... 33Creating orderer.example.com 34Creating peer0.org2.example.com 35Creating orderer.example.com ... done 36CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 37c9f50ffaa78d hyperledger/fabric-peer:latest "peer node start" 4 seconds ago Up Less than a second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com 38b0997434fbe6 hyperledger/fabric-peer:latest "peer node start" 4 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp peer0.org1.example.com 39b8ebbe2006ea hyperledger/fabric-orderer:latest "orderer" 4 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com 40halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$

查看docker容器,发现是停止状态
在这里插入图片描述
到这里,fabric测试网络test-network部署成功。

4、使用测试网络

1.创建channel,使用network.sh脚本创建来创建一个连接org1和org2组织并加入他们peer的通道,命令如下:

 ./network.sh createChannel

报错如下:

1Error: failed to create deliver client for orderer: orderer client failed to connect to localhost:7050: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:7050: connect: connection refused" 2Channel creation failed 3Create channel failed

看了其他教程,在执行上述启动网络命令后,容器是启动状态,我的这边确实停止状态,所以再次启动网络先,如果不行就单独启动docker容器。(经测试,docker容器仍然是未启动状态),我们直接启动容器,启动容器后发现还是无法正常启动,主要排查思路如下,最终解决问题。

11、针对上述连接被拒绝的问题,网上查找发现是防火墙阻止了7050端口,可以用以下命令解决 2sudo firewall-cmd --list-ports 3sudo firewall-cmd --zone=public --add-port=7050/tcp --permanent 4sudo firewall-cmd --reload 52、再次启动还是失败,查看network.sh源文件后,发现最末尾有几个命令,执行了其中的restart命令后,又报错如下 6#ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-8ef0f2f88baa -j RETURN: iptables: No chain/target/match by that name.(exit status 1)) 73、经再次查证,发现需要重启防火墙也需要,重启docker,执行如下命令 8service docker restart 94、再次重新启动网络,发现终于成功了,如下 10 11halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh restart 12Restarting network 13Removing network net_test 14WARNING: Network net_test not found. 15Removing volume net_peer0.org1.example.com 16WARNING: Volume net_peer0.org1.example.com not found. 17Removing volume net_peer0.org2.example.com 18WARNING: Volume net_peer0.org2.example.com not found. 19Removing volume net_orderer.example.com 20WARNING: Volume net_orderer.example.com not found. 21Removing network net_test 22WARNING: Network net_test not found. 23Removing volume net_peer0.org3.example.com 24WARNING: Volume net_peer0.org3.example.com not found. 25LOCAL_VERSION=2.2.0 26DOCKER_IMAGE_VERSION=2.2.0 27Creating network "net_test" with the default driver 28Creating volume "net_peer0.org1.example.com" with default driver 29Creating volume "net_peer0.org2.example.com" with default driver 30Creating volume "net_orderer.example.com" with default driver 31Creating peer0.org2.example.com ... 32Creating orderer.example.com ... 33Creating peer0.org1.example.com ... 34Creating peer0.org2.example.com 35Creating peer0.org1.example.com 36Creating peer0.org1.example.com ... done 37CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 38904395b01869 hyperledger/fabric-orderer:latest "orderer" 3 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com 3944dad802a505 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp peer0.org1.example.com 406d17e9b84c87 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com 41halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ docker ps 42CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 43904395b01869 hyperledger/fabric-orderer:latest "orderer" 11 seconds ago Up 7 seconds 0.0.0.0:7050->7050/tcp orderer.example.com 4444dad802a505 hyperledger/fabric-peer:latest "peer node start" 11 seconds ago Up 7 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com 456d17e9b84c87 hyperledger/fabric-peer:latest "peer node start" 11 seconds ago Up 7 seconds 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com 46halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ docker ps -a 47CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 48904395b01869 hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com 4944dad802a505 hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 0.0.0.0:7051->7051/tcp peer0.org1.example.com 506d17e9b84c87 hyperledger/fabric-peer:latest "peer node start" About a minute ago Up About a minute 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com

鲁迅说,人间处处是真坑,踩的多了,就习惯了。(周树人:我没有说。)

再次创建Channel,发现终于成功了

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh createChannel 2Creating channel 'mychannel'. 3If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb 4Generating channel create transaction 'mychannel.tx' 5+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel 62020-09-28 10:10:08.392 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 72020-09-28 10:10:08.430 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 82020-09-28 10:10:08.430 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx 92020-09-28 10:10:08.433 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx 10+ res=0 11Generating anchor peer update transactions 12Generating anchor peer update transaction for Org1MSP 13+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP 142020-09-28 10:10:08.468 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 152020-09-28 10:10:08.507 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 162020-09-28 10:10:08.507 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 172020-09-28 10:10:08.508 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update 18+ res=0 19Generating anchor peer update transaction for Org2MSP 20+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP 212020-09-28 10:10:08.550 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 222020-09-28 10:10:08.584 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 232020-09-28 10:10:08.584 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 242020-09-28 10:10:08.586 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update 25+ res=0 26Creating channel mychannel 27Using organization 1 28+ peer channel create -o localhost:7050 -c mychannel --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/mychannel.tx --outputBlock ./channel-artifacts/mychannel.block --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 29+ res=0 302020-09-28 10:10:11.785 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 312020-09-28 10:10:11.893 CST [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND} 322020-09-28 10:10:11.905 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 332020-09-28 10:10:12.107 CST [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE} 342020-09-28 10:10:12.110 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized 352020-09-28 10:10:12.315 CST [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE} 362020-09-28 10:10:12.330 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized 372020-09-28 10:10:12.535 CST [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE} 382020-09-28 10:10:12.542 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized 392020-09-28 10:10:12.745 CST [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE} 402020-09-28 10:10:12.749 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized 412020-09-28 10:10:12.953 CST [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE} 422020-09-28 10:10:12.964 CST [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized 432020-09-28 10:10:13.186 CST [cli.common] readBlock -> INFO 00e Received block: 0 44Channel 'mychannel' created 45Join Org1 peers to the channel... 46Using organization 1 47+ peer channel join -b ./channel-artifacts/mychannel.block 48+ res=0 492020-09-28 10:10:16.363 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 502020-09-28 10:10:16.471 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 51Join Org2 peers to the channel... 52Using organization 2 53+ peer channel join -b ./channel-artifacts/mychannel.block 54+ res=0 552020-09-28 10:10:19.617 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 562020-09-28 10:10:19.665 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 57Updating anchor peers for org1... 58Using organization 1 59+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 60+ res=0 612020-09-28 10:10:22.721 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 622020-09-28 10:10:22.755 CST [channelCmd] update -> INFO 002 Successfully submitted channel update 63Anchor peers updated for org 'Org1MSP' on channel 'mychannel' 64Updating anchor peers for org2... 65Using organization 2 66+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 67+ res=0 682020-09-28 10:10:28.835 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 692020-09-28 10:10:28.854 CST [channelCmd] update -> INFO 002 Successfully submitted channel update 70Anchor peers updated for org 'Org2MSP' on channel 'mychannel' 71Channel successfully joined

拓展:
也可以带上channel标签,命令如下(-c channelName):

 ./network.sh createChannel -c channel1

如果要在一个步骤中启动网络并创建频道,可以同时使用up和create channel模式:

./network.sh up createChannel

2.在通道上启动链码

2-1.使用network.sh创建通道之后,可以使用以下命令在通道上启动链码(默认使用go语言):

1./network.sh deployCC 2可以指定语言,加-l ,比如我用java,命令如下: 3./network.sh deployCC -ccl java

启动结果如下:

1deploying chaincode on channel 'mychannel' 2executing with the following 3- CHANNEL_NAME: mychannel 4- CC_NAME: basic 5- CC_SRC_PATH: NA 6- CC_SRC_LANGUAGE: java 7- CC_VERSION: 1.0 8- CC_SEQUENCE: 1 9- CC_END_POLICY: NA 10- CC_COLL_CONFIG: NA 11- CC_INIT_FCN: NA 12- DELAY: 3 13- MAX_RETRY: 5 14- VERBOSE: false 15Determining the path to the chaincode 16asset-transfer-basic 17Compiling Java code... 18~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/asset-transfer-basic/chaincode-java ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network 19Downloading https://services.gradle.org/distributions/gradle-6.5.1-bin.zip 20................................................................................................. 21 22Welcome to Gradle 6.5.1! 23 24Here are the highlights of this release: 25 - Experimental file-system watching 26 - Improved version ordering 27 - New samples 28 29For more details see https://docs.gradle.org/6.5.1/release-notes.html 30 31Starting a Gradle Daemon (subsequent builds will be faster) 32 33> Task :test 34 35AssetTransferTest > invokeGetAllAssetsTransaction() PASSED 36 37AssetTransferTest > invokeInitLedgerTransaction() PASSED 38 39AssetTransferTest > invokeUnknownTransaction() PASSED 40 41AssetTransferTest > DeleteAssetTransaction > whenAssetDoesNotExist() PASSED 42 43AssetTransferTest > UpdateAssetTransaction > whenAssetExists() PASSED 44 45AssetTransferTest > UpdateAssetTransaction > whenAssetDoesNotExist() PASSED 46 47AssetTransferTest > TransferAssetTransaction > whenAssetExists() PASSED 48 49AssetTransferTest > TransferAssetTransaction > whenAssetDoesNotExist() PASSED 50 51AssetTransferTest > InvokeCreateAssetTransaction > whenAssetExists() PASSED 52 53AssetTransferTest > InvokeCreateAssetTransaction > whenAssetDoesNotExist() PASSED 54 55AssetTransferTest > InvokeReadAssetTransaction > whenAssetExists() PASSED 56 57AssetTransferTest > InvokeReadAssetTransaction > whenAssetDoesNotExist() PASSED 58 59AssetTest > toStringIdentifiesAsset() PASSED 60 61AssetTest > Equality > handlesOtherObjects() PASSED 62 63AssetTest > Equality > isReflexive() PASSED 64 65AssetTest > Equality > isTransitive() PASSED 66 67AssetTest > Equality > handlesInequality() PASSED 68 69AssetTest > Equality > isSymmetric() PASSED 70 71AssetTest > Equality > handlesNull() PASSED 72 73BUILD SUCCESSFUL in 4m 24s 7410 actionable tasks: 10 executed 75~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network 76Finished compiling Java code 77Using organization 1 78+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-java//build/install/basic --lang java --label basic_1.0 79+ res=0 80Chaincode is packaged on peer0.org1 81Installing chaincode on peer0.org1... 82Using organization 1 83+ peer lifecycle chaincode install basic.tar.gz 84+ res=0 852020-09-28 10:30:23.946 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4\022\tbasic_1.0" > 862020-09-28 10:30:23.963 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4 87Chaincode is installed on peer0.org1 88Install chaincode on peer0.org2... 89Using organization 2 90+ peer lifecycle chaincode install basic.tar.gz 91+ res=0 922020-09-28 10:30:27.885 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nJbasic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4\022\tbasic_1.0" > 932020-09-28 10:30:27.886 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4 94Chaincode is installed on peer0.org2 95Using organization 1 96+ peer lifecycle chaincode queryinstalled 97+ res=0 98Installed chaincodes on peer: 99Package ID: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4, Label: basic_1.0 100Query installed successful on peer0.org1 on channel 101Using organization 1 102+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4 --sequence 1 103+ res=0 1042020-09-28 10:30:30.706 CST [chaincodeCmd] ClientWait -> INFO 001 txid [4961f4b46dd431d7f6513aa8bdf349926382d65867f03b0c231fa39ddeac3521] committed with status (VALID) at 105Chaincode definition approved on peer0.org1 on channel 'mychannel' 106Using organization 1 107Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... 108Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds. 109+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json 110+ res=0 111{ 112 113 114 "approvals": { 115 116 117 "Org1MSP": true, 118 "Org2MSP": false 119 } 120} 121Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' 122Using organization 2 123Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... 124Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds. 125+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json 126+ res=0 127{ 128 129 130 "approvals": { 131 132 133 "Org1MSP": true, 134 "Org2MSP": false 135 } 136} 137Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' 138Using organization 2 139+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --version 1.0 --package-id basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4 --sequence 1 140+ res=0 1412020-09-28 10:30:39.115 CST [chaincodeCmd] ClientWait -> INFO 001 txid [25ac5d89ce064ef33caeb22c643e9fb231be8e97ddfcfeb020381551860810c9] committed with status (VALID) at 142Chaincode definition approved on peer0.org2 on channel 'mychannel' 143Using organization 1 144Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... 145Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds. 146+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json 147+ res=0 148{ 149 150 151 "approvals": { 152 153 154 "Org1MSP": true, 155 "Org2MSP": true 156 } 157} 158Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' 159Using organization 2 160Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... 161Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds. 162+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json 163+ res=0 164{ 165 166 167 "approvals": { 168 169 170 "Org1MSP": true, 171 "Org2MSP": true 172 } 173} 174Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' 175Using organization 1 176Using organization 2 177+ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name basic --peerAddresses localhost:7051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1.0 --sequence 1 178+ res=0 1792020-09-28 10:30:48.344 CST [chaincodeCmd] ClientWait -> INFO 001 txid [6b571b656eea9ef7a15b94ad0125ec5b0fcd282b8ca6e00669cd8640260d167a] committed with status (VALID) at localhost:9051 1802020-09-28 10:30:48.534 CST [chaincodeCmd] ClientWait -> INFO 002 txid [6b571b656eea9ef7a15b94ad0125ec5b0fcd282b8ca6e00669cd8640260d167a] committed with status (VALID) at localhost:7051 181Chaincode definition committed on channel 'mychannel' 182Using organization 1 183Querying chaincode definition on peer0.org1 on channel 'mychannel'... 184Attempting to Query committed status on peer0.org1, Retry after 3 seconds. 185+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic 186+ res=0 187Committed chaincode definition for chaincode 'basic' on channel 'mychannel': 188Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true] 189Query chaincode definition successful on peer0.org1 on channel 'mychannel' 190Using organization 2 191Querying chaincode definition on peer0.org2 on channel 'mychannel'... 192Attempting to Query committed status on peer0.org2, Retry after 3 seconds. 193+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic 194+ res=0 195Committed chaincode definition for chaincode 'basic' on channel 'mychannel': 196Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true] 197Query chaincode definition successful on peer0.org2 on channel 'mychannel' 198Chaincode initialization is not required

3.与网络互动

网络启动成功后,可以使用peer cli客户端去操作网络,可以通过cli客户端去调用部署智能合约,更新通道,或者安装部署新的智能合约。
回到test-network目录(很重要很重要),使用以下命令将二进制文件添加到cli路径:

export PATH =${PWD}/../bin:${PWD}:$PATH

还需要设置FABRIC_CFG_PATH路径指向fabric-samples中的core.yaml文件,命令如下:

export FABRIC_CFG_PATH=${PWD}/../config/

设置允许org1操作peer cli的环境变量:

1# Environment variables for Org1 2export CORE_PEER_TLS_ENABLED=true 3export CORE_PEER_LOCALMSPID="Org1MSP" 4export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt 5export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp 6export CORE_PEER_ADDRESS=localhost:7051

使用以下命令获取汽车资产列表:

peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'

上述路径都正常的话,报错如下:

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}' 2Error: endorsement failure during query. response: status:500 message:"make sure the chaincode fabcar has been successfully defined on channel mychannel and try again: chaincode fabcar not found"

查看报错信息,我们可以知道,链码 fabcar 没有在通道上被定义,所以我们进入对应目录,执行启动指令:

1cd /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar 2./startFabric.sh

但是执行命令之后,又报错,报错信息如下:
在这里插入图片描述

1./network.sh: line 588: unexpected EOF while looking for matching ``' 2./network.sh: line 589: syntax error: unexpected end of file

emm 这个是我的锅,之前不小心修改了network.sh文件,你们可以忽略哈。

再次执行发现又报错如下:

1+ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1 2+ res=1 3Error: failed to normalize chaincode path: 'go list' failed with: go: github.com/hyperledger/fabric-contract-api-go@v1.1.0: Get "https://proxy.golang.org/github.com/hyperledger/fabric-contract-api-go/@v/v1.1.0.mod": dial tcp 216.58.200.241:443: i/o timeout: exit status 1 4Chaincode packaging on peer0.org1 has failed 5Deploying chaincode failed

网上找到解决方案,执行以下命令

1go env -w GO111MODULE=on 2go env -w GOPROXY=https://goproxy.cn,direct

然后再次执行./startFabric.sh,显示成功结果如下:

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ go env -w GO111MODULE=on 2halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ go env -w GOPROXY=https://goproxy.cn,direct 3halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ ./startFabric.sh 4~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar 5Stopping network 6Stopping peer0.org2.example.com ... done 7Stopping peer0.org1.example.com ... done 8Stopping orderer.example.com ... done 9Stopping couchdb1 ... done 10Stopping couchdb0 ... done 11Stopping ca_org1 ... done 12Stopping ca_org2 ... done 13Stopping ca_orderer ... done 14Removing peer0.org2.example.com ... done 15Removing peer0.org1.example.com ... done 16Removing orderer.example.com ... done 17Removing couchdb1 ... done 18Removing couchdb0 ... done 19Removing ca_org1 ... done 20Removing ca_org2 ... done 21Removing ca_orderer ... done 22Removing network net_test 23Removing volume net_peer0.org1.example.com 24Removing volume net_peer0.org2.example.com 25Removing volume net_orderer.example.com 26Removing network net_test 27WARNING: Network net_test not found. 28Removing volume net_peer0.org3.example.com 29WARNING: Volume net_peer0.org3.example.com not found. 30No containers available for deletion 31No images available for deletion 32Creating channel 'mychannel'. 33If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'couchdb with crypto from 'Certificate Authorities' 34Bringing up network 35LOCAL_VERSION=2.2.0 36DOCKER_IMAGE_VERSION=2.2.0 37CA_LOCAL_VERSION=1.4.7 38CA_DOCKER_IMAGE_VERSION=1.4.7 39Generate certificates using Fabric CA's 40Creating network "net_test" with the default driver 41Creating ca_org1 ... 42Creating ca_org2 ... 43Creating ca_org1 44Creating ca_orderer ... 45Creating ca_org2 46Creating ca_orderer ... done 47Create Org1 Identities 48Enroll the CA admin 49+ fabric-ca-client enroll -u https://admin:adminpw@localhost:7054 --caname ca-org1 --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 502020/09/28 19:24:36 [INFO] Created a default configuration file at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/fabric-ca-client-config.yaml 512020/09/28 19:24:36 [INFO] TLS Enabled 522020/09/28 19:24:36 [INFO] generating key: &{ 53 54 A:ecdsa S:256} 552020/09/28 19:24:36 [INFO] encoded CSR 562020/09/28 19:24:36 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/signcerts/cert.pem 572020/09/28 19:24:36 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem 582020/09/28 19:24:36 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/IssuerPublicKey 592020/09/28 19:24:36 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/IssuerRevocationPublicKey 60Register peer0 61+ fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 622020/09/28 19:24:36 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/fabric-ca-client-config.yaml 632020/09/28 19:24:36 [INFO] TLS Enabled 642020/09/28 19:24:36 [INFO] TLS Enabled 65Password: peer0pw 66Register user 67+ fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 682020/09/28 19:24:36 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/fabric-ca-client-config.yaml 692020/09/28 19:24:36 [INFO] TLS Enabled 702020/09/28 19:24:36 [INFO] TLS Enabled 71Password: user1pw 72Register the org admin 73+ fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 742020/09/28 19:24:36 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/fabric-ca-client-config.yaml 752020/09/28 19:24:36 [INFO] TLS Enabled 762020/09/28 19:24:36 [INFO] TLS Enabled 77Password: org1adminpw 78Generate the peer0 msp 79+ fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 802020/09/28 19:24:36 [INFO] TLS Enabled 812020/09/28 19:24:36 [INFO] generating key: &{ 82 83 A:ecdsa S:256} 842020/09/28 19:24:36 [INFO] encoded CSR 852020/09/28 19:24:36 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/signcerts/cert.pem 862020/09/28 19:24:36 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem 872020/09/28 19:24:36 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/IssuerPublicKey 882020/09/28 19:24:36 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/IssuerRevocationPublicKey 89Generate the peer0-tls certificates 90+ fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 912020/09/28 19:24:37 [INFO] TLS Enabled 922020/09/28 19:24:37 [INFO] generating key: &{ 93 94 A:ecdsa S:256} 952020/09/28 19:24:37 [INFO] encoded CSR 962020/09/28 19:24:37 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/signcerts/cert.pem 972020/09/28 19:24:37 [INFO] Stored TLS root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/tlscacerts/tls-localhost-7054-ca-org1.pem 982020/09/28 19:24:37 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/IssuerPublicKey 992020/09/28 19:24:37 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/IssuerRevocationPublicKey 100Generate the user msp 101+ fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 1022020/09/28 19:24:37 [INFO] TLS Enabled 1032020/09/28 19:24:37 [INFO] generating key: &{ 104 105 A:ecdsa S:256} 1062020/09/28 19:24:37 [INFO] encoded CSR 1072020/09/28 19:24:37 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/cert.pem 1082020/09/28 19:24:37 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem 1092020/09/28 19:24:37 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/IssuerPublicKey 1102020/09/28 19:24:37 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/IssuerRevocationPublicKey 111Generate the org admin msp 112+ fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org1/tls-cert.pem 1132020/09/28 19:24:37 [INFO] TLS Enabled 1142020/09/28 19:24:37 [INFO] generating key: &{ 115 116 A:ecdsa S:256} 1172020/09/28 19:24:37 [INFO] encoded CSR 1182020/09/28 19:24:37 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem 1192020/09/28 19:24:37 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/cacerts/localhost-7054-ca-org1.pem 1202020/09/28 19:24:37 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/IssuerPublicKey 1212020/09/28 19:24:37 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/IssuerRevocationPublicKey 122Create Org2 Identities 123Enroll the CA admin 124+ fabric-ca-client enroll -u https://admin:adminpw@localhost:8054 --caname ca-org2 --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1252020/09/28 19:24:37 [INFO] Created a default configuration file at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/fabric-ca-client-config.yaml 1262020/09/28 19:24:37 [INFO] TLS Enabled 1272020/09/28 19:24:37 [INFO] generating key: &{ 128 129 A:ecdsa S:256} 1302020/09/28 19:24:37 [INFO] encoded CSR 1312020/09/28 19:24:37 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/msp/signcerts/cert.pem 1322020/09/28 19:24:37 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem 1332020/09/28 19:24:37 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/msp/IssuerPublicKey 1342020/09/28 19:24:37 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/msp/IssuerRevocationPublicKey 135Register peer0 136+ fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1372020/09/28 19:24:37 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/fabric-ca-client-config.yaml 1382020/09/28 19:24:37 [INFO] TLS Enabled 1392020/09/28 19:24:37 [INFO] TLS Enabled 140Password: peer0pw 141Register user 142+ fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1432020/09/28 19:24:38 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/fabric-ca-client-config.yaml 1442020/09/28 19:24:38 [INFO] TLS Enabled 1452020/09/28 19:24:38 [INFO] TLS Enabled 146Password: user1pw 147Register the org admin 148+ fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1492020/09/28 19:24:38 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/fabric-ca-client-config.yaml 1502020/09/28 19:24:38 [INFO] TLS Enabled 1512020/09/28 19:24:38 [INFO] TLS Enabled 152Password: org2adminpw 153Generate the peer0 msp 154+ fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1552020/09/28 19:24:38 [INFO] TLS Enabled 1562020/09/28 19:24:38 [INFO] generating key: &{ 157 158 A:ecdsa S:256} 1592020/09/28 19:24:38 [INFO] encoded CSR 1602020/09/28 19:24:38 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/signcerts/cert.pem 1612020/09/28 19:24:38 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem 1622020/09/28 19:24:38 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/IssuerPublicKey 1632020/09/28 19:24:38 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/IssuerRevocationPublicKey 164Generate the peer0-tls certificates 165+ fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1662020/09/28 19:24:38 [INFO] TLS Enabled 1672020/09/28 19:24:38 [INFO] generating key: &{ 168 169 A:ecdsa S:256} 1702020/09/28 19:24:38 [INFO] encoded CSR 1712020/09/28 19:24:38 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/signcerts/cert.pem 1722020/09/28 19:24:38 [INFO] Stored TLS root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/tlscacerts/tls-localhost-8054-ca-org2.pem 1732020/09/28 19:24:38 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/IssuerPublicKey 1742020/09/28 19:24:38 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/IssuerRevocationPublicKey 175Generate the user msp 176+ fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1772020/09/28 19:24:38 [INFO] TLS Enabled 1782020/09/28 19:24:38 [INFO] generating key: &{ 179 180 A:ecdsa S:256} 1812020/09/28 19:24:38 [INFO] encoded CSR 1822020/09/28 19:24:38 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/cert.pem 1832020/09/28 19:24:38 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem 1842020/09/28 19:24:38 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/IssuerPublicKey 1852020/09/28 19:24:38 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/IssuerRevocationPublicKey 186Generate the org admin msp 187+ fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/org2/tls-cert.pem 1882020/09/28 19:24:39 [INFO] TLS Enabled 1892020/09/28 19:24:39 [INFO] generating key: &{ 190 191 A:ecdsa S:256} 1922020/09/28 19:24:39 [INFO] encoded CSR 1932020/09/28 19:24:39 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/cert.pem 1942020/09/28 19:24:39 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/cacerts/localhost-8054-ca-org2.pem 1952020/09/28 19:24:39 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/IssuerPublicKey 1962020/09/28 19:24:39 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/IssuerRevocationPublicKey 197Create Orderer Org Identities 198Enroll the CA admin 199+ fabric-ca-client enroll -u https://admin:adminpw@localhost:9054 --caname ca-orderer --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2002020/09/28 19:24:39 [INFO] Created a default configuration file at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/fabric-ca-client-config.yaml 2012020/09/28 19:24:39 [INFO] TLS Enabled 2022020/09/28 19:24:39 [INFO] generating key: &{ 203 204 A:ecdsa S:256} 2052020/09/28 19:24:39 [INFO] encoded CSR 2062020/09/28 19:24:39 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/msp/signcerts/cert.pem 2072020/09/28 19:24:39 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/msp/cacerts/localhost-9054-ca-orderer.pem 2082020/09/28 19:24:39 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/msp/IssuerPublicKey 2092020/09/28 19:24:39 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/msp/IssuerRevocationPublicKey 210Register orderer 211+ fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2122020/09/28 19:24:39 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/fabric-ca-client-config.yaml 2132020/09/28 19:24:39 [INFO] TLS Enabled 2142020/09/28 19:24:39 [INFO] TLS Enabled 215Password: ordererpw 216Register the orderer admin 217+ fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2182020/09/28 19:24:39 [INFO] Configuration file location: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/fabric-ca-client-config.yaml 2192020/09/28 19:24:39 [INFO] TLS Enabled 2202020/09/28 19:24:39 [INFO] TLS Enabled 221Password: ordererAdminpw 222Generate the orderer msp 223+ fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2242020/09/28 19:24:39 [INFO] TLS Enabled 2252020/09/28 19:24:39 [INFO] generating key: &{ 226 227 A:ecdsa S:256} 2282020/09/28 19:24:39 [INFO] encoded CSR 2292020/09/28 19:24:39 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/signcerts/cert.pem 2302020/09/28 19:24:39 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/localhost-9054-ca-orderer.pem 2312020/09/28 19:24:39 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/IssuerPublicKey 2322020/09/28 19:24:39 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/IssuerRevocationPublicKey 233Generate the orderer-tls certificates 234+ fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2352020/09/28 19:24:39 [INFO] TLS Enabled 2362020/09/28 19:24:39 [INFO] generating key: &{ 237 238 A:ecdsa S:256} 2392020/09/28 19:24:39 [INFO] encoded CSR 2402020/09/28 19:24:39 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/signcerts/cert.pem 2412020/09/28 19:24:39 [INFO] Stored TLS root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/tlscacerts/tls-localhost-9054-ca-orderer.pem 2422020/09/28 19:24:39 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/IssuerPublicKey 2432020/09/28 19:24:39 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/IssuerRevocationPublicKey 244Generate the admin msp 245+ fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/fabric-ca/ordererOrg/tls-cert.pem 2462020/09/28 19:24:39 [INFO] TLS Enabled 2472020/09/28 19:24:39 [INFO] generating key: &{ 248 249 A:ecdsa S:256} 2502020/09/28 19:24:39 [INFO] encoded CSR 2512020/09/28 19:24:40 [INFO] Stored client certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/cert.pem 2522020/09/28 19:24:40 [INFO] Stored root CA certificate at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/cacerts/localhost-9054-ca-orderer.pem 2532020/09/28 19:24:40 [INFO] Stored Issuer public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/IssuerPublicKey 2542020/09/28 19:24:40 [INFO] Stored Issuer revocation public key at /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/IssuerRevocationPublicKey 255Generate CCP files for Org1 and Org2 256/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/configtxgen 257Generating Orderer Genesis block 258+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block 2592020-09-28 19:24:40.105 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 2602020-09-28 19:24:40.150 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft 2612020-09-28 19:24:40.151 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 2622020-09-28 19:24:40.151 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 2632020-09-28 19:24:40.153 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block 2642020-09-28 19:24:40.153 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block 265+ res=0 266Creating volume "net_peer0.org1.example.com" with default driver 267Creating volume "net_peer0.org2.example.com" with default driver 268Creating volume "net_orderer.example.com" with default driver 269WARNING: Found orphan containers (ca_orderer, ca_org2, ca_org1) 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. 270Creating couchdb0 ... 271Creating couchdb1 ... 272Creating couchdb0 273Creating orderer.example.com ... 274Creating couchdb1 275Creating couchdb0 ... done 276Creating peer0.org1.example.com ... 277Creating couchdb1 ... done 278Creating peer0.org2.example.com ... 279Creating peer0.org2.example.com ... done 280CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 281f67481c753a1 hyperledger/fabric-peer:latest "peer node start" 2 seconds ago Up Less than a second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com 2822e6acaa2e6de hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp peer0.org1.example.com 283addd0468c8e1 hyperledger/fabric-orderer:latest "orderer" 7 seconds ago Up 2 seconds 0.0.0.0:7050->7050/tcp orderer.example.com 2844617a52baf05 couchdb:3.1 "tini -- /docker-ent…" 7 seconds ago Up 2 seconds 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb1 2850c59116b95bd couchdb:3.1 "tini -- /docker-ent…" 7 seconds ago Up 3 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0 286579e3671065a hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 15 seconds ago Up 12 seconds 7054/tcp, 0.0.0.0:9054->9054/tcp ca_orderer 28740b9c11d100f hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 15 seconds ago Up 12 seconds 7054/tcp, 0.0.0.0:8054->8054/tcp ca_org2 288d870924d9c90 hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 15 seconds ago Up 13 seconds 0.0.0.0:7054->7054/tcp ca_org1 289Generating channel create transaction 'mychannel.tx' 290+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel 2912020-09-28 19:24:48.554 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 2922020-09-28 19:24:48.611 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 2932020-09-28 19:24:48.611 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx 2942020-09-28 19:24:48.615 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx 295+ res=0 296Generating anchor peer update transactions 297Generating anchor peer update transaction for Org1MSP 298+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP 2992020-09-28 19:24:48.671 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 3002020-09-28 19:24:48.731 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 3012020-09-28 19:24:48.731 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 3022020-09-28 19:24:48.744 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update 303+ res=0 304Generating anchor peer update transaction for Org2MSP 305+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP 3062020-09-28 19:24:48.794 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 3072020-09-28 19:24:48.859 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/configtx/configtx.yaml 3082020-09-28 19:24:48.859 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 3092020-09-28 19:24:48.861 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update 310+ res=0 311Creating channel mychannel 312Using organization 1 313+ peer channel create -o localhost:7050 -c mychannel --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/mychannel.tx --outputBlock ./channel-artifacts/mychannel.block --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 314+ res=0 3152020-09-28 19:24:51.951 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 3162020-09-28 19:24:51.968 CST [cli.common] readBlock -> INFO 002 Expect block, but got status: &{ 317 318 NOT_FOUND} 3192020-09-28 19:24:51.971 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 3202020-09-28 19:24:52.173 CST [cli.common] readBlock -> INFO 004 Expect block, but got status: &{ 321 322 SERVICE_UNAVAILABLE} 3232020-09-28 19:24:52.176 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized 3242020-09-28 19:24:52.378 CST [cli.common] readBlock -> INFO 006 Expect block, but got status: &{ 325 326 SERVICE_UNAVAILABLE} 3272020-09-28 19:24:52.381 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized 3282020-09-28 19:24:52.586 CST [cli.common] readBlock -> INFO 008 Expect block, but got status: &{ 329 330 SERVICE_UNAVAILABLE} 3312020-09-28 19:24:52.589 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized 3322020-09-28 19:24:52.790 CST [cli.common] readBlock -> INFO 00a Expect block, but got status: &{ 333 334 SERVICE_UNAVAILABLE} 3352020-09-28 19:24:52.793 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized 3362020-09-28 19:24:52.995 CST [cli.common] readBlock -> INFO 00c Expect block, but got status: &{ 337 338 SERVICE_UNAVAILABLE} 3392020-09-28 19:24:52.998 CST [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized 3402020-09-28 19:24:53.201 CST [cli.common] readBlock -> INFO 00e Received block: 0 341Channel 'mychannel' created 342Join Org1 peers to the channel... 343Using organization 1 344+ peer channel join -b ./channel-artifacts/mychannel.block 345+ res=0 3462020-09-28 19:24:56.279 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 3472020-09-28 19:24:56.738 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 348Join Org2 peers to the channel... 349Using organization 2 350+ peer channel join -b ./channel-artifacts/mychannel.block 351+ res=0 3522020-09-28 19:24:59.823 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 3532020-09-28 19:25:00.112 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 354Updating anchor peers for org1... 355Using organization 1 356+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 357+ res=0 3582020-09-28 19:25:03.166 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 3592020-09-28 19:25:03.182 CST [channelCmd] update -> INFO 002 Successfully submitted channel update 360Anchor peers updated for org 'Org1MSP' on channel 'mychannel' 361Updating anchor peers for org2... 362Using organization 2 363+ peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 364+ res=0 3652020-09-28 19:25:09.246 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 3662020-09-28 19:25:09.263 CST [channelCmd] update -> INFO 002 Successfully submitted channel update 367Anchor peers updated for org 'Org2MSP' on channel 'mychannel' 368Channel successfully joined 369deploying chaincode on channel 'mychannel' 370executing with the following 371- CHANNEL_NAME: mychannel 372- CC_NAME: fabcar 373- CC_SRC_PATH: ../chaincode/fabcar/go/ 374- CC_SRC_LANGUAGE: go 375- CC_VERSION: 1 376- CC_SEQUENCE: 1 377- CC_END_POLICY: NA 378- CC_COLL_CONFIG: NA 379- CC_INIT_FCN: initLedger 380- DELAY: 3 381- MAX_RETRY: 5 382- VERBOSE: false 383Vendoring Go dependencies at ../chaincode/fabcar/go/ 384~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/fabcar/go ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network 385go: downloading github.com/hyperledger/fabric-contract-api-go v1.1.0 386go: downloading github.com/hyperledger/fabric-chaincode-go v0.0.0-20200424173110-d7076418f212 387go: downloading github.com/xeipuuv/gojsonschema v1.2.0 388go: downloading github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e 389go: downloading github.com/go-openapi/spec v0.19.4 390go: downloading github.com/gobuffalo/packr v1.30.1 391go: downloading github.com/golang/protobuf v1.3.2 392go: downloading google.golang.org/grpc v1.23.0 393go: downloading github.com/go-openapi/jsonreference v0.19.2 394go: downloading github.com/PuerkitoBio/purell v1.1.1 395go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 396go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 397go: downloading github.com/go-openapi/jsonpointer v0.19.3 398go: downloading github.com/go-openapi/swag v0.19.5 399go: downloading golang.org/x/text v0.3.2 400go: downloading golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 401go: downloading golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 402go: downloading google.golang.org/genproto v0.0.0-20180831171423-11092d34479b 403go: downloading github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e 404go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f 405go: downloading github.com/gobuffalo/packd v0.3.0 406go: downloading gopkg.in/yaml.v2 v2.2.8 407go: downloading github.com/gobuffalo/envy v1.7.0 408go: downloading github.com/rogpeppe/go-internal v1.3.0 409go: downloading github.com/joho/godotenv v1.3.0 410~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network 411Finished vendoring Go dependencies 412Using organization 1 413+ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1 414+ res=0 415Chaincode is packaged on peer0.org1 416Installing chaincode on peer0.org1... 417Using organization 1 418+ peer lifecycle chaincode install fabcar.tar.gz 419+ res=0 4202020-09-28 19:25:50.806 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nIfabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506\022\010fabcar_1" > 4212020-09-28 19:25:50.807 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 422Chaincode is installed on peer0.org1 423Install chaincode on peer0.org2... 424Using organization 2 425+ peer lifecycle chaincode install fabcar.tar.gz 426+ res=0 4272020-09-28 19:26:12.230 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:<status:200 payload:"\nIfabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506\022\010fabcar_1" > 4282020-09-28 19:26:12.231 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 429Chaincode is installed on peer0.org2 430Using organization 1 431+ peer lifecycle chaincode queryinstalled 432+ res=0 433Installed chaincodes on peer: 434Package ID: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506, Label: fabcar_1 435Query installed successful on peer0.org1 on channel 436Using organization 1 437+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --version 1 --package-id fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 --sequence 1 --init-required 438+ res=0 4392020-09-28 19:26:15.916 CST [chaincodeCmd] ClientWait -> INFO 001 txid [355f68105cdd5ed2b48754ec3faa0780724c8a67319bd45945836d80b19101e2] committed with status (VALID) at 440Chaincode definition approved on peer0.org1 on channel 'mychannel' 441Using organization 1 442Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... 443Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds. 444+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json 445+ res=0 446{ 447 448 449 "approvals": { 450 451 452 "Org1MSP": true, 453 "Org2MSP": false 454 } 455} 456Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' 457Using organization 2 458Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... 459Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds. 460+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json 461+ res=0 462{ 463 464 465 "approvals": { 466 467 468 "Org1MSP": true, 469 "Org2MSP": false 470 } 471} 472Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' 473Using organization 2 474+ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --version 1 --package-id fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506 --sequence 1 --init-required 475+ res=0 4762020-09-28 19:26:24.809 CST [chaincodeCmd] ClientWait -> INFO 001 txid [b02e043ef240dccfb291961b1072957399c248481decd528d9e292290eac905e] committed with status (VALID) at 477Chaincode definition approved on peer0.org2 on channel 'mychannel' 478Using organization 1 479Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... 480Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds. 481+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json 482+ res=0 483{ 484 485 486 "approvals": { 487 488 489 "Org1MSP": true, 490 "Org2MSP": true 491 } 492} 493Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' 494Using organization 2 495Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... 496Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds. 497+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json 498+ res=0 499{ 500 501 502 "approvals": { 503 504 505 "Org1MSP": true, 506 "Org2MSP": true 507 } 508} 509Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' 510Using organization 1 511Using organization 2 512+ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name fabcar --peerAddresses localhost:7051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1 --init-required 513+ res=0 5142020-09-28 19:26:34.208 CST [chaincodeCmd] ClientWait -> INFO 001 txid [7f6773b0394bb3ed90b75ebe5fdf3d8e7d72ce7ebbba818660fe30084477d55b] committed with status (VALID) at localhost:9051 5152020-09-28 19:26:34.228 CST [chaincodeCmd] ClientWait -> INFO 002 txid [7f6773b0394bb3ed90b75ebe5fdf3d8e7d72ce7ebbba818660fe30084477d55b] committed with status (VALID) at localhost:7051 516Chaincode definition committed on channel 'mychannel' 517Using organization 1 518Querying chaincode definition on peer0.org1 on channel 'mychannel'... 519Attempting to Query committed status on peer0.org1, Retry after 3 seconds. 520+ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar 521+ res=0 522Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel': 523Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true] 524Query chaincode definition successful on peer0.org1 on channel 'mychannel' 525Using organization 2 526Querying chaincode definition on peer0.org2 on channel 'mychannel'... 527Attempting to Query committed status on peer0.org2, Retry after 3 seconds. 528+ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar 529+ res=0 530Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel': 531Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true] 532Query chaincode definition successful on peer0.org2 on channel 'mychannel' 533Using organization 1 534Using organization 2 535+ fcn_call='{"function":"initLedger","Args":[]}' 536+ infoln 'invoke fcn call:{"function":"initLedger","Args":[]}' 537+ println '\033[0;34minvoke fcn call:{"function":"initLedger","Args":[]}\033[0m' 538+ echo -e '\033[0;34minvoke fcn call:{"function":"initLedger","Args":[]}\033[0m' 539invoke fcn call:{ 540 541 "function":"initLedger","Args":[]} 542+ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n fabcar --peerAddresses localhost:7051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles /home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"function":"initLedger","Args":[]}' 543+ res=0 5442020-09-28 19:26:40.708 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 545Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' 546~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar 547 548Total setup execution time : 155 secs ... 549 550Next, use the FabCar applications to interact with the deployed FabCar contract. 551The FabCar applications are available in multiple programming languages. 552Follow the instructions for the programming language of your choice: 553 554JavaScript: 555 556 Start by changing into the "javascript" directory: 557 cd javascript 558 559 Next, install all required packages: 560 npm install 561 562 Then run the following applications to enroll the admin user, and register a new user 563 called appUser which will be used by the other applications to interact with the deployed 564 FabCar contract: 565 node enrollAdmin 566 node registerUser 567 568 You can run the invoke application as follows. By default, the invoke application will 569 create a new car, but you can update the application to submit other transactions: 570 node invoke 571 572 You can run the query application as follows. By default, the query application will 573 return all cars, but you can update the application to evaluate other transactions: 574 node query 575 576TypeScript: 577 578 Start by changing into the "typescript" directory: 579 cd typescript 580 581 Next, install all required packages: 582 npm install 583 584 Next, compile the TypeScript code into JavaScript: 585 npm run build 586 587 Then run the following applications to enroll the admin user, and register a new user 588 called appUser which will be used by the other applications to interact with the deployed 589 FabCar contract: 590 node dist/enrollAdmin 591 node dist/registerUser 592 593 You can run the invoke application as follows. By default, the invoke application will 594 create a new car, but you can update the application to submit other transactions: 595 node dist/invoke 596 597 You can run the query application as follows. By default, the query application will 598 return all cars, but you can update the application to evaluate other transactions: 599 node dist/query 600 601Java: 602 603 Start by changing into the "java" directory: 604 cd java 605 606 Then, install dependencies and run the test using: 607 mvn test 608 609 The test will invoke the sample client app which perform the following: 610 - Enroll admin and appUser and import them into the wallet (if they don't already exist there) 611 - Submit a transaction to create a new car 612 - Evaluate a transaction (query) to return details of this car 613 - Submit a transaction to change the owner of this car 614 - Evaluate a transaction (query) to return the updated details of this car 615 616Go: 617 618 Start by changing into the "go" directory: 619 cd go 620 621 Then, install dependencies and run the test using: 622 go run fabcar.go 623 624 The test will invoke the sample client app which perform the following: 625 - Import user credentials into the wallet (if they don't already exist there) 626 - Submit a transaction to create a new car 627 - Evaluate a transaction (query) to return details of this car 628 - Submit a transaction to change the owner of this car 629 - Evaluate a transaction (query) to return the updated details of this car 630

我们的应用程序也就启动成功了,再次回到test-network目录。使用命令获取汽车资产列表,结果如下:

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples$ cd test-network/ 2 3halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}' 4[{ 5 6 "Key":"CAR0","Record":{ 7 8 "make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{ 9 10 "Key":"CAR1","Record":{ 11 12 "make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{ 13 14 "Key":"CAR2","Record":{ 15 16 "make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{ 17 18 "Key":"CAR3","Record":{ 19 20 "make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{ 21 22 "Key":"CAR4","Record":{ 23 24 "make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{ 25 26 "Key":"CAR5","Record":{ 27 28 "make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{ 29 30 "Key":"CAR6","Record":{ 31 32 "make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{ 33 34 "Key":"CAR7","Record":{ 35 36 "make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{ 37 38 "Key":"CAR8","Record":{ 39 40 "make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{ 41 42 "Key":"CAR9","Record":{ 43 44 "make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]

终于成功了。。。。

同理,设置org2的环境变量:

1# Environment variables for Org2 2export CORE_PEER_TLS_ENABLED=true 3export CORE_PEER_LOCALMSPID="Org2MSP" 4export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt 5export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp 6export CORE_PEER_ADDRESS=localhost:9051

在peer0.org2.example.com上调用链码查询fabcar列表:

1halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_TLS_ENABLED=true 2halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_LOCALMSPID="Org2MSP" 3halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt 4halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp 5halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_ADDRESS=localhost:9051 6halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}' 7[{ 8 9 "Key":"CAR0","Record":{ 10 11 "make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{ 12 13 "Key":"CAR1","Record":{ 14 15 "make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{ 16 17 "Key":"CAR2","Record":{ 18 19 "make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{ 20 21 "Key":"CAR3","Record":{ 22 23 "make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{ 24 25 "Key":"CAR4","Record":{ 26 27 "make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{ 28 29 "Key":"CAR5","Record":{ 30 31 "make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{ 32 33 "Key":"CAR6","Record":{ 34 35 "make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{ 36 37 "Key":"CAR7","Record":{ 38 39 "make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{ 40 41 "Key":"CAR8","Record":{ 42 43 "make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{ 44 45 "Key":"CAR9","Record":{ 46 47 "make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]

4、关闭网络

执行关闭网络命令

./network.sh down

5、使用证书颁发机构启动网络

1.执行以下命令确保关闭其他fabric网络:

 ./network.sh down

2.标志并启动网络(ca为网络的标志):

 ./network.sh up -ca

启动成功,如图:
在这里插入图片描述

参考文章:

https://blog.csdn.net/tianshuhao521/article/details/104695687
https://wangcj.com.cn/2020/08/25/Fabric-2-2-0-%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/
https://www.cnblogs.com/linjiqin/p/8608975.html

写在最后

到底,我们的Fabric安装终于告一段落。如果你觉得这篇文章对你有帮助,那么可以关注微信公众号半路猿,加我微信,拉你进我们的学习交流群,一起学习,一同成长。

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )