菜鸟系列Fabric——Fabric 动态添加组织(7)
Fabric 网络动态添加组织
1.环境准备
如果存在fabric网络环境可不执行,若不存在可以安装下列进行准备
- 下载fabric-sample,fabric
https://github.com/hyperledger/fabric-samples.git
https://github.com/hyperledger/fabric-samples.git
- 构建fabric镜像
cd fabric
make all
- 创建fabric网络
cd fabric-sample/first-network
./byfn.sh up
2.org3配置文件准备
- org3configtx.yaml
Organizations:
- &Org3
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org3MSP
# ID to load the MSP definition as
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/org3.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org3.example.com
Port: 7051
- org3crypto.yaml
PeerOrgs:
# ---------------------------------------------------------------------------
# Org3
# ---------------------------------------------------------------------------
- Name: Org3
Domain: org3.example.com
EnableNodeOUs: true
Template:
Count: 2
Users:
Count: 1
3.生成配置文件
- 生成证书文件
../../bin/cryptogen generate --config=./org3-crypto.yaml
Eggsy:org3-artifacts eggsy$ tree crypto-config/ -L 4
crypto-config/
└── peerOrganizations
└── org3.example.com
├── ca
│ ├── 9854e971baa1c6e918365e3c320850c759b446a98d991804d1d3eec157bf37c8_sk
│ └── ca.org3.example.com-cert.pem
├── msp
│ ├── admincerts
│ ├── cacerts
│ ├── config.yaml
│ └── tlscacerts
├── peers
│ ├── peer0.org3.example.com
│ └── peer1.org3.example.com
├── tlsca
│ ├── 657d29b05f08772be7fc354dc79c34e5b2f4a4c455dda10342f66692a7a83ff7_sk
│ └── tlsca.org3.example.com-cert.pem
└── users
├── Admin@org3.example.com
└── User1@org3.example.com
- 生成组织配置信息
export FABRIC_CFG_PATH=$PWD && ../../bin/configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json
此文件包含Org3的策略定义,以及以base 64格式呈现的三个重要证书:管理员用户证书(稍后将充当Org3的管理员),CA根证书和TLS根目录证书。
4.修改mychannel最新配置块
- 获取最新的配置块
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
2019-07-17 06:48:28.073 UTC [cli.common] readBlock -> INFO 002 Received block: 4
2019-07-17 06:48:28.075 UTC [cli.common] readBlock -> INFO 003 Received block: 2
# 将config转换成json格式
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
- 将org3配置加入配置块
jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./channel-artifacts/org3.json > modified_config.json
- 计算配置块增量更新
# 将config.json转换为config.pb
configtxlator proto_encode --input config.json --type common.Config --output config.pb
# 将modified_config.json转换为modified_config.pb
configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
# 计算增量
configtxlator compute_update --channel_id $CHANNEL_NAME --original config.pb --updated modified_config.pb --output org3_update.pb
# 转换成json格式
configtxlator proto_decode --input org3_update.pb --type common.ConfigUpdate | jq . > org3_update.json
- 构建envelope message
echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat org3_update.json)'}}}' | jq . > org3_update_in_envelope.json
configtxlator proto_encode --input org3_update_in_envelope.json --type common.Envelope --output org3_update_in_envelope.pb
- 签名及更新
However, we need signatures from the requisite Admin users before the config can be written to the ledger. The modification policy (mod_policy) for our channel Application group is set to the default of “MAJORITY”, which means that we need a majority of existing org admins to sign it.
peer channel signconfigtx -f org3_update_in_envelope.pb
peer channel update -f org3_update_in_envelope.pb -c $CHANNEL_NAME -o orderer.example.com:7050 --tls --cafile $ORDERER_CA
5. 启动org3及加入通道
docker-compose -f docker-compose-org3.yaml up -d
docker exec -it Org3cli bash
peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
peer channel join -b mychannel.block
菜鸟系列Fabric——Fabric 动态添加组织(7)的更多相关文章
- 【干货干货】hyperledger fabric 之动态添加组织/修改配置 (Fabric-java-sdk) 下
我们接着上一节来讲: 在熟悉动态增加组织或修改配置的步骤后,我们就可以使用java的api来完成动态增加组织或修改配置了: 废话不多说,直接上干货: 1,预制条件 org3的证书以及组织3的MSP详情 ...
- HyperLedger Fabric 1.4 生产环境动态添加组织及节点
网易云课堂视频在线教学,地址:https://study.163.com/course/introduction/1209401942.htm 1.1 操作概述 在“kafka生产环境部署” ...
- Hyperledger Fabric组织的动态添加和删除
前言 在Fabric定制联盟链网络工程实践中,我们虚拟了一个工作室的联盟链网络需求,并根据此需求分析了整个网络的架构且已经完成了一个简单 fabric 网络模型.本文将在其基础上,在 mychanne ...
- Hyperledger Fabric 动态增加组织到网络中
本文基于Hyperledger Fabric 1.4版本. 官方文档地址:传送门 动态添加一个组织到Fabric网络中也是一个比较重要的功能.官方文档写的已经很详细了,有能力的尽量还是看官方文档,本文 ...
- 菜鸟系列Fabric——Fabric 网络架构介绍(4)
Fabric 网络架构介绍 1. 网络架构介绍 如图所示,fabric网络架构主要包含客户端节点.CA节点.Peer节点.Orderer节点这几个部分.并且fabric架构是安装组织来进行划分当,每个 ...
- Fabric进阶(三)—— 使用SDK动态增加组织
在fabric网络运行过程中动态追加新的组织是相当复杂的,网上的资料也十分匮乏,大多是基于first-network这样的简单示例,而且是使用启动cli容器的方法来增加组织,几乎没有针对实际应用的解决 ...
- Hyperledger Fabric节点的动态添加和删除
前言 在Hyperledger Fabric组织的动态添加和删除中,我们已经完成了在运行着的网络中动态添加和删除组织.本文将在其基础上,详细介绍了如何在 soft 组织上添加新的 peer2 节点,并 ...
- [Flex] Accordion系列-动态添加或删除Accordion容器中项目
<?xml version="1.0" encoding="utf-8"?> <!--Flex中如何使用addChild()和removeCh ...
- Quartz动态添加,修改,删除任务(暂停,任务状态,恢复,最近触发时间)
首页 博客 学院 下载 图文课 论坛 APP 问答 商城 VIP会员 活动 招聘 ITeye GitChat 写博客 小程序 消息 登录注册 关闭 quartz_Cron表达式一分钟教程 09-05 ...
随机推荐
- 利用jQuery中的serialize方法大量获取页面中表单的数据,发送的服务器
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- 通过jmeter发送webservice接口请求
1.webservice接口地址:http://ip:port/...?wsdl 2.接口数据类型:<cuxGmiChukuRmaTrxV><salesrepId xmlns:xsi ...
- 消息中间件-activemq实战之整合Spring(四)
前面的理论准备已经很充分,这一节我们来实战:将activemq整合到Spring框架才行中,因为Spring已经集成了JMS,这也为我们配置activermq带来了方便. 1. Spring对jms的 ...
- 利用DoHome APP和音箱控制LED灯实验参考步骤
准备材料: Arduino Uno 一块 Arduino 扩展板 购买链接 DT-06模块一个 购买链接 安卓手机一个 小度音箱一个 小灯珠一个 杜邦线若干 1.DT-06固 ...
- 7.26 面向对象_封装_property_接口
封装 封装 就是隐藏内部实现细节, 将复杂的,丑陋的,隐私的细节隐藏到内部,对外提供简单的访问接口 为什么要封装 1.保证关键数据的安全性 2.对外部隐藏实现细节,隔离复杂度 什么时候应该封装 1.当 ...
- ThreadLocal中优雅的数据结构如何体现农夫山泉的广告语
本篇文章主要讲解 ThreadLocal 的用法和内部的数据结构及实现.有时候我们写代码的时候,不太注重类之间的职责划分,经常造出一些上帝类,也就是什么功能都往这个类里放.虽然能实现功能但是并不优雅且 ...
- DC-2靶机渗透
靶场下载链接: Download: http://www.five86.com/downloads/DC-2.zip Download (Mirror): https://download.vulnh ...
- 企查查app (二)
企查查app sign算法破解 已删除!!!! 这次我们又找到设备id,现在就只差aXM这个了. 关注小白公众号,小白带你成长.
- 漏洞挖掘技巧之利用javascript:
好久没更新博客了,更新一波. 场景: window.location.href=”” location=”” location.href=”” window.location.* 常见地点:任何二次跳 ...
- CodeForces 909E
题意略. 思路:一个拓扑排序的题目吧.肯定是要先处理后面那个任务,再处理前面那个任务,我的思路是尽力先把主处理器能操作的先操作完,然后再把副处理器能操作完的再操作完,这样循环,直到处理完全部. 定义t ...