主頁 > 前端設計 > Fabric開發(五) Ubuntu20.04.1快速搭建Fabric2.2.0 (排雷版)

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

2020-09-30 11:32:15 前端設計

寫在前面

看到題目,你可能會想,這個作者腦子抽吧,怎么又要出一篇關于環境搭建的, 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安裝終于告一段落,如果你覺得這篇文章對你有幫助,那么可以關注微信公眾號半路猿,加我微信,拉你進我們的學習交流群,一起學習,一同成長,

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/141892.html

標籤:其他

上一篇:用hyperledger cello H3C分支創建單機模式區塊鏈系統

下一篇:ubuntu系統Tushare安裝、注冊與使用

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • vue移動端上拉加載

    可能做得過于簡單或者比較low,請各位大佬留情,一起探討技術 ......

    uj5u.com 2020-09-10 04:38:07 more
  • 優美網站首頁,頂部多層導航

    一個個人用的瀏覽器首頁,可以把一下常用的網站放在這里,平常打開會比較方便。 第一步,HTML代碼 <script src=https://www.cnblogs.com/szharf/p/"js/jquery-3.4.1.min.js"></script> <div id="navigate"> <ul> <li class="labels labels_1"> ......

    uj5u.com 2020-09-10 04:38:47 more
  • 頁面為要加<!DOCTYPE html>

    最近因為寫一個js函式,需要用到$(window).height(); 由于手寫demo的時候,過于自信,其實對前端方面的認識也不夠體系,用文本檔案直接敲出來的html代碼,第一行沒有加上<!DOCTYPE html> 導致了$(window).height();的結果直接是整個document的高 ......

    uj5u.com 2020-09-10 04:38:52 more
  • WordPress網站程式手動升級要做好資料備份

    WordPress博客網站程式在進行升級前,必須要做好網站資料的備份,這個問題良家佐言是遇見過的;在剛開始接觸WordPress博客程式的時候,因為升級問題和博客網站的修改的一些嘗試,良家佐言是吃盡了苦頭。因為購買的是西部數碼的空間和域名,每當佐言把自己的WordPress博客網站搞到一塌糊涂的時候 ......

    uj5u.com 2020-09-10 04:39:30 more
  • WordPress程式不能升級為5.4.2版本的原因

    WordPress是一款個人博客系統,受到英文博客愛好者和中文博客愛好者的追捧,并逐步演化成一款內容管理系統軟體;它是使用PHP語言和MySQL資料庫開發的,用戶可以在支持PHP和MySQL資料庫的服務器上使用自己的博客。每一次WordPress程式的更新,就會牽動無數WordPress愛好者的心, ......

    uj5u.com 2020-09-10 04:39:49 more
  • 使用CSS3的偽元素進行首字母下沉和首行改變樣式

    網頁中常見的一種效果,首字改變樣式或者首行改變樣式,效果如下圖。 代碼: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, ......

    uj5u.com 2020-09-10 04:40:09 more
  • 關于a標簽的講解

    什么是a標簽? <a> 標簽定義超鏈接,用于從一個頁面鏈接到另一個頁面。 <a> 元素最重要的屬性是 href 屬性,它指定鏈接的目標。 a標簽的語法格式:<a href=https://www.cnblogs.com/summerxbc/p/"指定要跳轉的目標界面的鏈接">需要展示給用戶看見的內容</a> a標簽 在所有瀏覽器中,鏈接的默認外觀如下: 未被訪問的鏈接帶 ......

    uj5u.com 2020-09-10 04:40:11 more
  • 前端輪播圖

    在需要輪播的頁面是引入swiper.min.js和swiper.min.css swiper.min.js地址: 鏈接:https://pan.baidu.com/s/15Uh516YHa4CV3X-RyjEIWw 提取碼:4aks swiper.min.css地址 鏈接:https://pan.b ......

    uj5u.com 2020-09-10 04:40:13 more
  • 如何設定html中的背景圖片(全屏顯示,且不拉伸)

    1 <style>2 body{background-image:url(https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture); 3 background-size:cover;background ......

    uj5u.com 2020-09-10 04:40:16 more
  • Java學習——HTML詳解(上)

    HTML詳解 初識HTML Hyper Text Markup Language(超文本標記語言) 1 <!--DOCTYPE:告訴瀏覽器我們要使用什么規范--> 2 <!DOCTYPE html> 3 <html lang="en"> 4 <head> 5 <!--meta 描述性的標簽,描述一些 ......

    uj5u.com 2020-09-10 04:40:33 more
最新发布
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 07:59:23 more
  • 生產事故-走近科學之消失的JWT

    入職多年,面對生產環境,盡管都是小心翼翼,慎之又慎,還是難免捅出簍子。輕則滿頭大汗,面紅耳赤。重則系統停擺,損失資金。每一個生產事故的背后,都是寶貴的經驗和教訓,都是專案成員的血淚史。為了更好地防范和遏制今后的各類事故,特開此專題,長期更新和記錄大大小小的各類事故。有些是親身經歷,有些是經人耳傳口授 ......

    uj5u.com 2023-04-18 07:55:04 more
  • 記錄--Canvas實作打飛字游戲

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 打開游戲界面,看到一個畫面簡潔、卻又富有挑戰性的游戲。螢屏上,有一個白色的矩形框,里面不斷下落著各種單詞,而我需要迅速地輸入這些單詞。如果我輸入的單詞與螢屏上的單詞匹配,那么我就可以獲得得分;如果我輸入的單詞錯誤或者時間過長,那么我就會輸 ......

    uj5u.com 2023-04-04 08:35:30 more
  • 了解 HTTP 看這一篇就夠

    在學習網路之前,了解它的歷史能夠幫助我們明白為何它會發展為如今這個樣子,引發探究網路的興趣。下面的這張圖片就展示了“互聯網”誕生至今的發展歷程。 ......

    uj5u.com 2023-03-16 11:00:15 more
  • 藍牙-低功耗中心設備

    //11.開啟藍牙配接器 openBluetoothAdapter //21.開始搜索藍牙設備 startBluetoothDevicesDiscovery //31.開啟監聽搜索藍牙設備 onBluetoothDeviceFound //30.停止監聽搜索藍牙設備 offBluetoothDevi ......

    uj5u.com 2023-03-15 09:06:45 more
  • canvas畫板(滑鼠和觸摸)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>canves</title> <style> #canvas { cursor:url(../images/pen.png),crosshair; } #canvasdiv{ bo ......

    uj5u.com 2023-02-15 08:56:31 more
  • 手機端H5 實作自定義拍照界面

    手機端 H5 實作自定義拍照界面也可以使用 MediaDevices API 和 <video> 標簽來實作,和在桌面端做法基本一致。 首先,使用 MediaDevices.getUserMedia() 方法獲取攝像頭媒體流,并將其傳遞給 <video> 標簽進行渲染。 接著,使用 HTML 的 < ......

    uj5u.com 2023-01-12 07:58:22 more
  • 記錄--短視頻滑動播放在 H5 下的實作

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 短視頻已經無數不在了,但是主體還是使用 app 來承載的。本文講述 H5 如何實作 app 的視頻滑動體驗。 無聲勝有聲,一圖頂百辯,且看下圖: 網址鏈接(需在微信或者手Q中瀏覽) 從上圖可以看到,我們主要實作的功能也是本文要講解的有: ......

    uj5u.com 2023-01-04 07:29:05 more
  • 一文讀懂 HTTP/1 HTTP/2 HTTP/3

    從 1989 年萬維網(www)誕生,HTTP(HyperText Transfer Protocol)經歷了眾多版本迭代,WebSocket 也在期間萌芽。1991 年 HTTP0.9 被發明。1996 年出現了 HTTP1.0。2015 年 HTTP2 正式發布。2020 年 HTTP3 或能正... ......

    uj5u.com 2022-12-24 06:56:02 more
  • 【HTML基礎篇002】HTML之form表單超詳解

    ??一、form表單是什么

    ??二、form表單的屬性

    ??三、input中的各種Type屬性值

    ??四、標簽 ......

    uj5u.com 2022-12-18 07:17:06 more