Configure the Hyperledger Fabric environment under Ubuntu

Install and configure the Hyperledger Fabric environment on the desktop of the win10 system

  • Install Ubuntu 16.04 dual system
    mirror download address: https://www.ubuntu.com/download/desktop
    Installation tutorial: http://www.cnblogs.com/Duane/p/5424218.html Note: The partition
    is set here and used as /bootStart the bootloader to retain the boot of the win10 system, pay attention to allocating a larger space (200M is not enough), otherwise it will lead apt-getto a series of problems such as inability to use.

  • cURL

    sudo apt-get install curl
  • Git

    sudo apt-get install git
  • Node.js

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
  • Docker
    here is the recommended method of downloading through the warehouse according to the official document https://docs.docker.com/install/linux/docker-ce/ubuntu/ . Note that the source used is the source.list that comes with Ubuntu16.04. If Changing the source will most likely fail the installation.
    First update aptthe package index:

    sudo apt-get update

    Install the relevant packages needed to use the repository:

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

    Install GPG key:

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

    Verify that the fingerprint of the key is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88:

        apt-key fingerprint 0EBFCD88

    install repository

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

    Update apt-getwarehouse information again and downloadDocker CE

    sudo apt-get update
    sudo apt-get install docker-ce

    The download is successful. For convenience, you can give the current user (username) dockerthe authority

    sudo usermod -aG docker username
  • Docker Compose
    needs to be installed before installation Python-pip. Execute the command from the githubdownload and increase the execute permission:

    curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose

    Download from DaoClound if it is slow

    curl -L https://get.daocloud.io/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
    sudo mv ~/docker-compose /usr/local/bin/docker-compose 
    chmod +x /usr/local/bin/docker-compose

  • The downloaded version of Goapt-get is too old, so wgetdownload the latest version from the official website and save the path as/usr/local

    sudo wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
    sudo tar -C /usr/local -xzf go1.9.linux-amd64.tar.gz

    After installation, you need to configure environment variables:

    vim ~/.profile

    Add the following, where GOROOTis the installation path and GOPATHis the working path:

    export GOROOT=/usr/local/go 
    export PATH=$PATH:$GOROOT/bin 
    export GOPATH=$HOME/go 
    export PATH=$PATH:$GOPATH/bin

    Put the go directory GOPATHunder the user directory ~, so you need to create the go directory:

    cd ~
    mkdir go
  • The fabric source code
    first needs to create the corresponding directory, and then clone fabricthe source code in it. Note here that fabricsome tools in the source code need to be compiled by Go language, so the source code should be cloned to the GOPATHpath, otherwise an error will occur when running the example.

    mkdir -p ~/go/src/github.com/hyperledger
    cd ~/go/src/github.com/hyperledger 
    git clone https://github.com/hyperledger/fabric.git

    Code can be switched to 1.0.0version

    cd fabric
    git checkout v1.0.0
  • Fabric image download
    Execute the script in the project to complete the batch download of docker images. The parameters can set the image version to be downloaded.

    cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/
    source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

    If the speed is slow, use the DaoCloudaccelerator:

    curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6e4616d7.m.daocloud.io
  • Test the Fabric network
    After entering the e2e_clidirectory, run the script to start the network:

    ./network_setup.sh up

    If you get an error showing missing ltdl.h, you need to execute:

    sudo apt install libtool libltdl-dev

    When executed, the script completes the following tasks:

    • Compile the tool cryptogenand run it crypto-config.yamlto generate the keys and certificates of network members based on the configuration file;

    • Generate genesis blocks and channel configuration transactions based on configuration files through configtxgentools ;configtx.yaml

    • Start containers based on docker-compose-cli.yamlconfiguration files, including 4Peer+1Orderer+1CLI;

    • When the CLI container is started, the script scripts/script.shin it will be automatically run to complete the tasks of creating a channel, adding nodes to the channel, installing Chaincode, instantiating and executing related Chaincode.

    Turn off the network after normal operation:

        ./network_setup.sh down

    Note: If an error occurs (for example, during the creation channelprocess), it needs to fabricbe executed in the directory make clean. At this time, the compilation information will be deleted and all images will be deleted. You need to execute step by step from the download image step, and finally succeed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325937376&siteId=291194637