Consortium chain HyperLeader Fabric environment construction

1. Basic environment preparation

1. Apt source change

Open the URL: ubuntu | Mirror Station Use Help | Tsinghua University Open Source Software Mirror Station | Tsinghua Open Source Mirror , select the corresponding Ubuntu version number, and copy the content in the red box.

Execute the command: sudo gedit /etc/apt/sources.list, paste the above content to replace the content of the original file.

Execute the command: sudo apt update to update the mirror source.

2. Install docker

ns@ubuntu:~$ sudo apt install docker docker-compose

Configure the Docker boot self-start service:

ns@ubuntu:~$ sudo systemctl enable docker
Synchronizing state of docker.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable docker

Then, add the current user to the docker user group.

ns@ubuntu:~$ sudo usermod -a -G docker ns

3. Install golang

Go to the official Go documentation: Download and install - The Go Programming Language , select the Linux version and download it.

Execute sudo su to switch to the root user.

Execution command:

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz

Extract it to the specified directory.

Then configure the environment variable:

root@ubuntu:/usr/local# vim /etc/profile
export PATH=$PATH:/usr/local/go/bin            #写入该行语句
root@ubuntu:/usr/local# source /etc/profile    #更新配置

Note: In order to avoid executing the source statement every time, you can execute the vim ~/.bashrc command to write source /etc/profile into the file, save and exit, then you don’t need to execute the modified statement in the future, switch to the ns user and execute it again.

Check the go version: go version

2. Install Hyperledger Fabric

1. Install samples, docker

Enter URL: https://github.com/hyperledger/fabric/blob/main/scripts/bootstrap.sh

Copy the content of bootstrap.sh and create a new fabric directory and a file with the same name as bootstrap.sh in the Linux directory, paste the content in and save it.

root@ubuntu:/home/ns/Software# mkdir fabric
root@ubuntu:/home/ns/Software# cd fabric/
root@ubuntu:/home/ns/Software/fabric# vim bootstrap.sh

Note: For the convenience of testing, modify the true generation below to false.

Then grant permission:

chmod u+x bootstrap.sh

implement:

./bootstrap.sh

Next, the samples will be cloned locally:

root@ubuntu:/home/ns/Software/fabric# git clone https://github.com/hyperledger/fabric-samples.git
Cloning into 'fabric-samples'...
remote: Enumerating objects: 10607, done.
remote: Counting objects: 100% (348/348), done.
remote: Compressing objects: 100% (240/240), done.
remote: Total 10607 (delta 134), reused 228 (delta 85), pack-reused 10259
Receiving objects: 100% (10607/10607), 19.22 MiB | 822.00 KiB/s, done.
Resolving deltas: 100% (5659/5659), done.
Checking connectivity... done.
root@ubuntu:/home/ns/Software/fabric# ls
bootstrap.sh  fabric-samples

2. Install binaries

According to the version requirements of the bootstrap.sh file , go to the following two URLs to download the corresponding file:

https://github.com/hyperledger/fabric/releases

https://github.com/hyperledger/fabric-ca/releases

Unzip the file to the fabric/fabric-samples/ directory:

root@ubuntu:/home/ns/Software/packets# tar -zxvf hyperledger-fabric-linux-amd64-2.4.4.tar.gz -C ../fabric/fabric-samples/
bin/
bin/peer
bin/configtxlator
bin/configtxgen
bin/ledgerutil
bin/ccaas_builder/
bin/ccaas_builder/bin/
bin/ccaas_builder/bin/build
bin/ccaas_builder/bin/release
bin/ccaas_builder/bin/detect
bin/orderer
bin/cryptogen
bin/discover
bin/osnadmin
config/
config/core.yaml
config/orderer.yaml
config/configtx.yaml
root@ubuntu:/home/ns/Software/packets# tar -zxvf hyperledger-fabric-ca-linux-amd64-1.5.5.tar.gz -C ../fabric/fabric-samples/
bin/
bin/fabric-ca-client
bin/fabric-ca-server

3. Configure go agent

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

3. Test

root@ubuntu:/home/ns/Software/fabric/fabric-samples# cd test-network
root@ubuntu:/home/ns/Software/fabric/fabric-samples/test-network# ls
addOrg3  CHAINCODE_AS_A_SERVICE_TUTORIAL.md  compose  configtx  monitordocker.sh  network.sh  organizations  prometheus-grafana  README.md  scripts  setOrgEnv.sh  system-genesis-block
root@ubuntu:/home/ns/Software/fabric/fabric-samples/test-network# ./network.sh up

Then test fabcar

root@ubuntu:/home/ns/Software/fabric/fabric-samples# cd fabcar/
root@ubuntu:/home/ns/Software/fabric/fabric-samples/fabcar# ls
go  java  javascript  networkDown.sh  startFabric.sh  typescript
root@ubuntu:/home/ns/Software/fabric/fabric-samples/fabcar# ./startFabric.sh up

The execution is successful, and then follow the prompts.

root@ubuntu:/home/ns/Software/fabric/fabric-samples/fabcar# ls
go  java  javascript  networkDown.sh  startFabric.sh  typescript
root@ubuntu:/home/ns/Software/fabric/fabric-samples/fabcar# cd go
root@ubuntu:/home/ns/Software/fabric/fabric-samples/fabcar/go# ls
fabcar.go  go.mod  go.sum  runfabcar.sh

Test success!

Guess you like

Origin blog.csdn.net/py_123456/article/details/125790925