Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The installation of docker and the steps of building Fabric1.1

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "docker installation and Fabric1.1 construction steps". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

install Docker

yum -y install docker

View docker version docker version

Question:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Solution: Because docker service is not started, the docker process cannot be found under the corresponding/var/run/path; execute the service docker start command to start the docker service.

Enable docker official China accelerator:

vim /etc/sysconfig/docker

--registry-mirror=https://registry.docker-cn.com Just add this sentence

service docker start Start docker service

Install docker-compose

yum -y install epel-release Install third-party repositories

yum -y install python-pip Install python third-party libraries

pip install --upgrade pip update pip

pip install docker-compose pip Installazione docker-compose

Question: Collecting docker-compose? Could not find a version that satisfies the requirement docker-compose (from versions: ) No matching distribution found for docker-compose(6)?

Solution: replace the docker-compose command

pip --default-timeout=200 install -U docker-compose Collecting docker-compose

Install go(if already installed, do not use)

wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz

Download go zip pack

tar -xvf go1.8.3.linux-amd64.tar.gz unzip

mv go /usr/local/can choose where to put it

mkdir /root/golang Create a folder for the fabric project

vim /etc/profile Configuration environment variables

export GOPATH=/root/golang

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

source /etc/profile Refresh environment variables

Download fabnric1.1 source code

wget https://github.com/hyperledger/fabric/archive/release-1.1.zip

The requested URL/root/golang/was not found on this server.

unzip release-1.1.zip unzip

mv fabric-release-1.1 fabric modify folder name to fabric

fabric project construction

cd fabric

Create project directory mkdir fabric_project

cd scripts into file execution./ bootstrap.sh Download bin (a bit long, wait a bit)

cp bin -r bin/ ../ fabric_project/Copy the bin folder under the project folder

Copy the private key and certificate file configuration file to the fabric directory under the project folder

cp examples/e2e_cli/configtx.yaml fabric_project/

cp examples/e2e_cli/crypto-config.yaml fabric_project/

Create a channel-artifacts folder under the project folder to store genesis files, channel files, and organization files

Under the project folder:

Generate public key, private key, certificate

./ bin/cryptogen generate --config=./ crypto-config.yaml

Creation Block Generation

./ bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./ channel-artifacts/genesis.block

Generate a Channel configuration block. The channel id is mychannel, and the name can be arbitrarily chosen. However, when the channel is used later, the channel id needs to be consistent with it.

./ bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./ channel-artifacts/mychannel.tx -channelID mychannel

Update anchor node

./ bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./ channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP

./ bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./ channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP

Create docker-orderer.yaml and docker-peer.yaml startup files to start the order service and ca, peer, cli, couchdb services

docker-orderer.yaml and docker-peer.yaml are separated from docker-compose-e2e.yaml under fabric/ examples/ e2e_cli/as follows:

//=========================================================================================

His specific configuration is in the included file

It's two organizations and four nodes, but I don't know what that means.

//=========================================================================================

order: screenshot below

peer: screenshot below

Order and Pee

docker-compose -f docker-orderer.yaml up -d

docker-compose -f docker-peer.yaml up -d

====== Start successfully as follows docker ps -a Query mirror service ====

There will be these port mappings

Enter client

docker exec -it cli bash

Creating a channel

peer channel create -o orderer.example.com:7050 -c mychannel -f ./ channel-artifacts/mychannel.tx

Join the channel via mychannel.block file

peer channel join -b mychannel.block

Install smart contracts

peer chaincode install -n tracegoods -p github.com/hyperledger/fabric/longlin/chaincode/go/trace_goods -v 1.0

initialization

peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n tracegoods -c '{"Args":["init","admin","admin"]}' -P "OR ('Org1MSP.member')" -v 1.0

query

peer chaincode query -C mychannel -n tracegoods -c '{"Args":["query","sheep_goods_list"]}'

peer chaincode invoke -C mychannel -n tracegoods -c '{"Args":["addGoods","94cdaa8576314e6bb4277c11bc3f0492","mychannel1's items1","2000","2018/12/12","admin"]}'

peer chaincode query -C mychannel -n tracegoods -c '{"Args":["queryAllGoods","admin","1","10"]}'

Docker command

docker stop $(docker ps -aq)

docker rm $(docker ps -aq)

docker rmi --force $(docker images | grep peer0.org1 | awk '{print $3}')

******************

If something goes wrong,

docker logs -f ca query logs ca is to view ca logs

********************

Solution: Delete old certificate and regenerate new certificate file

***** ERROR: channel create configuration tx file not found open ./ channel-artifacts/mychannel.tx: no such file or directory

Solution: mychannel.tx file generation exception Delete all files in channel-artifacts and regenerate

Error getting chaincode chaincode: path to chaincode does

not exist: /opt/gopath/src/github.com/hyperledger/fabric/longlin/chaincode/go/chaincode_example02

Solution: Modify the above order/peer screenshot

"Docker installation and Fabric1.1 building steps" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report