Hyperledger Fabric environment configuration

Hyperledger Fabric environment configuration, taking Ubuntu16.04 as an example

Note: If there is any infringement, please contact the author to delete. If reproduced, please indicate the source. When using this tutorial, please check whether tools such as git, curl, and python are installed in advance. If you don't know which tools to use, you can install the tools according to the error message during the installation process.

The construction of the Hyperledger Fabric environment under Linux is mainly divided into the following steps:

1. Install linux virtual machine or physical machine

The installation method of the virtual machine is not described here. If necessary, it is recommended to search for keywords such as VmWare Ubuntu or VmWare Centos . (Note, any virtual machine is fine)

2. Install docker

You can refer to the link https://www.runoob.com/docker/ubuntu-docker-install.html

Directly use the following command to install directly, and the command does not distinguish between directories

$ sudo curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

3. Install docker-compose

You can refer to the link https://docs.docker.com/compose/install/

Commands can be entered in any directory, since directories are specified in the following commands. The current docker-compose version below is 1.29.2. For other versions, please refer to the link above.

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

4. Install go

You can refer to the link https://www.runoob.com/go/go-environment.html

(1) Download the linux installation package from https://golang.google.cn/dl/ , and upload the installation package to the linux system through the ftp tool, or download it directly through the linux built-in browser.

(2) Unzip the downloaded binary file to the /usr/local directory, such as

tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz

(3) Add the /usr/local/go/bin directory to the PATH environment variable:

Temporary effective method:

export PATH=$PATH:/usr/local/go/bin

Permanent method:

Edit ~/.bash_profile or /etc/profile (different systems modify files differently, such as ubuntu modifies /etc/profile), and add the following command to the end of the file

export PATH=$PATH:/usr/local/go/bin

After adding to ~/.bash_profile or /etc/profile, it needs to be executed (the files modified by different systems are different, such as ubuntu modifying /etc/profile):

source ~/.bash_profile

or

source /etc/profile

5. Download fabric/fabric-ca related docker images (you can directly jump to step 9)

ARCH=x86_64
IMAGE_TAG=2.4.2
CA_VERSION=1.5.2
BASE_IMAGE_VERSION=2.4.2

# pull images
docker pull hyperledger/fabric-peer:$IMAGE_TAG \
&& docker pull hyperledger/fabric-orderer:$IMAGE_TAG \
&& docker pull hyperledger/fabric-ca:$CA_VERSION \
&& docker pull hyperledger/fabric-tools:$IMAGE_TAG \
&& docker pull hyperledger/fabric-ccenv:$IMAGE_TAG \
&& docker pull hyperledger/fabric-baseos:$BASE_IMAGE_VERSION

# add fabric-peer fabric-orderer fabric-ca fabric-tools
docker tag  hyperledger/fabric-peer:$IMAGE_TAG hyperledger/fabric-peer \
docker tag  hyperledger/fabric-orderer:$IMAGE_TAG hyperledger/fabric-orderer \
docker tag  hyperledger/fabric-ca:$CA_VERSION hyperledger/fabric-ca \
docker tag  hyperledger/fabric-tools:$IMAGE_TAG hyperledger/fabric-tools

insert image description here

Figure 5-1 images obtained by docker pull

6. Download fabric-sample (you can jump directly to step 9)

Download link: https://github.com/hyperledger/fabric-samples/

7. Download the fabric release package, and put bin/config into the fabric-sample folder after decompression

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

insert image description here

Figure 7-1 Contents of the fabric release bin folder

insert image description here

Figure 7-2 Contents of the fabric release config folder

8. Download the fabric-ca release package, which contains fabric-ca-client and fabric-ca-server in the bin folder, which needs to be copied to the bin folder in step 7

Download link: https://github.com/hyperledger/fabric-ca/releases
insert image description here

Figure 8-1 Contents of the fabric-ca bin folder

Final directory structure and specific files
insert image description here

Figure 8-2 Specific files in the /root/fabric-samples directory

insert image description here

Figure 8-3 Specific files in the /root/fabric-samples/bin directory

insert image description here

Figure 8-4 Specific files in the /root/fabric-samples/config directory

9. Steps 5-8 can be done directly through the script.

Can be installed directly using official scripts and commands

(1) Fabric and Fabric CA versions can be specified

Format

curl -sSL https://bit.ly/2ysbOFE | bash -s -- <fabric_version> <fabric-ca_version>

Example, specifying Fabric v2.2.5 and Fabric CA v1.5.2 :

curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.2.5 1.5.2

If the above link is not available, you can use the following link (https://bit.ly/2ysbOFE is replaced by https://raw.githubusercontent.com/hyperledger/fabric/release-2.2/scripts/bootstrap.sh)

curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-2.2/scripts/bootstrap.sh| bash -s -- 2.2.5 1.5.2

If you do not specify a version, you can use the following command to install the latest version

curl -sSL https://bit.ly/2ysbOFE | bash -s

If the link doesn't work, replace http://bit.ly/2ysbOFE with https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh

curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s

Pay attention to distinguish the above two long links, the first is the specified version release-2.2 , and the latter is master .

use:

Enter fabric-sample/test-network, execute

$./network.sh down
$./network.sh up

Note that the 1.x version sample uses the first-network/byfn.sh script, and the 2.x version uses the test-network/network.sh script.

insert image description here

Figure 9-1 ./network.sh up interface and started docker images

Reference tutorial:

https://www.freesion.com/article/33671040877/

https://learnblockchain.cn/books/enterprise/

https://blog.csdn.net/wxid2798226/article/details/81709837

https://blog.csdn.net/so5418418/article/details/78355868

fabric-ca tutorial:

http://www.manongjc.com/detail/15-zqgzneucconismy.html

https://hyperledger-fabric-ca.readthedocs.io/en/latest/users-guide.html

Common commands:

登录服务器:
ssh [email protected] 使用ssh命令以root用户登录ip为192.168.x.x的linux服务器

查看ip地址:
ifconfig
ip addr

目录相关命令:
cd xxxx 进入名字为xxxx的目录
cd ../ 跳转到当前目录的上一层目录
cd ../../ 跳转到当前目录的上两层目录
cd - 跳转到前一次访问的目录
pwd 查看当前所在目录的路径

文件操作:
vim xxx 使用vim命令打开xxx文件
i 进入文件后对文件开启编辑模式
esc键 退出编辑模式
:wq 保存文件并退出
:q 退出
:q! 强制退出

文件权限操作:
chmod a+x xxxx 为文件xxxx添加可执行权限

用户切换:
su 如果当前用户不是超级用户,可使用该命令切换到超级用户
su xxx 切换到名为xxx的用户

Guess you like

Origin blog.csdn.net/u010571114/article/details/123882414