成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Fabric學(xué)習(xí)筆記(二) - Docker下手工啟動(dòng)Fabric v1.0.5網(wǎng)絡(luò)

ad6623 / 2003人閱讀

摘要:前言安裝筆記中的是一站式的運(yùn)行例子具體做了什么我們這里一步一步分開來看參考資料網(wǎng)絡(luò)拓?fù)渖山M織關(guān)系和身份證書設(shè)置環(huán)境變量檢查環(huán)境變量的生成確保自己在目錄下生成密鑰文件查看生成的密鑰目錄生成服務(wù)啟動(dòng)區(qū)塊設(shè)

前言

Fabric v1.0.5安裝筆記 中的network_setup.sh up是一站式的運(yùn)行,e 2e cli例子.具體做了什么,我們這里一步一步分開來看

參考資料:

end-to-end

script.sh

網(wǎng)絡(luò)拓?fù)?/b> 生成組織關(guān)系和身份證書

1.設(shè)置環(huán)境變量

for power or z
os_arch=$(echo "$(uname -s)-$(uname -m)" | awk "{print tolower($0)}")
$for linux, osx or windows
os_arch=$(echo "$(uname -s)-amd64" | awk "{print tolower($0)}")

2.檢查環(huán)境變量的生成

echo $os_arch

3.確保自己在e2e_cli目錄下

   /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli

4.生成密鑰文件

./../../release/$os_arch/bin/cryptogen generate --config=./crypto-config.yaml

5.查看生成的密鑰目錄

 tree -L 4 crypto-config
crypto-config
├── ordererOrganizations
│?? └── example.com
│??     ├── ca
│??     │?? ├── 06ae0192afb55ee494bbec1095b9a73148ab011d19450df5eee540696ffbcd00_sk
│??     │?? └── ca.example.com-cert.pem
│??     ├── msp
│??     │?? ├── admincerts
│??     │?? ├── cacerts
│??     │?? └── tlscacerts
│??     ├── orderers
│??     │?? └── orderer.example.com
│??     ├── tlsca
│??     │?? ├── 1056171c60cfd8e918b86404bf3976726ce69640dc7d9b81cbfad1d9a6b7b282_sk
│??     │?? └── tlsca.example.com-cert.pem
│??     └── users
│??         └── [email protected]
└── peerOrganizations
   ├── org1.example.com
   │?? ├── ca
   │?? │?? ├── ca.org1.example.com-cert.pem
   │?? │?? └── e55f885168a48ea087362c472bb285c28531c8df58b8ac92f1d76c9e8c8aba9e_sk
   │?? ├── msp
   │?? │?? ├── admincerts
   │?? │?? ├── cacerts
   │?? │?? └── tlscacerts
   │?? ├── peers
   │?? │?? ├── peer0.org1.example.com
   │?? │?? └── peer1.org1.example.com
   │?? ├── tlsca
   │?? │?? ├── d6eb52db2db3854a1feccfe66494b2b0e89aac1bdd9b68d35ce286873ff85cb0_sk
   │?? │?? └── tlsca.org1.example.com-cert.pem
   │?? └── users
   │??     ├── [email protected]
   │??     └── [email protected]
   └── org2.example.com
       ├── ca
       │?? ├── 5cfdefb1d98601b287ea75805ba679de94108e61d1e595df88bfd2c5ff332542_sk
       │?? └── ca.org2.example.com-cert.pem
       ├── msp
       │?? ├── admincerts
       │?? ├── cacerts
       │?? └── tlscacerts
       ├── peers
       │?? ├── peer0.org2.example.com
       │?? └── peer1.org2.example.com
       ├── tlsca
       │?? ├── e423b8beda388a330c78d4bea3248b464133daaa1fb32abdc71c975fc6c3a7a7_sk
       │?? └── tlsca.org2.example.com-cert.pem
       └── users
           ├── [email protected]
           └── [email protected]
生成Ordering服務(wù)啟動(dòng)genesis區(qū)塊

1.設(shè)置環(huán)境變量,告訴configtxgen那去找配置文件configtx.yaml

FABRIC_CFG_PATH=$PWD

2.創(chuàng)建orderer的創(chuàng)世區(qū)塊

./../../release/$os_arch/bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

3.設(shè)置通道名稱mumubin

CHANNEL_NAME=mumubin
 

4.新建應(yīng)用通道

./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ${CHANNEL_NAME}
生成錨節(jié)點(diǎn)配置更新文件

1.生成Org1錨節(jié)點(diǎn)配置更新文件

 ./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org1MSP
 

2.生成Org2錨節(jié)點(diǎn)配置更新文件

./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org2MSP

至此,網(wǎng)絡(luò)拓?fù)渚蜕赏戤吜?

ll channel-artifacts/
-rw-r--r-- 1 root root  390 1月  18 09:02 channel.tx
-rw-r--r-- 1 root root 9085 1月  18 08:59 genesis.block
-rw-r--r-- 1 root root  280 1月  18 09:04 Org1MSPanchors.tx
-rw-r--r-- 1 root root  280 1月  18 09:05 Org2MSPanchors.tx
啟動(dòng)網(wǎng)絡(luò) 準(zhǔn)備工作

1.清理啟動(dòng)的線程

docker rm -f $(docker ps -aq)

2.查驗(yàn)(結(jié)果應(yīng)該為空)

docker ps
   

3.查看images

 docker images
   
 dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   latest                          647439adf7f6        14 hours ago        145 MB
hyperledger/fabric-tools                                                                               latest                          3275ebd1bb71        2 days ago          1.328 GB
hyperledger/fabric-tools                                                                               x86_64-1.0.6-snapshot-78e18d1   3275ebd1bb71        2 days ago          1.328 GB
hyperledger/fabric-orderer                                                                             latest                          6b311f088ccb        2 days ago          151.3 MB
hyperledger/fabric-orderer                                                                             x86_64-1.0.6-snapshot-78e18d1   6b311f088ccb        2 days ago          151.3 MB
hyperledger/fabric-peer                                                                                latest                          725c3f9ca713        2 days ago          154.3 MB
hyperledger/fabric-peer                                                                                x86_64-1.0.6-snapshot-78e18d1   725c3f9ca713        2 days ago          154.3 MB
hyperledger/fabric-ccenv                                                                               latest                          b2b067a6c6d9        2 days ago          1.282 GB
hyperledger/fabric-ccenv                                                                               x86_64-1.0.6-snapshot-78e18d1   b2b067a6c6d9        2 days ago          1.282 GB
hyperledger/fabric-kafka                                                                               latest                          b8c5172bb83c        6 weeks ago         1.286 GB
docker.io/hyperledger/fabric-kafka                                                                     x86_64-1.0.5                    b8c5172bb83c        6 weeks ago         1.286 GB
docker.io/hyperledger/fabric-zookeeper                                                                 x86_64-1.0.5                    68945f4613fc        6 weeks ago         1.316 GB
hyperledger/fabric-zookeeper                                                                           latest                          68945f4613fc        6 weeks ago         1.316 GB
docker.io/hyperledger/fabric-baseimage                                                                 x86_64-0.3.2                    c92d9fdee998        4 months ago        1.257 GB
hyperledger/fabric-baseimage                                                                           latest                          c92d9fdee998        4 months ago        1.257 GB
docker.io/hyperledger/fabric-baseos                                                                    x86_64-0.3.2                    bbcbb9da2d83        4 months ago        128.8 MB
hyperledger/fabric-baseos                                                                              latest                          bbcbb9da2d83        4 months ago        128.8 MB

4.刪除直接生成的無用的images(帶mycc字段)

   docker rmi -f 647439adf7f6

5.修改掉docker-compose-cli.yaml,防止其自動(dòng)跑所有流程

git diff docker-compose-cli.yaml
  
  diff --git a/examples/e2e_cli/docker-compose-cli.yaml b/examples/e2e_cli/docker-compose-cli.yaml
index e6290cf..27b92f9 100644
--- a/examples/e2e_cli/docker-compose-cli.yaml
+++ b/examples/e2e_cli/docker-compose-cli.yaml
@@ -54,7 +54,7 @@ services:
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
-    command: /bin/bash -c "./scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT"
+    #command: /bin/bash -c "./scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT"
    volumes:
        - /var/run/:/host/var/run/
        - ../chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
一步步啟動(dòng)網(wǎng)絡(luò)

1.設(shè)置環(huán)境變量peer0

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

2.啟動(dòng)容器

CHANNEL_NAME=mumubin TIMEOUT=1000 docker-compose -f docker-compose-cli.yaml up 

P.S. 不要加-d參數(shù),這樣可以打日志
3.另起窗口,進(jìn)入cli容器

docker exec -it cli bash

4.設(shè)置環(huán)境變量

CHANNEL_NAME=mumubin
ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

5.創(chuàng)建channel(這里end-to-end文檔有錯(cuò),參見script腳本)

peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA

6.加入Channel(目前是Org1的peer0加入的網(wǎng)絡(luò))

peer channel join -b mumubin.block

7.Org1的peer1加入的網(wǎng)絡(luò)

CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
peer channel join -b mumubin.block

8.Org2的peer0加入的網(wǎng)絡(luò)

CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
peer channel join -b mumubin.block

9.Org2的peer1加入的網(wǎng)絡(luò)

CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
peer channel join -b mumubin.block
交易運(yùn)行

1.回歸peer0

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

2.安裝 install chaincode

peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

3.實(shí)例化 instantiate chaincode

peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 1.0 -c "{"Args":["init","a","100","b","200"]}" -P "OR    ("Org1MSP.member","Org2MSP.member")"
   

驗(yàn)證實(shí)例化是否成功

peer chaincode query -C $CHANNEL_NAME -n mycc -c "{"Args":["query","a"]}"
Query Result: 100

4.觸發(fā)交易 Invoke chaincode

peer chaincode invoke -o orderer.example.com:7050  --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c "{"Args":["invoke","a","b","10"]}"

5.查詢交易

peer chaincode query -C $CHANNEL_NAME -n mycc -c "{"Args":["query","a"]}"
Query Result: 90

交易順利執(zhí)行成功

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/23949.html

相關(guān)文章

  • Fabric學(xué)習(xí)筆記(三) - Fabric v1.0.5 使用CouchDB

    摘要:前言默認(rèn)的為功能有限現(xiàn)在把它該歸它提供了豐富的查詢功能拉取使用啟動(dòng)利用上節(jié)教程使所有添加至改用安裝請(qǐng)把環(huán)境變量都改為的實(shí)例化創(chuàng)建一些并交易 前言 默認(rèn)的state DB為goleveldb,功能有限,現(xiàn)在把它該歸CouchDB.它提供了豐富的查詢功能 拉取coundb image docker pull hyperledger/fabric-couchdb:x86_64-1.0.5 d...

    liangzai_cool 評(píng)論0 收藏0
  • SegmentFault 技術(shù)周刊 Vol.41 - 深入學(xué)習(xí)區(qū)塊鏈

    摘要:和比特幣協(xié)議有所不同的是,以太坊的設(shè)計(jì)十分靈活,極具適應(yīng)性。超級(jí)賬本區(qū)塊鏈的商業(yè)應(yīng)用超級(jí)賬本超級(jí)賬本是基金會(huì)下的眾多項(xiàng)目中的一個(gè)。證書頒發(fā)機(jī)構(gòu)負(fù)責(zé)簽發(fā)撤 showImg(https://segmentfault.com/img/bV2ge9?w=900&h=385); 從比特幣開始 一個(gè)故事告訴你比特幣的原理及運(yùn)作機(jī)制 這篇文章的定位會(huì)比較科普,盡量用類比的方法將比特幣的基本原理講出來...

    qianfeng 評(píng)論0 收藏0
  • Fabric學(xué)習(xí)筆記(四) - Fabric CA的簡單實(shí)用

    摘要:前言本文嚴(yán)重參考官方文檔并去除復(fù)雜部分和相應(yīng)解釋基本只覆蓋操作流程下載下載鏡像啟動(dòng)進(jìn)入鏡像查詢并啟動(dòng)已啟動(dòng)注冊(cè)實(shí)體注冊(cè)修改下的配置文件注冊(cè)新成員 前言 本文嚴(yán)重參考官方文檔,并去除復(fù)雜部分和相應(yīng)解釋,基本只覆蓋操作流程 下載fabric-ca go get -u github.com/hyperledger/fabric-ca/cmd/... 下載fabric-ca鏡像 docker ...

    ninefive 評(píng)論0 收藏0
  • CentOS學(xué)習(xí)筆記 - 8. docker 編譯基于gofabric8的java應(yīng)用鏡像

    摘要:所以這里一般就是執(zhí)行啟動(dòng)我們應(yīng)用的那條命令。編譯運(yùn)行編譯好的鏡像打開瀏覽器進(jìn)行測(cè)試 編譯docker鏡像 1.加速docker鏡像下載速度 取決于網(wǎng)絡(luò)速度,如果不慢的話,可以先不裝 https://www.daocloud.io/mirror#accelerator-doc 執(zhí)行下面的命令配置加速器 curl -sSL https://get.daocloud.io/daotools...

    BingqiChen 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<