Learn about the blockchain, record the learning process, there are some errors in the article, I hope the big guys can correct me, and I am happy to help if I don’t understand
1. Preparation
1. Install curl curl --version query version
2. Install docker docker --version query version
3. Install docker-compose docker-compose --version query version
4. Install go locale go version query version
5. Install node.js node -v query version
Two, configuration environment
1. Create a directory
mkdir hyperledgerfabric #创建目录
cd hyperledger-fabric #进入目录
2. Download and execute the script
This process is very slow. If the download fails, try again. Be patient.
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- 2.2.0 1.4.7 0.4.10
The downloaded export is:
Clone hyperledger/fabric-samples repo
===> Cloning hyperledger/fabric-samples repo
正克隆到 'fabric-samples'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 7386 (delta 2), reused 8 (delta 0), pack-reused 7366
接收对象中: 100% (7386/7386), 4.26 MiB | 22.00 KiB/s, 完成.
处理 delta 中: 100% (3823/3823), 完成.
===> Checking out v2.2.0 of hyperledger/fabric-samples
Pull Hyperledger Fabric binaries
===> Downloading version 2.2.0 platform specific fabric binaries
===> Downloading: https://github.com/hyperledger/fabric/releases/download/v2.2.0/hyperledger-fabric-linux-amd64-2.2.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 649 100 649 0 0 511 0 0:00:01 0:00:01 --:--:-- 511
100 72.7M 100 72.7M 0 0 81006 0 0:15:41 0:15:41 --:--:-- 106k
==> Done.
===> Downloading version 1.4.7 platform specific fabric-ca-client binary
===> Downloading: https://github.com/hyperledger/fabric-ca/releases/download/v1.4.7/hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 652 100 652 0 0 686 0 --:--:-- --:--:-- --:--:-- 686
100 23.6M 100 23.6M 0 0 68041 0 0:06:03 0:06:03 --:--:-- 47732
==> Done.
Next, docker will pull the image files, which are:
hyperledger/fabric-tools 2.2.0
hyperledger/fabric-peer 2.2.0
hyperledger/fabric-orderer 2.2.0
hyperledger/fabric-ccenv 2.2.0
hyperledger/fabric-baseos 2.2.0
hyperledger/fabric-nodeenv 2.2.0
hyperledger/fabric-javaenv 2.2.0
hyperledger/fabric-ca 1.4.7
hyperledger/fabric-zookeeper 0.4.10
hyperledger/fabric-kafka 0.4.10
hyperledger/fabric-couchdb 0.4.10
I suggest to pull these files by myself in advance, so that it will not cause the binary files to be downloaded hard, and the image will be stuck in the pull and it will have to be downloaded again, which is a kind of mentality.
Remember to change the domestic source before pulling the mirror image, the method is summarized in another article
E.g:
docker pull hyperledger/fabric-tools:2.2.0
Three, test network
cd fabric-samples
ls #查看是否有test-network目录
ls
asset-transfer-abac CHANGELOG.md LICENSE
asset-transfer-basic ci MAINTAINERS.md
asset-transfer-events CODE_OF_CONDUCT.md off_chain_data
asset-transfer-ledger-queries CODEOWNERS README.md
asset-transfer-private-data commercial-paper scripts
asset-transfer-sbe config SECURITY.md
asset-transfer-secured-agreement CONTRIBUTING.md test-application
auction fabcar test-network
bin high-throughput token-erc-20
chaincode interest_rate_swaps token-utxo
cd test-network
Start the test network
sudo ./network.sh up
Export test results
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.2.0
DOCKER_IMAGE_VERSION=2.2.0
/home/zhangxiushan/hyperledger-fabric/fabric-samples/test-network/../bin/cryptogen
Generating certificates using cryptogen tool
Creating Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Creating Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Creating Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generating CCP files for Org1 and Org2
/home/zhangxiushan/hyperledger-fabric/fabric-samples/test-network/../bin/configtxgen
Generating Orderer Genesis block
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2021-02-25 05:47:23.810 EET [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-02-25 05:47:23.917 EET [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2021-02-25 05:47:23.917 EET [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2021-02-25 05:47:23.917 EET [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/zhangxiushan/hyperledger-fabric/fabric-samples/test-network/configtx/configtx.yaml
2021-02-25 05:47:23.921 EET [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2021-02-25 05:47:23.921 EET [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
+ res=0
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating peer0.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
28c8f7283ce7 hyperledger/fabric-tools:latest "/bin/bash" 6 seconds ago Up 1 second cli
8f41c84eb8fb hyperledger/fabric-peer:latest "peer node start" 28 seconds ago Up 6 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
1031ad6ca3aa hyperledger/fabric-peer:latest "peer node start" 28 seconds ago Up 6 seconds 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
877e4cd6ff23 hyperledger/fabric-orderer:latest "orderer" 28 seconds ago Up 8 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
Configuration complete
Turn off the network
./network.sh down
Stopping network
Stopping cli ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com ... done
Removing cli ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing orderer.example.com ... done
Removing network net_test
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer0.org2.example.com
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Thanks to the blogger and reference article:
https://blog.csdn.net/shengsikandan/article/details/107656060?spm=1001.2014.3001.5502
https://blog.csdn.net/aiwaston/article/details/108800937