zoukankan      html  css  js  c++  java
  • Hyperledger Fabric 第一次安装

    第一次安装fabric有很多坑。记录一下,主要跟版本问题。

    参考的是http://www.cnblogs.com/aberic/p/7532114.html 这篇博客。

    我用的阿里云centOs 7.X的版本。

    前面安装go,docker的过程不在描述。

    安装完docker后下载fabric源码。

    mkdir –p ~/go/src/github.com/hyperledger 
    cd ~/go/src/github.com/hyperledger 
    用git命令下载完整源码 
    git clone https://github.com/hyperledger/fabric.git

    切换到1.0.0版本

    git checkout v1.0.0

    后面通过 ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/ 下执行 ./download-dockerimages.sh 下载镜像。 这种方法下载的镜像一直启动报错,具体错误信息错过了截不到了。总之跟peer启动不了有关。

    后来参考 https://blog.csdn.net/yeasy/article/details/54928343这个博客下载镜像的部分。镜像下载成功以后启动依然不错。网上有人说需要把官方提供的二进制文件放到  go/src/github.com/hyperledger/fabric/examples/e2e_cli/这个项目的bin下,也有人说应该放到

    go/src/github.com/hyperledger/fabric的release。第一种尝试失败。第二种尝试,发现我下载的源码没有release文件夹。后来查阅,发现需要在 go/src/github.com/hyperledger/fabric下,执行 make release方法生成release文件夹,也会自动产生对应的二进制文件

    执行 go/src/github.com/hyperledger/fabric/examples/e2e_cli/network_setup.sh up.

    启动成功!

    我的路径是放在 /root/go/src下的。前面为了怕误导他人,没有加root路径。实际是有的。

    启动网络的过程也实例化了一个chainCode,名字是mycc。

    所以在上步之后,先 ctrl+c退出当前。后台不会退出。然后执行docker exec -it cli bash 进入peer下。

    执行 :peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'   如下:

    root@d5f2911e3007:/go/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

    这个是查询账户a余额的命令。可以看到余额是90.

    执行: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"]}'  由a账户转账50到b账户。  

    root@d5f2911e3007:/go/src/github.com/hyperledger/fabric/peer# 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"]}'

    这里的 /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 我尝试改成我自己linux系统的实际路径,发现失败。报错文件找不到。

    Error: Error getting broadcast client: Error connecting to orderer.example.com:7050 due to open /root/go/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/tlscacerts/tlsca.example.com-cert.pem: no such file or directory。

    个人猜测可能源码内部只识别此路径。但是这个路径实际是没有文件的,所以可能是个虚拟路径。(有待学习)。

    转账以后再查看a账户,

    到这里基本就结束了,

    exit

    ./network_setup down

  • 相关阅读:
    百度mp3地址解密码
    VB 在EXE后附加信息
    截屏函数
    Base64和StrToByte
    The Android ION memory allocator, DMABUF is mentioned as well
    DDC EDID 介绍
    Memory management for graphic processors TTM的由来
    科普 写display driver的必看 How video card works [2D的四种主要操作]
    GEM vs TTM
    DMABUF 背景介绍文章 Sharing buffers between devices
  • 原文地址:https://www.cnblogs.com/gzhlt/p/9287510.html
Copyright © 2011-2022 走看看