In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the mac Hyperledger fabric multi-channel multi-node addition, deletion, modification and query example analysis, I hope you will gain something after reading this article, let's discuss it together!
Cd / opt/gopath/src/github.com/hyperledger/fabric/aberic
$docker images
$docker rmi f0fe49196c40 (IMAGE ID)
$docker ps-a
$docker stop $(docker ps-a-Q)
$docker rm $(docker ps-a-Q)
=
Cd / opt/gopath/src/github.com/hyperledger/fabric/scripts
. / bootstrap.sh
Need to create for the first time (problem)
. / bin/cryptogen generate-- config=./crypto-config.yaml
Create a new channel-artifacts folder
Export FABRIC_CFG_PATH=$PWD
. / bin/configtxgen-profile TwoOrgsOrdererGenesis-outputBlock. / channel-artifacts/genesis.block
Chmod + x / opt/gopath/src/github.com/hyperledger/fabric/aberic/bin/configtxgen
Chmod-R 777 / opt/gopath/src/github.com/hyperledger/fabric/aberic/bin
$. / bin/configtxgen-profile TwoOrgsChannel-outputCreateChannelTx. / channel-artifacts/mychannel.tx-channelID mychannel
New channel: $/ opt/gopath/src/github.com/hyperledger/fabric/aberic/bin/configtxgen-profile TwoOrgsChannel-outputCreateChannelTx. / channel-artifacts/mychannel2.tx-channelID mychannel2
Export CHANNEL_NAME=mychannel
New channel: export CHANNEL_NAME=mychannel2
$. / bin/configtxgen-profile TwoOrgsChannel-outputAnchorPeersUpdate channel-artifacts/Org1MSPanchors.tx-channelID $CHANNEL_NAME-asOrg Org1MSP
$. / bin/configtxgen-profile TwoOrgsChannel-outputAnchorPeersUpdate channel-artifacts/Org2MSPanchors.tx-channelID $CHANNEL_NAME-asOrg Org2MSP
Modify the docker-peer.yaml file, change it to red, / Users/shijun/Desktop/fabricWorkspace/membersheepFabric/crypto-config/peerOrganizations/org1.example.com/ca/4855be3f47ea89f3e86425d6b2bf3fbc5343d187d61887188396405c844077ca_sk
Channel-artifacts and crypto-config folders are packaged and sent to child nodes
= =
Primary node execution (not used by child nodes): $docker-compose-f docker-orderer.yaml up-d
The master node executes the command: $docker-compose-f docker-peer.yaml up-d
Child node executes the command: docker-compose-f docker-peer0-org2.yaml up-d
$docker exec-it cli bash
Primary node executes: # peer channel create-o orderer.example.com:7050-c mychannel-f. / channel-artifacts/mychannel.tx
Create a new channel for the primary node: # peer channel create-o orderer.example.com:7050-c mychannel2-f. / channel-artifacts/mychannel2.tx
Instead of executing the above command, the child node directly executes: peer channel fetch 0 mychannel.block-o orderer.example.com:7050-c mychannel
(new channel) instead of executing the above command, the child node directly executes: peer channel fetch 0 mychannel2.block-o orderer.example.com:7050-c mychannel2
# peer channel join-b mychannel.block
New channel: # peer channel join-b mychannel2.block
The new channel does not need to execute this sentence: # peer chaincode install-n traceGoods-p github.com/hyperledger/fabric/aberic/chaincode/go/trace_goods-v 1.0
The child node does not execute the sentence # peer chaincode instantiate-o orderer.example.com:7050-C mychannel-n traceGoods-c'{"Args": ["init", "admin", "admin"]}'- P "OR ('Org1MSP.member')"-v 1.0
(new channel) the child node does not execute the sentence # peer chaincode instantiate-o orderer.example.com:7050-C mychannel2-n traceGoods-c'{"Args": ["init", "admin", "admin"]}'- P "OR ('Org1MSP.member')"-v 1.0
# peer chaincode query-C mychannel-n traceGoods-c'{"Args": ["queryAllGoods", "admin", "1", "10"]}'
New channel: # peer chaincode query-C mychannel2-n traceGoods-c'{"Args": ["queryAllGoods", "admin", "1", "10"]}'
# peer chaincode invoke-C mychannel-n traceGoods-c'{"Args": ["addGoods", "94cdaa8576314e6bb4277c11bc3f0492", "PS4", "2000", "2018-12-12", "admin"]}'
After restarting the computer, start fabric and execute the following three commands
$docker-compose-f docker-orderer.yaml up-d
$docker-compose-f docker-peer.yaml up-d
$docker exec-it cli bash
=
Docker-peer0-org2.yaml
# Copyright IBM Corp. All Rights Reserved.
# #
# # SPDX-License-Identifier: Apache-2.0
# #
#
Version:'2'
Services:
Couchdb:
Container_name: couchdb
Image: hyperledger/fabric-couchdb
Environment:
-GODEBUG=netdns=go
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service
# for example map it to utilize Fauxton User Interface in dev environments.
Ports:
-"5984DU 5984"
Ca:
Container_name: ca
Image: hyperledger/fabric-ca
Restart: always
Environment:
-GODEBUG=netdns=go
-FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
-FABRIC_CA_SERVER_CA_NAME=ca
-FABRIC_CA_SERVER_TLS_ENABLED=false
-FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem
-FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/373d2325b9a13a35b2eebefe5acc0529702f2194e3058bdad0d99b16d092e8ee_sk
Ports:
-"7054 Suzhou 7054"
Command: sh-c 'fabric-ca-server start-- ca.certfile / etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem-- ca.keyfile / etc/hyperledger/fabric-ca-server-config/373d2325b9a13a35b2eebefe5acc0529702f2194e3058bdad0d99b16d092e8ee_sk-b admin:adminpw-d'
Volumes:
-. / crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
Peer0.org2.example.com:
Container_name: peer0.org2.example.com
Image: hyperledger/fabric-peer
Restart: always
Environment:
-GODEBUG=netdns=go
-CORE_LEDGER_STATE_STATEDATABASE=couchdb
-CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
-CORE_PEER_ID=peer0.org2.example.com
-CORE_PEER_NETWORKID=aberic
-CORE_PEER_ADDRESS=peer0.org2.example.com:7051
-CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052
-CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
-CORE_PEER_LOCALMSPID=Org2MSP
-CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
-CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=aberic
#-CORE_LOGGING_LEVEL=ERROR
-CORE_LOGGING_LEVEL=DEBUG
-CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=aberic_default
-CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
-CORE_PEER_GOSSIP_USELEADERELECTION=true
-CORE_PEER_GOSSIP_ORGLEADER=false
-CORE_PEER_PROFILE_ENABLED=false
-CORE_PEER_TLS_ENABLED=false
-CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
-CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
-CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
Volumes:
-/ var/run/:/host/var/run/
-. / crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
-. / crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
Working_dir: / opt/gopath/src/github.com/hyperledger/fabric/peer
Command: peer node start
Ports:
-7051 Phantom 7051
-7052PUR 7052
-7053 7053
Depends_on:
-couchdb
Networks:
Default:
Aliases:
-aberic
Extra_hosts:
-"orderer.example.com:10.85.106.142"
Networks:
Default:
Aliases:
-aberic
Cli:
Container_name: cli
Image: hyperledger/fabric-tools
Tty: true
Environment:
-GODEBUG=netdns=go
-GOPATH=/opt/gopath
-CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
-CORE_LOGGING_LEVEL=DEBUG
-CORE_PEER_ID=cli
-CORE_PEER_ADDRESS=peer0.org2.example.com:7051
-CORE_PEER_LOCALMSPID=Org2MSP
-CORE_PEER_TLS_ENABLED=false
-CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.crt
-CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/server.key
-CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
-CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
Working_dir: / opt/gopath/src/github.com/hyperledger/fabric/peer
Volumes:
-/ var/run/:/host/var/run/
-. / chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/aberic/chaincode/go
-. / crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
-. / channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
Depends_on:
-peer0.org2.example.com
Extra_hosts:
-"orderer.example.com:10.85.106.142"
-"peer0.org1.example.com:10.85.106.142"
-"peer1.org1.example.com:10.85.106.227"
=
Docker-orderer.yaml
Version:'2'
Services:
Orderer.example.com:
Container_name: orderer.example.com
Image: hyperledger/fabric-orderer
Environment:
-GODEBUG=netdns=go
-CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=aberic_default
#-ORDERER_GENERAL_LOGLEVEL=error
-ORDERER_GENERAL_LOGLEVEL=debug
-ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
-ORDERER_GENERAL_LISTENPORT=7050
#-ORDERER_GENERAL_GENESISPROFILE=AntiMothOrdererGenesis
-ORDERER_GENERAL_GENESISMETHOD=file
-ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
-ORDERER_GENERAL_LOCALMSPID=OrdererMSP
-ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
#-ORDERER_GENERAL_LEDGERTYPE=ram
#-ORDERER_GENERAL_LEDGERTYPE=file
# enabled TLS
-ORDERER_GENERAL_TLS_ENABLED=false
-ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
-ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
-ORDERER_GENERAL_TLS_ROOTCAS= [/ var/hyperledger/orderer/tls/ca.crt]
Working_dir: / opt/gopath/src/github.com/hyperledger/fabric
Command: orderer
Volumes:
-. / channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
-. / crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
-. / crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
Networks:
Default:
Aliases:
-aberic
Ports:
-7050 7050
After reading this article, I believe you have a certain understanding of the "sample analysis of Hyperledger fabric multi-channel, multi-node addition, deletion, modification and query in mac". If you want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.