摘要:前言安裝筆記中的是一站式的運行例子具體做了什么我們這里一步一步分開來看參考資料網絡拓撲生成組織關系和身份證書設置環境變量檢查環境變量的生成確保自己在目錄下生成密鑰文件查看生成的密鑰目錄生成服務啟動區塊設
前言
Fabric v1.0.5安裝筆記 中的network_setup.sh up是一站式的運行,e 2e cli例子.具體做了什么,我們這里一步一步分開來看
參考資料:
end-to-end
script.sh
網絡拓撲 生成組織關系和身份證書1.設置環境變量
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.檢查環境變量的生成
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 │?? └── Admin@example.com └── 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 │?? ├── Admin@org1.example.com │?? └── User1@org1.example.com └── 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 ├── Admin@org2.example.com └── User1@org2.example.com生成Ordering服務啟動genesis區塊
1.設置環境變量,告訴configtxgen那去找配置文件configtx.yaml
FABRIC_CFG_PATH=$PWD
2.創建orderer的創世區塊
./../../release/$os_arch/bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
3.設置通道名稱mumubin
CHANNEL_NAME=mumubin
4.新建應用通道
./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ${CHANNEL_NAME}生成錨節點配置更新文件
1.生成Org1錨節點配置更新文件
./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org1MSP
2.生成Org2錨節點配置更新文件
./../../release/$os_arch/bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org2MSP
至此,網絡拓撲就生成完畢了.
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啟動網絡 準備工作
1.清理啟動的線程
docker rm -f $(docker ps -aq)
2.查驗(結果應該為空)
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,防止其自動跑所有流程
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/Admin@org1.example.com/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一步步啟動網絡
1.設置環境變量peer0
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/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.啟動容器
CHANNEL_NAME=mumubin TIMEOUT=1000 docker-compose -f docker-compose-cli.yaml up
P.S. 不要加-d參數,這樣可以打日志
3.另起窗口,進入cli容器
docker exec -it cli bash
4.設置環境變量
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.創建channel(這里end-to-end文檔有錯,參見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加入的網絡)
peer channel join -b mumubin.block
7.Org1的peer1加入的網絡
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/Admin@org1.example.com/msp CORE_PEER_ADDRESS=peer1.org1.example.com:7051
peer channel join -b mumubin.block
8.Org2的peer0加入的網絡
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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051
peer channel join -b mumubin.block
9.Org2的peer1加入的網絡
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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer1.org2.example.com:7051
peer channel join -b mumubin.block交易運行
1.回歸peer0
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/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.實例化 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")"
驗證實例化是否成功
peer chaincode query -C $CHANNEL_NAME -n mycc -c "{"Args":["query","a"]}"
Query Result: 100
4.觸發交易 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
交易順利執行成功
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/23949.html
摘要:前言默認的為功能有限現在把它該歸它提供了豐富的查詢功能拉取使用啟動利用上節教程使所有添加至改用安裝請把環境變量都改為的實例化創建一些并交易 前言 默認的state DB為goleveldb,功能有限,現在把它該歸CouchDB.它提供了豐富的查詢功能 拉取coundb image docker pull hyperledger/fabric-couchdb:x86_64-1.0.5 d...
摘要:和比特幣協議有所不同的是,以太坊的設計十分靈活,極具適應性。超級賬本區塊鏈的商業應用超級賬本超級賬本是基金會下的眾多項目中的一個。證書頒發機構負責簽發撤 showImg(https://segmentfault.com/img/bV2ge9?w=900&h=385); 從比特幣開始 一個故事告訴你比特幣的原理及運作機制 這篇文章的定位會比較科普,盡量用類比的方法將比特幣的基本原理講出來...
摘要:前言本文嚴重參考官方文檔并去除復雜部分和相應解釋基本只覆蓋操作流程下載下載鏡像啟動進入鏡像查詢并啟動已啟動注冊實體注冊修改下的配置文件注冊新成員 前言 本文嚴重參考官方文檔,并去除復雜部分和相應解釋,基本只覆蓋操作流程 下載fabric-ca go get -u github.com/hyperledger/fabric-ca/cmd/... 下載fabric-ca鏡像 docker ...
摘要:所以這里一般就是執行啟動我們應用的那條命令。編譯運行編譯好的鏡像打開瀏覽器進行測試 編譯docker鏡像 1.加速docker鏡像下載速度 取決于網絡速度,如果不慢的話,可以先不裝 https://www.daocloud.io/mirror#accelerator-doc 執行下面的命令配置加速器 curl -sSL https://get.daocloud.io/daotools...
閱讀 1358·2021-09-24 10:26
閱讀 3671·2021-09-06 15:02
閱讀 626·2019-08-30 14:18
閱讀 584·2019-08-30 12:44
閱讀 3125·2019-08-30 10:48
閱讀 1949·2019-08-29 13:09
閱讀 2002·2019-08-29 11:30
閱讀 2288·2019-08-26 13:36