HyperLedgr如何部署以及初始化網(wǎng)絡(luò)

小編給大家分享一下HyperLedgr如何部署以及初始化網(wǎng)絡(luò),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、鄒平ssl等。為超過(guò)千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢(xún)和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的鄒平網(wǎng)站制作公司

先決條件列表

  • 最新版本的 git

  • 最新版本的 curl

  • 任意版本的 wget

  • docker 和 docker-compose
    docker --version需要

  • Go 環(huán)境設(shè)置

  • Node.js 環(huán)境設(shè)置(包括 npm)

  • Python

安裝示例、二進(jìn)制和 Docker 映像

根據(jù)腳本下載源文件, 并存儲(chǔ)到 bin 文件夾,最后該腳本將從 Docker Hub 下載最新的 Hyperledger Fabric Docker 鏡像到本地的 Docker 注冊(cè)表

測(cè)試安裝環(huán)境正確性

開(kāi)始之前

確認(rèn)第二章節(jié)的安裝實(shí)例工作成功

啟動(dòng)測(cè)試網(wǎng)絡(luò)

cd fabric-samples/test-network
啟用./network.sh -h查看測(cè)試網(wǎng)絡(luò)搭建腳本的用法

1.Usage:
2.  network.sh <Mode> [Flags]
3.    <Mode>
4.      - 'up' - bring up fabric orderer and peer nodes. No channel is created
5.      - 'up createChannel' - bring up fabric network with one channel
6.      - 'createChannel' - create and join a channel after the network is created
7.      - 'deployCC' - deploy the fabcar chaincode on the channel
8.      - 'down' - clear the network with docker-compose down
9.      - 'restart' - restart the network
10.
11.    Flags:
12.    -ca <use CAs> -  create Certificate Authorities to generate the crypto material
13.    -c <channel name> - channel name to use (defaults to "mychannel")
14.    -s <dbtype> - the database backend to use: goleveldb (default) or couchdb
15.    -r <max retry> - CLI times out after certain number of attempts (defaults to 5)
16.    -d <delay> - delay duration in seconds (defaults to 3)
17.    -l <language> - the programming language of the chaincode to deploy: go (default), javascript, or java
18.    -v <version>  - chaincode version. Must be a round number, 1, 2, 3, etc
19.    -i <imagetag> - the tag to be used to launch the network (defaults to "latest")
20.    -verbose - verbose mode
21.  network.sh -h (print this message)
22.
23. Possible Mode and flags
24.  network.sh up -ca -c -r -d -s -i -verbose
25.  network.sh up createChannel -ca -c -r -d -s -i -verbose
26.  network.sh createChannel -c -r -d -verbose
27.  network.sh deployCC -l -v -r -d -verbose
28.
29. Taking all defaults:
30.    network.sh up
31.
32. Examples:
33.  network.sh up createChannel -ca -c mychannel -s couchdb -i 2.0.0-beta
34.  network.sh createChannel -c channelName
35.  network.sh deployCC -l javascript

當(dāng)使用這個(gè)腳本network.sh up時(shí)將不產(chǎn)生任何人通道(只創(chuàng)建兩個(gè)組織和一個(gè)排序節(jié)點(diǎn))
docker ps -a命令會(huì)顯示目前計(jì)算機(jī)上創(chuàng)建的幾個(gè)節(jié)點(diǎn) (3)

創(chuàng)建頻道

使用腳本為 Org1 和 Org2 之間的事務(wù)創(chuàng)建 Fabric 通道,不同的通道有不同的分類(lèi)帳本;./neteork.sh createChannel -c channelName

部署鏈碼

./network.sh deployCC -l javascript
init 將會(huì)初始化智能合約內(nèi)容,并調(diào)用鏈碼將初始化的數(shù)據(jù)寫(xiě)入賬本

  • 查詢(xún)帳本所有信息
    Org1 的環(huán)境變量配置,查詢(xún) Org2 的環(huán)境配置需更改

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

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

  • 更改帳上資本
    peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n fabcar --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"changeCarOwner","Args":["CAR9","Dave"]}'
    --peerAddresses localhost:7051表示 Org1 的地址
    --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt表示 Org1 的私鑰地址
    --peerAddresses localhost:9051表示 Org2 的地址
    --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt表示 Org2 的私鑰地址
    ‘命令太長(zhǎng)了,還是使用 fabcar 里面的 sdk 編輯代碼更改吧’

  • 關(guān)閉網(wǎng)絡(luò)
    ./network.sh down該命令將停止并刪除節(jié)點(diǎn)、鏈碼容器、組織密鑰、Docker 注冊(cè)表中的鏈碼鏡像、通道、dock 卷。

使用證書(shū)頒發(fā)機(jī)構(gòu)啟動(dòng)網(wǎng)絡(luò)

Hyperledger 結(jié)構(gòu)使用公鑰基礎(chǔ)結(jié)構(gòu)(PKI),創(chuàng)建對(duì)等節(jié)點(diǎn)和排序節(jié)點(diǎn)之前必須創(chuàng)建部署和操作網(wǎng)絡(luò)的所需的所有加密材料:節(jié)點(diǎn),網(wǎng)絡(luò)管理員,提交事務(wù)的用戶(hù)都需要公共證書(shū)和私鑰來(lái)驗(yàn)證身份。
默認(rèn)情況使用Crptogen工具來(lái)創(chuàng)建證書(shū)和密鑰, 創(chuàng)建過(guò)程如下

/Usr/fabric-samples/test-network/../bin/cryptogen
##########################################################
############ Create Org1 Identities ######################
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
+ set +x
##########################################################
############ Create Org2 Identities ######################
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
+ set +x
##########################################################
############ Create Orderer Org Identities ###############
##########################################################
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
+ set +x

以上是“HyperLedgr如何部署以及初始化網(wǎng)絡(luò)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站題目:HyperLedgr如何部署以及初始化網(wǎng)絡(luò)
網(wǎng)站網(wǎng)址:http://bm7419.com/article12/pciggc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、App開(kāi)發(fā)網(wǎng)站設(shè)計(jì)公司、網(wǎng)站設(shè)計(jì)、網(wǎng)站內(nèi)鏈、微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)