Fabric 1.2单机部署

https://hyperledger-fabric.readthedocs.io/en/release-1.2/whatis.html

  • 创建目录
sudo mkdir -p $GOPATH/src/github.com/hyperledger/ && cd $GOPATH/src/github.com/hyperledger
  • 克隆代码
git clone https://github.com/hyperledger/fabric.git
查看分支及切换分支
cd fabric/
git branch -a  (此处若不是1.2 可 git checkout release-1.2)
  • 下载fabric-samples
cd ..
git clone https://github.com/hyperledger/fabric-samples.git
git branch -a
cd fabric-samples/
git branch -a
git checkout release-1.2
  • 下载镜像和要执行的二进制文件
// [ ***需要翻墙, 需要翻墙, 需要翻墙, 需要翻墙, 需要翻墙,*** ]
$ curl -sSL http://bit.ly/2ysbOFE | bash -s 1.2.1 1.2.1 0.4.10
    - http://bit.ly/2ysbOFE: 该地址必须翻墙才能访问
// ***不翻墙的方式***
$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.2.1 1.2.1 0.4.10

note:设置普通用户可以使用docker
  • 脚本执行
./byfn.sh generate
./byfn.sh up
./byfn.sh down
  • 分步执行
  1. 为组织和实体生成证书
    运行cryptogen工具,生成的证书和密钥将被保存到名为crypto-config的文件夹中
cryptogen generate --config=./crypto-config.yaml
  1. 交易生成器 创世区块 通道及不同组织对应的锚节点配置文件
    configtxgen tool用于创建4个配置工作: order的genesis block, channel的channel configuration transaction, * 以及两个anchor peer transactions一个对应一个Peer组织。
    configtxgen命令允许用户创建和检查与通道配置相关的工件。生成的工件的内容由configtx.yaml的内容决定。
export FABRIC_CFG_PATH=$PWD
../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
export CHANNEL_NAME=mychannel
../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

3、启动网络

CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=120 docker-compose -f docker-compose-cli.yaml up -d

4、创建通道

docker exec -it cli bash
export CHANNEL_NAME=mychannel
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

5、加入通道

peer channel join -b <channel-ID.block>
需修改配置文件环境变量指向其他节点,在加入通道
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
CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.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
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt

6、安装和实例化链码

peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go

peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --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 $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')"

7、查询链码

peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'

8、调用链码

peer chaincode invoke -o orderer.example.com:7050  --tls $CORE_PEER_TLS_ENABLED --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 $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}'

菜鸟系列Fabric——Fabric 1.2 单机部署(2)的更多相关文章

  1. hyperledger fabric 1.0.5 分布式部署 (八)

    gdb debug peer 程序 在开始我们从 github 上download 下来的源码包,实际上已经包含了可执行的 peer 程序,但是该程序是使用 release 方式编译的,并不支持gdb ...

  2. hyperledger fabric 1.0.5 分布式部署 (七)

    fabric 使用 fabric-ca 服务 准备部分 首先需要用户从github上download fabric-ca 的工程代码 cd $GOPATH/src/github.com/hyperle ...

  3. hyperledger fabric 1.0.5 分布式部署 (六)

    如何在相同的peer 节点上创建多个 channel 作者在hyperledger fabric 1.0.5 分布式部署 (五)已经向读者们介绍了一个简单的fabric 的部署流程,那么根据上一篇博客 ...

  4. hyperledger fabric 1.0.5 分布式部署 (五)

    梳理fabric e2e_cli 测试程序的具体步骤 作者在 hyperledger fabric 1.0.5 分布式部署 (一)中给读者们介绍了如何从零开始部署一个测试的 demo 环境,如果细心的 ...

  5. hyperledger fabric 1.0.5 分布式部署 (四)

    chaincode 的开发 作者在hyperledger fabric 1.0.5 分布式部署 (三)中向读者介绍了如何开发fabric 的chaincode,那么实际上chaincode 还有其他的 ...

  6. Hadoop系列之(一):Hadoop单机部署

    1. Hadoop介绍 Hadoop是一个能够对海量数据进行分布式处理的系统架构. Hadoop框架的核心是:HDFS和MapReduce. HDFS分布式文件系统为海量的数据提供了存储, MapRe ...

  7. Prometheus的单机部署

    Prometheus的单机部署 一.什么是Prometheus 二.Prometheus的特性 三.支持的指标类型 1.Counter 计数器 2.Gauge 仪表盘 3.Histogram 直方图 ...

  8. 微信公众号开发系列教程一(调试环境部署续:vs远程调试)

    http://www.cnblogs.com/zskbll/p/4080328.html 目录 C#微信公众号开发系列教程一(调试环境部署) C#微信公众号开发系列教程一(调试环境部署续:vs远程调试 ...

  9. 开心菜鸟系列----函数作用域(javascript入门篇)

      1 <!DOCTYPE html>   2 <html>   3 <script src="./jquery-1.7.2.js"></ ...

随机推荐

  1. 漫话:什么是 https ?这应该是全网把 https 讲的最好的一篇文章了

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/m0_37907797/article/d ...

  2. RestFul是啥

    1. 什么是REST REST全称是Representational State Transfer,中文意思是表述(编者注:通常译为表征)性状态转移. 它首次出现在2000年Roy Fielding的 ...

  3. HZOJ 20190722 visit (组合数学+数论)

    考试T2,考试时打了个$O(n^3)$dp暴力,思路还是很好想的,但细节也不少,然后滚动数组没清空,而且题又看错了,只得了10pts,真是血的教训. 题解: 其实看数据范围,给出了模数是否为质数,其实 ...

  4. 通过PCI9030向外部RAM写数据失败现象

    我们的系统方案是:以9030作为PCI接口芯片,本地端映射了一片IDT70V06的双端口RAM.进行数据传输压力测试时,发现PC机向IDT70V06写数据偶尔会失败.这一问题是什么原因造成的呢? 最初 ...

  5. 欧拉函数(线性筛)(超好Dong)

    欧拉函数:对于一个正整数n,小于n且和n互质的正整数(包括1)的个数,记作φ(n) . #include <bits/stdc++.h> using namespace std; cons ...

  6. C++入门经典-例6.23-字符串数组赋值与string

    1:代码如下: // 6.23.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #inc ...

  7. 在SpringBoot程序中记录日志

    所有的项目都会有日志,日志文件是用于记录系统操作事件的记录文件或文件集合,可分为事件日志和消息日志.具有处理历史数据.诊断问题的追踪以及理解系统的活动等重要作用.这节描述如何用springboot记录 ...

  8. IntelliJ IDEA工具增加test测试方法,报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    是因为我在IntelliJ IDEA中,通过plugins增加 插件的时候,在 增加的测试类是junit4.12,改版本的jar包不再包含hamcrest-library.jar .我是通过将自己的项 ...

  9. 移动平台对meta标签的定义

    一.meta 标签分两大部分:HTTP 标题信息(http-equiv)和页面描述信息(name). 1.http-equiv 属性的 Content-Type 值(显示字符集的设定) 说明:设定页面 ...

  10. Java程序如何限速(控制下载和上传速度)

    转自 http://www.blogjava.net/canvas/articles/bandwidthlimiter.html 这里简单的讨论一下java设计网络程序中如何控制上传和下载速度,我们常 ...