溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Hyperledger Fabric如何構(gòu)建第一個(gè)網(wǎng)絡(luò)

發(fā)布時(shí)間:2021-12-06 14:21:34 來(lái)源:億速云 閱讀:191 作者:小新 欄目:互聯(lián)網(wǎng)科技

小編給大家分享一下Hyperledger Fabric如何構(gòu)建第一個(gè)網(wǎng)絡(luò),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

先決條件

操作系統(tǒng)

建議使用Ubuntu或者M(jìn)acOS,不建議使用windows

Curl

下載最新版本的 curl 工具安裝(如果尚未安裝)

Docker和Docker Compose

Docker版本17.06.2-ce或更高版本。

Docker Compose版本1.14.0或更高版本。

以下命令檢查已安裝的Docker的版本:

docker --version

以下命令檢查已安裝的Docker Compose的版本:

docker-compose --version

Go

Hyperledger Fabric對(duì)其許多組件使用Go編程語(yǔ)言1.11.x

環(huán)境變量設(shè)置 GOPATH 為:

export GOPATH=$HOME/go

將 GOPATH/bin 添加到 PATH 中:

export PATH = $ PATH:$ GOPATH / bin

Node.js和NPM

利用針對(duì)Node.js的Hyperledger Fabric SDK開(kāi)發(fā)Hyperledger Fabric的應(yīng)用程序,則需要安裝版本8.9.x的Node.js。

安裝Node.js也會(huì)安裝NPM,但建議命令升級(jí)該工具:

npm install npm@5.6.0 -g

Git

下載安裝 Git

搭建第一個(gè)網(wǎng)絡(luò)

1.克隆 hyperledger/fabric-samples

git clone https://github.com/hyperledger/fabric-samples.git

2.切換到 fabric-samples 文件夾下

cd fabric-samples

3.指定版本的Hyperledger Fabric平臺(tái)特定二進(jìn)制文件和配置文件分別安裝到fabric-samples 存儲(chǔ)庫(kù)的根目錄中bin文件夾和config文件夾,和下載指定版本的Hyperledger Fabric docker鏡像

./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]

4.構(gòu)建第一個(gè)網(wǎng)絡(luò)

   (1) 使用 first-network 樣本

cd first-network

   (2) byfn.sh 腳本的幫助文本

Usage:
  byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-i <imagetag>] [-v]
    <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'
      - 'up' - bring up the network with docker-compose up
      - 'down' - clear the network with docker-compose down
      - 'restart' - restart the network
      - 'generate' - generate required certificates and genesis block
      - 'upgrade'  - upgrade the network from v1.0.x to v1.1
    -c <channel name> - channel name to use (defaults to "mychannel")
    -t <timeout> - CLI timeout duration in seconds (defaults to 10)
    -d <delay> - delay duration in seconds (defaults to 3)
    -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)
    -s <dbtype> - the database backend to use: goleveldb (default) or couchdb
    -l <language> - the chaincode language: golang (default), node or java
    -i <imagetag> - the tag to be used to launch the network (defaults to "latest")
    -v - verbose mode
  byfn.sh -h (print this message)Typically, one would first generate the required certificates andgenesis block, then bring up the network. e.g.:

        byfn.sh generate -c mychannel
        byfn.sh up -c mychannel -s couchdb
        byfn.sh up -c mychannel -s couchdb -i 1.1.0-alpha
        byfn.sh up -l node
        byfn.sh down -c mychannel
        byfn.sh upgrade -c mychannelTaking all defaults:
        byfn.sh generate
        byfn.sh up
        byfn.sh down

   (3) 生成msp證書(shū)密鑰文件,簡(jiǎn)要說(shuō)明,回車?yán)^續(xù)

./byfn.sh generate

      日志輸出

Hyperledger Fabric如何構(gòu)建第一個(gè)網(wǎng)絡(luò)

   (4) 啟動(dòng)網(wǎng)絡(luò)

./byfn.sh up

日志會(huì)看到從 start 

  Hyperledger Fabric如何構(gòu)建第一個(gè)網(wǎng)絡(luò)

到此,第一個(gè)聯(lián)盟鏈搭建成功,是自動(dòng)化腳本構(gòu)建的,接著下一章會(huì)分析細(xì)節(jié)。

   (5) 終止網(wǎng)絡(luò),終止容器,刪除加密材料和四個(gè)工件,并刪除鏈上代碼鏡像

./byfn.sh down

看完了這篇文章,相信你對(duì)“Hyperledger Fabric如何構(gòu)建第一個(gè)網(wǎng)絡(luò)”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI