1.1 Environment Resources

Fabric Recommends that the operating system be Linux or Mac. In this document, the installation environment is an Ubuntu VM and the memory is set to 4 GB. The system installation package used in this document is Ubuntu-20.04-live-server-amd64. iso. For how to install the VM, please search for it on your own.

1.2 Dependent Installation

This section describes how to install software for the Fabric platform after servers or VMS have been prepared. These include:

  • Curl: Download tool, version latest

  • Git: code cloning tool latest

  • Golang: Many components of Fabric are developed based on Go programming, version 1.14.2

  • Jq: JSON parser, version latest

  • Docker: Container, version 18.06.3- CE

  • Docker Compose: Container management tool, version 1.25.5

The Ubuntu system provides the software installation command apt-get. Before installing the software, update the resource list to ensure that the latest software version is downloaded. Run the following command to update the resource list:

sudo apt update -y --fix-missing
Copy the code

1.2.1 the curl is installed

Run the following command to install curl:

sudo apt install -y curl
Copy the code

To view the installation result, run the following command:

curl -V
Copy the code

If the version number and release time are displayed, the installation is successful, as shown in the following figure.

1.2.2 git installed

Run the following command to install Git:

sudo apt install -y git
Copy the code

To view the installation result, run the following command:

git version
Copy the code

If the version information is displayed, the installation is successful, as shown in the following figure.

1.2.3 jq installation

Run the following command to install the JQ:

sudo apt install -y jq
Copy the code

To view the installation result, run the following command:

jq --version
Copy the code

If the version information is displayed, the installation is successful, as shown in the following figure.

1.2.4 Golang installation and configuration

Golang is easy to install. You can download and decompress the package from a shared server. Run the following command:

Unzip the installation to /usr/localSudo tar -xvf go1.14.2.linux-amd64.tar.gz -c /usr/local	
Copy the code

To create the Go working directory, run the following command:

sudo mkdir -p /opt/goworkspace/bin	
sudo mkdir -p /opt/goworkspace/src	
sudo mkdir -p /opt/goworkspace/pkg 
Copy the code

Set environment variables related to Go:

Set environment variables
sudo vim /etc/profile
# append the following to the end of the file
export GOROOT=/usr/local/go
export GOPATH=/opt/goworkspace
export PATH=$GOROOT/bin:$PATH
# Enable environment variables
source /etc/profile
Copy the code

Go set proxy: Because some of the Go dependencies are blocked, the proxy needs to be set.

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
Copy the code

To view the installation result, run the following command:

go version
Copy the code

If the version information is displayed, the installation is successful, as shown in the following figure.

1.2.5 Docker installation

Before installing Docker online, make the following preparations:

  1. To install the HTTPS access dependency package, run the following command:
sudo apt-get install apt-transport-https ca-certificates software-properties-common
Copy the code
  1. Add docker official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Copy the code
  1. Docker Stable Repository:
# backup/etc/apt/sources. The list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# edit/etc/apt/sources. The list
sudo vim /etc/apt/sources.list
Add the following to the end of the file
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
Copy the code
# update source
sudo apt-get update 
Copy the code
  1. Install the Docker:

Install docker-CE (Docker community edition) by using the following command:

Install the latest version by default
sudo apt-get install -y docker-ce
Copy the code

To install the specified version, view the version list and run the following command:

sudo apt-cache madison docker-ce
Copy the code

The result is as follows:

In accordance with the version requirements, this document specifies to install the docker-ce 18.06.3~ce~3-0~ Ubuntu, run the following command:

Sudo apt-get install -y docker-ce=18.06.3~ce~3-0~ UbuntuCopy the code

To view the installation result, run the following command:

docker -v
Copy the code

If the version information is displayed, the installation is successful, as shown in the following figure.

1.2.6 Docker Image Acceleration Settings

Create a daemon.json file in /etc/docker and write the following to it:

{

"registry-mirrors": ["https://rl4uepop.mirror.aliyuncs.com"]
Copy the code

}

Reload the configuration file and restart the Docker, run the following command:

sudo systemctl daemon-reload
sudo systemctl restart docker
Copy the code

1.2.7 Docker Compose installation

Docker Compose is an application tool for defining and running multiple Docker containers. Docker Compose can manage Docker containers efficiently and easily.

# downloadSudo curl -l https://github.com/docker/compose/releases/download/1.25.5/docker-compose- ` uname-s`-`uname -m` -o /usr/local/bin/docker-compose
# set permissions
chmod +x /usr/local/bin/docker-compose
Check whether the installation is successful
docker-compose -v
Copy the code

If the version information is displayed, the installation is successful, as shown in the following figure.

In this section, the docker-compose download process is relatively long. You can obtain the downloaded docker-compose file from the shared file system.

In addition, docker-compose can be downloaded from the domestic image and run the following command:

Sudo curl -l https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose- ` uname-s`-`uname -m` -o /usr/local/bin/docker-compose
Copy the code

1.3 eggs

The above dependency installation requires readers to install it step by step. In order to facilitate readers to complete the dependency installation, this article provides one-click installation script, which needs root user (permission) to execute. It may take several minutes to download the Go installation package. If you cannot accept it, you can pull the Go installation package from the Internet and install it yourself. After the installation and configuration is complete, the script will automatically detect and skip the go installation.

The script content is as follows:

#! /bin/bash
# echo print with color
function echoColor()
{
	echo -e "\033[35;1mThe $1\033[0m"
}

# update os
function updateOS()
{
	echoColor "Updating system to newest version"
	sudo apt-get update -y --fix-missing
	echo
}

# install docker precondition
function installPreDependence()
{
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
	echoColor "Start install dependency items, please wait......."
	
	# install git
	echoColor "Start Install git"
	apt-get install -y git

	# install cURL
	echoColor "Start Install curl"
	apt-get install curl -y

	# installation jq
	echoColor "Start Install jq"
	apt-get install jq -y

	echoColor "Finish installed dependency items."
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
}

# Golang installation
function installGolang()
{
    echo
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
	echoColor "Start install Golang,please wait......."
	
	if [ -d ${GOROOT} ];then
		source /etc/profile
        go version
        return;
    fi

	# download Go
	echo
	echoColor "Download Golang package and unpack it"Sudo curl - O https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz tar - XVF go1.14.2. Linux - amd64. Tar. Gzecho
	echoColor "Move it to /usr/local/go"
	mv go /usr/local/go

	Set environment variables
	echoColor "Create GOPATH"
	mkdir -p /opt/goworkspace/bin
	mkdir -p /opt/goworkspace/src
	mkdir -p /opt/goworkspace/pkg

	echo
	echoColor "Set golang environment"
	echo >> /etc/profile
    echo "#set golang env" >> /etc/profile

    echo "export GOROOT=/usr/local/go" >> /etc/profile
    echo "export GOPATH=/opt/goworkspace" >> /etc/profile
    echo "export PATH=$PATH:$GOROOT/bin" >> /etc/profile
    source /etc/profile

	echo
	echoColor "Set goproxy"
	go env -w GO111MODULE=on
	go env -w GOPROXY=https://goproxy.cn,direct

	go version
	echo

	echo
	echoColor "Finish install Golang "
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
}

Docker compose and Docker compose
function installDocker()
{	
	echo
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
	echoColor "Start install docker,please wait......."
	
	if[!-f "/usr/bin/docker" ];then
		echoColor "Install dependency items for https"
		sudo apt-get install apt-transport-https ca-certificates software-properties-common
		
		echoColor "Set stable repo for docker"
		curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
		sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
		sudo echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" >> /etc/apt/sources.list
		sudo apt-get update

		echoColor "Install docker and start service"Sudo apt-get install -y docker-ce=18.06.3~ce~3-0~ UbuntuechoColor "Set accelerate registry-mirrors"
		sudo mkdir -p /etc/docker
		sudo tee /etc/docker/daemon.json <<-'EOF'
	{
	  "registry-mirrors": ["https://rl4uepop.mirror.aliyuncs.com"]
	}
	EOF
		sudo systemctl daemon-reload
		sudo systemctl restart docker
	fi
	docker -v

	echo
	if[!-f "/usr/local/bin/docker-compose" ];then
		echoColor "Install docker-compose"Sudo curl -l https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose- ` uname-s`-`uname -m` -o /usr/local/bin/docker-compose
		sudo chmod +x /usr/local/bin/docker-compose
    fi
	docker-compose -v

	echoColor "Finish install docker and docker-compose!"
	echoColor "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
	echo
}

echoColor "____ _____ _____ _____"
echoColor "/ ___ | | _ _ | / \ | _ \ | _ _ |"
echoColor "\ ___ \ | | / _ \ | | _) | | |"
echoColor "___) | | | / ___ \ | _ < | |"
echoColor There comes "| | / _ | / _ \ _ \ | _ | \ _ \ | _ |"

updateOS
installPreDependence
installGolang
installDocker

echoColor "_____ __ ____"
echoColor There comes "| | | \ | | | _ \"
echoColor "| | - | \ | | | | | |"
echoColor "| | ___ | | \ | | | _ | |"
echoColor "| _____ | | _ | \ _ | | ____ /"
Copy the code

  • Author: Xiaohui249
  • This paper links: javatech. Wang/index. PHP/a…
  • Edition © all reprinted must be in the form of a link to indicate the author and the original source

This article is published by OpenWrite, a blogging tool platform