写在前面
看到题目,你可能会想,这个作者脑子抽吧,怎么又要出一篇关于环境搭建的。 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版本
cd ~/go/src/github.com/hyperledger/fabric/
git checkout v2.2.0
Previous HEAD position was b8c4a6aa7 [FAB-16412] Release fabric v1.4.3
HEAD is now at 5ea85bc54 Fabric v2.2.0 release commit
2、执行bootstrap.sh下载镜像和二进制文件
cd scripts/
./bootstrap.sh
执行过程如下:
以上执行有点慢。。。我这边下载了20分钟左右。。。时间自行调整哈。emm ,我就说事情没有这么简单吧,又来一个,我就纳闷了下载1.4.7又是要作甚?(各位小伙伴有更好的办法请留言告知我,我这边也做一个记录和更新呀
)
这两个下载完应该可以了吧,不要还有啊。预计下载总时长30分钟。可以的,下载好了,结果如下。
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts$ ./bootstrap.sh
Clone hyperledger/fabric-samples repo
===> Checking out v2.2.0 of hyperledger/fabric-samples
error: pathspec 'v2.2.0' did not match any file(s) known to git
Pull Hyperledger Fabric binaries
===> Downloading version 2.2.0 platform specific fabric binaries
===> Downloading: https://github.com/hyperledger/fabric/releases/download/v2.2.0/hyperledger-fabric-linux-amd64-2.2.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 667 100 667 0 0 1089 0 --:--:-- --:--:-- --:--:-- 1089
100 72.7M 100 72.7M 0 0 66705 0 0:19:03 0:19:03 --:--:-- 48032
==> Done.
===> Downloading version 1.4.7 platform specific fabric-ca-client binary
===> Downloading: https://github.com/hyperledger/fabric-ca/releases/download/v1.4.7/hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 670 100 670 0 0 240 0 0:00:02 0:00:02 --:--:-- 239
100 23.6M 100 23.6M 0 0 49739 0 0:08:17 0:08:17 --:--:-- 106k
==> Done.
Pull Hyperledger Fabric docker images
FABRIC_IMAGES: peer orderer ccenv tools nodeenv baseos javaenv
===> Pulling fabric Images
====> hyperledger/fabric-peer:2.2.0
2.2.0: Pulling from hyperledger/fabric-peer
df20fa9351a1: Pull complete
2f32f83c5fab: Pull complete
9e46444d9bf3: Pull complete
861b7a9f9840: Pull complete
b4064bf05b0b: Pull complete
4ee14d1f801f: Pull complete
Digest: sha256:81efaab943387820815c9b9bd3e3bec9d262365e635bac6f500a287fb3e873e7
Status: Downloaded newer image for hyperledger/fabric-peer:2.2.0
docker.io/hyperledger/fabric-peer:2.2.0
====> hyperledger/fabric-orderer:2.2.0
2.2.0: Pulling from hyperledger/fabric-orderer
df20fa9351a1: Already exists
2f32f83c5fab: Already exists
894c488ba627: Pull complete
5bc2319b26e2: Pull complete
0d1a6ef2d9ec: Pull complete
94c4e0cdcdfb: Pull complete
cfb83833d872: Pull complete
Digest: sha256:bb97a8e80b53d9f32c3b850ae3b55bab57bf3cc9483978a471a5bee0ac49728e
Status: Downloaded newer image for hyperledger/fabric-orderer:2.2.0
docker.io/hyperledger/fabric-orderer:2.2.0
====> hyperledger/fabric-ccenv:2.2.0
2.2.0: Pulling from hyperledger/fabric-ccenv
df20fa9351a1: Already exists
ed8968b2872e: Pull complete
a92cc7c5fd73: Pull complete
9e0cccf56431: Pull complete
cbe0275821fc: Pull complete
d8f39229024f: Pull complete
9fe2c7972d12: Pull complete
050fa39404af: Pull complete
ab61a9ef0e4b: Pull complete
Digest: sha256:4ec2f71fbcd52a1e6717f5eb20f82452c24352faa2dcd08d3941e0bf2438610b
Status: Downloaded newer image for hyperledger/fabric-ccenv:2.2.0
docker.io/hyperledger/fabric-ccenv:2.2.0
====> hyperledger/fabric-tools:2.2.0
2.2.0: Pulling from hyperledger/fabric-tools
df20fa9351a1: Already exists
ed8968b2872e: Already exists
a92cc7c5fd73: Already exists
9e0cccf56431: Already exists
cbe0275821fc: Already exists
71ccef561004: Pull complete
b6f489e17ff2: Pull complete
c767f04d100e: Pull complete
Digest: sha256:d328c63a5ca2e9d27e74ee43d17fcfada9937961d5e70433a1d66352f6e7b652
Status: Downloaded newer image for hyperledger/fabric-tools:2.2.0
docker.io/hyperledger/fabric-tools:2.2.0
====> hyperledger/fabric-nodeenv:2.2.0
2.2.0: Pulling from hyperledger/fabric-nodeenv
aad63a933944: Pull complete
edd41271d385: Pull complete
dd731a721451: Pull complete
495807fcdd37: Pull complete
ea7337a9c641: Pull complete
500dc4d300c4: Pull complete
288c5daaa0fb: Pull complete
Digest: sha256:794194885581f59535d4c13b0e0ae8896f43d9333a42020eb35fdf8f28aba90e
Status: Downloaded newer image for hyperledger/fabric-nodeenv:2.2.0
docker.io/hyperledger/fabric-nodeenv:2.2.0
====> hyperledger/fabric-baseos:2.2.0
2.2.0: Pulling from hyperledger/fabric-baseos
df20fa9351a1: Already exists
2f32f83c5fab: Already exists
55a6005882ed: Pull complete
Digest: sha256:6584eb096bb3cf495e4c2ebf162ed7c1be45157b89662c0d407bfd9adc036d66
Status: Downloaded newer image for hyperledger/fabric-baseos:2.2.0
docker.io/hyperledger/fabric-baseos:2.2.0
====> hyperledger/fabric-javaenv:2.2.0
2.2.0: Pulling from hyperledger/fabric-javaenv
9d48c3bd43c5: Pull complete
15f4f2d99e41: Pull complete
37cbb5ebfe5b: Pull complete
98767d3f4b64: Pull complete
c9c532b143b0: Pull complete
ac32095a41c6: Pull complete
23295c8e3cc2: Pull complete
dd43e444d573: Pull complete
8c3d7e276648: Pull complete
a84723b6c2fc: Pull complete
Digest: sha256:6c85b2fce9b9d0c4420d6131f2dea321be728142e3d2d494a4296b43d66afdfa
Status: Downloaded newer image for hyperledger/fabric-javaenv:2.2.0
docker.io/hyperledger/fabric-javaenv:2.2.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.4.7
1.4.7: Pulling from hyperledger/fabric-ca
b8f262c62ec6: Pull complete
56b16818f60b: Pull complete
707812f2aa2d: Pull complete
400ab1f52b57: Pull complete
1e32346b61cd: Pull complete
d1832ac8c002: Pull complete
cb7ebebf613a: Pull complete
6af9a3114ec8: Pull complete
Digest: sha256:9418ea351bfbef4bf2bca34bcd77305bdb9a45d2c1aab3237c08c17da0b4d1dd
Status: Downloaded newer image for hyperledger/fabric-ca:1.4.7
docker.io/hyperledger/fabric-ca:1.4.7
===> List out hyperledger docker images
hyperledger/fabric-tools 2.2 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-tools 2.2.0 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-tools latest 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-peer 2.2 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-peer 2.2.0 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-peer latest 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-orderer 2.2 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-orderer 2.2.0 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-orderer latest 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-ccenv 2.2 aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-ccenv 2.2.0 aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-ccenv latest aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-baseos 2.2 aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-baseos 2.2.0 aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-baseos latest aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-nodeenv 2.2 ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-nodeenv 2.2.0 ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-nodeenv latest ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-javaenv 2.2 56c30f316b23 2 months ago 504MB
hyperledger/fabric-javaenv 2.2.0 56c30f316b23 2 months ago 504MB
hyperledger/fabric-javaenv latest 56c30f316b23 2 months ago 504MB
hyperledger/fabric-ca 1.4 743a758fae29 4 months ago 154MB
hyperledger/fabric-ca 1.4.7 743a758fae29 4 months ago 154MB
hyperledger/fabric-ca latest 743a758fae29 4 months ago 154MB
hyperledger/fabric-tools 1.4.3 18ed4db0cd57 13 months ago 1.55GB
hyperledger/fabric-ca 1.4.3 c18a0d3cc958 13 months ago 253MB
hyperledger/fabric-ccenv 1.4.3 3d31661a812a 13 months ago 1.45GB
hyperledger/fabric-orderer 1.4.3 b666a6ebbe09 13 months ago 173MB
hyperledger/fabric-peer 1.4.3 fa87ccaed0ef 13 months ago 179MB
hyperledger/fabric-javaenv 1.4.3 5ba5ba09db8f 14 months ago 1.76GB
hyperledger/fabric-zookeeper 0.4.15 20c6045930c8 18 months ago 1.43GB
hyperledger/fabric-zookeeper latest 20c6045930c8 18 months ago 1.43GB
hyperledger/fabric-kafka 0.4.15 b4ab82bbaf2f 18 months ago 1.44GB
hyperledger/fabric-kafka latest b4ab82bbaf2f 18 months ago 1.44GB
hyperledger/fabric-couchdb 0.4.15 8de128a55539 18 months ago 1.5GB
hyperledger/fabric-couchdb latest 8de128a55539 18 months ago 1.5GB
hyperledger/fabric-baseos amd64-0.4.15 9d6ec11c60ff 18 months ago 145MB
hyperledger/fabric-tools x86_64-1.0.0 0403fd1c72c7 3 years ago 1.32GB
hyperledger/fabric-couchdb x86_64-1.0.0 2fbdbf3ab945 3 years ago 1.48GB
hyperledger/fabric-kafka x86_64-1.0.0 dbd3f94de4b5 3 years ago 1.3GB
hyperledger/fabric-zookeeper x86_64-1.0.0 e545dbf1c6af 3 years ago 1.31GB
hyperledger/fabric-orderer x86_64-1.0.0 e317ca5638ba 3 years ago 179MB
hyperledger/fabric-peer x86_64-1.0.0 6830dcd7b9b5 3 years ago 182MB
hyperledger/fabric-javaenv x86_64-1.0.0 8948126f0935 3 years ago 1.42GB
hyperledger/fabric-ccenv x86_64-1.0.0 7182c260a5ca 3 years ago 1.29GB
hyperledger/fabric-ca x86_64-1.0.0 a15c59ecda5b 3 years ago 238MB
hyperledger/fabric-baseos x86_64-0.3.1 4b0cab202084 3 years ago 157MB
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts$
3、测试网络
1.启动test-network测试网络
(中间有一段排错过程,想跳过的直接点击右侧目录真正启动测试网络
哦)
网上看教程都说有这么一个test-network
的文件夹,但是我本地我是没有,网上说法如下:
我自己本地环境如下:
查看docker镜像显示如下。
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dev-peer1.org2.example.com-fabcar-1.0-a139c9f32bcd86b26c02c1cfecba01c235a9007e24c34b03cb1d82d000696338 latest 8a9b6a0e83af 47 hours ago 162MB
dev-peer0.org2.example.com-fabcar-1.0-264b0a1cb5efbecaac5cf8990339c24474dc8435c6e10f10f2be565d555d0e94 latest f249485f4870 47 hours ago 162MB
dev-peer1.org1.example.com-fabcar-1.0-791f4e9c59e5c5ae44b5e63c754aaf47cfa4757490019879665238e39ab45594 latest db02cd8473c1 47 hours ago 162MB
dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba latest 402ec60c1200 47 hours ago 162MB
hyperledger/fabric-tools 2.2 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-tools 2.2.0 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-tools latest 5eb2356665e7 2 months ago 519MB
hyperledger/fabric-peer 2.2 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-peer 2.2.0 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-peer latest 760f304a3282 2 months ago 54.9MB
hyperledger/fabric-orderer 2.2 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-orderer 2.2.0 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-orderer latest 5fb8e97da88d 2 months ago 38.4MB
hyperledger/fabric-ccenv 2.2 aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-ccenv 2.2.0 aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-ccenv latest aac435a5d3f1 2 months ago 586MB
hyperledger/fabric-baseos 2.2 aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-baseos 2.2.0 aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-baseos latest aa2bdf8013af 2 months ago 6.85MB
hyperledger/fabric-nodeenv 2.2 ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-nodeenv 2.2.0 ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-nodeenv latest ab88fe4d29dd 2 months ago 293MB
hyperledger/fabric-javaenv 2.2 56c30f316b23 2 months ago 504MB
hyperledger/fabric-javaenv 2.2.0 56c30f316b23 2 months ago 504MB
hyperledger/fabric-javaenv latest 56c30f316b23 2 months ago 504MB
hyperledger/fabric-ca 1.4 743a758fae29 4 months ago 154MB
hyperledger/fabric-ca 1.4.7 743a758fae29 4 months ago 154MB
hyperledger/fabric-ca latest 743a758fae29 4 months ago 154MB
hyperledger/fabric-tools 1.4.3 18ed4db0cd57 13 months ago 1.55GB
hyperledger/fabric-ca 1.4.3 c18a0d3cc958 13 months ago 253MB
hyperledger/fabric-ccenv 1.4.3 3d31661a812a 13 months ago 1.45GB
hyperledger/fabric-orderer 1.4.3 b666a6ebbe09 13 months ago 173MB
hyperledger/fabric-peer 1.4.3 fa87ccaed0ef 13 months ago 179MB
hyperledger/fabric-javaenv 1.4.3 5ba5ba09db8f 14 months ago 1.76GB
hyperledger/fabric-zookeeper 0.4.15 20c6045930c8 18 months ago 1.43GB
hyperledger/fabric-zookeeper latest 20c6045930c8 18 months ago 1.43GB
hyperledger/fabric-kafka 0.4.15 b4ab82bbaf2f 18 months ago 1.44GB
hyperledger/fabric-kafka latest b4ab82bbaf2f 18 months ago 1.44GB
hyperledger/fabric-couchdb 0.4.15 8de128a55539 18 months ago 1.5GB
hyperledger/fabric-couchdb latest 8de128a55539 18 months ago 1.5GB
hyperledger/fabric-baseos amd64-0.4.15 9d6ec11c60ff 18 months ago 145MB
hyperledger/fabric-tools x86_64-1.0.0 0403fd1c72c7 3 years ago 1.32GB
hyperledger/fabric-couchdb x86_64-1.0.0 2fbdbf3ab945 3 years ago 1.48GB
hyperledger/fabric-kafka x86_64-1.0.0 dbd3f94de4b5 3 years ago 1.3GB
hyperledger/fabric-zookeeper x86_64-1.0.0 e545dbf1c6af 3 years ago 1.31GB
hyperledger/fabric-orderer x86_64-1.0.0 e317ca5638ba 3 years ago 179MB
hyperledger/fabric-peer x86_64-1.0.0 6830dcd7b9b5 3 years ago 182MB
hyperledger/fabric-javaenv x86_64-1.0.0 8948126f0935 3 years ago 1.42GB
hyperledger/fabric-ccenv x86_64-1.0.0 7182c260a5ca 3 years ago 1.29GB
hyperledger/fabric-ca x86_64-1.0.0 a15c59ecda5b 3 years ago 238MB
hyperledger/fabric-baseos x86_64-0.3.1 4b0cab202084 3 years ago 157MB
我怀疑是我之前在下载V1.4.3的时候,带出了他这个版本的样例,然后V2.2.0的样例没有下载下来。所以删掉所有镜像在下载一遍。
1.停止所有的container,这样才能够删除其中的images:
sudo docker stop $(docker ps -a -q)
2.删除全部image
sudo docker rmi -f $(docker images -q)
3.删除掉fabirc-samples文件夹
cd scripts/
sudo rm -rf ./fabirc-samples/
4.重新下载镜像文件./
./bootstrap.sh
安装成功后,查看docker镜像如下:
好了,继续我们的表演,果然有了
1-1真正启动测试网络
cd test-network
./network.sh up
启动成功,会启动两个peer节点和一个order节点,启动成功代码如下:
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.2.0
DOCKER_IMAGE_VERSION=2.2.0
/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/cryptogen
Generate certificates using cryptogen tool
Create Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Create Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Create Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generate CCP files for Org1 and Org2
/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/configtxgen
Generating Orderer Genesis block
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-09-28 09:24:05.552 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-28 09:24:05.597 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-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
2020-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
2020-09-28 09:24:05.600 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-09-28 09:24:05.601 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
+ res=0
Creating network "net_test" with the default driver
Creating peer0.org2.example.com ...
Creating orderer.example.com ...
Creating peer0.org1.example.com ...
Creating orderer.example.com
Creating peer0.org2.example.com
Creating orderer.example.com ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9f50ffaa78d 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
b0997434fbe6 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
b8ebbe2006ea hyperledger/fabric-orderer:latest "orderer" 4 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com
halfape@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
报错如下:
Error: 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"
Channel creation failed
Create channel failed
看了其他教程,在执行上述启动网络命令后,容器是启动状态,我的这边确实停止状态,所以再次启动网络先,如果不行就单独启动docker容器。(经测试,docker容器仍然是未启动状态),我们直接启动容器,启动容器后发现还是无法正常启动,主要排查思路如下,最终解决问题。
1、针对上述连接被拒绝的问题,网上查找发现是防火墙阻止了7050端口,可以用以下命令解决
sudo firewall-cmd --list-ports
sudo firewall-cmd --zone=public --add-port=7050/tcp --permanent
sudo firewall-cmd --reload
2、再次启动还是失败,查看network.sh源文件后,发现最末尾有几个命令,执行了其中的restart命令后,又报错如下
#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))
3、经再次查证,发现需要重启防火墙也需要,重启docker,执行如下命令
service docker restart
4、再次重新启动网络,发现终于成功了,如下
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh restart
Restarting network
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org1.example.com
WARNING: Volume net_peer0.org1.example.com not found.
Removing volume net_peer0.org2.example.com
WARNING: Volume net_peer0.org2.example.com not found.
Removing volume net_orderer.example.com
WARNING: Volume net_orderer.example.com not found.
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
LOCAL_VERSION=2.2.0
DOCKER_IMAGE_VERSION=2.2.0
Creating network "net_test" with the default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
Creating peer0.org2.example.com ...
Creating orderer.example.com ...
Creating peer0.org1.example.com ...
Creating peer0.org2.example.com
Creating peer0.org1.example.com
Creating peer0.org1.example.com ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
904395b01869 hyperledger/fabric-orderer:latest "orderer" 3 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com
44dad802a505 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
6d17e9b84c87 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
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
904395b01869 hyperledger/fabric-orderer:latest "orderer" 11 seconds ago Up 7 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
44dad802a505 hyperledger/fabric-peer:latest "peer node start" 11 seconds ago Up 7 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
6d17e9b84c87 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
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
904395b01869 hyperledger/fabric-orderer:latest "orderer" About a minute ago Up About a minute 0.0.0.0:7050->7050/tcp orderer.example.com
44dad802a505 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
6d17e9b84c87 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,发现终于成功了
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ ./network.sh createChannel
Creating channel 'mychannel'.
If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb Generating channel create transaction 'mychannel.tx' + configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel 2020-09-28 10:10:08.392 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 2020-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 2020-09-28 10:10:08.430 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx 2020-09-28 10:10:08.433 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx + res=0 Generating anchor peer update transactions Generating anchor peer update transaction for Org1MSP + configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP 2020-09-28 10:10:08.468 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 2020-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 2020-09-28 10:10:08.507 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 2020-09-28 10:10:08.508 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update + res=0 Generating anchor peer update transaction for Org2MSP + configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP 2020-09-28 10:10:08.550 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration 2020-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 2020-09-28 10:10:08.584 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update 2020-09-28 10:10:08.586 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update + res=0 Creating channel mychannel Using organization 1 + 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 + res=0 2020-09-28 10:10:11.785 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2020-09-28 10:10:11.893 CST [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND} 2020-09-28 10:10:11.905 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized 2020-09-28 10:10:12.107 CST [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE} 2020-09-28 10:10:12.110 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized 2020-09-28 10:10:12.315 CST [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE} 2020-09-28 10:10:12.330 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized 2020-09-28 10:10:12.535 CST [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE} 2020-09-28 10:10:12.542 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized 2020-09-28 10:10:12.745 CST [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE} 2020-09-28 10:10:12.749 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized 2020-09-28 10:10:12.953 CST [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE} 2020-09-28 10:10:12.964 CST [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized 2020-09-28 10:10:13.186 CST [cli.common] readBlock -> INFO 00e Received block: 0 Channel 'mychannel' created Join Org1 peers to the channel... Using organization 1 + peer channel join -b ./channel-artifacts/mychannel.block + res=0 2020-09-28 10:10:16.363 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2020-09-28 10:10:16.471 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel Join Org2 peers to the channel... Using organization 2 + peer channel join -b ./channel-artifacts/mychannel.block + res=0 2020-09-28 10:10:19.617 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2020-09-28 10:10:19.665 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel Updating anchor peers for org1... Using organization 1 + 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 + res=0 2020-09-28 10:10:22.721 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2020-09-28 10:10:22.755 CST [channelCmd] update -> INFO 002 Successfully submitted channel update Anchor peers updated for org 'Org1MSP' on channel 'mychannel' Updating anchor peers for org2... Using organization 2 + 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 + res=0 2020-09-28 10:10:28.835 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2020-09-28 10:10:28.854 CST [channelCmd] update -> INFO 002 Successfully submitted channel update Anchor peers updated for org 'Org2MSP' on channel 'mychannel'
Channel successfully joined
拓展:
也可以带上channel标签,命令如下(-c channelName):
./network.sh createChannel -c channel1
如果要在一个步骤中启动网络并创建频道,可以同时使用up和create channel模式:
./network.sh up createChannel
2.在通道上启动链码
2-1.使用network.sh创建通道之后,可以使用以下命令在通道上启动链码(默认使用go语言):
./network.sh deployCC
可以指定语言,加-l ,比如我用java,命令如下:
./network.sh deployCC -ccl java
启动结果如下:
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: NA
- CC_SRC_LANGUAGE: java
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Determining the path to the chaincode
asset-transfer-basic
Compiling Java code...
~/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
Downloading https://services.gradle.org/distributions/gradle-6.5.1-bin.zip
.................................................................................................
Welcome to Gradle 6.5.1!
Here are the highlights of this release:
- Experimental file-system watching
- Improved version ordering
- New samples
For more details see https://docs.gradle.org/6.5.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :test
AssetTransferTest > invokeGetAllAssetsTransaction() PASSED
AssetTransferTest > invokeInitLedgerTransaction() PASSED
AssetTransferTest > invokeUnknownTransaction() PASSED
AssetTransferTest > DeleteAssetTransaction > whenAssetDoesNotExist() PASSED
AssetTransferTest > UpdateAssetTransaction > whenAssetExists() PASSED
AssetTransferTest > UpdateAssetTransaction > whenAssetDoesNotExist() PASSED
AssetTransferTest > TransferAssetTransaction > whenAssetExists() PASSED
AssetTransferTest > TransferAssetTransaction > whenAssetDoesNotExist() PASSED
AssetTransferTest > InvokeCreateAssetTransaction > whenAssetExists() PASSED
AssetTransferTest > InvokeCreateAssetTransaction > whenAssetDoesNotExist() PASSED
AssetTransferTest > InvokeReadAssetTransaction > whenAssetExists() PASSED
AssetTransferTest > InvokeReadAssetTransaction > whenAssetDoesNotExist() PASSED
AssetTest > toStringIdentifiesAsset() PASSED
AssetTest > Equality > handlesOtherObjects() PASSED
AssetTest > Equality > isReflexive() PASSED
AssetTest > Equality > isTransitive() PASSED
AssetTest > Equality > handlesInequality() PASSED
AssetTest > Equality > isSymmetric() PASSED
AssetTest > Equality > handlesNull() PASSED
BUILD SUCCESSFUL in 4m 24s
10 actionable tasks: 10 executed
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network
Finished compiling Java code
Using organization 1
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-java//build/install/basic --lang java --label basic_1.0
+ res=0
Chaincode is packaged on peer0.org1
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2020-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" >
2020-09-28 10:30:23.963 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4
Chaincode is installed on peer0.org1
Install chaincode on peer0.org2...
Using organization 2
+ peer lifecycle chaincode install basic.tar.gz
+ res=0
2020-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" >
2020-09-28 10:30:27.886 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4
Chaincode is installed on peer0.org2
Using organization 1
+ peer lifecycle chaincode queryinstalled
+ res=0
Installed chaincodes on peer:
Package ID: basic_1.0:0a21d26a6f929d0445ff6b0c6433aa7ff2cc22fec60a9c7431df0caff94acde4, Label: basic_1.0
Query installed successful on peer0.org1 on channel
Using organization 1
+ 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
+ res=0
2020-09-28 10:30:30.706 CST [chaincodeCmd] ClientWait -> INFO 001 txid [4961f4b46dd431d7f6513aa8bdf349926382d65867f03b0c231fa39ddeac3521] committed with status (VALID) at
Chaincode definition approved on peer0.org1 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": false
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": false
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 2
+ 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
+ res=0
2020-09-28 10:30:39.115 CST [chaincodeCmd] ClientWait -> INFO 001 txid [25ac5d89ce064ef33caeb22c643e9fb231be8e97ddfcfeb020381551860810c9] committed with status (VALID) at
Chaincode definition approved on peer0.org2 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": true
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name basic --version 1.0 --sequence 1 --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": true
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 1
Using organization 2
+ 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
+ res=0
2020-09-28 10:30:48.344 CST [chaincodeCmd] ClientWait -> INFO 001 txid [6b571b656eea9ef7a15b94ad0125ec5b0fcd282b8ca6e00669cd8640260d167a] committed with status (VALID) at localhost:9051
2020-09-28 10:30:48.534 CST [chaincodeCmd] ClientWait -> INFO 002 txid [6b571b656eea9ef7a15b94ad0125ec5b0fcd282b8ca6e00669cd8640260d167a] committed with status (VALID) at localhost:7051
Chaincode definition committed on channel 'mychannel'
Using organization 1
Querying chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to Query committed status on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Querying chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to Query committed status on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name basic
+ res=0
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org2 on channel 'mychannel'
Chaincode 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的环境变量:
# Environment variables for Org1
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051
使用以下命令获取汽车资产列表:
peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
上述路径都正常的话,报错如下:
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
Error: 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 没有在通道上被定义,所以我们进入对应目录,执行启动指令:
cd /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar
./startFabric.sh
但是执行命令之后,又报错,报错信息如下:
./network.sh: line 588: unexpected EOF while looking for matching ``'
./network.sh: line 589: syntax error: unexpected end of file
emm 这个是我的锅,之前不小心修改了network.sh
文件,你们可以忽略哈。
再次执行发现又报错如下:
+ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1
+ res=1
Error: 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
Chaincode packaging on peer0.org1 has failed
Deploying chaincode failed
网上找到解决方案,执行以下命令
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
然后再次执行./startFabric.sh
,显示成功结果如下:
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ go env -w GO111MODULE=on
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ go env -w GOPROXY=https://goproxy.cn,direct
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ ./startFabric.sh
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar
Stopping network
Stopping peer0.org2.example.com ... done
Stopping peer0.org1.example.com ... done
Stopping orderer.example.com ... done
Stopping couchdb1 ... done
Stopping couchdb0 ... done
Stopping ca_org1 ... done
Stopping ca_org2 ... done
Stopping ca_orderer ... done
Removing peer0.org2.example.com ... done
Removing peer0.org1.example.com ... done
Removing orderer.example.com ... done
Removing couchdb1 ... done
Removing couchdb0 ... done
Removing ca_org1 ... done
Removing ca_org2 ... done
Removing ca_orderer ... done
Removing network net_test
Removing volume net_peer0.org1.example.com
Removing volume net_peer0.org2.example.com
Removing volume net_orderer.example.com
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Creating channel 'mychannel'.
If 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' Bringing up network LOCAL_VERSION=2.2.0 DOCKER_IMAGE_VERSION=2.2.0 CA_LOCAL_VERSION=1.4.7 CA_DOCKER_IMAGE_VERSION=1.4.7 Generate certificates using Fabric CA's
Creating network "net_test" with the default driver
Creating ca_org1 ...
Creating ca_org2 ...
Creating ca_org1
Creating ca_orderer ...
Creating ca_org2
Creating ca_orderer ... done
Create Org1 Identities
Enroll the CA admin
+ 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
2020/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
2020/09/28 19:24:36 [INFO] TLS Enabled
2020/09/28 19:24:36 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:36 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Register peer0
+ 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
2020/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
2020/09/28 19:24:36 [INFO] TLS Enabled
2020/09/28 19:24:36 [INFO] TLS Enabled
Password: peer0pw
Register user
+ 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
2020/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
2020/09/28 19:24:36 [INFO] TLS Enabled
2020/09/28 19:24:36 [INFO] TLS Enabled
Password: user1pw
Register the org admin
+ 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
2020/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
2020/09/28 19:24:36 [INFO] TLS Enabled
2020/09/28 19:24:36 [INFO] TLS Enabled
Password: org1adminpw
Generate the peer0 msp
+ 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
2020/09/28 19:24:36 [INFO] TLS Enabled
2020/09/28 19:24:36 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:36 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the peer0-tls certificates
+ 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
2020/09/28 19:24:37 [INFO] TLS Enabled
2020/09/28 19:24:37 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:37 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the user msp
+ 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
2020/09/28 19:24:37 [INFO] TLS Enabled
2020/09/28 19:24:37 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:37 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the org admin msp
+ 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
2020/09/28 19:24:37 [INFO] TLS Enabled
2020/09/28 19:24:37 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:37 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Create Org2 Identities
Enroll the CA admin
+ 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
2020/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
2020/09/28 19:24:37 [INFO] TLS Enabled
2020/09/28 19:24:37 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:37 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Register peer0
+ 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
2020/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
2020/09/28 19:24:37 [INFO] TLS Enabled
2020/09/28 19:24:37 [INFO] TLS Enabled
Password: peer0pw
Register user
+ 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
2020/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
2020/09/28 19:24:38 [INFO] TLS Enabled
2020/09/28 19:24:38 [INFO] TLS Enabled
Password: user1pw
Register the org admin
+ 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
2020/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
2020/09/28 19:24:38 [INFO] TLS Enabled
2020/09/28 19:24:38 [INFO] TLS Enabled
Password: org2adminpw
Generate the peer0 msp
+ 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
2020/09/28 19:24:38 [INFO] TLS Enabled
2020/09/28 19:24:38 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:38 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the peer0-tls certificates
+ 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
2020/09/28 19:24:38 [INFO] TLS Enabled
2020/09/28 19:24:38 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:38 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the user msp
+ 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
2020/09/28 19:24:38 [INFO] TLS Enabled
2020/09/28 19:24:38 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:38 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the org admin msp
+ 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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:39 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Create Orderer Org Identities
Enroll the CA admin
+ 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
2020/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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:39 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Register orderer
+ 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
2020/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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] TLS Enabled
Password: ordererpw
Register the orderer admin
+ 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
2020/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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] TLS Enabled
Password: ordererAdminpw
Generate the orderer msp
+ 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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:39 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the orderer-tls certificates
+ 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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:39 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate the admin msp
+ 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
2020/09/28 19:24:39 [INFO] TLS Enabled
2020/09/28 19:24:39 [INFO] generating key: &{ A:ecdsa S:256}
2020/09/28 19:24:39 [INFO] encoded CSR
2020/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
2020/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
2020/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
2020/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
Generate CCP files for Org1 and Org2
/home/halfape/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/../bin/configtxgen
Generating Orderer Genesis block
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-09-28 19:24:40.105 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-28 19:24:40.150 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-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
2020-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
2020-09-28 19:24:40.153 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-09-28 19:24:40.153 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
+ res=0
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
WARNING: 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.
Creating couchdb0 ...
Creating couchdb1 ...
Creating couchdb0
Creating orderer.example.com ...
Creating couchdb1
Creating couchdb0 ... done
Creating peer0.org1.example.com ...
Creating couchdb1 ... done
Creating peer0.org2.example.com ...
Creating peer0.org2.example.com ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f67481c753a1 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
2e6acaa2e6de 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
addd0468c8e1 hyperledger/fabric-orderer:latest "orderer" 7 seconds ago Up 2 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
4617a52baf05 couchdb:3.1 "tini -- /docker-ent…" 7 seconds ago Up 2 seconds 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb1
0c59116b95bd couchdb:3.1 "tini -- /docker-ent…" 7 seconds ago Up 3 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
579e3671065a 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
40b9c11d100f 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
d870924d9c90 hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 15 seconds ago Up 13 seconds 0.0.0.0:7054->7054/tcp ca_org1
Generating channel create transaction 'mychannel.tx'
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
2020-09-28 19:24:48.554 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-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
2020-09-28 19:24:48.611 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-09-28 19:24:48.615 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx
+ res=0
Generating anchor peer update transactions
Generating anchor peer update transaction for Org1MSP
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2020-09-28 19:24:48.671 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-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
2020-09-28 19:24:48.731 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-09-28 19:24:48.744 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
Generating anchor peer update transaction for Org2MSP
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2020-09-28 19:24:48.794 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-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
2020-09-28 19:24:48.859 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-09-28 19:24:48.861 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
Creating channel mychannel
Using organization 1
+ 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
+ res=0
2020-09-28 19:24:51.951 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-28 19:24:51.968 CST [cli.common] readBlock -> INFO 002 Expect block, but got status: &{ NOT_FOUND}
2020-09-28 19:24:51.971 CST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-28 19:24:52.173 CST [cli.common] readBlock -> INFO 004 Expect block, but got status: &{ SERVICE_UNAVAILABLE}
2020-09-28 19:24:52.176 CST [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2020-09-28 19:24:52.378 CST [cli.common] readBlock -> INFO 006 Expect block, but got status: &{ SERVICE_UNAVAILABLE}
2020-09-28 19:24:52.381 CST [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2020-09-28 19:24:52.586 CST [cli.common] readBlock -> INFO 008 Expect block, but got status: &{ SERVICE_UNAVAILABLE}
2020-09-28 19:24:52.589 CST [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2020-09-28 19:24:52.790 CST [cli.common] readBlock -> INFO 00a Expect block, but got status: &{ SERVICE_UNAVAILABLE}
2020-09-28 19:24:52.793 CST [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2020-09-28 19:24:52.995 CST [cli.common] readBlock -> INFO 00c Expect block, but got status: &{ SERVICE_UNAVAILABLE}
2020-09-28 19:24:52.998 CST [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
2020-09-28 19:24:53.201 CST [cli.common] readBlock -> INFO 00e Received block: 0
Channel 'mychannel' created
Join Org1 peers to the channel...
Using organization 1
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2020-09-28 19:24:56.279 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-28 19:24:56.738 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Join Org2 peers to the channel...
Using organization 2
+ peer channel join -b ./channel-artifacts/mychannel.block
+ res=0
2020-09-28 19:24:59.823 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-28 19:25:00.112 CST [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Updating anchor peers for org1...
Using organization 1
+ 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
+ res=0
2020-09-28 19:25:03.166 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-28 19:25:03.182 CST [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peers updated for org 'Org1MSP' on channel 'mychannel'
Updating anchor peers for org2...
Using organization 2
+ 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
+ res=0
2020-09-28 19:25:09.246 CST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-28 19:25:09.263 CST [channelCmd] update -> INFO 002 Successfully submitted channel update
Anchor peers updated for org 'Org2MSP' on channel 'mychannel'
Channel successfully joined
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: fabcar
- CC_SRC_PATH: ../chaincode/fabcar/go/
- CC_SRC_LANGUAGE: go
- CC_VERSION: 1
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: initLedger
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Vendoring Go dependencies at ../chaincode/fabcar/go/
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/fabcar/go ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network
go: downloading github.com/hyperledger/fabric-contract-api-go v1.1.0
go: downloading github.com/hyperledger/fabric-chaincode-go v0.0.0-20200424173110-d7076418f212
go: downloading github.com/xeipuuv/gojsonschema v1.2.0
go: downloading github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e
go: downloading github.com/go-openapi/spec v0.19.4
go: downloading github.com/gobuffalo/packr v1.30.1
go: downloading github.com/golang/protobuf v1.3.2
go: downloading google.golang.org/grpc v1.23.0
go: downloading github.com/go-openapi/jsonreference v0.19.2
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: downloading github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
go: downloading github.com/go-openapi/jsonpointer v0.19.3
go: downloading github.com/go-openapi/swag v0.19.5
go: downloading golang.org/x/text v0.3.2
go: downloading golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542
go: downloading golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
go: downloading google.golang.org/genproto v0.0.0-20180831171423-11092d34479b
go: downloading github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e
go: downloading github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
go: downloading github.com/gobuffalo/packd v0.3.0
go: downloading gopkg.in/yaml.v2 v2.2.8
go: downloading github.com/gobuffalo/envy v1.7.0
go: downloading github.com/rogpeppe/go-internal v1.3.0
go: downloading github.com/joho/godotenv v1.3.0
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network
Finished vendoring Go dependencies
Using organization 1
+ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1
+ res=0
Chaincode is packaged on peer0.org1
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install fabcar.tar.gz
+ res=0
2020-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" >
2020-09-28 19:25:50.807 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506
Chaincode is installed on peer0.org1
Install chaincode on peer0.org2...
Using organization 2
+ peer lifecycle chaincode install fabcar.tar.gz
+ res=0
2020-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" >
2020-09-28 19:26:12.231 CST [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506
Chaincode is installed on peer0.org2
Using organization 1
+ peer lifecycle chaincode queryinstalled
+ res=0
Installed chaincodes on peer:
Package ID: fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506, Label: fabcar_1
Query installed successful on peer0.org1 on channel
Using organization 1
+ 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
+ res=0
2020-09-28 19:26:15.916 CST [chaincodeCmd] ClientWait -> INFO 001 txid [355f68105cdd5ed2b48754ec3faa0780724c8a67319bd45945836d80b19101e2] committed with status (VALID) at
Chaincode definition approved on peer0.org1 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": false
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": false
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 2
+ 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
+ res=0
2020-09-28 19:26:24.809 CST [chaincodeCmd] ClientWait -> INFO 001 txid [b02e043ef240dccfb291961b1072957399c248481decd528d9e292290eac905e] committed with status (VALID) at
Chaincode definition approved on peer0.org2 on channel 'mychannel'
Using organization 1
Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": true
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to check the commit readiness of the chaincode definition on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1 --sequence 1 --init-required --output json
+ res=0
{
"approvals": {
"Org1MSP": true,
"Org2MSP": true
}
}
Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 1
Using organization 2
+ 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
+ res=0
2020-09-28 19:26:34.208 CST [chaincodeCmd] ClientWait -> INFO 001 txid [7f6773b0394bb3ed90b75ebe5fdf3d8e7d72ce7ebbba818660fe30084477d55b] committed with status (VALID) at localhost:9051
2020-09-28 19:26:34.228 CST [chaincodeCmd] ClientWait -> INFO 002 txid [7f6773b0394bb3ed90b75ebe5fdf3d8e7d72ce7ebbba818660fe30084477d55b] committed with status (VALID) at localhost:7051
Chaincode definition committed on channel 'mychannel'
Using organization 1
Querying chaincode definition on peer0.org1 on channel 'mychannel'...
Attempting to Query committed status on peer0.org1, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar
+ res=0
Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org1 on channel 'mychannel'
Using organization 2
Querying chaincode definition on peer0.org2 on channel 'mychannel'...
Attempting to Query committed status on peer0.org2, Retry after 3 seconds.
+ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar
+ res=0
Committed chaincode definition for chaincode 'fabcar' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
Query chaincode definition successful on peer0.org2 on channel 'mychannel'
Using organization 1
Using organization 2
+ fcn_call='{"function":"initLedger","Args":[]}'
+ infoln 'invoke fcn call:{"function":"initLedger","Args":[]}'
+ println '\033[0;34minvoke fcn call:{"function":"initLedger","Args":[]}\033[0m'
+ echo -e '\033[0;34minvoke fcn call:{"function":"initLedger","Args":[]}\033[0m'
invoke fcn call:{ "function":"initLedger","Args":[]}
+ 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":[]}'
+ res=0
2020-09-28 19:26:40.708 CST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel'
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar
Total setup execution time : 155 secs ...
Next, use the FabCar applications to interact with the deployed FabCar contract.
The FabCar applications are available in multiple programming languages.
Follow the instructions for the programming language of your choice:
JavaScript:
Start by changing into the "javascript" directory:
cd javascript
Next, install all required packages:
npm install
Then run the following applications to enroll the admin user, and register a new user
called appUser which will be used by the other applications to interact with the deployed
FabCar contract:
node enrollAdmin
node registerUser
You can run the invoke application as follows. By default, the invoke application will
create a new car, but you can update the application to submit other transactions:
node invoke
You can run the query application as follows. By default, the query application will
return all cars, but you can update the application to evaluate other transactions:
node query
TypeScript:
Start by changing into the "typescript" directory:
cd typescript
Next, install all required packages:
npm install
Next, compile the TypeScript code into JavaScript:
npm run build
Then run the following applications to enroll the admin user, and register a new user
called appUser which will be used by the other applications to interact with the deployed
FabCar contract:
node dist/enrollAdmin
node dist/registerUser
You can run the invoke application as follows. By default, the invoke application will
create a new car, but you can update the application to submit other transactions:
node dist/invoke
You can run the query application as follows. By default, the query application will
return all cars, but you can update the application to evaluate other transactions:
node dist/query
Java:
Start by changing into the "java" directory:
cd java
Then, install dependencies and run the test using:
mvn test
The test will invoke the sample client app which perform the following:
- Enroll admin and appUser and import them into the wallet (if they don't already exist there) - Submit a transaction to create a new car - Evaluate a transaction (query) to return details of this car - Submit a transaction to change the owner of this car - Evaluate a transaction (query) to return the updated details of this car Go: Start by changing into the "go" directory: cd go Then, install dependencies and run the test using: go run fabcar.go The test will invoke the sample client app which perform the following: - Import user credentials into the wallet (if they don't already exist there)
- Submit a transaction to create a new car
- Evaluate a transaction (query) to return details of this car
- Submit a transaction to change the owner of this car
- Evaluate a transaction (query) to return the updated details of this car
我们的应用程序也就启动成功了,再次回到test-network
目录。使用命令获取汽车资产列表,结果如下:
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples$ cd test-network/
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
[{ "Key":"CAR0","Record":{ "make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{ "Key":"CAR1","Record":{ "make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{ "Key":"CAR2","Record":{ "make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{ "Key":"CAR3","Record":{ "make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{ "Key":"CAR4","Record":{ "make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{ "Key":"CAR5","Record":{ "make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{ "Key":"CAR6","Record":{ "make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{ "Key":"CAR7","Record":{ "make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{ "Key":"CAR8","Record":{ "make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{ "Key":"CAR9","Record":{ "make":"Holden","model":"Barina","colour":"brown","owner":"Shotaro"}}]
终于成功了。。。。
同理,设置org2的环境变量:
# Environment variables for Org2
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=localhost:9051
在peer0.org2.example.com上调用链码查询fabcar列表:
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_TLS_ENABLED=true
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_LOCALMSPID="Org2MSP"
halfape@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
halfape@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
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ export CORE_PEER_ADDRESS=localhost:9051
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network$ peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}'
[{ "Key":"CAR0","Record":{ "make":"Toyota","model":"Prius","colour":"blue","owner":"Tomoko"}},{ "Key":"CAR1","Record":{ "make":"Ford","model":"Mustang","colour":"red","owner":"Brad"}},{ "Key":"CAR2","Record":{ "make":"Hyundai","model":"Tucson","colour":"green","owner":"Jin Soo"}},{ "Key":"CAR3","Record":{ "make":"Volkswagen","model":"Passat","colour":"yellow","owner":"Max"}},{ "Key":"CAR4","Record":{ "make":"Tesla","model":"S","colour":"black","owner":"Adriana"}},{ "Key":"CAR5","Record":{ "make":"Peugeot","model":"205","colour":"purple","owner":"Michel"}},{ "Key":"CAR6","Record":{ "make":"Chery","model":"S22L","colour":"white","owner":"Aarav"}},{ "Key":"CAR7","Record":{ "make":"Fiat","model":"Punto","colour":"violet","owner":"Pari"}},{ "Key":"CAR8","Record":{ "make":"Tata","model":"Nano","colour":"indigo","owner":"Valeria"}},{ "Key":"CAR9","Record":{ "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安装终于告一段落。如果你觉得这篇文章对你有帮助,那么可以关注微信公众号半路猿
,加我微信,拉你进我们的学习交流群,一起学习,一同成长。