Hyperledger fablic 0.6 installation and deployment in a CENTOS7 environment

Source: Internet
Author: User
Tags curl zip git clone hyperledger fabric
Hyperledger Fabric Super Ledger

The basic principles of the project agreement are: attaching importance to the modular design, including the trade, contract, consistency, identity, storage and other technical scenarios; Code readability ensures that new features and modules can be easily added and extended, evolving paths that evolve and evolve new projects as needs go deeper and more scenarios are applied. Catalogue

Hyperledger Fabric Super Ledger directory One install Docker two installation docker-compose three download image four install git five use PBFT mode six start deployment Chaincode Seven Rights Management eight Super Ledger Resource management page

First, install Docker execution code as follows:

Curl-ssl Https://get.daocloud.io/docker | Sh
When the installation is complete, review the installation:
Docker-v

Second, installation Docker-compose

Install the PYTHON-PIP first, the specific installation step is as follows: 1. Install the Epel extension source first:

sudo yum-y install Epel-release
2. Then install PYTHON-PIP
sudo yum-y install Python-pip
3. When the installation is complete, clear the following cache caches
sudo yum clean all

Start installing Docker-compose 1. Install Docker-compose:

Curl-l https://get.daocloud.io/docker/compose/releases/download/1.9.0/docker-compose-' uname-s '-' uname-m ' >/ Usr/local/bin/docker-compose
chmod +x/usr/local/bin/docker-compose
2. Check the installation status:

Configure the following Docker image acceleration to download the mirror faster:

Curl-ssl https://get.daocloud.io/daotools/set_mirror.sh | Sh-s Http://860eaa91.m.daocloud.io

To restart the Docker service:

sudo service docker restart
Third, download the image
Docker pull Hyperledger/fabric-peer:x86_64-0.6.1-preview \
  && Docker pull HYPERLEDGER/FABRIC-MEMBERSRVC: X86_64-0.6.1-preview \
  && docker pull yeasy/blockchain-explorer:latest \
  && docker tag Hyperledger/fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-peer \
  && docker tag hyperledger/ Fabric-peer:x86_64-0.6.1-preview hyperledger/fabric-baseimage \
  && docker tag hyperledger/ Fabric-membersrvc:x86_64-0.6.1-preview HYPERLEDGER/FABRIC-MEMBERSRVC
After the download is complete, review the download image

Four, install git

1. Install the dependent packages:

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-extutils-makemaker

2. Download the git source and unzip the installation:

$ wget https://github.com/git/git/archive/v2.3.0.zip
$ unzip v2.3.0.zip
$ cd git-2.3.0

3. Compile and install:

Make prefix=/usr/local/git any
sudo make prefix=/usr/local/git install

4. Modify the Environment variables:

sudo vim/etc/profile
then in the last line of the file, add the following content, and then save the exit.
Export Path=/usr/local/git/bin: $PATH

5. Save immediately using the source command:

Source/etc/profile

6. View version

v. Use of PBFT mode

PBFT is a classic distributed consistency algorithm and is also the most recommended algorithm for Hyperledger, which requires at least 4 nodes. 1. First, download the Compose template file.

git clone https://github.com/yeasy/docker-compose-files
2. Check the download status:

3. Go to the HYPERLEDGER/0.6/PBFT directory to view including several template files

Details of the following nodes that can be started quickly:
4-PEERS.YML: Launches 4 PBFT peer nodes.
4-PEERS-WITH-MEMBERSRVC.YML: Start the 4 pbft peer node + 1 CA nodes and enable the CA feature.
4-PEERS-WITH-EXPLORER.YML: Launches 4 PBFT peer nodes + 1 Blockchain-explorer to monitor cluster status through a WEB interface.
4-PEERS-WITH-MEMBERSRVC-EXPLORER.YML: Start 4 PBFT Peer nodes + 1 CA nodes + 1 Blockchain-explorer, and enable the CA feature. 4. Quickly start a cluster of 4 PBFT nodes + 1 CA nodes + 1 Blockchain-explorer, and enable the CA feature:

Docker-compose-f 4-peers-with-membersrvc-explorer.yml up
vi. Start deployment of ChaincodeAfter the cluster starts, it enters a VP node. Take PBFT mode as an example, the node name is Pbft_vp0_1
Docker exec-it Pbft_vp0_1 Bash

Deploying EXAMPLE02

Peer Chaincode deploy-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02-c ' {"Function": " Init "," Args ": [" a "," + "," B "," 200 "]} '

Log in to the environment variable cc_id.

Cc_id= " Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539 "

Query Chaincode

Peer Chaincode Query-n ${cc_id}-C ' {"Function": "Query", "Args": ["a"]} '

Call Chaincode

Peer Chaincode Invoke-n ${cc_id}-C ' {"Function": "Invoke", "Args": ["a", "B", "10"]} '

Query the value of a again

Peer Chaincode Query-n ${cc_id}-C ' {"Function": "Query", "Args": ["a"]} '


An example of the transfer of the super ledger has been completed, and a block is recorded every time a turn is made. vii. Rights Management

When Rights management is enabled, you need to log in first, such as with a built-in account Jim account.
Log in to Vp0 and execute the login command.

Docker exec-it Pbft_vp0_1 Bash

Log in with the built-in Jim account

Peer Network login Jim

The built-in password is:

6avzqlwcue9b

The login situation is as follows:

After successful login, the following is the specific action. Deploy trading assets First

Peer Chaincode deploy-u jim-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02-c ' {"Function ":" Init "," Args ": [" a "," + "," B "," 200 "]} '

Description: The initial value of A/b is given at deployment TIME 100 200

After deployment, a name value is generated:

Assigns the name value to the variable cc_id

Cc_id= Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539

Query under Assignment result:

Echo ${cc_id}

Important: After successful deployment, the Docker container will be created, there will be delays in creating the Docker container, so sometimes the query does not come out, and so on, when the query is ready.
You can see that many containers have been created, as shown below:

Let's do the query operation, check the value of a:

Peer Chaincode query-u jim-n ${cc_id}-C ' {"Function": "Query", "Args": ["a"]} '

Check the value of B:

Peer Chaincode query-u jim-n ${cc_id}-C ' {"Function": "Query", "Args": ["B"]} '

Let's do the transfer operation below:
such as: A to B transfer 10 yuan

Peer Chaincode invoke-u jim-n ${cc_id}-C ' {"Function": "Invoke", "Args": ["a", "B", "10"]} '

After the transfer is successful, let's perform the following query on the values of A and B:

Peer Chaincode query-u jim-n ${cc_id}-C ' {"Function": "Query", "Args": ["B"]} '

Peer Chaincode query-u jim-n ${cc_id}-C ' {"Function": "Query", "Args": ["a"]} '

Rights Management can transfer the query correctly.

let's use the rest method below to execute the following query:

Cc_id= Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539

Use this cc_id to make a query.

POST  Host:7050/chaincode

Request:

{
  "JSONRPC": "2.0",
  "method": "Query",
  "params": {
      "type": 1,
      "Chaincodeid": {
          "name": " Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539 "
      },
      " Ctormsg ": {
         " function ":" Query ",
         " args ": [" a "]
      },
    " Securecontext ":" Jim "
  },
  "id": 3
}

The value of query A is:

Request:

{
  "JSONRPC": "2.0",
  "method": "Query",
  "params": {
      "type": 1,
      "Chaincodeid": {
          "name": " Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539 "
      },
      " Ctormsg ": {
         " function ":" Query ",
         " args ": [" B "]
      },
    " Securecontext ":" Jim "
  },
  "id": 3
}

The value of query B is:

At this point,A is 145,b is 155 below to execute the following A to B transfer

{
  "JSONRPC": "2.0",
  "method": "Invoke",
  "params": {
      "type": 1,
      "Chaincodeid": {
          "name": " Ee5b24a1f17c356dd5f6e37307922e39ddba12e5d2e203ed93401d7d05eb0dd194fb9070549c5dc31eb63f4e654dbd5a1d86cbb30c48e3ab1812590cd 0f78539 "
      },
      " Ctormsg ": {
         " function ":" Invoke ",
         " args ": [" a "," B "," + "]
      },
    " Securecontext ":" Jim "
  },
  " id ": 3
}

As shown in figure:

The following executes the query A, and B values, request parameters such as above, directly above.
A is a value of

The value of B is

The following block information is queried below:

GET  HOST:7050/CHAIN/BLOCKS/2

Response:

{"Transactions": [{"Type": 2, "Chaincodeid": "Eoabnzhjytmyzmmxmjlmmdexmjllmdewyzm3ytc4zdu2odhiodeynjy 1nwi5ndu2mtnkmjfimmm2mgjjyjnlmtfkytfjzgviytljmjm1njnjmzhmytq3mtc3ywywzgu2ztnkotrmnjc4mwqzmdlhmzbln2qxotbhnju1nwu3ywu0zwy = "," Payload ":" Cp0bcaesgwesgae3ognhmzjmyzeyowywmteyowuwmtbjmzdhnzhknty4ogi4mti2nju1yjk0ntyxm2qymwiyyzywymnim2uxmwrhmwnkzwjhowmymzu2m2mzo gzhndcxnzdhzjbkztzlm2q5ngy2nzgxzdmwowezmgu3zde5mge2ntu1ztdhztrlzhotcgzpbnzva2ukawekawikazewma== "," Txid ":"
      8616608f-9762-44cc-bc09-ef93b88eb770 "," timestamp ": {" Seconds ": 1484792805," Nanos ": 467224609 }, "Nonce": "Qtktub7nu/jjfxv5lhjcdysxivib27yf", "cert": "Miicqtccaeegawibagiqw9a+u+4it7crrchjpxu1zjakbggqhkj Opqqdazaxmqswcqydvqqgewjvuzeumbiga1uechmlshlwzxjszwrnzxixddakbgnvbamta3rjytaefw0xnzaxmtkwmji0mjbafw0xnza0mtkwmji0mjbameux Czajbgnvbaytalvtmrqwegydvqqkewtiexblcmxlzgdlcjegmb4ga1ueaxmxvhjhbnnhy3rpb24gq2vydglmawnhdguwwtatbgcqhkjopqibbggqhkjopqmbb Wncaaqylvgqiwliwjfef1j0o+2lbpes0pqc90moon/iqejesx3gw7hvx51nq0r9azhs3hzqwdt6/0ouj5881bgcgufjo4hmmihjma4ga1uddweb/ wqeawihgdambgnvhrmbaf8eajaama0ga1uddgqgbaqbagmema8ga1udiwqimaaabaecawqwtqygkgmebqyhaqh/ Bearlnyvnxk3ztvpvustqnu90soz7fkorqd0znfskd32vwi8nvzkplkuzidfulfqskehv7uavl28xjkpxjpa4toumdogbiodbaugcaqwdce6zf7kxukqavqte rsczyxjnx3yi1qbmuniiyxpttkzhpci+tkpa5nmxwlbbqbnmaogccqgsm49bamda0gameuciqc/ Tjprxcpq4l4f3hwolt6owo5f1a9hg1apyurdum4oowigbtibdjl98j7dt7fw3tbcmvbsdska9fwlddqdse/3bwa= "," signature ":" Meuciqctxchiu3kl5autos11tnv4wp35pdtdq7qcfxmr9txpbaigh64aarcnrinlnn7v69ha75sdvqokn/opkydwhxofsfm= "}]," StateHash ":" zhyqtow0tz9g1jbfawgxb9udeetdocwet6hcsonkej9ncyzacjlnajs4fao9w6aqr6fokzr7fr7bvmocjtf00w== ","
  Previousblockhash ":" q3b82ofuju0god7j4qglldlaa4iw7cwu2yg6/onnnqcawyjxs/4wfgkxo75fgfdmvmedputiqmdjc4vmrvkw8w== ", "Consensusmetadata": "cai=", "Nonhashdata": {"Localledgercommittimestamp": {"Seconds": 1484794929, "NA Nos ": 31349065}," Chaincodeevents ": [{}
    ]
  }
} 

As shown in figure:

Here the rest request is complete. The above is the specific operation of Rights management. Viii. Super Ledger Resource Management page

Let's take a look at the port of the node, as shown below:

Then we can access it in Google Chrome,

host:9090

visit the normal page as:

query for specific information, as shown in the following diagram:

View the transaction details as shown below:

In this context, the entire Hyperledger fabric Super Ledger environment has been deployed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.