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/boot
Start the bootloader to retain the boot of the win10 system, pay attention to allocating a larger space (200M is not enough), otherwise it will leadapt-get
to 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 updateapt
the 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-get
warehouse 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)
docker
the authoritysudo usermod -aG docker username
Docker Compose
needs to be installed before installationPython-pip
. Execute the command from thegithub
download 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, sowget
download 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
GOROOT
is the installation path andGOPATH
is 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
GOPATH
under 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 clonefabric
the source code in it. Note here thatfabric
some tools in the source code need to be compiled by Go language, so the source code should be cloned to theGOPATH
path, 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.0
versioncd 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
DaoCloud
accelerator:curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6e4616d7.m.daocloud.io
Test the Fabric network
After entering thee2e_cli
directory, 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
cryptogen
and run itcrypto-config.yaml
to 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
configtxgen
tools ;configtx.yaml
Start containers based on
docker-compose-cli.yaml
configuration files, including 4Peer+1Orderer+1CLI;When the CLI container is started, the script
scripts/script.sh
in 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
channel
process), it needs tofabric
be executed in the directorymake 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.