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/01 Report--
This article mainly shows you "how to deploy the hyperledger fabric local development environment under mac", 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 deploy the hyperledger fabric local development environment under mac" this article.
Preparatory work:
Git client (https://git-scm.com/downloads) Go-1.6 or later (https://golang.org/) Vagrant-1.8.6 or later (https://www.vagrantup.com/) VirtualBox-5.0 or later (https://www.virtualbox.org/)
These must be used, git is mainly used to synchronize the source code, go is mainly to build the compilation environment of the go language, because the source code is written in the go language. Click on the link described in the document to download, the installation method and the setting of environment variables can be Baidu, a lot of reference materials, basically more reliable. The last two are even easier, just download them and install them. In addition, due to the ssh command to be used later, I downloaded a Cygwin64 Terminal, searched for openssh when installing the selected package, and then selected this package. After installation, I also need to configure environment variables to specify my own Baidu.
Build steps:
Step one:
First of all, make sure that the compilation environment in which you installed the go language has been set up.
Then enter on the git command line:
Gitconfig-get core.autocrlfgitconfig-global core.autocrlf false
Step 2:
Pull down the fabric source code in github
Cd $GOPATH/srcmkdir-p github.com/hyperledgercd github.com/hyperledgergit clone https://github.com/hyperledger/fabric.git
The directory of $GOPATH can be ordered freely under windows, and it is suggested that the following should be done as he says. The git clone command of the source document may be aimed at those with Linux id, and his command can be used without it.
Step 3:
Configure the virtual machine with Vagrant
Cd $GOPATH/src/github.com/hyperledger/fabric/devenv vagrant up
The first time of vagrant up is very long, sometimes even broken, so it is recommended to FQ, and to accelerate globally, the testing speed should be more stable indeed. The document says that after running this command, you can have coffee. If you want a few minutes, I am not satisfied.
After the Vagrant is installed, most of the work is done, and then something is deployed.
The subsequent vagrant up startup looks like this:
In this step, vagrant has many commands, probably the way it downloads the latest version of the image from vagrant's box image is about 1G, and then installs it. We can download the latest version manually through Xunlei. Then pass through
Vagrant box add hyperledger/fabric-baseimage virtualbox.box
To add the image file directly. Download address (https://atlas.hashicorp.com/hyperledger/boxes/fabric-baseimage/versions/0.2.1/providers/virtualbox.box))
You can browse through the mirror gallery.
The current latest version is 0.2.1
The local version can be accessed through the
Update the way of vagrant box update.
Then after installing the image, an error is usually reported. You just can't connect to google.com to update the code, because files will be generated under the current default project directory. The error goes like this:
= > default: package golang.org/x/tools/go/gcimporter15: unrecognized import path "golang.org/x/tools/go/gcimporter15" (https fetch: Get https://golang.org/x/tools/go/gcimporter15?go-get=1: dial tcp 216.239.371)
Golang.org/x/tools/go/ these addresses can not be connected because of the wall. But in fact, all this code is available in github, so we have to create a directory manually and download it through github. For example, this tools directory.
The directory mkdir golang.org/x is under the src directory.
Create a golang.rog directory at the level of github.com, and then enter the x directory
Localhost:golang.org pro$ cd x/localhost:x pro$ lslocalhost:x pro$ git clone https://github.com/golang/tools.git
Just execute git clone under the x directory and generate a directory structure. The result is as follows
In fact, if this way of installing the tools source code still can not compile through, I looked for a long time to find out. You also have your own workspace in the hyperledger directory.
It was generated during vagrant up. We go into the fabric directory and see
It needs to be generated again, and then I thought it would only be good to add it to my first workspace, who knows it will continue to install the tools source code, so it is still needed here, as long as we
Just download the source code from git clone in another directory and copy it here.
The above gotools directory is generated when you need to execute vagrant up under the devenv directory, as long as the problem is solved. There is no problem installing the virtual environment.
Deployment steps:
Open ssh:
Cd $GOPATH/src/github.com/hyperledger/fabric/devenvvagrant ssh
If you don't install the previous ssh at this time, you will report an error.
After the above login is successful, it will be displayed: @ hyperledger-devenv, which means that the virtual environment has been successfully installed. If there is only a login for unbunt, it means that there is an error during the installation, although there are a lot of things missing that will cause the compilation to fail.
When we go back to the desired directory, we will see that there will be a hyperledger directory that maps to our host host. At present, we have updated the source code on our computers, and it will be updated automatically here to facilitate our development.
Security verification (optional):
To set up the local development environment with security enabled, you must first build and run the Certificate Authority (CA) server:
This is optional, mainly used for member authentication, the specific role is reflected in the following command whether to add username.
Make membersrvc & & membersrvc
Run the verification peer:
Open another command line window and run
Cd $GOPATH/src/github.com/hyperledger/fabric/devenvvagrant ssh
Then, note that the following actions are done only after the vagrant ssh login above. Not in the current host system source code operation.
Cd $GOPATH/src/github.com/hyperledger/fabricmake peerpeer node start-- peer-chaincodedev
The make peer process will take a long time. It took me about an hour to install and download a lot of stuff.
After the download is complete, the interface installed below will appear.
When the above is done, execute: peer node start-- peer-chaincodedev so that the peer node gets up.
Compile chaincode:
Open another command line window and run:
Cd $GOPATH/src/github.com/hyperledger/fabric/devenvvagrant ssh
Then select an example in the source code, the chaincode model, to compile
Cd$GOPATH/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02go build
Register and run chaincode:
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051. / chaincode_example02
Mycc is the name of chaincode, and you can choose it as long as you use it later in the process.
Ready for invocations, this is it, OK.
CLI debugging:
I didn't use REST, I used CLI.
User Registration:
Then open a terminal through vagrant ssh and log in again.
Cd $GOPATH/src/github.com/hyperledger/fabric/peerpeer network login
Username to choose from the membersrvc.yaml, for example, alice tried several times other users are not successful, and then will ask for a password, enter the following password on the line. Then the registration will be successful.
List of membersrvc.yaml file users:
The registration information can be seen in the peer window:
Deployment transactions for Chaincode:
Peer chaincode deploy-n mycc-c'{"Function": "init", "Args": ["a", "100"," b "," 200"]}'
If safe mode is used:
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode deploy-u jim-n mycc-c'{"Function": "init", "Args": ["a", "100"," b "," 200"]}'
Call transaction for Chaincode:
Peer chaincode invoke-l golang-n mycc-c'{"Function": "invoke", "Args": ["a", "b", "10"]}'
If safe mode is used:
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode invoke-u jim-l golang-n mycc-c'{"Function": "invoke", "Args": ["a", "b", "10"]}'
Query transaction of Chaincode:
Peer chaincode query-l golang-n mycc-c'{"Function": "query", "Args": ["b"]}'
Security mode:
CORE_SECURITY_ENABLED=true CORE_SECURITY_PRIVACY=true peer chaincode query-u jim-l golang-n mycc-c'{"Function": "query", "Args": ["b"]}'
Peer window
Chaincode window
Deploying, invoking, and querying three transactions can be seen in these windows.
The deployment was finally completed, but I was useless in the department of the black window above. I ran the smart contract he brought with me.
I really feel that hyperledger is too big for ordinary people to play with. Highly modular, and now in the development stage has changed a lot. For example, there is a part above to compile and start the user module membersrvc. There is no such code in the current git branch. I don't know why. So it doesn't work, but there's still this module in branch 0.6.
But...
However, there is no code for this piece of code under the master branch, and please give us some guidance if it has been analyzed.
These are all the contents of the article "how to deploy the hyperledger fabric native development environment under mac". 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.