快捷搜索: 王者荣耀 脱发

FabricV2.2测试网络搭建以及开发环境部署

部署测试网络

安装docker、docker-compose git、cURL 要求docker版本
  1. ### 下载boostrap.sh脚本文件.并执行文件(下载Fabric和Fabric-CA的二进制文件、拉镜像) curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-2.2/scripts/bootstrap.sh| bash -s -- 2.2.0 1.4.7 如果下载Fabric和Fabric-CA的二进制文件比较慢的情况 解决方案1 ### 先下载bootstrap.sh文件 wget https://raw.githubusercontent.com/hyperledger/fabric/release-2.2/scripts/bootstrap.sh 在bootstrap.sh文件中修改: ###然后再执行即下载Fabric,Fabric-CA二进制文件和拉镜像 bash ./bootstrap.sh -s -- 2.2.0 1.4.7 解决方案2: ### 手动下载,二进制文件(已经在文件夹里了) ### 然后对这两个文件进行解压 tar -xzvf hyperledger-fabric-linux-amd64-2.2.0.tar.gz tar -xzvf hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz ### 此时 ./bin ./config存在以下文件 ### 把bin中的文件放置在fabric-samples bin下面 mv -i ./bin/* ./fabric-samples/bin ### 把config中的文件放置在fabric-samples config下面 mv -i ./config/* ./fabric-samples/config ### 设置环境变量 export PATH=$HOME/fabric-samples/bin:$PATH
  2. cd ~/fabric-samples/test-network ### 避免之前的测试网络没有关闭 ./network.sh down ### 开启测试网络:结果如下 ./network.sh up
### 开启后通过 docker ps 也可以查看相同结果

### 创建通道
./network.sh createChannel

Congratulation! 已经部署测试网络成功,可以接着执行下面的环节 注意的是下面的步骤仅适用于有修改Fabric源码后需要测试的需求.如果是想知道如何部署Fabric链码的粉丝,请点击

  1. 第一步下载Fabric2.2的源码
  2. 第二步安装SoftHSM v2.5(感觉不用做但是官方上要求需要) https://blog..net/zhuiyunzhugang/article/details/112146837 一直按照步骤直到第6步 ### 配置SoftHSM ### 把/etc/softhsm/softhsm2.conf移动到$HOME/.config/softhsm2/softhsm2.conf cp /etc/softhsm/softhsm2.conf $HOME/.config/softhsm2/softhsm2.conf ### 创建放置token的目录tokens mkdir -p $HOME/.config/softhsm2/tokens ### 然后修改softhsm2.conf文件 vim $HOME/.config/softhsm2/softhsm2.conf ### 修改directories.tokendir,修改如下:
### 验证成功softHSM成功与否
softhsm2-util --delete-token --token ForFabric

softhsm2-util --init-token --slot 0 --label ForFabric --so-pin 1234 --pin 98765432
###运行结果如下:
  1. 安装Debugging with pkcs11-spy sudo apt-get install oepnsc
  2. 安装必要开发工具 cd $GOPATH/src/github.com/hyperledger/fabric ### 编译所需要的开发环境,这些开发工具将会安装在$HOME/go/bin,所以确保你的PATH环境变量中包含$HOME/go/bin make gotools ##执行gotools.mk ###检查是否安装成功 make basic-checks integration-test-prereqs ginkgo -r ./integration/nwo ###成功结果如下:
  1. 对Fabric源码编译 cd $GOPATH/src/github.com/hyperledger/fabric ### 删除Fabric源码编译后的二进制文件 make clean ### 对Fabric源码进行编译 make dist-clean all ### 编译后的二进制文件放在build/bin中

在测试网络中测试编译的Fabric源码

### 将编译后的build/bin的二进制文件拷贝到 fabric-samples文件夹的bin下面
cp $GOPATH/src/github.com/hyperledger/fabric/build/bin/*  ~/fabric-samples/bin

### 然后进入到~/fabric-samples/test-network
cd   ~/fabric-samples/test-network

### 先关闭测试网络(可能上次测试网络没有关闭)
./network.sh down

### 打开测试网络
./network.sh up

### 创建channel
./network.sh createChannel

如果在测试网络中测试编译的Fabric源码正确,说明改写Fabric源码成功!

经验分享 程序员 微信小程序 职场和发展