In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "Fabric2.0 how to create a channel", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to create a channel in Fabric2.0" this article.
1. Create Channel preparation 1.1 create Channel profile
Since configtx.yaml already exists in the first-network directory, if you need to modify the tunnel configuration, you can back up the original configtx.yaml and modify the relevant tunnel configuration.
1.2 Environmental preparation
Open the console and execute the following command
Set the binary configtxgen directory to the environment variable to make it easy to call
Export PATH=$ {PWD} /.. / bin:$ {PWD}: $PATH
Set the environment variable FABRIC_CFG_PATH to the directory where configtx.yaml is located
Export FABRIC_CFG_PATH=$ {PWD} 1.3Create channel tx file
The console executes the following command
Configtxgen-profile TwoOrgsChannel-outputCreateChannelTx. / channel-artifacts/channel2.tx-channelID channel2
-outputCreateChannelTx: output tx file path-channelID: tunnel ID
Execution result:
two。 Create a channel
Originally, the channel is created through the cli client, but 2.0 can be created directly through binaries this time. The difference between binary and cli is the same except for the superficial difference. The difference is that the environment variable of cli is set to a default at the beginning, such as the certificate path of peer. If binary is used, set the environment code directly in the console. For more information, see the script of fabric-samples/test-network. Without going into details here, let's use cli to create a test channel more quickly.
Enter the cli container
Docker exec-it cli bash
After entering:
Since the channel-artifacts of cli has been mapped to the ~ / first-network/channel-artifacts of the host, the newly created channel file above also exists in the cli directory.
Enter the command in the current directory:
Peer channel create-o orderer.example.com:7050-c channel2-f. / channel-artifacts/channel2.tx-- tls true-- cafile / opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
If you customize it, you only need to modify the-o parameter sort node service domain name port-c channel ID-f channel file path-whether tls enables tls-cafile ca path
The results of the console data are as follows, indicating that the channel is created successfully. The channel block file appears in the current directory as follows:
3. Node join channel
You only need to set the corresponding environment variable to set the cli connection node object. Currently, the node set by cli is peer0.org1.example.com.
Enter commands to view environment variabl
Env | grep CORE
Output result: if you need to modify the node, you only need to change the above environment variable to the configuration of the corresponding node, and now add peer0.org1.example.com to the channel.
The console enters the following command:
Peer channel join-b channel2.block
-b block file path
The console outputs the following result, indicating that the node joined successfully
Check the sort node log as follows: the sort node writes a new block and creates a raft cluster for the channel.
4. Verify that the node joins the channel
Console input
Peer channel list
The output from the console is as follows: you can see that the current node has joined the channel2
The above is all the content of the article "how to create channels for Fabric2.0". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.