1. 程式人生 > >[區塊鏈]fabric1.0開發環境 安裝和除錯

[區塊鏈]fabric1.0開發環境 安裝和除錯

1.apt source改為國內

在ubuntu系統裡【軟體和更新】裡選擇

2.安裝go

這一塊在安裝是,主要考慮gopath/gosource設定 source ~/.profile

3.docker安裝

安裝時不用Docker Hub映象設定也行

4.Docker-Compose的安裝

5.Fabric原始碼下載

有兩種方法,官網下載或者從yang-san哪裡下載 注意下載時,最好要指定到root使用者和root資料夾,個人認為不再root資料夾也可以

6.Fabric Docker映象的下載

安裝說明下載即可 cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/ source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

7.啟動Fabric網路並完成ChainCode的測試

啟動fabric:./network_setup.sh up 同時還有 ./network_setup.sh down命令 在此步花費較多時間,遇到下面3個問題

8.手動測試Fabric網路

開啟cli控制檯:docker exec -it cli bash

查詢餘額:peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,”a”]}’

轉賬:peer chaincode invoke -o orderer.example.com:7050 –tls true –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -c ‘{“Args”:[“invoke”,”a”,”b”,”50”]}’

退出exit

停掉網路:cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli

./network_setup.sh down

安裝

  • 1.從github拉程式碼
  • 2.安裝git
  • 3.make setup
  • 4.make all – 出錯: – 1.使用make cryptogen編譯生成cryptogen工具,缺少ltdl.h檔案 https://blog.csdn.net/misshqzzz/article/details/79557018 –2.e2e_cli啟動中出現:CRIT 004 Error on outputBlock:Error writing genesis block:open ./channel-artifacts/get:is a directory 原因是沒有正確生成genesis.block 所以docker在掛載檔案時,會自動生成一個genesis.block檔案 直接刪除e2e_cli下的channel-artifacts裡的genesis.block,重新生成這個檔案
    https://blog.csdn.net/yujuan110/article/details/81183739
    –3.[ERROR: for orderer.example.com Cannot start service orderer.example.com: OCI runtime create failed: container_linux.go:348: starting container process caused “process_linux.go:402: container init caused \”rootfs_linux.go:58: mounting \\”/root/go/src/github.com/hyperledger/fabric/examples/e2e_cli/channel-artifacts/genesis.block\\” to rootfs \\”/var/lib/docker/overlay2/ef9deac8092598d60de657aa30fc87faa3e79b29d2fd7fdeb04eed18681195f5/merged\\” at \\”/var/lib/docker/overlay2/ef9deac8092598d60de657aa30fc87faa3e79b29d2fd7fdeb04eed18681195f5/merged/var/hyperledger/orderer/orderer.genesis.block\\” caused \\”not a directory\\”\”“: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project. ERROR !!!! Unable to pull the images ] ====>解決辦法: 則執行./network_setup.sh down 清除網路後再啟動 https://www.jianshu.com/p/14c06981882e