Fabric1.4 super detailed environment can't be built. Our blogger writes code upside down

Introduction: in the process of fabric environment configuration, it is normal to make mistakes. Every pit I stepped on is a stepping stone on our way to success. Of course, I hope you can cross the pit I stepped on

1. Manually configure Alibaba's download source

vim /etc/apt/sources.list

2. Enter the following to save and exit

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

3. Update download source

sudo apt-get update

4. Update all software

sudo apt-get upgrade

5. Switch to the home directory (if there is too much data base here, you should be able to contact the blogger)

cd $HOME

Download the latest version of go1.14.6.linux-amd64.tar.gz to Ubuntu at https://studygolang.com/dl

6. Unzip the compressed package to the / usr/local directory

tar -zxvf /home/wyg/go1.14.6.linux-amd64.tar.gz -C /usr/local

7. Configure environment variables for go

vim /etc/profile

Add the following, save and exit

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

8. Make environment variables effective

source /etc/profile

9. View version

go version

10. Install curl tool:

sudo apt-get install -y curl

11. Install GPG certificate

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

12. Write software source information

 sudo add-apt-repository "deb [arch=amd64]http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

13. Update the download source again: (note that there is a pit here. If an error is reported, open the sources.list file. There should be a space outside the brackets in the penultimate line. Add a space to save and exit)

sudo apt-get update

14. Install the latest version of Docker CE:

sudo apt-get -y install docker-ce

15. Add the current user to the docker user group:

sudo gpasswd -a $USER docker

16. Update docker user group:

newgrp docker

17. Verify docker:

docker -v 
docker ps -a

18. docker is set to startup and self startup:

sudo systemctl enable docker

19. Change the docker image library to the domestic address, and edit the / etc/docker/daemon.json file:

vim /etc/docker/daemon.json

20. Add the following

{"registry-mirrors": [ "https://registry.docker-cn.com", "https://cr.console.aliyun.com", "http://hub-mirror.c.163.com" ]}

21. Finally restart the service:

sudo systemctl daemon-reload 
sudo systemctl restart docker

22. Install docker compose

sudo apt install docker-compose

23. Inspection

docker-compose -v

24. Pull the fabric source code and create a folder first

cd $HOME 
mkdir -p go/src/github.com/hyperledger/ 
cd go/src/github.com/hyperledger/

25. Pull the source code of fabric from github:

git clone https://github.com/hyperledger/fabric.git

26. Switch to fabric version 1.4:

cd fabric/ 
git checkout release-1.4

27. Download docker images and fabric samples: (if there is an error here, pull the fabric source code again)

cd scripts/ 
./bootstrap.sh -b

28. Compile fabric source code to obtain relevant binary components (supported by golang language environment)

cd $GOPATH/src/github.com/hyperledger/fabric/ 
make release 
cd release/linux-amd64/bin 
ls

29. When executing. / bootstrap.sh -b just now, fabric samples will be generated in the scripts directory and placed in the home directory:

cd $HOME/go/src/github.com/hyperledger/fabric/scripts 
mv ./fabric-samples $HOME/

30. Create a new bin directory in the fabric smaples Directory:

cd $HOME/fabric-samples 
mkdir -p bin/

31. Copy the binary components of fabric to the bin directory of fabric samples:

mv $HOME/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/* $HOME/fabric-samples/bin/

32. Configure the fabric binary file into the environment variable:

vim /etc/profile

33. Add the following contents at the end of the document:

export PATH=$PATH:$HOME/fabric-samples/bin

34. Update documents

source /etc/profile

35. Restart the computer

36. Go to the first network directory under fabric samples:

cd $HOME/fabric-samples/first-network

37. Execute script:

./byfn.sh up

38. Operation results

This is success.

39. If the last step is wrong. Please enter the following command

./byfn.sh -m restart -c mychannel

This error may occur because you have tried E2E of fabric locally_ CLI, the first network of fabric samples starts the deployment test, and multiple tests are not normally closed during startup. The root cause is that there is an existing channel that prevents further execution (if it still hangs, continue to execute)

Although the road is endless and faraway, I still want to pursue the truth in the world.

It would be a great honor if I could help you

Tags: Linux Blockchain Docker Ubuntu

Posted on Sun, 10 Oct 2021 07:50:30 -0400 by Ice