Hyperledger Fabric 2.2 version environment construction

Preface

Deployment environment: CentOS7.9
install the following tools in advance

  • git client
  • golang
  • docker
  • docker-compose
  • curl tool

The following is the version for personal use

  • git: 2.39.2
  • golang: 1.18.6
  • docker: 23.0.3
  • dockkekr-compose: v2.17.2
  • curl: 7.29.0

Official document reference link: jump link , different versions correspond to different official documents, please pay attention to the corresponding version of the document when referring , the docker version cannot be too low, the official requirement is 17.06.2-ce or later

Environment build

  • Download fabric source code
git clone https://github.com/hyperledger/fabric.git

Insert image description here

  • Go to the root directory of the source code and view the current branch.
cd fabric/
git branch
  • The source code you just downloaded is in the main branch by default.

Insert image description here

  • Switch to the branch corresponding to version 2.2
git checkout -b release-2.2 origin/release-2.2
git branch

Insert image description here

  • Enter the scripts folder of the fabric source code
cd scripts/
ls -l

You can see that there is a bootstrap.sh file
Insert image description here

  • Execute script to install
sh bootstrap.sh 
  • If you do not have executable permissions, use the following command to modify the permissions
chmod +x bootstrap.sh 

The execution script mainly does the following things:

  1. Download the source code of fabric-samples and switch to the corresponding version
  2. Download hyperledger-fabric-linux-amd64-2.2.10.tar.gz. After decompression, the bin and config directories will be generated.
  3. Download hyperledger-fabric-ca-linux-amd64-1.5.5.tar.gz and unzip it to generate the bin directory.
  4. Download the docker image related to hyperledger fabric and modify the image tag to latest
  • After the script is executed, the following content is mainly generated:
  1. fabric-samples source code
    Insert image description here
  2. Switching to fabric-samples will have two directories: bin and configInsert image description here
  3. docker image
    Insert image description here
  • Modify the executable permissions of the bin and config directories, enter the fabric-samples source code root directory, and execute the following command
chmod -R +x bin/
chmod -R +x config/
  • Enter the test-network directory of fabric-samples
cd test-network/
  • Start with the following command
sh network.sh up

Insert image description here

  • Using the docker command, you can see that the following containers are started:

Insert image description here

  • Create channels
./network.sh createChannel -c mychannel

The following content appears, indicating that the channel is successfully created. After the channel is successfully created, it is added to the node.
Insert image description here
Insert image description here

  • Deploy contract
./network.sh deployCC -ccn contract-name -ccv 1 -ccs 1 -ccp fabric-samples/asset-transfer-basic/chaincode-go -ccl go

The meanings of the parameters of the above command:
deployCC: This script comes with the source code, under fabric-samples/test-network/scripts/
-ccn: contract name
-ccv: contract version
-ccl: contract language, java, go, etc.
-ccs: the sequence of the contract, which must be an integer
-ccp: the path where the contract is located
Other parameters can be found in the fabric-samples/test-network/scripts/utils.sh script, which has a detailed description of each parameter .
For the deployed contract, you can define it yourself or use the official example. After the
Insert image description here
above command of fabric-samples/asset-transfer-basic is successfully executed, the official example will finally output the following results:
Insert image description here

  • If you want to shut down the network, execute the following command
./network.sh down

The above command will close and remove all started docker images.
Insert image description here

problem solved

  • During the contract deployment process: dial tcp 142.251.42.241:443: connect: connection refused
    Insert image description here
    Solution: Change the proxy address and execute the following command
    go env -w GOPROXY=https://goproxy.cn
    

Finish

The above is the construction of the Hyperledger Fabric 2.2 version environment. If you have any questions, please feel free to communicate.

Guess you like

Origin blog.csdn.net/LSW_JAVADP/article/details/130133656