Fabric SDK to build a test network (v1.4)

Preparatory

 Operating System: centOS 7
 Fabric Version: 1.4.4

  1. Already installed go, git
  2. It has been installed docker, docker-compose
  3. Binary tool (already installed Download )

  Download fabric-samples Source:

git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v1.4.4
mkdir bin  #建立二进制工具存放文件夹

  The downloaded binary tools, placed in the fabric-samples / bin path, be sure to download the tool binary version v1.4.4

Modify the configuration file

    The default fabric-samples / first-network organization will start a two to four nodes (excluding nodes CA), SDK in order to facilitate the testing, we make the following modifications:

vim byfn.sh

Modify COMPOSE_FILE = Docker-Compose-e2e.yaml (default docker-compose yaml), do not worry about without this document under the first-network directory, the startup script automatically creates docker-compose- according to the directory docker-compose-e2e-template.yaml e2e.yaml
Here Insert Picture Description
the following code (copy from docker-compose-ca.yaml) was added to the docker-compose-e2e-template.yaml

 ca0:
    image: hyperledger/fabric-ca:$IMAGE_TAG
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA1_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg1
    networks:
      - byfn

  ca1:
    image: hyperledger/fabric-ca:$IMAGE_TAG
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - FABRIC_CA_SERVER_TLS_ENABLED=false
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY
    ports:
      - "8054:7054"
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/CA2_PRIVATE_KEY -b admin:adminpw -d'
    volumes:
      - ./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2
    networks:
      - byfn

保存docker-compose-e2e-template.yaml

About Enable / Disable TLS

Enable / Disable TLS modify peer-base.yaml under the fabric-samples / first-network / base / directory

Orderer node:

- ORDERER_GENERCORE_PEER_TLS_ENABLED=true

Peer node:

- CORE_PEER_TLS_ENABLED=true

Script modifications

fabric-samples / first-network / scripts
execution script by default, the node will install three chain code, the following modifications:

if [ "${NO_CHAINCODE}" != "true" ]; then

        ## Install chaincode on peer0.org1 and peer0.org2
        echo "Installing chaincode on peer0.org1..."
        installChaincode 0 1
        echo "Install chaincode on peer0.org2..."
        installChaincode 0 2

        # Instantiate chaincode on peer0.org2
        echo "Instantiating chaincode on peer0.org2..."
        instantiateChaincode 0 2

        # Query chaincode on peer0.org1
        #echo "Querying chaincode on peer0.org1..."
        #chaincodeQuery 0 1 100

        # Invoke chaincode on peer0.org1 and peer0.org2
        #echo "Sending invoke transaction on peer0.org1 peer0.org2..."
        #chaincodeInvoke 0 1 0 2

        ## Install chaincode on peer0.org1
        echo "Installing chaincode on peer1.org1.."
        installChaincode 1 1
        ## Install chaincode on peer1.org2
        echo "Installing chaincode on peer1.org2..."
        installChaincode 1 2

        # Query on chaincode on peer1.org2, check if the result is 90
        #echo "Querying chaincode on peer1.org2..."
        #chaincodeQuery 1 2 90

fi

Here Insert Picture Description

Run the script

./byfn.sh up

File Reference

docker-compose-e2e-template.yaml (already changing for the better configuration)
Download: https: //pan.baidu.com/s/1qhXKi4iqIPtUj-bsDruUeA
extraction code: djrf


Other blog (constantly updated):
1. perform first network-test and manual hyperledger 1.4 Fabric
2. endorsement strategy 1.4 Faric
3. How Fabric Hyperledger ensure data privacy?
4. Fabric Hyperledger of private data (Private Data)
5. The Fabric enable CouchDB
6. The Fabric consensus mechanism

Published 13 original articles · won praise 0 · Views 2566

Guess you like

Origin blog.csdn.net/weixin_43839871/article/details/105351950