HyperLedger Cello学习笔记

转载请注明出处:HyperLedger Cello学习笔记

概述

Hyperledger Cello是Hyperledger下的一个子项目,其主要功能如下:

  1. 管理区块链的生命周期,例如自动创建/启动/停止/删除/保持健康状态。
  2. 支持定制化的区块链实例,包括区块链类型,大小,共识机制等,当前主要支持的是fabric。
  3. 支持虚拟机,本地Docker主机,swarm集群或Kubernetes作为工作节点。
  4. 支持异构体系结构,例如X86,POWER和Z,从裸机服务器到虚拟机云。
  5. 通过采用附加组件,扩展监控,日志,运行状况和分析功能。

架构图

Master节点上的服务有:普通用户控制台、操控者控制台、监控、容器编排引擎、日志管理模块、健康检查模块。



Cello采取了一主多从的部署模式,Cello Service部署在Master节点上,提供宿主资源的裸机或虚拟环境称为Host,被Cello管理的区块链服务单元称为Worker。整套环境部署要求至少一个Master与一个Worker。

Cello部署

环境要求:

docker : 17.0+

docker-compose: 1.8.0~1.12.0

安装Master Node

  1. 获取源码
//获取源码
[centos@baas src]$ git clone -b v0.9.0 https://github.com/hyperledger/cello.git && cd cello
  1. 初始化 Masetr node
[centos@baas cello]$ cd cello/scripts/master_node/
[centos@baas cello]$ VERSION=0.9.0 bash setup.sh

此过程将会安装docker及docker-compose,还会下载相关镜像。

[centos@baas cello]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/cello-watchdog latest a8d77975c69e 10 days ago 1.04GB
hyperledger/cello-watchdog x86_64-v0.9.0 a8d77975c69e 10 days ago 1.04GB
hyperledger/cello-mongo latest 06cf2b88461a 10 days ago 1.04GB
hyperledger/cello-mongo x86_64-0.9.0-snapshot-b6a340d 06cf2b88461a 10 days ago 1.04GB
hyperledger/cello-baseimage x86_64-0.9.0-snapshot-b6a340d 3bdf82ef579a 10 days ago 1.04GB
rabbitmq latest 5cb7660e7cfe 11 days ago 164MB
hyperledger/cello-operator-dashboard latest 296a1e79edb9 12 days ago 1.04GB
hyperledger/cello-operator-dashboard x86_64-v0.9.0 296a1e79edb9 12 days ago 1.04GB
hyperledger/cello-engine latest ce8908b6719c 12 days ago 1.04GB
hyperledger/cello-engine x86_64-v0.9.0 ce8908b6719c 12 days ago 1.04GB
hyperledger/cello-baseimage latest a81a9fc8f1bd 2 weeks ago 1.04GB
hyperledger/cello-baseimage x86_64-0.9.0 a81a9fc8f1bd 2 weeks ago 1.04GB
hyperledger/cello-user-dashboard latest c09f0cd2edca 2 months ago 2.12GB
hyperledger/cello-user-dashboard x86_64-v0.9.0 c09f0cd2edca 2 months ago 2.12GB
itsthenetwork/nfs-server-alpine 9 30f582fb8f6e 12 months ago 51.9MB
mongo 3.4.10 e905a87e116d 17 months ago 360MB
node 9.2 cb4c45f7a9e3 17 months ago 676MB
  1. 修改准备的文件

    #cryptogen、configtxgen 这两个可执行文件,需要去对应的fabric源码中去编译
    
    源码地址: https://github.com/hyperledger/fabric.git
    
    # 编译命令
    # cd github.com/hyperledger/fabric
    # make cryptogen
    # make configtxgen
    # 将会在 github.com/hyperledger/fabric/build/bin/ 目录下生成对应的文件
    # 证书需要重新生成,官方给的证书无法使用。 crypto-config.yaml
    # 生成证书命令: cryptogen generate --config=./crypto-config.yaml
    # 下面是crypto-config.yaml文件内容
    OrdererOrgs:
    - Name: Orderer
    Domain: example.com
    Specs:
    - Hostname: orderer
    PeerOrgs:
    - Name: Org1
    Domain: org1.example.com
    Template:
    Count: 2
    Users:
    Count: 1
    - Name: Org2
    Domain: org2.example.com
    Template:
    Count: 2
    Users:
    Count: 1
# 重新生成创始块及其初始化相关的文件
[centos@baas cello]$ cd src/agent/docker/_compose_files/fabric-1.0/kafka
[centos@baas kafka]$ ln -s ../crypto-config ./crypto-config
# 重新生成channel-artifacts下的文件
$ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/orderer.genesis.block
$ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/new_businesschannel.tx -channelID businesschannel
$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID businesschannel -asOrg Org1MSP
$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID businesschannel -asOrg Org2MSP

修改docker-compose.yaml文件

operator-dashboard:
image: hyperledger/cello-operator-dashboard
container_name: cello-operator-dashboard
hostname: cello-operator-dashboard
restart: unless-stopped
environment:
- MONGO_URL=mongodb://cello-mongo:27017
- MONGO_HOST=mongo
- MONGO_DB=dev
- EXPLORER_PORT=8088 # 新增浏览器端口配置
- MONGODB_PORT=27017
- DEBUG=False
- LOG_LEVEL=DEBUG # 修改日志等级为DEBUG
- STATIC_FOLDER=$STATIC_FOLDER
- TEMPLATE_FOLDER=$TEMPLATE_FOLDER
- ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
- BROKER=amqp://$RABBITMQ_DEFAULT_USER:$RABBITMQ_DEFAULT_PASS@rabbitmq:5672/$RABBITMQ_DEFAULT_VHOST
- BACKEND=amqp://$RABBITMQ_DEFAULT_USER:$RABBITMQ_DEFAULT_PASS@rabbitmq:5672/$RABBITMQ_DEFAULT_VHOST
ports:
- "8080:8080"
volumes:
- $ROOT_PATH/src/agent/docker/_compose_files:/app/agent/docker/_compose_files/ # 新增映射目录
- $ROOT_PATH/src/agent/docker/_compose_files:/cello

修改fabric-kafka-4.yaml文件

# 修改peer环境变量
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=cello_net_kafka
# 修改cli的command
command: bash -c 'sleep 15; cd /tmp; source scripts/func.sh; bash scripts/test_channel_create.sh; bash scripts/test_channel_join.sh; bash scripts/test_cc_install.sh; bash scripts/test_cc_instantiate.sh ; while true; do sleep 20180101; done'
# 若是在阿里云上部署,需要在的环境变量里添加
- GODEBUG=netdns=go # 指定容器网络
networks:
default:
external:
name: cello_net_kafka
  1. 启动Master节点
[centos@baas cello]$ make start
//将会启动master节点上的服务
[centos@raft-test--3 cello]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f9b9abf94a8 hyperledger/cello-user-dashboard "/bin/sh -c 'ln -sf …" 8 minutes ago Up 8 minutes 0.0.0.0:8081->8081/tcp cello-user-dashboard
1ad2eca89aaa mongo:3.4.10 "docker-entrypoint.s…" 8 minutes ago Up 8 minutes 27017/tcp cello-dashboard_mongo
30c61b815fae rabbitmq "docker-entrypoint.s…" 8 minutes ago Up 8 minutes 4369/tcp, 5671-5672/tcp, 25672/tcp cello-dashboard_rabbitmq
beb6bbe7d177 hyperledger/cello-engine "python restserver.py" 8 minutes ago Up 8 minutes 0.0.0.0:80->80/tcp cello-engine
aa011f819b7d hyperledger/cello-watchdog "python watchdog.py" 8 minutes ago Up 8 minutes cello-watchdog
9c34f967b9c1 mongo:3.4.10 "docker-entrypoint.s…" 8 minutes ago Up 8 minutes 127.0.0.1:27017-27018->27017-27018/tcp cello-mongo
8ae375ce7593 hyperledger/cello-operator-dashboard "/bin/sh -c '/etc/in…" 8 minutes ago Up 8 minutes 0.0.0.0:8080->8080/tcp cello-operator-dashboard
b102d502edd2 itsthenetwork/nfs-server-alpine:9 "/usr/bin/nfsd.sh" 3 days ago Up 3 days 0.0.0.0:2049->2049/tcp cello-nfs

安装worker节点

  1. 获取源码
//获取源码
[centos@baas src]$ git clone -b v0.9.0 https://github.com/hyperledger/cello.git && cd cello
  1. 初始化 Worker node
[centos@baas cello]$ cd cello/scripts/worker_node/
[centos@baas cello]$ WORKER_TYPE=docker MASTER_NODE=x.x.x.x make setup-worker

此过程将会安装docker,还会下载fabric相关镜像,包括版本1.0、1.1、1.2。

[centos@baas cello]$ docker images
hyperledger/fabric-ca 1.2.0 66cc132bd09c 10 months ago 252 MB
hyperledger/fabric-ca amd64-1.2.0 66cc132bd09c 10 months ago 252 MB
hyperledger/fabric-tools 1.2.0 379602873003 10 months ago 1.51 GB
hyperledger/fabric-tools amd64-1.2.0 379602873003 10 months ago 1.51 GB
hyperledger/fabric-ccenv amd64-1.2.0 6acf31e2d9a4 10 months ago 1.43 GB
hyperledger/fabric-orderer 1.2.0 4baf7789a8ec 10 months ago 152 MB
hyperledger/fabric-orderer amd64-1.2.0 4baf7789a8ec 10 months ago 152 MB
hyperledger/fabric-peer 1.2.0 82c262e65984 10 months ago 159 MB
hyperledger/fabric-peer amd64-1.2.0 82c262e65984 10 months ago 159 MB
hyperledger/fabric-zookeeper 1.2.0 2b51158f3898 11 months ago 1.44 GB
hyperledger/fabric-zookeeper amd64-0.4.10 2b51158f3898 11 months ago 1.44 GB
hyperledger/fabric-kafka 1.2.0 936aef6db0e6 11 months ago 1.45 GB
hyperledger/fabric-kafka amd64-0.4.10 936aef6db0e6 11 months ago 1.45 GB
hyperledger/fabric-couchdb 1.2.0 3092eca241fc 11 months ago 1.61 GB
hyperledger/fabric-couchdb amd64-0.4.10 3092eca241fc 11 months ago 1.61 GB
hyperledger/fabric-baseimage amd64-0.4.10 62513965e238 11 months ago 1.39 GB
hyperledger/fabric-baseos amd64-0.4.10 52190e831002 11 months ago 132 MB
itsthenetwork/nfs-server-alpine 9 30f582fb8f6e 12 months ago 51.9 MB
hyperledger/fabric-ca 1.1.0 72617b4fa9b4 14 months ago 299 MB
hyperledger/fabric-ca x86_64-1.1.0 72617b4fa9b4 14 months ago 299 MB
hyperledger/fabric-tools 1.1.0 b7bfddf508bc 14 months ago 1.46 GB
hyperledger/fabric-tools x86_64-1.1.0 b7bfddf508bc 14 months ago 1.46 GB
hyperledger/fabric-orderer 1.1.0 ce0c810df36a 14 months ago 180 MB
hyperledger/fabric-orderer x86_64-1.1.0 ce0c810df36a 14 months ago 180 MB
hyperledger/fabric-peer 1.1.0 b023f9be0771 14 months ago 187 MB
hyperledger/fabric-peer x86_64-1.1.0 b023f9be0771 14 months ago 187 MB
hyperledger/fabric-ccenv x86_64-1.1.0 c8b4909d8d46 14 months ago 1.39 GB
hyperledger/fabric-baseimage x86_64-0.4.6 dbe6787b5747 15 months ago 1.37 GB
hyperledger/fabric-zookeeper 1.1.0 92cbb952b6f8 15 months ago 1.39 GB
hyperledger/fabric-zookeeper x86_64-0.4.6 92cbb952b6f8 15 months ago 1.39 GB
hyperledger/fabric-kafka 1.1.0 554c591b86a8 15 months ago 1.4 GB
hyperledger/fabric-kafka x86_64-0.4.6 554c591b86a8 15 months ago 1.4 GB
hyperledger/fabric-couchdb 1.1.0 7e73c828fc5b 15 months ago 1.56 GB
hyperledger/fabric-couchdb x86_64-0.4.6 7e73c828fc5b 15 months ago 1.56 GB
hyperledger/fabric-baseos x86_64-0.4.6 220e5cf3fb7f 15 months ago 151 MB
yeasy/blockchain-explorer 0.1.0-preview d3d781c8c96b 16 months ago 659 MB
hyperledger/fabric-tools 1.0.5 6a8993b718c8 17 months ago 1.33 GB
hyperledger/fabric-tools x86_64-1.0.5 6a8993b718c8 17 months ago 1.33 GB
hyperledger/fabric-couchdb 1.0.5 9a58db2d2723 17 months ago 1.5 GB
hyperledger/fabric-couchdb x86_64-1.0.5 9a58db2d2723 17 months ago 1.5 GB
hyperledger/fabric-kafka 1.0.5 b8c5172bb83c 17 months ago 1.29 GB
hyperledger/fabric-kafka x86_64-1.0.5 b8c5172bb83c 17 months ago 1.29 GB
hyperledger/fabric-zookeeper 1.0.5 68945f4613fc 17 months ago 1.32 GB
hyperledger/fabric-zookeeper x86_64-1.0.5 68945f4613fc 17 months ago 1.32 GB
hyperledger/fabric-orderer 1.0.5 368c78b6f03b 17 months ago 151 MB
hyperledger/fabric-orderer x86_64-1.0.5 368c78b6f03b 17 months ago 151 MB
hyperledger/fabric-peer 1.0.5 c2ab022f0bdb 17 months ago 154 MB
hyperledger/fabric-peer x86_64-1.0.5 c2ab022f0bdb 17 months ago 154 MB
hyperledger/fabric-ccenv x86_64-1.0.5 33feadb8f7a6 17 months ago 1.28 GB
hyperledger/fabric-ca 1.0.5 002c9089e464 17 months ago 238 MB
hyperledger/fabric-ca x86_64-1.0.5 002c9089e464 17 months ago 238 MB
hyperledger/fabric-baseimage x86_64-0.3.2 c92d9fdee998 21 months ago 1.26 GB
hyperledger/fabric-baseos x86_64-0.3.2 bbcbb9da2d83 21 months ago 129 MB
  1. 对docker进行设置

    使docker监听2375端口,并且确认master可以调用此接口。
//查看配置文件位于哪里
systemctl show --property=FragmentPath docker //编辑配置文件内容,接收所有ip请求
sudo vim /usr/lib/systemd/system/docker.service [Service]
ExecStart=/usr/bin/dockerd -H fd:// -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384
//使修改的配置生效
sudo systemctl daemon-reload; sudo systemctl restart docker.service
// 注意在云上开通此端口,易被在docker上部署挖矿软件,最好加上防火墙,仅允许master节点调用该端口。由于cello不支持TLS,所以安全性较低。

通过cello的web界面部署fabric

  1. 打开web界面,登录并添加worker主机,用户名: admin, 密码 pass



    添加成功后,即可在主机列表中看到该主机。

  2. 部署fabric



    在worker主机上,查看cli容器的日志,可以实时查看fabric部署进度。
[centos@baas cello]$ docker ps |grep cli
[centos@baas cello]$ docker logs -f xxxxxxx_cli
=== Creating channel businesschannel with new_businesschannel.tx... ===
=== Create Channel businesschannel by org 1/peer 0 ===
=== Channel businesschannel is created. ===
=== Created channel businesschannel with new_businesschannel.tx === === Join peers 0 from org 1 into businesschannel... ===
=== Join org 1/peer 0 into channel businesschannel ===
=== org 1/peer 0 joined into channel businesschannel ===
=== Join org 1/peer 1 into channel businesschannel ===
=== org 1/peer 1 joined into channel businesschannel ===
=== Join org 2/peer 0 into channel businesschannel ===
=== org 2/peer 0 joined into channel businesschannel ===
=== Join org 2/peer 1 into channel businesschannel ===
=== org 2/peer 1 joined into channel businesschannel ===
=== Join peers 0 from org 1 into businesschannel Complete === === Installing chaincode exp02 on all 4 peers... ===
=== Install Chaincode exp02:1.0 (examples/chaincode/go/chaincode_example02) on org 1/peer 0 ===
=== Chaincode is installed on remote peer0 ===
=== Install Chaincode exp02:1.0 (examples/chaincode/go/chaincode_example02) on org 1/peer 1 ===
=== Chaincode is installed on remote peer1 ===
=== Install Chaincode exp02:1.0 (examples/chaincode/go/chaincode_example02) on org 2/peer 0 ===
=== Chaincode is installed on remote peer0 ===
=== Install Chaincode exp02:1.0 (examples/chaincode/go/chaincode_example02) on org 2/peer 1 ===
=== Chaincode is installed on remote peer1 ===
=== Install chaincode done === === Instantiating chaincode on channel businesschannel... ===
=== chaincodeInstantiate for channel businesschannel on org 1/peer 0 ====
=== Chaincode Instantiated in channel businesschannel by peer0 ===
=== chaincodeInstantiate for channel businesschannel on org 2/peer 0 ====
=== Chaincode Instantiated in channel businesschannel by peer0 ===
=== Instantiate chaincode on channel businesschannel done ===

至此,fabric已经部署完成。

通过cello的用户界面操作fabric

  1. 打开界面,并登陆。

  1. 创建链

  1. 查看链详情

  1. 部署合约
  • 上传合约

    • 安装及部署合约

    • 执行交易

    • channel详情界面可以看到操作记录

转载请注明出处:HyperLedger Cello学习笔记

HyperLedger Cello学习笔记的更多相关文章

  1. [转帖]Hyperledger Fabric 学习一:简介

    Hyperledger Fabric 学习一:简介 https://www.jianshu.com/p/f971858b70f3?utm_campaign=maleskine&utm_cont ...

  2. js学习笔记:webpack基础入门(一)

    之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...

  3. PHP-自定义模板-学习笔记

    1.  开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2.  整体架构图 ...

  4. PHP-会员登录与注册例子解析-学习笔记

    1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...

  5. 2014年暑假c#学习笔记目录

    2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...

  6. JAVA GUI编程学习笔记目录

    2014年暑假JAVA GUI编程学习笔记目录 1.JAVA之GUI编程概述 2.JAVA之GUI编程布局 3.JAVA之GUI编程Frame窗口 4.JAVA之GUI编程事件监听机制 5.JAVA之 ...

  7. seaJs学习笔记2 – seaJs组建库的使用

    原文地址:seaJs学习笔记2 – seaJs组建库的使用 我觉得学习新东西并不是会使用它就够了的,会使用仅仅代表你看懂了,理解了,二不代表你深入了,彻悟了它的精髓. 所以不断的学习将是源源不断. 最 ...

  8. CSS学习笔记

    CSS学习笔记 2016年12月15日整理 CSS基础 Chapter1 在console输入escape("宋体") ENTER 就会出现unicode编码 显示"%u ...

  9. HTML学习笔记

    HTML学习笔记 2016年12月15日整理 Chapter1 URL(scheme://host.domain:port/path/filename) scheme: 定义因特网服务的类型,常见的为 ...

随机推荐

  1. VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法

     created() {     var that=this     axios.get('http://jsonplaceholder.typicode.com/todos')     .then( ...

  2. c语言查漏补缺

    getchar:执行getchar()函数时,首先从输入缓存区读取字符,直到输入缓存区为空时才等待从键盘继续输入.scanf()之间不要有printf操作. 逗号表达式 a= (++a,1,2),只取 ...

  3. 最初步的.NET MvcApi + Vue 前后端分离IIS部署

    一.完成项目,各个项目部署在IIS上 1.前端项目部署     完成项目后在控制台npm run build 生成了dist文件夹 主要是部署这个文件夹 打开IIS  和部署AspNet MVC项目一 ...

  4. 035、Java中自增之++在后面的写法

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  5. 014、MySQL取本月天数(这个月有多少天)

    #取本月天数 SELECT DATEDIFF( date_add( curdate( ) , INTERVAL MONTH ), DATE_ADD( curdate( ), INTERVAL DAY ...

  6. thread.start和threadstart.invoke的区别

    new Thread(() =>refreshDGVdelegate(App.StockList)).Start();//在新线程中执行操作 new ThreadStart(() => r ...

  7. 数据结构第二版之(课后题)BF算法病毒感染检测

    //vs2013下编译通过.换别的编译器自行补充头文件和修改源代码#include<iostream> #include<fstream> #include <strin ...

  8. springboot创建bean

    springboot创建bean的方式有两种: 1.直接类上加注解@Component@Controller@Service ... 2.使用@Bean注解配合@Configuration注解 区别是 ...

  9. 响应式布局之 px、em、 rem

    一.写在前面的话 作为一面前端开发者,对 px .em . rem 应该是再熟悉不过了,但大多数小伙伴应该都和我一样仅仅停留在了解的层面,并不是实质性的掌握它们.本文对三者进行了详细的总结和详细说明, ...

  10. POJ3295 Tautology重言式

    Tautology 思路很简单,对于p.q.r.s.t暴力枚举是0还是1,判断即可.判断时像写表达式求值那样用栈.为了方便可以从后往前,因为最后一个肯定不是运算.那几个奇奇怪怪的函数可以找规律然后转为 ...