In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
HyperLeger Fabric Development (2)-- introduction to HyperLeger Fabric
This article uses the RHEL 7.3 workstation version of the operating system.
Deployment of HyperLeger Fabric environment 1. Deployment of Go language development environment
(1) installation of Go language environment
Download address of Go locale installation package:
Https://golang.org/dl/
Https://golang.google.cn/dl/
Extract the downloaded source package to the / usr/local directory
Sudo tar-C / usr/local-xzf go1.10.1.linux-amd64.tar.gz
Add the / usr/local/go/bin directory to the PATH environment variable
Export PATH=$PATH:/usr/local/go/bin
(2) setting of GOPATH environment variable
GOPATH=/home/user/GoLang:/home/user/devexport GOPATH
For ease of use, you usually need to add bin paths to all workspaces to the PATH environment variable, such as:
Export $PATH:$GOPATH/bin
If $GOPATH has multiple working directories, use ${GOPATH//://bin:} / bin to add all the bin directories.
Export $PATH:$ {GOPATH//://bin:} / bin
2. Docker tool installation
Yum install docker
3. Download HyperLeger Fabric
GitHub address: https://github.com/hyperledger/fabric
(1) download go get
Use the go language tool go get to download HyperLeger Fabric from the GitHub address of the HyperLeger Fabric project:
Go get-u-v github.com/hyperledger/fabric
(2) download git clone
The size of the HyperLeger Fabric project is about 76MB. If you use the go get tool to download slowly, you can download it using git clone:
Create a hyperledger directory:
Mkdir-p $GOPATH/src/github.com/hyperledger
Change to the hyperledger directory:
Cd $GOPATH/src/github.com/hyperledger
Git clone download:
Git clone https://github.com/hyperledger/fabric.git
II. Deployment of HyperLeger Fabric tools 1. Switch between HyperLeger Fabric versions
Enter the source directory where the HyperLeger Fabric project is located:
Cd $GOPATH/src/github.com/hyperledger/fabric
Switch to the release-1.0 version:
Git checkout release-1.0
2. Configtxgen tool installation
The configtxgen tool is used to generate configuration artifacts for Fabric.
Change to the configtxgen directory:
Cd common/configtx/tool/configtxgen
Compile and install:
Go install
Error report:
Fatal error: ltdl.h: No such file or directory
Install Itdl:
Yum install libtool-ltdl-devel
Continue to compile and install:
Go install
The target tool is installed in the $GOPATH/bin directory.
3. Cryptogen tool installation
The cryptogen tool is used to generate Fabric certificates and keys.
Change to the cryptogen source directory:
Cd common/tools/cryptogen
Compile and install:
Go install
The target tool is installed in the $GOPATH/bin directory.
Deploy the first Fabric network 1. Download the fabric-samples project
The fabric-samples project contains several examples of HyperLeger Fabric projects such as first-network.
Https://github.com/hyperledger/fabric-samples.git
Download the fabric-samples project to $GOPATH/src/github.com/hyperledger:
Git clone https://github.com/hyperledger/fabric-samples.git
2. Switch to the first-network sample source directory
Switch to first-network example:
Cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
Switch to the release-1.0 version:
Git checkout release-1.0
The first-network source code directory is as follows:
The first-network example is BYFN (build your first network). The BYFN scheme specifies a simple HyperLeger Fabric network consisting of two organizations, each maintaining two peer nodes and an solo sorting service.
The byfn.sh script uses Docker images to quickly boot the BYFN (build your first network) sample network, which consists of four peer nodes and one sorted node representing two different organizations. The byfn.sh script starts the container to run a script that joins the peer node into a channel, deploys and instantiates the chain code, and drives the transaction on the deployed chain code.
3. Generate BYFN sample network components
The byfn.sh script provides the ability to generate network artifacts to generate all certificates and keys for different network entities, to guide the initiator block of the sorting service, and to configure a collection of transaction configurations required for the channel. The command is as follows:
. / byfn.sh-m generate-c scorpio-I 1.0.0
Byfn.sh-m generate: generate network artifacts using cryptogen and configtxgen
-c: specify the channel name
-I: specified version
[user@localhost first-network] $. / byfn.sh-m generate-c scorpio-I 1.0.0Generating certs and genesis block for with channel 'scorpio' and CLI timeout of' 10'Continue (YSEO)? Yproceeding... / home/user/GoLang/bin/cryptogen### Generate certificates using cryptogen tool # # # # org1.example.comorg2.example.com/home/user/GoLang/bin/configtxgen# Generating Orderer Genesis block # 2018-10-21 15 main 52main [common/configtx/tool] 45.442 CST [common/configtx/tool] doOutputBlock-> INFO 001 Loading configuration2018-10-21 1515 purge 52VR 45.467 CST [common/configtx/tool] doOutputBlock- > INFO 002 Generating genesis block2018-10-21 15 CST 52group 45.469 CST [common/configtx/tool] doOutputBlock-> INFO 003 Writing genesis block#### Generating channel configuration transaction 'channel.tx' # 2018-10-21 15 main CST [common/configtx/tool] main-> INFO 0001 Loading configuration2018-10-21 15 main 5252 CST [common/configtx/tool] doOutputChannelCreateTx-> INFO 002 Generating new channel configtx2018-10-21 15: 52doOutputChannelCreateTx 45.482 CST [common/configtx/tool] doOutputChannelCreateTx-> INFO 003 Writing new channel tx#### Generating anchor peer update for Org1MSP # # 2018-10-21 15 main CST [common/configtx/tool] main-> INFO 001 Loading configuration2018-10-21 15 main 5297 CST [common/configtx/tool] doOutputAnchorPeersUpdate-> INFO 002 Generating anchor peer update2018-10-21 15:52 : 45.498 CST [common/configtx/tool] doOutputAnchorPeersUpdate-> INFO 003 Writing anchor peer update#### Generating anchor peer update for Org2MSP # # 2018-10-21 15 main 52.508 CST [common/configtx/tool] main-> INFO 001 Loading configuration2018-10-21 15 main 5213 CST [common/configtx/tool] doOutputAnchorPeersUpdate-> INFO 002 Generating anchor peer update2018-10-21 15:52: 45.513 CST [common/configtx/tool] doOutputAnchorPeersUpdate-> INFO 003 Writing anchor peer update
Cryptogen is used to generate encryption materials (x509 certificates and signing keys) for various network entities. The x509 certificate represents the identity / identity and allows signature / authentication authentication when the entity communicates and trades.
Cryptogen (fabric Certificate / key Generation tool) uses a profile crypto-config.yaml that contains the network topology to generate a set of certificates and keys for the organization and its components (peer/orderer). Each organization is configured with a unique root certificate (ca-cert) to bind specific components (peer and orderer) to the organization. By assigning a unique CA certificate to each organization, you can mimic a typical network in which members use their own certification authorities. Transactions and communications in Hyperledger Fabric are signed by the private key (KeyStore) of the entity and then verified by the public key (signature).
The certificates and keys generated by the cryptogen tool are saved to the crypto-config directory, which is structured as follows:
Configtxgen uses a configtx.yaml file, and configtx.yam defines a sample network with a sorting service organization OrdererOrg and two peer node organizations (Org1,Org2), each of which manages and holds two peer nodes. The configtx.yam file also specifies an SampleConsortium federation made up of two peer-to-peer organizations. You need to pay special attention to the Profiles section at the top of the file, which has two unique header information, one is the creation block TwoOrgsOrdererGenesis of the sort node, and the other is the channel TwoOrgsChannel. These two header information are used as parameters when creating a network component.
The configtx.yaml file also contains two additional specifications that are required. First, the peer node (peer0.org1.example.com,peer0.org2.example.com) of the two peer node organizations is specified; second, the MSP directory location of each member (specified by MSPDir) is specified, allowing the root certificate of each organization to be stored in the Genesis block of the sorting node. At present, any network entity and sorting service communication must be authenticated by digital signature.
4. Start the BYFN example
Start first-network and specify version 1.0.0 with the-I parameter:
. / byfn.sh-m up-c scorpio-I 1.0.0
Byfn.sh-m up: launch BYFN example
When you start first-network for the first time, the following three images are downloaded from the Docker image repository:
Docker.io/hyperledger/fabric-orderer:x86_64-1.0.0docker.io/hyperledger/fabric-peer:x86_64-1.0.0docker.io/hyperledger/fabric-tools:x86_64-1.0.05, BYFN shutdown exampl
. / byfn.sh-m down-c scorpio
Used to shut down the BYFN network, the container is closed, the encrypted material and 4 configuration messages are removed, and the chain code image is removed from the Docker repository.
7. Troubleshooting
Before starting the BYFN network example again, you must close the BYFN network and delete the generated certificates, containers, network components, chain code images, and so on. If the BYFN network is not shut down, it will cause the creation of the channel to fail. The error is as follows:
! Channel creation failed! = ERROR!! FAILED to execute End-2-End Scenario =
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.