Table of contents
1. Use Docker to quickly run Fabric network
1.1. Operating system installation
1.2. Install go language environment
1.3. Install dependency packages
2. Start running test-network to test the network
3. Run first-network (end-to-end test)
1. Use Docker to quickly run Fabric network
1. Environment configuration
1.1. Operating system installation
1.2. Install go language environment
For example, to download go 1.17.5, use the following command, and then unzip the directory
curl -O https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
tar -zxvf go1.17.5.linux-amd64.tar.gz
Move to appropriate location
sudo mv go /usr/local
Configure the GOPATH environment variable
export GOPATH=/usr/Go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
You can verify the success of the installation with the go version command
go version
go version go1.17.5 linux/amd64
ConfigureGOPROXY
go env -w GOPROXY=https://goproxy.cn,direct
1.3. Install dependency packages
Compiling Fabric code depends on some development libraries
Note: CentOS uses yum to install: yum -y install
sudo apt-get update \
&& apt-get install -y libsnappy-dev zliblg-dev libbz2-dev libyaml-dev libltdl-dev libtool
2. Install Docker service
Fabric currently uses Docker containers as the chaincode execution environment, so even if it is run locally, the Docker environment must be installed on the chaincode server.
curl -fsSL https://get.docker.com/ | sh
Set up docker to automatically start at boot
chkconfig docker on
Execute the following commands in sequence to configure the domestic source
vim /etc/docker/daemon.json
{
"registry-mirrors": ["http://f1361db2.m.daocloud.io","https://hub-mirror.c.163.com","https://xsoeja86.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
3. Install docker-compose
Download docker-compose to the /usr/local/bin/docker-compose directory
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
Set the /usr/local/bin/docker-compose directory permission to be executable
chmod +x /usr/local/bin/docker-compose
2. Start the Fabric network
1. Preparation
Create folder
cd #cd 不加内容是默认返回Home文件夹
mkdir -p go/src/github.com/hyperledger/
#进入刚刚创建的文件夹内
cd go/src/github.com/hyperledger/
Pull the source code of fabric from github
git clone "https://github.com/hyperledger/fabric.git"
cd fabric/
cd scripts/
#这一步会下载官方的例子以及所需要的Docker镜像
#下载是比较慢的,如果出现错误或者长时间没有速度只需要重新运行就可以了
sudo ./bootstrap.sh
The download may fail because the binary file cannot be downloaded. You can modify the bootstrap.sh file to disable the binary file from being downloaded through bootstrap.sh; and go to Release v2.0.0 · hyperledger/fabric · GitHub to manually download the binary file; then download it Unzip it and put it in the fabric-samples folder.
Another thing worth noting is that the version set in bootstrap.sh should be consistent with the binary file version.
2. Start running test-network to test the network
After all the downloads are complete, there will be an additional fabric-samples folder, which is a test network sample for you to experience or test.
Switch to the fabric-samples folder:
cd fabric-samples
Switch to test-network:
cd test-network/
Start the test network:
sudo ./network.sh up
3. Run first-network (end-to-end test)
First enter the fabric-sample directory, then enter the first-network folder
cd first-network
Run the file byfn.sh
./byfn.sh up
After the first-network is started, the orderer and peer nodes are started, and the end-to-end test is started
-----If executed successfully, as shown in the figure below-----
The test is performed automatically and goes through:
Create channel
Node joins channel
Update anchor node information
Execute chaincode-related tests (installation, instantiation, invocation)
wait...
After all tests are completed successfully , as shown below:
! ! ! congratulations ! ! !
3. Summary (error sorting)
The whole installation and test are not smooth, especially end-to-end test errors occur frequently
For related error sorting, please refer to some problems encountered in Fabric 2.0_m0_47233175's blog-CSDN blog