Build Hyperledger Fabric2.x environment

basic environment

official document

install docker

Link: https://pan.baidu.com/s/1s1lhCLlmbZk0NpFuw2sySA
Extraction code: ss9h

Install latest curl

install git

yum -y install git

Before running any git clonecommands, run the following command:

git config --global core.autocrlf false
git config --global core.longpaths true

You can check the settings of these parameters with the following command: They must be false and true respectively.

git config --get core.autocrlf
git config --get core.longpaths

Clone the hyperledger/fabric-samples warehouse (you can skip it, just look at installing the Hyperledger image)

git clone https://github.com/hyperledger/fabric-samples

If I can't pull down the upper warehouse, I will change the lower warehouse and pull it down

git clone https://github.com/GitHeP/fabric-samples.git

Solve the git failure solution caused by the inability of the Tencent Cloud lightweight server to access Github (common to other servers).
When selecting the IP, first ping it to see if it can be pinged. After changing /etc/hosts, restart the machine

reboot

Download binary files and mirrors (you can skip them and see Installing Hyperledger mirrors directly)

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

If the above file cannot be executed, there is a bootstrap.sh file in the following project

git clone https://github.com/GitHeP/fabric-samples.git

Execute the bootstrap.sh script,
if the error $'\r': command not found is reported , this is because the newline encoding of windows is different from that of Linux

vi hello.sh 
### Esc进入命令行运行模式
### : set ff=unix

Install the Hyperledger image

I am here to execute the bootstrap.sh script, the official command fails to execute,
first clone the project, and then execute the bootstrap.sh script inside

cd /root
git clone https://github.com/GitHeP/fabric-samples.git

You cannot access github.com when cloning, and you cannot access raw.githubusercontent.com to download mirrors when executing scripts, so you need to specify the domain name to access the ip first

vi /etc/hosts

# 添加下面的内容
192.30.255.112 github.com
192.30.255.112 raw.githubusercontent.com
# 重启机器
reboot

Solve the solution to git failure caused by the inability of Tencent Cloud Lightweight Server to access Github (common to other servers)

bootstrap.sh execution result
insert image description here
insert image description here
insert image description here
After the bootstrap.sh file is executed, there are some downloaded images in the docker container
insert image description here

Deploy a Fabric test network

Go to the test-network directory of the fabric-samplesd just cloned

cd /root/fabric-samples/test-network

Launch test network

./network.sh up

After successful startup, there are many more containers in docker
insert image description here

create a channel

Use the network.sh script to create a channel between Org1 and Org2 and join their peers. Run the following command to create a channel with the default name "mychannel":

./network.sh createChannel

insert image description here
So far, the basic environment of Hyperledger Fabric has been built

expand

Delete any previously running Fabric containers or projects:

./network.sh down

Start the Fabric network

./network.sh up

Create a channel, the default channel name is: mychannel

./network.sh createChannel

Create a channel, the custom channel name is: channel1

./network.sh createChannel -c channel1

While starting the Fabric network, create a channel, the default channel name is: mychannel

./network.sh up createChannel

Start a chaincode on a channel

Guess you like

Origin blog.csdn.net/qq_44154912/article/details/126173262