Fabric多机部署-e2e

2023-11-05 00:38
文章标签 部署 fabric 多机 e2e

本文主要是介绍Fabric多机部署-e2e,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Fabric多机部署-e2e

测试环境为三台华为云ECS主机,加入在同一虚拟子网中;
实验将fabric/example/e2e_cli进行修改测试多机部署;
三个node上的fabric环境一致,需要修改e2e配置文件;
fabric v1.4已经移除e2e demo,本次版本为fabric v1.2。
  • 部署环境

    nodeorg
    192.168.0.145orderer、peer0.org1、peer1.org1、cli
    192.168.0.105peer0.org2
    192.168.0.151peer1.org2
  • docker-compose文件修改

    • node1:修改base/docker-compose-base.yaml中orderer服务的配置,添加extra_hosts的org2配置
    27   orderer.example.com:
    28     container_name: orderer.example.com
    29     image: hyperledger/fabric-orderer
    30     extra_hosts: #
    31       - "peer0.org2.example.com:192.168.0.105"
    32       - "peer1.org2.example.com:192.168.0.151"
    33     environment:
    34       - ORDERER_GENERAL_LOGLEVEL=debug
    35       - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
    36       - ORDERER_GENERAL_GENESISMETHOD=file...
    
    • node1:修改docker-compose-cli.yaml中cli的配置,并删除org2的服务配置
    123   cli:
    124     container_name: cli
    125     image: hyperledger/fabric-tools
    126     tty: true
    127     extra_hosts:
    128       - "peer0.org2.example.com:192.168.0.105"
    129       - "peer1.org2.example.com:192.168.0.151"
    130       #- "peer0.org1.example.com:192.168.0.145"
    131       #- "peer1.org1.example.com:192.168.0.145"
    132     environment:
    133       - GOPATH=/opt/gopath
    134       - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
    135       - CORE_LOGGING_LEVEL=DEBUG
    136       - CORE_PEER_ID=cli
    137       - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
    138       - CORE_PEER_LOCALMSPID=Org1MSP...
    
    • node2:修改docker-compose-cli.yaml中peer0.org2的配置,删除其他服务及peer1.org2的配置
     8 services:9   peer0.org2.example.com:
    10     container_name: peer0.org2.example.com
    11     extends:
    12       file:  base/docker-compose-base.yaml
    13       service: peer0.org2.example.com
    14     extra_hosts:
    15       - "orderer.example.com:192.168.0.145"
    16       - "peer1.org2.example.com:192.168.0.151"
    • node2:修改base/docker-compose-base.yaml中peer0.org2的端口
     98   peer0.org2.example.com:99     container_name: peer0.org2.example.com
    100     extends:
    101       file: peer-base.yaml
    102       service: peer-base
    103     environment:
    104       - CORE_PEER_ID=peer0.org2.example.com
    105       - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
    106       - CORE_PEER_CHAINCODEADDRESS=peer0.org2.example.com:7052
    107       - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
    108       - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
    109       - CORE_PEER_LOCALMSPID=Org2MSP
    110     volumes:
    111         - /var/run/:/host/var/run/
    112         - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
    113         - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
    114     ports:
    115       - 7051:7051
    116       - 7052:7052
    117       - 7053:7053
    
    • node3:修改docker-compose-cli.yaml中peer1.org2的配置,删除其他服务及peer0.org2的配置
     8 services:9   peer1.org2.example.com:
    10     container_name: peer1.org2.example.com
    11     extends:
    12       file:  base/docker-compose-base.yaml
    13       service: peer1.org2.example.com
    14     extra_hosts:
    15       - "orderer.example.com:192.168.0.145"
    16       - "peer0.org2.example.com:192.168.0.105"
    
    • node3:修改base/docker-compose-base.yaml中peer1.org2的端口
    119   peer1.org2.example.com:
    120     container_name: peer1.org2.example.com
    121     extends:
    122       file: peer-base.yaml
    123       service: peer-base
    124     environment:
    125       - CORE_PEER_ID=peer1.org2.example.com
    126       - CORE_PEER_ADDRESS=peer1.org2.example.com:7051
    127       - CORE_PEER_CHAINCODEADDRESS=peer1.org2.example.com:7052
    128       - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
    129       - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051
    130       - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
    131       - CORE_PEER_LOCALMSPID=Org2MSP
    132     volumes:
    133         - /var/run/:/host/var/run/
    134         - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
    135         - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
    136     ports:
    137       - 7051:7051
    138       - 7052:7052
    139       - 7053:7053
    
  • 启动前,生成初始块及相关证书

    简化操作,注释掉三个node上network_setup.sh脚本的networkDown函数中删除证书和初始块的命令
    
    77 function networkDown () {
    78     docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH down
    79 
    80     #Cleanup the chaincode containers
    81     clearContainers
    82 
    83     #Cleanup images
    84     removeUnwantedImages
    85 
    86     # remove orderer block and other channel configuration transactions and certs
    87     #rm -rf channel-artifacts/*.block channel-artifacts/*.tx crypto-config
    88 }   
    
    ./network_setup.sh启动,生成channel-artifacts、crypto-config两个文件,通过scp命令服务到node2、node3的e2e目录下
    
  • 测试

    启动demo,在三个node上启动脚本
    
    #node1
    root@liu:~/work/go/src/github.com/hyperledger/fabric/examples/e2e_cli# ./network_setup.sh 
    #node2
    root@lhys:~/work/go/src/github.com/hyperledger/fabric/examples/e2e_cli# ./network_setup.sh 
    #node3
    [root@cce-demo1522483688765-00274 e2e_cli]# ./network_setup.sh 
    
    观察node1的输出,正常结果如下所示
    
...
2018-12-27 02:50:36.649 UTC [channelCmd] executeJoin -> INFO 041 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================  
...
2018-12-27 02:50:44.068 UTC [channelCmd] update -> INFO 04d Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' ===================== 
...
2018-12-27 02:50:49.607 UTC [chaincodeCmd] install -> INFO 083 Installed remotely response:<status:200 payload:"OK" > 
===================== Chaincode is installed on peer0.org2 ===================== 
...
===================== All GOOD, End-2-End execution completed ===================== _____   _   _   ____            _____   ____    _____ 
| ____| | \ | | |  _ \          | ____| |___ \  | ____|
|  _|   |  \| | | | | |  _____  |  _|     __) | |  _|  
| |___  | |\  | | |_| | |_____| | |___   / __/  | |___ 
|_____| |_| \_| |____/          |_____| |_____| |_____|
中间如果有其他异常,比如org2拒绝连接,背书失败等,可通过docker log 查看日志
  • 测试过程中遇到的问题

    • ip记错,导致org2 connect: connection refused
    • 端口没改,因为e2e中peer均开方7051、7052、7053端口,为防止冲突,fabric进行了暴露了对应的外部端口如80** 90** 100**;
      但peer内部访问仍是705*,单机下fabric进行了转发处理,多机下需要改回705*端口
  • 总结

    • 添加为orderer、org2、cli添加extra_hosts
    • 修改org2的peer容器暴露的端口
    • 生成创世块、证书,并复制到其他节点

这篇关于Fabric多机部署-e2e的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/346243

相关文章

Web技术与Nginx网站环境部署教程

《Web技术与Nginx网站环境部署教程》:本文主要介绍Web技术与Nginx网站环境部署教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Web基础1.域名系统DNS2.Hosts文件3.DNS4.域名注册二.网页与html1.网页概述2.HTML概述3.

Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例

《Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例》本文介绍Nginx+Keepalived实现Web集群高可用负载均衡的部署与测试,涵盖架构设计、环境配置、健康检查、... 目录前言一、架构设计二、环境准备三、案例部署配置 前端 Keepalived配置 前端 Nginx

ubuntu如何部署Dify以及安装Docker? Dify安装部署指南

《ubuntu如何部署Dify以及安装Docker?Dify安装部署指南》Dify是一个开源的大模型应用开发平台,允许用户快速构建和部署基于大语言模型的应用,ubuntu如何部署Dify呢?详细请... Dify是个不错的开源LLM应用开发平台,提供从 Agent 构建到 AI workflow 编排、RA

ubuntu16.04如何部署dify? 在Linux上安装部署Dify的技巧

《ubuntu16.04如何部署dify?在Linux上安装部署Dify的技巧》随着云计算和容器技术的快速发展,Docker已经成为现代软件开发和部署的重要工具之一,Dify作为一款优秀的云原生应用... Dify 是一个基于 docker 的工作流管理工具,旨在简化机器学习和数据科学领域的多步骤工作流。它

Nginx部署React项目时重定向循环问题的解决方案

《Nginx部署React项目时重定向循环问题的解决方案》Nginx在处理React项目请求时出现重定向循环,通常是由于`try_files`配置错误或`root`路径配置不当导致的,本文给大家详细介... 目录问题原因1. try_files 配置错误2. root 路径错误解决方法1. 检查 try_f

Spring Boot项目部署命令java -jar的各种参数及作用详解

《SpringBoot项目部署命令java-jar的各种参数及作用详解》:本文主要介绍SpringBoot项目部署命令java-jar的各种参数及作用的相关资料,包括设置内存大小、垃圾回收... 目录前言一、基础命令结构二、常见的 Java 命令参数1. 设置内存大小2. 配置垃圾回收器3. 配置线程栈大小

tomcat多实例部署的项目实践

《tomcat多实例部署的项目实践》Tomcat多实例是指在一台设备上运行多个Tomcat服务,这些Tomcat相互独立,本文主要介绍了tomcat多实例部署的项目实践,具有一定的参考价值,感兴趣的可... 目录1.创建项目目录,测试文China编程件2js.创建实例的安装目录3.准备实例的配置文件4.编辑实例的

SpringBoot配置Ollama实现本地部署DeepSeek

《SpringBoot配置Ollama实现本地部署DeepSeek》本文主要介绍了在本地环境中使用Ollama配置DeepSeek模型,并在IntelliJIDEA中创建一个Sprin... 目录前言详细步骤一、本地配置DeepSeek二、SpringBoot项目调用本地DeepSeek前言随着人工智能技

通过Docker Compose部署MySQL的详细教程

《通过DockerCompose部署MySQL的详细教程》DockerCompose作为Docker官方的容器编排工具,为MySQL数据库部署带来了显著优势,下面小编就来为大家详细介绍一... 目录一、docker Compose 部署 mysql 的优势二、环境准备与基础配置2.1 项目目录结构2.2 基

CentOS 7部署主域名服务器 DNS的方法

《CentOS7部署主域名服务器DNS的方法》文章详细介绍了在CentOS7上部署主域名服务器DNS的步骤,包括安装BIND服务、配置DNS服务、添加域名区域、创建区域文件、配置反向解析、检查配置... 目录1. 安装 BIND 服务和工具2.  配置 BIND 服务3 . 添加你的域名区域配置4.创建区域