[blockchain] Fabric v1.4.0 installation and deployment

Fabric v1.4.0 installation deployment

1, Preliminary preparation

number tool Version number
1 cURL Latest version (7.63.0)
2 Docker 17.06.2-ce and above
3 Docker Compose 1.14.0 and above
4 Go 1.11.x
  1. cURL latest installation

    The default curl does not support https. You need to configure the curl https protocol

    To install openssl:

    wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz
    sudo tar -zxvpf openssl-1.1.0g.tar.gz
    cd openssl-1.1.0g
    ./config    #Default installation path / usr/local/ssl
    make
    sudo make install
    #Create a soft connection
    sudo ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
    sudo ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
    #View version
    openssl version    
    
    # Download the latest version of cURL and extract it to the specified directory (take / opt directory as an example here)
    wget https://curl.haxx.se/download/curl-7.63.0.tar.gz
    # next step::::
    sudo tar xzvf curl-7.63.0.tar.gz -C /opt
    
    # Compile and install cURL
    cd /opt/curl-7.63.0
    ./configure -with-ssh=/usr/local/ssl
    make
    sudo make install
    

    Check whether the installation is successful by running curl --version. If the curl version is displayed, it means the installation is successful.

    If the curl command is not found, do the following.

    # Add / usr/local/lib to / etc/ld.so.conf
    sudo echo "/usr/local/lib" >> /etc/ld.so.conf
    
    # Execute the following order to make the added content effective
    sudo /sbin/ldconfig -v
    
  2. Docker and Docker Compose installation

    • Docker (Ref Get Docker CE for Ubuntu)
      Start installation

      Since the version of docker in apt official library may be older, uninstall the existing version first:

      sudo apt-get remove docker docker-engine docker-ce docker.io
      

      Update apt package index:

      sudo apt-get update
      

      Install the package to allow apt to use the repository over HTTPS:

      sudo apt-get install \
      apt-transport-https \
      ca-certificates \
      curl \
      gnupg-agent \
      software-properties-common
      

      Add the official GPG key of Docker:

      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      

      Use the following command to set up the stable Repository:

      sudo add-apt-repository \
      "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) \
      stable"
      

      Update the apt package index again:

      sudo apt-get update
      

      Install the latest version of Docker CE:

      sudo apt-get install -y docker-ce
      

      Verify the docker to see if the docker service is started:

      systemctl status docker
      

      If not, start the docker service:

      sudo systemctl start docker
      

      Classic hello world:

      sudo docker run hello-world
      
    • Docker Compose

      # Download Docker Compose binary
      # ! download is very slow, and then the download speed is 0
      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
      # Standby: curl - L https://get.daocloud.io/docker/compose/releases/download/1.23.2/docker-compose - ` uname - s ` - ` uname - M ` > / usr / local / bin / docker compose 
      sudo chmod +x /usr/local/bin/docker-compose
      
  3. 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
    
    # Create $GOPATH
    mkdir /home/ubuntu
    mkdir /home/ubuntu/gopath
    # Edit the goenvset.sh file
    vim 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 the existing goenvset.sh to write the corresponding environment variable to / etc/profile
    # Change the permissions of goenvset.sh to make it executable
    sudo chmod 705 goenvset.sh     
    # Execute the goenvset.sh script 
    sudo ./goenvset.sh				
    
    # Make environment variables effective
    source /etc/profile
    

2, Fabric online installation

  1. Download fabric samples to the $GOPATH/src/github.com/hyperledger directory

    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 you install through the bootstrap.sh script due to network problems, there may be errors. You can install manually at this time. The installation steps are as follows:

    • Install the specified version of the Hyperledger Fabric platform specific binaries and configuration files into the bin and config directories of fabric samples

      #! the reason for this step's failure is the network, but it can't be downloaded by using the following wget, so download it from Baidu online disk and transfer it to ubuntu
      # Download link of two compressed files: https://download.csdn.net/download/qq_/12154763 
      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
      
    • Download relevant Docker images

      # 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
      ------------------------------------------
      docker pull hyperledger/fabric-orderer:1.4.0
      docker tag hyperledger/fabric-orderer:1.4.0 hyperledger/fabric-orderer:latest
      ------------------------------------------
      docker pull hyperledger/fabric-ccenv:1.4.0
      docker tag hyperledger/fabric-ccenv:1.4.0 hyperledger/fabric-ccenv:latest
      ------------------------------------------
      docker pull hyperledger/fabric-tools:1.4.0
      docker tag hyperledger/fabric-tools:1.4.0 hyperledger/fabric-tools: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
      ------------------------------------------
      docker pull hyperledger/fabric-kafka:0.4.14
      docker tag hyperledger/fabric-kafka:0.4.14 hyperledger/fabric-kafka:latest
      ------------------------------------------
      docker pull hyperledger/fabric-zookeeper:0.4.14
      docker tag hyperledger/fabric-zookeeper:0.4.14 hyperledger/fabric-zookeeper: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
      
    • (optional) backup and recovery of image

      # Store the above Docker image in the fabric images file
      docker save $(docker images | grep fabric | grep latest | awk '{print $1}') -o fabric-images
      # If multi machine deployment is required, distribute it to other machines with the following command
      scp fabric-images ubuntu@192.168.70.21:~
      # Load the above image on 192.168.70.21
      docker load -o fabric-images
      
  3. Test by running the Build your first network sample

    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, Org1MSPanchor.tx, Org2MSPanchor.tx) and chaincode image
    ./byfn.sh down
    

    Supplement:

    # Problems encountered by Huawei cloud Ubuntu 16.4 in the implementation of up:
    Error: failed to create deliver client: orderer client failed to connect
    to orderer.example.com:7050: failed to create new connection: context 
    deadline exceeded
    # terms of settlement:
    vim /etc/resolv.conf
    # Just comment out the options line
    
  4. Summarize the downloaded fabric related installation files (including fabric samples, hyperledger-fabric-linux-amd64-1.4.0.tar.gz, hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz and fabric images) into a folder and compress them to generate fabric-offline-install.tar.gz

3, Fabric offline installation

This section mainly introduces how to install Fabric offline through fabric-offline-install.tar.gz mentioned in Fabric installation chapter.

tar xzvf fabric-offline-install.tar.gz
unzip xzvf fabric-offline-install.tar.gz
cd fabric-offline-install
cp -rf fabric-samples $GOPATH/src/github.com/hyperledger

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/
sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
source /etc/profile

docker load -i fabric-images

Reference material

  1. Hyperledger Fabric release-1.4 official document

Using couchdb database

cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
./byfn.sh up -s couchdb
./byfn.sh -m down

Data structure analysis of smart contract block

Enter the docker container:

docker exec -it cli bash

View block information

peer channel getinfo -c mychannel
84 original articles published, 23 praised, 20000 visitors+
Private letter follow

Keywords: Docker sudo curl Linux

Added by angus930 on Sun, 23 Feb 2020 08:01:02 +0200