ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

搭建自己的Fabric网络

2020-02-05 20:41:40  阅读:302  来源: 互联网

标签:CORE Fabric 网络 xidian org2 hyperledger org1 com 搭建


搭建自己的Fabric网络

文章目录


前边,我们用自动化脚本进行了Fabric网络的搭建,今天我们用手动的方式来搭建一个Fabric网络,这样更有利于我们对Fabric网络的理解,以下搭建过程主要参考byfn.sh脚本。今天一起来学习如何创建属于自己的Fabric网络!

一、生成组织结构与身份证书

1.1、crypto-config.yaml配置文件

byfn.sh中创建网络的时候,第一步加载crypto-config.yaml。该文件主要指定整个网络中的相关组织信息,我们稍加修改示例即可,最终结果如下,各个注释写的很详细的(老美的优点吧),稍微懂点英语就可以看懂了:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
  # ---------------------------------------------------------------------------
  # Orderer
  # ---------------------------------------------------------------------------
  - Name: Orderer
    Domain: xidian.com
    # ---------------------------------------------------------------------------
    # "Specs" - See PeerOrgs below for complete description
    # ---------------------------------------------------------------------------
    Specs:
      - Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
  # ---------------------------------------------------------------------------
  # Org1
  # ---------------------------------------------------------------------------
  - Name: Org1
    Domain: org1.xidian.com
    EnableNodeOUs: true
    # ---------------------------------------------------------------------------
    # "Specs"
    # ---------------------------------------------------------------------------
    # Uncomment this section to enable the explicit definition of hosts in your
    # configuration.  Most users will want to use Template, below
    #
    # Specs is an array of Spec entries.  Each Spec entry consists of two fields:
    #   - Hostname:   (Required) The desired hostname, sans the domain.
    #   - CommonName: (Optional) Specifies the template or explicit override for
    #                 the CN.  By default, this is the template:
    #
    #                              "{{.Hostname}}.{{.Domain}}"
    #
    #                 which obtains its values from the Spec.Hostname and
    #                 Org.Domain, respectively.
    # ---------------------------------------------------------------------------
    # Specs:
    #   - Hostname: foo # implicitly "foo.org1.example.com"
    #     CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
    #   - Hostname: bar
    #   - Hostname: baz
    # ---------------------------------------------------------------------------
    # "Template"
    # ---------------------------------------------------------------------------
    # Allows for the definition of 1 or more hosts that are created sequentially
    # from a template. By default, this looks like "peer%d" from 0 to Count-1.
    # You may override the number of nodes (Count), the starting index (Start)
    # or the template used to construct the name (Hostname).
    #
    # Note: Template and Specs are not mutually exclusive.  You may define both
    # sections and the aggregate nodes will be created for you.  Take care with
    # name collisions
    # ---------------------------------------------------------------------------
    Template:
      Count: 2
      # Start: 5
      # Hostname: {{.Prefix}}{{.Index}} # default
    # ---------------------------------------------------------------------------
    # "Users"
    # ---------------------------------------------------------------------------
    # Count: The number of user accounts _in addition_ to Admin
    # ---------------------------------------------------------------------------
    Users:
      Count: 1
  # ---------------------------------------------------------------------------
  # Org2: See "Org1" for full specification
  # ---------------------------------------------------------------------------
  - Name: Org2
    Domain: org2.xidian.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

该配置创建了OrdererOrgs和PeerOrgs两个组织信息,其中PeerOrgs中有两个org,每个org中有两个peer节点和一个user。

1.2、生成组织结构及身份证书

我们使用以前编译好的cryptogen工具来生成,命令如下:

cryptogen generate --config=./crypto-config.yaml

结果如下:
在这里插入图片描述
执行完该命令后就会在当前目录crypto-config文件夹,里边包括相关的结果及证书,我们可以用tree命令看详细情况,展开三级哈,
在这里插入图片描述

二、生成其他配置文件

2.1、configtx.yaml文件

再生成组织结构等文件后,我们还需要创世区块和通道。该文件的生成依然依靠yaml文件,而这些相关文件主要在configtx.yaml文件,我们指定上一步生成文件的路径就可以了。

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    TwoOrgsOrdererGenesis:
        Capabilities:
            <<: *ChannelCapabilities
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
    TwoOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities

################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
Organizations:

    # SampleOrg defines an MSP using the sampleconfig.  It should never be used
    # in production but may be used as a template for other definitions
    - &OrdererOrg
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrdererOrg

        # ID to load the MSP definition as
        ID: OrdererMSP

        # MSPDir is the filesystem path which contains the MSP configuration
        MSPDir: crypto-config/ordererOrganizations/xidian.com/msp

    - &Org1
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org1MSP

        # ID to load the MSP definition as
        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.xidian.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.org1.xidian.com
              Port: 7051

    - &Org2
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: Org2MSP

        # ID to load the MSP definition as
        ID: Org2MSP

        MSPDir: crypto-config/peerOrganizations/org2.xidian.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.org2.xidian.com
              Port: 7051

################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    # Available types are "solo" and "kafka"
    OrdererType: solo

    Addresses:
        - orderer.xidian.com:7050

    # Batch Timeout: The amount of time to wait before creating a batch
    BatchTimeout: 2s

    # Batch Size: Controls the number of messages batched into a block
    BatchSize:

        # Max Message Count: The maximum number of messages to permit in a batch
        MaxMessageCount: 10

        # Absolute Max Bytes: The absolute maximum number of bytes allowed for
        # the serialized messages in a batch.
        AbsoluteMaxBytes: 99 MB

        # Preferred Max Bytes: The preferred maximum number of bytes allowed for
        # the serialized messages in a batch. A message larger than the preferred
        # max bytes will result in a batch larger than preferred max bytes.
        PreferredMaxBytes: 512 KB

    Kafka:
        # Brokers: A list of Kafka brokers to which the orderer connects
        # NOTE: Use IP:port notation
        Brokers:
            - 127.0.0.1:9092

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

################################################################################
#
#   SECTION: Capabilities
#
#   - This section defines the capabilities of fabric network. This is a new
#   concept as of v1.1.0 and should not be utilized in mixed networks with
#   v1.0.x peers and orderers.  Capabilities define features which must be
#   present in a fabric binary for that binary to safely participate in the
#   fabric network.  For instance, if a new MSP type is added, newer binaries
#   might recognize and validate the signatures from this type, while older
#   binaries without this support would be unable to validate those
#   transactions.  This could lead to different versions of the fabric binaries
#   having different world states.  Instead, defining a capability for a channel
#   informs those binaries without this capability that they must cease
#   processing transactions until they have been upgraded.  For v1.0.x if any
#   capabilities are defined (including a map with all capabilities turned off)
#   then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
    # Channel capabilities apply to both the orderers and the peers and must be
    # supported by both.  Set the value of the capability to true to require it.
    Global: &ChannelCapabilities
        # V1.1 for Global is a catchall flag for behavior which has been
        # determined to be desired for all orderers and peers running v1.0.x,
        # but the modification of which would cause incompatibilities.  Users
        # should leave this flag set to true.
        V1_1: true

    # Orderer capabilities apply only to the orderers, and may be safely
    # manipulated without concern for upgrading peers.  Set the value of the
    # capability to true to require it.
    Orderer: &OrdererCapabilities
        # V1.1 for Order is a catchall flag for behavior which has been
        # determined to be desired for all orderers running v1.0.x, but the
        # modification of which  would cause incompatibilities.  Users should
        # leave this flag set to true.
        V1_1: true

    # Application capabilities apply only to the peer network, and may be safely
    # manipulated without concern for upgrading orderers.  Set the value of the
    # capability to true to require it.
    Application: &ApplicationCapabilities
        # V1.1 for Application is a catchall flag for behavior which has been
        # determined to be desired for all peers running v1.0.x, but the
        # modification of which would cause incompatibilities.  Users should
        # leave this flag set to true.
        V1_1: true

2.2、Orderer服务启动初始区块创建

这一步使用到的工具为configtxgen,关于详细使用情况我们用help即可查看,生成配置文件的命令如下:

configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

在这里插入图片描述

2.3、通道创始文件

相关命令:

export CHANNEL_NAME=mychannel
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

最终结果:
在这里插入图片描述

2.4、生成锚节点更新配置文件

锚节点更新配置文件在通道创建之后用来更新组织中的锚节点,同样基于configtx.yaml文件和configtxgen工具,相关命令如下:

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

最终结果如下:
在这里插入图片描述

三、网络的启动

3.1、相关配置文件

截止上一步我们的网络相关配置文件已经生成,下一步就是启动网络,启动网络主要用到的文件有:docker-compose-cli.yamlbase/docker-compose-base.yaml 、``base/peer-base.yaml`

相关内容如下:

  • docker-compose-cli.yaml 文件内容:
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

volumes:
  orderer.xidian.com:
  peer0.org1.xidian.com:
  peer1.org1.xidian.com:
  peer0.org2.xidian.com:
  peer1.org2.xidian.com:

networks:
  byfn:

services:

  orderer.xidian.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.xidian.com
    container_name: orderer.xidian.com
    networks:
      - byfn

  peer0.org1.xidian.com:
    container_name: peer0.org1.xidian.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.xidian.com
    networks:
      - byfn

  peer1.org1.xidian.com:
    container_name: peer1.org1.xidian.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.xidian.com
    networks:
      - byfn

  peer0.org2.xidian.com:
    container_name: peer0.org2.xidian.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.xidian.com
    networks:
      - byfn

  peer1.org2.xidian.com:
    container_name: peer1.org2.xidian.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.xidian.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- CORE_LOGGING_LEVEL=DEBUG
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.xidian.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.xidian.com/peers/peer0.org1.xidian.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xidian.com/peers/peer0.org1.xidian.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xidian.com/peers/peer0.org1.xidian.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.xidian.com/users/Admin@org1.xidian.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - orderer.xidian.com
      - peer0.org1.xidian.com
      - peer1.org1.xidian.com
      - peer0.org2.xidian.com
      - peer1.org2.xidian.com
    networks:
      - byfn
  • docker-compose-base.yaml文件内容:
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

services:

  orderer.xidian.com:
    container_name: orderer.xidian.com
    image: hyperledger/fabric-orderer:$IMAGE_TAG
    environment:
      - ORDERER_GENERAL_LOGLEVEL=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer
    volumes:
    - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
    - ../crypto-config/ordererOrganizations/xidian.com/orderers/orderer.xidian.com/msp:/var/hyperledger/orderer/msp
    - ../crypto-config/ordererOrganizations/xidian.com/orderers/orderer.xidian.com/tls/:/var/hyperledger/orderer/tls
    - orderer.xidian.com:/var/hyperledger/production/orderer
    ports:
      - 7050:7050

  peer0.org1.xidian.com:
    container_name: peer0.org1.xidian.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org1.xidian.com
      - CORE_PEER_ADDRESS=peer0.org1.xidian.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.xidian.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.xidian.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org1.xidian.com/peers/peer0.org1.xidian.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org1.xidian.com/peers/peer0.org1.xidian.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org1.xidian.com:/var/hyperledger/production
    ports:
      - 7051:7051
      - 7053:7053

  peer1.org1.xidian.com:
    container_name: peer1.org1.xidian.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org1.xidian.com
      - CORE_PEER_ADDRESS=peer1.org1.xidian.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.xidian.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.xidian.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org1.xidian.com/peers/peer1.org1.xidian.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org1.xidian.com/peers/peer1.org1.xidian.com/tls:/etc/hyperledger/fabric/tls
        - peer1.org1.xidian.com:/var/hyperledger/production

    ports:
      - 8051:7051
      - 8053:7053

  peer0.org2.xidian.com:
    container_name: peer0.org2.xidian.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.xidian.com
      - CORE_PEER_ADDRESS=peer0.org2.xidian.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.xidian.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.xidian.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org2.xidian.com/peers/peer0.org2.xidian.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org2.xidian.com/peers/peer0.org2.xidian.com/tls:/etc/hyperledger/fabric/tls
        - peer0.org2.xidian.com:/var/hyperledger/production
    ports:
      - 9051:7051
      - 9053:7053

  peer1.org2.xidian.com:
    container_name: peer1.org2.xidian.com
    extends:
      file: peer-base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org2.xidian.com
      - CORE_PEER_ADDRESS=peer1.org2.xidian.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.xidian.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.xidian.com:7051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
        - /var/run/:/host/var/run/
        - ../crypto-config/peerOrganizations/org2.xidian.com/peers/peer1.org2.xidian.com/msp:/etc/hyperledger/fabric/msp
        - ../crypto-config/peerOrganizations/org2.xidian.com/peers/peer1.org2.xidian.com/tls:/etc/hyperledger/fabric/tls
        - peer1.org2.xidian.com:/var/hyperledger/production
    ports:
      - 10051:7051
      - 10053:7053
  • peer-base.yaml文件内容
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

services:
  peer-base:
    image: hyperledger/fabric-peer:$IMAGE_TAG
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
      - CORE_LOGGING_LEVEL=INFO
      #- CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start

3.2、网络启动

用docker-compose来启动,相关命令:

docker-compose -f docker-compose-cli.yaml up

这个时候会报错如下:

WARNING: The IMAGE_TAG variable is not set. Defaulting to a blank string.
WARNING: The COMPOSE_PROJECT_NAME variable is not set. Defaulting to a blank string.
Creating network "test_byfn" with the default driver
ERROR: no such image: hyperledger/fabric-orderer:: invalid reference format

解决方案,是由于环境变量中base/docker-compose-base.yaml没有相关内容,export即可

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-735V29ii-1580904942626)(C:\Users\Br0w5e\AppData\Roaming\Typora\typora-user-images\image-20200205185345355.png)]

export IMAGE_TAG=latest

然后重新运行即可,结果如下:
在这里插入图片描述
到此为止,我们的网络已经完成启动了。

四、通道创建

通道的概念类似子网,通道提供一种通信机制,能够将Peer和Orderer连接在一起,形成一个具有保密性质的通信链路。

4.1、创建通道

  • 进入cli容器
docker exec -it cli bash
  • 设置环境变量
export CHANNEL_NAME=mychannel
  • 创建通道
peer channel create -o orderer.xidian.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xidian.com/orderers/orderer.xidian.com/msp/tlscacerts/tlsca.xidian.com-cert.pem

在这里插入图片描述

上图左边为后台信息,右边为容器信息。

4.2、将节点加入应用通道

peer channel join -b mychannel.block

在这里插入图片描述
在这里插入图片描述

上图为容器信息,下图为网络信息。

4.3、更新锚节点

使用Org1的管理员身份更新

peer channel update -o orderer.xidian.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xidian.com/orderers/orderer.xidian.com/msp/tlscacerts/tlsca.xidian.com-cert.pem

在这里插入图片描述
以Org2的管理员身份更新,因为在配置文件中所有相关配置文件的环境变量都默认Org1的管理员,要进行Org2管理员更新必须将相关的环境变量设置为Org2的,所有较上一步麻烦一点,相关操作如下

CORE_PEER_ADDRESS=peer0.org2.xidian.com:7051
CORE_PEER_LOCALMSPID="Org2MSP"
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.xidian.com/peers/peer0.org2.xidian.com/tls/server.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.xidian.com/peers/peer0.org2.xidian.com/tls/server.key
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.xidian.com/peers/peer0.org2.xidian.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.xidian.com/users/Admin@org2.xidian.com/msp

peer channel update -o orderer.xidian.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/xidian.com/orderers/orderer.xidian.com/msp/tlscacerts/tlsca.xidian.com-cert.pem

在这里插入图片描述
至此为止,手动配置的网络启动完成。后边将会把写好的链码部署上来!

Rookie_Hang 发布了12 篇原创文章 · 获赞 2 · 访问量 5834 私信 关注

标签:CORE,Fabric,网络,xidian,org2,hyperledger,org1,com,搭建
来源: https://blog.csdn.net/qq_40185499/article/details/104187913

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有