Hyperledger fabric 1.4 standalone installation tutorial

Time:2020-6-15

Fabric v1.4.0 stand-alone installation deployment

1、 Preliminary preparation

The installation of fabric depends on the docker environment, so the prerequisite is to install docker, and some software versions are also required as follows:

  • Curl requires the latest version,
  • Docker version above 17.06
  • Docker-compose 1.14.0 and above
  • Go version 1.11 and above

The operating system installed in this document is Ubuntu. If it is CentOS, please switch to CentOS for the preparation of the basic environment. For video learning, please refer to the video tutorial

  1. Curl latest installation

    #Download and unzip the latest version of curl
    wgethttps://curl.haxx.se/download/curl-7.65.3.tar.xz
    sudo tar xzvf curl-7.63.0.tar.gz -C /home
       #Compile and install curl
    cd /home/curl-7.65.3
    ./configure
    make
    sudo make install

    By runningcurl --versionCheck to see if the installation was successful.

  2. Docker and docker compose installation

    • Docker

Uninstall the possible older version first

sudo apt-get remove docker docker-engine docker.io containerd runc
   sudo apt-get update 
sudo apt-get install  apt-transport-https  ca-certificates gnupg-agent software- properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu
   $(lsb_release -cs) stable"
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
Docker version to see if it is successful
 ```
    • Docker Compose

      #Download docker compose binary
      sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      
      sudo chmod +x /usr/local/bin/docker-compose
    1. Go installation

      #Download go1.11.linux-amd64 tar.gz And extract it to the specified directory (here, / usr / local)
      wget https://studygolang.com/dl/golang/go1.11.linux-amd64.tar.gz
      tar xzvf go1.11.linux-amd64.tar.gz -C /usr/local
      
      goenvset.sh The contents of the document are as follows:
      
      cat >> /etc/profile << EOF
      export GOROOT=/usr/local/go
      export GOARCH=amd64
      export GOOS=linux
      export GOPATH=/home/ubuntu/gopath
      export GOBIN=$GOPATH/bin
      export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
      EOF
      
      #Execute existing goenvset.sh Write the corresponding environment variables to / etc / profile
      sudo chmod 705  goenvset.sh       #Change goenvset.sh To make it executable
      sudo ./ goenvset.sh                 #Execution goenvset.sh script
      
      #Make environment variables effective
      source /etc/profile

    2、 Fabric installation

    1. Download fabric samples to$GOPATH/src/github.com/hyperledgerIn the catalog

      mkdir -p $GOPATH/src/github.com/hyperledger
      cd $GOPATH/src/github.com/hyperledger
      #Clone the fabric samples project and switch to v1.4tag
      git clone https://github.com/hyperledger/fabric-samples.git
      cd fabric-samples
      git checkout -b sample v1.4.0
    2. Install fabric binaries and fabric related docker images

      cd $GOPATH/src/github.com/hyperledger/fabric-samples/scripts
      #Install fabric, fabric Ca, and third-party docker images (/ bootstrap.sh  <fabric> <fabric-ca> <thirdparty>)
      ./bootstrap.sh 1.4.0 1.4.0 0.4.14

      It is worth noting that if the packages are not downloaded successfully due to network problems, manual installation is required at this time. The installation steps are as follows:
      If the following binaries are not downloaded, execute the command manually

      wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz
      wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.0/hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz
      
      tar xzvf hyperledger-fabric-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
      tar xzvf hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
      
      #Write environment variables to / etc / profile
      sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
      
      #Make environment variables effective
      source /etc/profile

    If the docker related image is not downloaded, execute the following command to download the related image.

    #Download fabric related images (fabric peer, fabric orderer, fabric ccenv, fabric tools). Take fabric peer image as an example, and other images are the same
    docker pull hyperledger/fabric-peer:1.4.0
    docker tag hyperledger/fabric-peer:1.4.0 hyperledger/fabric-peer:latest
    
    #Download the third-party image of fabric (fabric CouchDB, fabric Kafka, fabric zookeeper). Take fabric CouchDB as an example, and other images are the same
    docker pull hyperledger/fabric-couchdb:0.4.14
    docker tag hyperledger/fabric-couchdb:0.4.14 hyperledger/fabric-couchdb:latest
    
    #Download fabric CA image
    docker pull hyperledger/fabric-ca:1.4.0
    docker tag hyperledger/fabric-ca:1.4.0 hyperledger/fabric-ca:latest
    1. By runningBuild your first networkSamples to test

      cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
      #Compile the chain code developed by golang and start the relevant container
      ./byfn.sh up
      
      ./byfn.sh up -l node
      
      ./byfn.sh up -o kafka
      
      #Stop all containers in the first-Network, delete the crypto material and 4 artifacts( genesis.block , mychannel.block 、Org1 MSPanchor.tx 、Org2 MSPanchor.tx )And chaincode image
      ./byfn.sh down

    reference material

    1. Hyperledger fabric release-1.4 official manual
    2. Get docker CE for Ubuntu