hyperledger fabric 2.4 installation and running test

Chapter 1 hyperledger fabric 2.4 installation



foreword

Recently, due to the pressure of scientific research, I am learning hyperledger fabric. I hope it can be practically applied to actual research in the future. Here I use it to record my learning process and detailed experimental steps. I hope these articles can help people who also study hyperLedger fabric.

Let me talk about the overall learning idea. The overall learning route here follows the official documentation, but some small details may be slightly modified.
It is recommended to read more source code here.
Official github address
https://github.com/hyperledger/fabric
Official document address
https://hyperledger-fabric.readthedocs.io/en/release-2.4
Some tutorials I read by myself
https://www.bilibili.com/video/BV1eb4y1o7xd?share_source=copy_web

  • install fabric
  • run test network
  • Run the chaincode of the official example

1. Prerequisites

First of all, you need a liunx computer or server. I am using a VMware virtual machine with two cores of 8G and a hard disk of 100G. The system is ubuntu 18.04.6-live-server.
You need to install dependent packages

  • git
  • curl
  • docker
  • docker-compose
  • Go
    note, please install docker, docker-compose and go from the official website, not through apt. (Pro test will affect the installation)
    docker
    https://docs.docker.com/engine/install/ubuntu/
    docker-compose
    https://docs.docker.com/compose/install/other/
    go
    https://go.dev/doc/install

2. Formal installation

1.git download code

First, enter the fabric project of github and download it using git.
The method provided by the official website is not recommended.
(curl -sSL https://bit.ly/2ysbOFE | bash -s This script actually exists on the fabric, so you don’t need to use this method to download it.)
We can download it ourselves, and then run the corresponding script.

git clone https://github.com/hyperledger/fabric.git
//查看所有分支
git branch -r
//切换到2.4分支
git checkout -b '分支名字'

The download may be very slow, you can consider downloading it yourself and copying it to the corresponding folder.

2. Example of fabric configuration

Enter the corresponding folder
and run the script
to do this, the command given in the official document actually does so many things.
curl -sSL https://bit.ly/2ysbOFE | bash -s

$ cd fabric/scripts/
$ ./bootstrap.sh

Note here that when running this file, there may be a problem that the download of the binary file is extremely slow and always fails.
At this time, you can enter the script file, directly download and decompress the binary file of the script to the fabric-samples folder, and two new folders (bin config) will be generated at this time.

At the same time, comment out the code for downloading the binary file directly in the script.
Then run the script again to pull the corresponding docker image.
After completion, the directory structure is as shown in the figure

Contents of the decompressed binary

After running the script, it looks like this

insert image description here

3. Run the test network

If everything above goes well, you can start running the test network here.

If it doesn't go well, don't be discouraged. A whole set of modified templates are prepared here, which can be copied directly. The link is as follows:
https://download.csdn.net/download/qq_40482198/85100644
But the docker image must be downloaded through the bootstrap.sh script, or run this script. (Remember to add the running permission)
Then prepare to test the network operation, and then just follow along.

To run the test network here, you need to give permission to the folder

 chmod -R 755 fabric-samples/

After granting permissions, enter the corresponding folder and run the script.

cd fabric-samples/test-network
//启动测试网络
sudo ./network.sh up
//关闭测试网络
sudo ./network.sh down

Summarize

For the rest of the operation of the test network, just refer to the official documentation, and it will run smoothly.
Even if the article is over here, here is just a pit I stepped on, to share with you, and I am still learning, welcome to learn and exchange.

Guess you like

Origin blog.csdn.net/qq_40482198/article/details/124059791