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

How to deploy Network based on ubuntu system by Hyperledger Fabric

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly shows you "Hyperledger Fabric how to deploy the network based on ubuntu system", 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 "Hyperledger Fabric how to deploy the network based on ubuntu system" this article.

Hyperledger Composer network elements

Business Network Definition

Before we start executing the code, let's take a look at the concept of Business Network Definition. Because this concept runs through this network system. BND defines the data model, transaction logic and access control rules for the blockchain. We can deploy the bna package to the Fabric network. In order to generate bna, we need to generate it in advance:

A set of model files

A set of JavaScript files

An Access Control file

All of these files are understandably descriptive files of our network. The network executes according to our description.

BusinessNetworkFiles

Then we start to build and deploy a network. The following code is executed on the ubuntu system.

1Setp 1 creates a business network application

(1) from the command line, create a new dir and cd to the dir

Amy@amy-wu:~/pg/sandbox/bnd$ yo hyperledger-composer:businessnetworkWelcome to the businessnetwork generator? Business network name: tutorial-network? Description: Here is a hello world example? Author name: Amy Wu? Author email: AmyWu@123abc.com? License: Apache-2.0? Namespace: org.example.biznet? Do you want to generate an empty template network? No: generate a populated sample network create package.json create README.md create models/org.example.biznet.cto create permissions.acl create .eslintrc.yml create features/sample.feature create features/support/index.js create test/logic.js create lib/logic.jsamy@amy-wu:~/pg/sandbox/bnd$

(2) View the file created by the instruction just now

Amy@amy-wu:~/pg/sandbox/bnd$ tree. └── tutorial-network ├── features │ ├── sample.feature │ └── support │ └── index.js ├── lib │ └── logic.js ├── models │ └── org.example.biznet.cto ├── package.json ├── permissions.acl ├── README .md └── test └── logic.js6 directories 8 filesamy@amy-wu:~/pg/sandbox/bnd$2Setp 2 players * View org.example.biznet.cto and permission.acl**

Org.example.biznet.cto defines the participants, assets and other information in the network.

Permission.acl defines access rights

3Setp 3 package to generate bna package

(1) cd to / tutorial-network directory

Need to install the composer environment in advance

Upgrade the Fabric Composer version

Error prompt

Cannot use v0.16.6 version of composer with fabric 1.1, v0.19 or higher is required

Confirm the version

Composer-vv0.19.10

Uninstall the existing version

Npm uninstall-g composer-clinpm uninstall-g composer-rest-servernpm uninstall-g generator-hyperledger-composer

Reinstall the latest version

Npm install-g composer-clinpm install-g composer-rest-servernpm install-g generator-hyperledger-composeramy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ composer archive create-t dir-n. Creating Business Network ArchiveLooking for package.json of Business Network Definition Input directory: / home/amy/pg/sandbox/bnd/tutorial-networkFound: Description: Here is a hello world example Name: tutorial-network Identifier: tutorial-network@0.0.1Written Business Network Definition Archive file to Output file: tutorial-network@0.0.1.bnaCommand succeeded

(2) View the generated bna file

Amy@amy-wu:~/pg/sandbox/bnd$ tree. └── tutorial-network ├── features │ ├── sample.feature │ └── support │ └── index.js ├── lib │ └── logic.js ├── models │ └── org.example.biznet.cto ├── package.json ├── permissions.acl ├── README .md ├── test │ └── logic.js └── tutorial-network@0.0.1.bna newly generated file 6 directories 9 files4Setp 4 deployment business network

Before you deploy, start a Fabric network.

(1) download fabric-dev-servers.zip

Mkdir fabric-dev-servers & & cd fabric-dev-serverscurl-O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zipunzip fabric-dev-servers.zip

(2) when starting the Fabric network for the first time

Cd fabric-dev-servers./downloadFabric.sh./startFabric.sh./createPeerAdminCard.sh

(3) at the end

. / stopFabric.sh. / teardownFabric.sh

(4) initialize the network

Amy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ composer network install-card PeerAdmin@hlfv1-archiveFile tutorial-network@0.0.1.bna ✔ Installing business network. This may take a minute...Successfully installed business network tutorial-network, version 0.0.1Command succeededamy@amy-wu:~/pg/sandbox/bnd/tutorial-network$

(5) View docker containers

Docker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES27b30f42cc5e hyperledger/fabric-peer:x86_64-1.1.0 "peer node start" 5 minutes ago Up 5 minutes 0.0.0.0 minutes ago Up 7051-> 7051/tcp 0.0.0.0minutes 7053-> 7053/tcp peer0.org1.example.com2f62650005f4 hyperledger/fabric-orderer:x86_64-1.1.0 "orderer" 5 minutes ago Up 5 minutes 0.0.0.0 minutes 7050-> 7050/tcp orderer.example.com96ec8b462e0e hyperledger/fabric-couchdb:x86_64-0.4.6 "tini-/ docker-ent …" 5 minutes ago Up 5 minutes 4369/tcp, 9100/tcp, 0.0.0.0 9100/tcp 5984-> 5984/tcp couchdbecd55c74cb76 hyperledger/fabric-ca:x86_64-1.1.0 "sh-c 'fabric-ca-se …" 5 minutes ago Up 5 minutes 0.0.0.0 9100/tcp 7054-> 7054/tcp ca.org1.example.com

(6) start the network

Amy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ composer network start-- networkName tutorial-network-- networkVersion 0.1-- networkAdmin admin-- networkAdminEnrollSecret adminpw-- card PeerAdmin@hlfv1-- file networkadmin.cardStarting business network tutorial-network at version 0.0.1Processing these Network Admins: userName: admin ✔ Starting business network definition. This may take a minute...Successfully created business network card: Filename: networkadmin.cardCommand succeeded

(7) Import network administrator identity

Amy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ composer card import-- file networkadmin.cardSuccessfully imported business network card Card file: networkadmin.card Card name: admin@tutorial-networkCommand succeeded

(8) testing

Amy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ composer network ping-- card admin@tutorial-networkThe connection to the network was successfully tested: tutorial-network Business network version: 0.0.1 Composer runtime version: 0.19.10 participant: org.hyperledger.composer.system.NetworkAdmin#admin identity: org.hyperledger.composer.system.Identity#d9e43201ca1bcc328e0e81ceaf96caf4f113019f41d26d292699151a50d0a3acCommand succeeded5Setp 5 generate REST serveramy@amy-wu:~$ composer-rest-server? Enter the name of the business network card to use: admin@tutorial-network? Specify if you want namespaces in the generated REST API: never use namespaces? Specify if you want to use an API key to secure the REST API: No? Specify if you want to enable authentication for the REST API using Passport: Yes? Specify if you want to enable multiple user and identity management using wallets: No? Specify if you want to enable event publication over WebSockets: Yes? Specify if you want to enable TLS security for the REST API: NoTo restart the REST server using the same options, issue the following command: composer-rest-server-c admin@tutorial-network-n never-a true-w trueDiscovering types from business network definition... Discovered types from business network definitionGenerating schemas for all types in business network definition... Generated schemas for all types in business network definitionAdding schemas for all types to Loopback... Added schemas for all types to LoopbackWeb server listening at: http://localhost:3000Browse your REST API at http://localhost:3000/explorer

View API: http://localhost:3000/explorer

6Setp 6 generates application amy@amy-wu:~/pg/sandbox/bnd/tutorial-network$ yo hyperledger-composer:angularWelcome to the Hyperledger Composer Angular project generator? Do you want to connect to a running Business Network? Yes? Project name: angular-app? Description: Hyperledger Composer Angular project? Author name: Amy WU? Author email: 123@gmail.com? License: Apache-2.0? Name of the Business Network card: admin@tutorial-network? Do you want to generate a new REST API or connect to an existing REST API? Connect to an existing REST API? REST server address: http://localhost? REST server port: 3000? Should namespaces be used in the generated REST API? Namespaces are not usedCreated applications completed generation process create app.jsBinary found at / home/amy/pg/sandbox/bnd/tutorial-network/angular-app/node_modules/node-sass/vendor/linux-x64-59/binding.nodeTesting binaryBinary is finenpm notice created a lockfile as package-lock.json. You should commit this file.npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os": "darwin", "arch": "any"} (current: {"os": "linux", "arch": "x64"}) added 1162 packages in 145.973sApplication generated

(1) start the application

Amy@amy-wu:~/pg/sandbox/bnd/tutorial-network/angular-app$ npm start > angular-app@0.0.1 start / home/amy/pg/sandbox/bnd/tutorial-network/angular-app > ng serve-- proxy-config proxy.conf.js-- host 0.0.0.0 * NG Live Development Server is running on http://0.0.0.0:4200 * * 10% building modules 4amp 4 modules 0 active [HPM] Proxy created: ['/ auth' '/ api']-> http://localhost:3000[HPM] Proxy created: /-> http://localhost:3000Hash: a0d3dc89fcbecd8aa802 Time: 12249mschunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 270 kB {5} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.js.map (main) 101 kB {4} [initial] [rendered] chunk {2} styles.bundle.js Styles.bundle.js.map (styles) 184kB {5} [initial] [rendered] chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 439 kB {5} [initial] [rendered] chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.12 MB [initial] [rendered] chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered] webpack: Compiled successfully.

(2) View the application

Http://0.0.0.0:4200

The above is all the contents of the article "how to deploy the network based on the ubuntu system in Hyperledger Fabric". 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.

Share To

Internet Technology

Wechat

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

12
Report