Quickly build fabric2.0 networks based on official Fabric-samples.

Resources to prepare

Binary tool

  1. Get fabric source code

    git clone https://github.com/hyperledger/fabric.git
    Copy the code
  2. Switch to the 2.0.0 branch

    CD $GOPATH/src/github.com/hyperledger/fabric git checkout v2.0.0Copy the code
  3. Compiling binary tools (additional tools need to be installed)

    Making all-release in the root directory generates a release folder

    make all-release
    Copy the code

The deployment environment

Create centos7 virtual machine based on Vagrant

  1. The bootstrap.sh script file is used to initialize the VM environment.

    #! /usr/bin/bashSudo su echo "nameserver 8.8.8.8" >> /etc/resolv.conf sleep 3s yum install -y epel-release yum install -y vim yum install -y golang yum remove docker docker-common docker-selinux docker-engine yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum makecache fast yum -y install docker-ce yum -y install docker-compose service docker start mkdir -p /etc/docker echo {\"registry-mirrors\": [\"https://8w1wqmsz.mirror.aliyuncs.com\"]} > /etc/docker/daemon.json service docker restart echo "export GOPROXY=https://goproxy.io" >> ~/.bashrcCopy the code
  2. Vagrantfile Create file of the VM.

    Vagrant.configure("2") do |config|
      config.vm.box = "centos/7"
      config.vm.provider "virtualbox" do |vb|
         vb.memory = "2048"
         vb.cpus = 4
      end
      config.vm.provision "shell".path: "bootstrap.sh"
    end
    Copy the code

Deployment of resources

  1. Create the Resource directory and copy the Fabric-samples project into it.
  2. Create the resource/bin directory and copy the configtxlator, ConfigtxGen, and Cryptogen files that you compiled for the Linux version.

The complete result table is as follows:

.Bass Exercises ── Bass Exercises ── bass Exercises ── fabric exercisesCopy the code

Deploying a Fabric Network

  1. Starting a VM

    vagrant up
    Copy the code
  2. Switch to user root on the VM

    vagrant ssh
    sudo su
    Copy the code
  3. Go to the fabric-samples directory

    cd /vagrant/resource/fabric-samples
    Copy the code
  4. Switch to v2.0.0

    Git checkout v2.0.0Copy the code
  5. Copy binary tool

    cp .. /bin/* first-network/Copy the code
  6. Go to the first-network directory and change the image version

    cd first-network/
    #Example Change the version number to 2.0.0
    vim byfn.sh
    Copy the code

  7. Starting a Fabric Network

    ./byfn.sh up
    Copy the code
  8. After a few minutes, you can see the following symbol, that is, the Fabric network has started successfully.