zoukankan      html  css  js  c++  java
  • hyperledger fabric 1.0.5 分布式部署 (六)

    如何在相同的peer 节点上创建多个 channel

    作者在hyperledger fabric 1.0.5 分布式部署 (五)已经向读者们介绍了一个简单的fabric 的部署流程,那么根据上一篇博客的内容,大家实际上可以推断出,创建channel ,实际上需要涉及到 generateArtifacts.sh 脚本和 scritp.sh 脚本

    在一个启动了order 节点、peer 节点和cli 节点的fabric 环境里,实际创建一个channel 的操作步骤应该是怎样的呢?

    • 首先应该利用 generateArtifacts.sh 脚本生成相关节点的密钥和创建创世块,以及将组织机构信息添加到channel 中
    source generateArtifacts.sh $CH_NAME

    如果用户的fabric 环境中之前已经创建了相关节点的私钥和证书,那么用户只需要将要再次执行  generateArtifacts.sh 脚本中的generateChannelArtifacts 函数即可。

    • 利用cli 镜像再次创建channel 和安装 chaincode

    在 e2e_cli demo 中,docker-compose-cli.yaml 配置文件是描述docker-compose 启动哪些节点的,那么竟然fabric 环境中已经存在了,我们只要临时启动一个cli 镜像,然后再此执行 script.sh 脚本即可

    修改后的 docker-compose-cli.yaml 文件内容如下

    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    #
    
    version: '2'
    
    services:
    
    
      cli:
        container_name: cli
        image: hyperledger/fabric-tools
        tty: true
        environment:
          - GOPATH=/opt/gopath
          - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
          - CORE_LOGGING_LEVEL=DEBUG
          - CORE_PEER_ID=cli
          - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
          - CORE_PEER_LOCALMSPID=Org1MSP
          - CORE_PEER_TLS_ENABLED=true
          - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
          - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
          - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.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
        working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
        command: /bin/bash -c './scripts/script_test.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
        volumes:
            - /var/run/:/host/var/run/
            - ../chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
            - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
            - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
            - ./channel_test:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts

    由于script.sh 脚本中还存在一些不必要的步骤,所以用户应该只需要确保createChanneljoinChannelupdateAnchorPeersinstallChaincode函数被正确执行即可。

    docker-compose-cli.yaml 配置中script_test.sh 脚本即为修改后的脚本。

    docker-compose 的执行命令

    CHANNEL_NAME=*** TIMEOUT=10 docker-compose -f docker-compose-cli.yaml run --rm --no-deps cli 2>&1

    通过以上步骤,用户就可以在已经存在的fabric 集群中创建任意名字的channel。

  • 相关阅读:
    How to clean up BizTalk Message Box
    BizTalk: Database ‘BizTalkMsgBoxDb’ is full
    Install or Uninstall a Windows Service
    Distinguished Fields and Optional Elements
    Stay Hungry, Stay Foolish
    男子英文名大全,来历、释义
    Correlations in BizTalk 2004
    17.域环境解决方案
    18.windows痕迹清理
    Burpsuit手机抓包
  • 原文地址:https://www.cnblogs.com/chenfool/p/8483220.html
Copyright © 2011-2022 走看看