Chapter XIII nine analysis with you easily complete explosion hyperledger fabric - to create static organization

This series of articles:


Chapter one: nine analyze with you after blasting hyperledger fabric - Quick Start basic-network Sample

Chapter II: nine analyze with you after blasting hyperledger fabric - to quickly build environment GO

Chapter 3: nine analyze with you after blasting hyperledger fabric - Quick Start Sample first-network

Chapter 4: nine analyze with you after blasting hyperledger fabric - system logic architecture articles

Chapter V: nine analyze with you after blasting hyperledger fabirc - Network Node Introduction

Chapter 6:   nine analyze with you easily complete explosion hyperledger fabric - block and block chain introduced

Chapter 7:   nine analyze with you easily complete explosion hyperledger fabric - block chain tamper-resistant mechanism

Chapter 8: nine analyze with you easily complete explosion hyperledger fabric - Couchdb installation

Chapter 9: nine analyze with you easily complete explosion hyperledger fabric - NVM installation and Nodejs

Chapter X: nine analyze with you easily complete explosion hyperledger fabric - chaincode life cycle introduction

Chapter 11:  nine analyze with you easily complete explosion hyperledger fabric - to create alliances

Chapter XII:  nine analyze with you easily complete explosion hyperledger fabric - configtxlator early adopters

Chapter XIII:  nine analyze with you easily complete explosion hyperledger fabric - to create static organization

table of Contents

1 Introduction

2 Create the configuration files and directories

    2.1 Create a working directory

    2.2 Create the necessary directory

    2.3 Creating block creation, channel, Alliance Resource File

    2.4 Creating node configuration file

    2.5 Create a docker-compose.yaml file

3 generates a certificate

4 blocks to generate Creation

Channel 5 generated transaction documents

6 Create Anchor node MSP answer file

7 initialization container

Create a channel 8

9 other organizations channel

Section 10

11 in-depth

    11.1 generate a new channel transaction documents

    11.2 generate Anchor node MSP file

    11.3 create a channel


1 Introduction

        In the sections above, we have created alliances Here's how to create an organization. Creating organization can be divided into two types: static and dynamic. The so-called static is already determined before the establishment of the block chain network in the league better organized in the future business development, it will not be a new organization; that is, with the so-called dynamic business, there will be new organization He asked to join in, then you can not stop re-block chain network, and then modify the configuration file, and then start the establishment, but by adding dynamic increments. Due to the dynamic organization to add a little harder, we will explain on the follow-up. This section describes the way to create a static organization.

        It should be noted, fabric Source Version 1.4.4 is used herein. In addition, for simplicity and easier to understand, we will use the self-built script. This section will use tools configtxgen and cryptogen, so make sure you have these two tools correctly installed and configured. If you do not configure, please refer to Chapter 3 brother, you're welcome.


2 Create the configuration files and directories

2.1 Create a working directory

mkdir jiuxi

cd jiuxi

2.2 Create the necessary directory

        Here is a catalog of necessary storage directory certificate creation and storage blocks, directory channel transaction documents, peer master node (Anchor) transaction file:

mkdir crypto-config config

2.3 Creating block creation, channel, Alliance Resource File

touch configtx.yaml

        configtx.yaml used to store configuration information creation block, alliances, channels, organizations, etc., as follows, based on the content seen that already in the configuration phase completes the creation of the organization:

Organizations:

    - &OrdererOrg

        Name: OrdererOrg

        ID: OrdererMSP

        MSPDir: crypto-config/ordererOrganizations/jiuxi.org/msp

    - &Org1

        Name: Org1MSP

        ID: Org1MSP

        MSPDir: crypto-config/peerOrganizations/org1.jiuxi.org/msp

        AnchorPeers:

            - Host: peer0.org1.jiuxi.org

              Port: 11151

    - &Org2

        Name: Org2MSP

        ID: Org2MSP

        MSPDir: crypto-config/peerOrganizations/org2.jiuxi.org/msp

        AnchorPeers:

            - Host: peer0.org2.jiuxi.org

              Port: 12151

    - &Org3

        Name: Org3MSP

        ID: Org3MSP

        MSPDir: crypto-config/peerOrganizations/org3.jiuxi.org/msp

        AnchorPeers:

            - Host: peer0.org3.jiuxi.org

              Port: 13151

Orderer: &OrdererDefaults

    OrdererType: solo

    Addresses:

        - orderer.jiuxi.org:7050

    Btctimeout: 2s

    BatchSize:

        MaxMessageCount: 10

        AbsoluteMaxBytes: 99 MB

        PreferredMaxBytes: 512 KB

    Kafka:

        Brokers:

            - 127.0.0.1:9092

    Organizations:

Application: &ApplicationDefaults

    Organizations:

Profiles:

    JiuxiOrdererGenesis:

        Orderer:

            <<: *OrdererDefaults

            Organizations:

                - *OrdererOrg

        Consortiums:

            JiuxiConsortium;

                Organizations:

                    - *Org1

                    - *Org2

                    - * Org3

    JiuxiChannel:

        Consortium: JiuxiConsortium

        Application:

            <<: *ApplicationDefaults

            Organizations:

                - *Org1

                - *Org2

                - * Org3

2.4 Creating node configuration file

touch  crypto-config.yaml

        crypto-config.yaml sort to configure the node and peer nodes, as follows:

OrdererOrgs:

  - Name: Orderer

    Domain: jiuxi.org 

    Specs:

      - Hostname: orderer

PeerOrgs:

  - Name: Org1

    Domain: org1.jiuxi.org

    Template:

      Count: 2

    Users:

      Count: 1

  - Name: Org2

    Domain: org2.jiuxi.org

    Template:

      Count: 2

    Users:

      Count: 1

  - Name: Org3

    Domain: org3.jiuxi.org

    Template:

      Count: 2

    Users:

      Count: 1

2.5 Create a docker-compose.yaml file

        docker-compose.yaml layout file container or containers used to declare dependency, as follows:

version: '2'

networks:

  jiuxi:

services:

  couchdb:

    container_name: couchdb

    image: hyperledger/fabric-couchdb

    environment:

      - COUCHDB_USER=

      - COUCHDB_PASSWORD=

    ports:

      - 5984:5984

    networks:

      - jiuxi

  orderer.jiuxi.org:

    container_name: orderer.jiuxi.org

    image: hyperledger/fabric-orderer

    environment:

      - FABRIC_LOGGING_SPEC=info

      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0

      - ORDERER_GENERAL_GENESISMETHOD=file

      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block

      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP

      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer

    command: orderer

    ports:

      - 7050:7050

    volumes:

        - ./config/:/etc/hyperledger/configtx

        - ./crypto-config/ordererOrganizations/jiuxi.org/orderers/orderer.jiuxi.org/:/etc/hyperledger/msp/orderer

        - ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer0.org1.jiuxi.org/:/etc/hyperledger/msp/peerOrg1

    networks:

      - jiuxi

  peer0.org1.jiuxi.org:

    container_name: peer0.org1.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer0.org1.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org1MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer0.org1.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 11151:7051

      - 11153:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer0.org1.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org1.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  peer1.org1.jiuxi.org:

    container_name: peer1.org1.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer1.org1.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org1MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer1.org1.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 11251:7051

      - 11253:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org1.jiuxi.org/peers/peer1.org1.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org1.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  peer0.org2.jiuxi.org:

    container_name: peer0.org2.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer0.org2.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org2MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer0.org2.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 12151:7051

      - 12153:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org2.jiuxi.org/peers/peer0.org2.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org2.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  peer1.org2.jiuxi.org:

    container_name: peer1.org2.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer1.org2.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org2MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer1.org2.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 12251:7051

      - 12253:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org2.jiuxi.org/peers/peer1.org2.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org2.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  peer0.org3.jiuxi.org:

    container_name: peer0.org3.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer0.org3.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org3MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer0.org3.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 13151:7051

      - 13153:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org3.jiuxi.org/peers/peer0.org3.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org3.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  peer1.org3.jiuxi.org:

    container_name: peer1.org3.jiuxi.org

    image: hyperledger/fabric-peer

    environment:

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - CORE_PEER_ID=peer1.org3.jiuxi.org

      - FABRIC_LOGGING_SPEC=info

      - CORE_CHAINCODE_LOGGING_LEVEL=info

      - CORE_PEER_LOCALMSPID=Org3MSP

      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/

      - CORE_PEER_ADDRESS=peer1.org3.jiuxi.org:7051

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_jiuxi

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB

      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984

      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=

      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=

    working_dir: /opt/gopath/src/github.com/hyperledger/fabric

    command: peer node start

    ports:

      - 13251:7051

      - 13253:7053

    volumes:

        - / var / run /: / host / var / run /

        - ./crypto-config/peerOrganizations/org3.jiuxi.org/peers/peer1.org3.jiuxi.org/msp:/etc/hyperledger/msp/peer

        - ./crypto-config/peerOrganizations/org3.jiuxi.org/users:/etc/hyperledger/msp/users

        - ./config:/etc/hyperledger/configtx

    depends_on:

      - orderer.jiuxi.org

      - couchdb

    networks:

      - jiuxi

  cli:

    container_name: cli

    image: hyperledger/fabric-tools

    tty: true

    environment:

      - GOPATH=/opt/gopath

      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock

      - FABRIC_LOGGING_SPEC=info

      - CORE_PEER_ID=cli

      - CORE_PEER_ADDRESS=peer0.org1.jiuxi.org:11251

      - CORE_PEER_LOCALMSPID=Org1MSP

      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.jiuxi.org/users/[email protected]/msp

      - CORE_CHAINCODE_KEEPALIVE=10

    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/

        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/

    networks:

        - jiuxi

        All directory structure is created as follows:image1.png


3 generates a certificate

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

        Command is successful certificate will be generated in the crypto-config directory


4 blocks to generate Creation

configtxgen -profile JiuxiOrdererGenesis -outputBlock ./config/genesis.block

        The successful implementation will generate the creation block genesis.block in the config directory.


Channel 5 generated transaction documents

configtxgen -profile JiuxiChannel -outputCreateChannelTx ./config/channel1.tx -channelID channel1

        命令执行成功会将通道交易文件生成在 config 目录下。


6 创建 Anchor 节点的 MSP 回话文件

configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel1Org1MSPanchors.tx -channelID channel1 -asOrg Org1MSP

configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel1Org2MSPanchors.tx -channelID channel1 -asOrg Org2MSP


7 初始化容器

        启动 docker-compose.yaml 配置文件,生成容器:

docker-compose -f docker-compose.yaml up &

docker ps -a

        启动成功后截图如下:image4.png

        执行到此步骤已经完成了区块链搭建,orderer、peer、cli、couchdb 节点的启动,但是目前组织的 peer 节点还并没有处于通道之中,下一步就需要开始创建通道和将节点加入到通道中了。


8 创建通道

        在 peer0.org1.jiuxi.org 节点上创建通道 channel1,通道创建成功后,会生成通道区块文件 .block,并将自身组织加入到通道中:

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel create -o orderer.jiuxi.org:7050 -c channel1 -f /etc/hyperledger/configtx/channel1.tx

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel join -b channel1.block

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.jiuxi.org peer channel list


9 其他组织加入通道

        上面只是 org1 组的 peer0 节点加入了通道,还需要将org1 和 org2 组织剩余的 peer 节点依次加入通道:

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel join -b channel1.block

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.jiuxi.org peer channel list

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel join -b channel1.block

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org2.jiuxi.org peer channel list

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel fetch 0 channel1.block -o orderer.jiuxi.org:7050 -c channel1

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel join -b channel1.block

docker exec -e "CORE_PEER_LOCALMSPID=Org2MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org2.jiuxi.org peer channel list


10 小节

        上面的步骤已经实现了创建联盟、创建静态组织(org1, org2, org3),其中每个组织都有 2 个 peer 节点,而且又创建了 ID 为 channel1 的通道,并把 org1 和 org2 的 2 个 peer 依次加入到该通道中。作为特殊,并没有将组织 org3 加入到通道中(当然你也可以加入,这里留给读者独爽)。下面再看看配置文件,理解一下:image6.png

        JiuxiConsortium 就是自声明的联盟(联盟下静态定义了三个组织、JiuxiChannel 就是自声明的渠道(该渠道跟自声明联盟 Consortium 关联)。


11 深入

        当然,你可以使用 org3 再创建一个通道,然后将其自身 2 个节点加入这个新的通道。相信你在理解上面的知识后,下面的操作简直容易到爆。步骤如下:

11.1 生成新的通道交易文件

configtxgen -profile JiuxiChannel -outputCreateChannelTx ./config/channel2.tx -channelID channel2

11.2 生成 Anchor 节点 MSP 文件

configtxgen -profile JiuxiChannel -outputAnchorPeersUpdate ./config/channel2Org3MSPanchors.tx -channelID channel2 -asOrg Org3MSP

11.3 创建通道

        在 peer0.org3.jiuxi.org 节点上创建通道 channel2,并自身加入到通道 channel2:

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel create -o orderer.jiuxi.org:7050 -c channel2 -f /etc/hyperledger/configtx/channel2.tx

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel join -b channel2.block

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org3.jiuxi.org peer channel list

        在 peer1.org3.jiuxi.org 节点也需要加入到通道 channel2 中:

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel fetch 0 channel2.block -o orderer.jiuxi.org:7050 -c channel2

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org ls

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel join -b channel2.block

docker exec -e "CORE_PEER_LOCALMSPID=Org3MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org3.jiuxi.org peer channel list

        Since then, nine analyze with you after blasting hyperledger fabirc easily create static organization.

Guess you like

Origin blog.51cto.com/14625168/2470698