Summary of fabric 1.4 environment construction
1. Install dependent tools
1.1 install Git
sudo apt update sudo apt install git
1.2 install Curl
sudo apt install curl
1.3 installing docker
//To check whether Docker has been installed on the system: docker --version //Not installed. Use the following command to install the latest version of Docker: sudo apt install docker.io //After installation, check the version. If the following words appear, the installation is successful: docker --version Docker version 18.09.7, build 2d0083d //!! If it is set to a non root user, you can also execute docker. You need to add ordinary users to the docker group: sudo usermod -aG docker Your user name (restart takes effect)
1.4 install docker compose
//Check whether docker compose has been installed on the system: docker-compose --version //Not installed. Use the following command to install the docker compose tool: sudo apt install docker-compose //After installation, check the version. If the following words appear, the installation is successful: docker-compose --version docker-compose version 1.17.1, build unknown //Allow other users to execute compose related commands: sudo chmod +x /usr/share/doc/docker-compose
1.5 install GO
Uninstall old version
sudo apt-get remove golang-go sudo apt-get remove --auto-remove golang-go
download
wget https://studygolang.com/dl/golang/go1.12.5.linux-amd64.tar.gz tar -zxvf go1.12.5.linux-amd64.tar.gz sudo mv go /usr/local/
Configuration path
vim .bashrc //vim is not familiar with using gedit export GOROOT=/usr/local/go # Installation directory. export GOPATH=$HOME/go # work environment export GOBIN=$GOPATH/bin # Storage of executable documents export PATH=$GOPATH:$GOBIN:$GOROOT/bin:$PATH # Add toPATHRoute
test
go version
2. Pull fabric source code
Create an empty directory and enter it:
$ mkdir -p ~/go/src/github.com/hyperledger $ cd ~/go/src/github.com/hyperledger
Pull the source code of fabric through the following command:
$ git clone https://github.com/hyperledger/fabric.git
To view and switch the current branch, I pull v 1.4.0:
$ cd ./fabric $ git branch -a $ git checkout v1.4.0
3. Pull fabric samples
Method 1: run. / bootstrap.sh directly, but if the network speed is slow, the timeout will fail.
bash bootstrap.sh
Method 2: analyze the bootstrap.sh script and execute it manually (valid for the parent book)
3.2.1 clone the source code (sampling in the source code)
$ git clone https://github.com/hyperledger/fabric-samples.git $ cd ./fabric-samples $ git branch -a $ git checkout v1.4.0```
3.2.2 download executable binary file (binaries install step in source code)
Download the binary file from the following two links. We can directly visit this page and choose the corresponding version to download. Here we choose linux-amd64-1.4.0.
https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric
https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca
The hyperledger-fabric-linux-amd64-1.4.0.tar package contains two folders: bin and config. The hyperledger-fabric-ca-linux-amd64-1.4.0.tar package contains a bin folder. The binary files in the two bin folders are summarized in a bin folder. Finally, copy the bin and config folders to the fabric samples folder.
3.2.3 download Docker image
Since the first two steps have been completed, you need to delete the Samplesinstall and binaries install steps in bootstrap.sh!!!!
Execute the bootstrap.sh script:
$ ./bootstrap.sh
4. Set environment variables
The default path for binary files needed to start the fabric samples / first network network is fabric samples / bin, which can be added to the environment variable:
$ sudo gedit /etc/profile //At the end of the profile file, add: export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$HOME/go/src/github.com/hyperledger/fabric-samples/bin //Use the source command to make the file effective: $ source /etc/profile //Verify whether the environment variable is successful (if not, restart the virtual machine): $ fabric-ca-client version fabric-ca-client: Version: 1.4.0 Go version: go1.11.5 OS/Arch: linux/amd64
5. Test network
5.1 starting the network
$ cd ./fabric-samples/first-network/ $ ./byfn.sh up
You can view the startup status of the node through the docker ps command.
5.2 shut down the network
./byfn.sh down