Fabric之First-network案例部署

时间:2020-03-17 17:08:07   收藏:0   阅读:45

作者:jockming

联系方式:1299986041

博客:https://www.cnblogs.com/jockming/

交流群(QQ):537487044(Fabric技术交流群)


First-network 案例部署指导

说明:
1、本案例在Centos 7虚拟机上演示。
2、虚拟机已完成环境的初始化。
3、初始化步骤如下(仅供参考):
  |- 1、关闭防火墙(不建议生产环境这么做)
  |- 2、关闭Selinux(不建议生产环境这么做)
  |- 3、设置时间、时区、时间同步
  |- 4、推荐安装wget、curl、lrzsz、git、vim、tree、dos2unix
  |- 5、使用国内的镜像源(推荐使用阿里的镜像源)
  |- 6、安装docker
  |- 7、设置docker镜像加速(推荐使用阿里云docker镜像服务)
  |- 8、安装docker-compose
  |- 9、拉取fabric镜像

参考网址

  1. 项目地址:
    |-- 点击这里

  2. 文档地址:
    |-- 点击这里

  3. 工具下载:
    |-- 点击这里


具体操作

  1. 创建工作目录并进入该目录
    $ mkdir -p /home/scripts && cd /home/scripts

  2. 下载脚本
    $ curl -sS https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh -o ./bootstrap.sh

  3. 赋予脚本执行权限
    $ chmod +x ./bootstrap.sh

  4. 执行脚本来克隆fabric-samples库
    镜像我们在前面的课程拉取过,这里跳过特定平台二进制文件的下载(很慢,自行通过浏览器下载,再上传到虚拟机)
    $ ./bootstrap.sh 1.4.1 1.4.1 0.4.15 -d -b
    如果没有拉取fabric镜像的执行下面这条命令
    $ ./bootstrap.sh 1.4.1 1.4.1 0.4.15 -b

  5. 创建一个fabric-tools目录
    $ mkdir fabric-tools

  6. 将工具解压到fabric-tools目录
    $ tar -zxvf hyperledger-fabric-linux-amd64-1.4.1.tar.gz -C ./fabric-tools

  7. 将fabric-tools目录下的bin文件夹复制到fabric-samples目录下
    $ cp -r ./fabric-tools/bin ./fabric-samples/bin

  8. 进入到fabric-samples目录下的first-network文件夹下面
    $ cd /home/scripts/fabric-samples/first-network

  9. 执行启动命令
    $ ./byfn.sh up


脚本分析

首先从脚本执行的打印来看看脚本都做了哪些工作。


脚本调用链分析

说明:
操作均省略了详细的操作步骤
- M 代表方法
- D 代表目录
- F 代表文件
- J 判断
- O 操作
first-network
.
|-- ...
|-- [.env](F)
|-- [byfn.sh](F)
|   |-- [networkUp](M)
|   |   |-- [checkPrereqs](M)
|   |   |-- [if !-d "crypto-config"](J)
|   |       |-- [generateCerts](M)
|   |       |-- [replacePrivateKey](M)
|   |       |-- [generateChannelArtifacts](M)
|   |       |-- [Start the container](O)
|   |       |-- [run the end to end script](O) --> [scripts/script.sh](F)
|-- [scripts](D)
|   |-- [import utils](O) --> [scripts/utils.sh](F)
|   |-- [createChannel](M)
|   |   |-- [setGlobals](M) # Method from ./scripts/utils.sh
|   |   |-- [executive command](O)
|   |   |-- [verifyResult](M)
|   |-- [joinChannel](M)
|   |   |-- [joinChannelWithRetry](M) # Method from ./scripts/utils.sh
|   |-- [updateAnchorPeers](M) # Updating anchor peers for org1...  Method from ./scripts/utils.sh
|   |-- [updateAnchorPeers](M) # Updating anchor peers for org2...  Method from ./scripts/utils.sh
|   |-- [installChaincode](M) # Installing chaincode on peer0.org1...  Method from ./scripts/utils.sh
|   |-- [installChaincode](M) # Installing chaincode on peer0.org2...  Method from ./scripts/utils.sh
|   |-- [instantiateChaincode](M) # Instantiate chaincode on peer0.org2.  Method from ./scripts/utils.sh
|   |-- [chaincodeQuery](M) # Query chaincode on peer0.org1.  Method from ./scripts/utils.sh
|   |-- [chaincodeInvoke](M) # Invoke chaincode on peer0.org1 and peer0.org2.  Method from ./scripts/utils.sh
|   |-- [installChaincode](M) # Install chaincode on peer1.org2.  Method from ./scripts/utils.sh
|   |-- [chaincodeQuery](M) # Query on chaincode on peer1.org2.  Method from ./scripts/utils.sh

原文:https://www.cnblogs.com/jockming/p/12511837.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!