Deploy and Test Fabric 1.0 Beta in Ubuntu

Source: Internet
Author: User
Tags curl zookeeper docker ps couchdb hyperledger fabric

Today Hyperledger Fabric released the 1.0 beta version of the image, according to the name, this should be a basic available version, so I hastened to download the first time, playing with the play. Here are the steps to install and test Fabric 1.0 Beta in Ubuntu:

First, Environment preparation 1.1 install VirtualBox and install Ubuntu in it.

This step is actually nothing to say, download the latest version of VirtualBox, download Ubuntu Server, I use 16.10 X64. After the installation of Ubuntu, you need to ensure that apt source is domestic, or if it is foreign words will be very slow and slow. The specific approach is

sudo VI /etc/apt/sources.list

Open this apt source list, if See is http://us.xxxxxx kind of, then is foreign, if see is http://cn.xxxxx kind of, then do not need to change. My is the source of the United States, so need to do a batch of replacement. In command mode, enter:

:%s/us./cn./g

You can change all of us to CN. Then enter: Wq to save the exit.

sudo apt-get update

Update the source.

Then install SSH so that you can connect to Ubuntu remotely with a client such as putty or SECURECRT.

sudo Install SSH
1.2 Installing Docker

Installing Docker will also encounter foreign network slow problem, fortunately the country has a good mirror, recommended daoclound, install Docker command is:

Curl-ssl https://get.daocloud.io/docker | sh
安装完成后,运行以下脚本将当前用户添加到Docker的组中
sudo usermod-ag Docker Studyzy
Re-login to the current user, then modify the Docker service configuration ( /etc/default/docker file).
sudo VI /etc/default/docker
添加以下内容:
docker_opts="$DOCKER _opts-h tcp://0.0.0.0:2375-h unix:///var/run/docker.sock--api-cors-header= ' * ' "
接下来就需要设置国内的Docker镜像地址,需要注册一个账号,然后在加速器页面提供了设置Docker镜像的脚本,加速器页面是:
Https://www.daocloud.io/mirror The script I provide is:
Curl-ssl https://http://d4cc5789.m.daocloud.io
运行完脚本后,重启Docker服务
sudo service docker restart
1.3 Installing Docker-compose

Docker-compose is a component that supports bulk creation of Docker containers through template scripting. Before installing Docker-compose, you need to install PYTHON-PIP and run the script:

sudo Install Python-pip

After the installation is complete, next install Docker-compose from Daoclound and run the script:

Curl-l https://sudomv ~/docker-compose/usr/local/bin/docker-   chmod +x/usr/local/bin/docker-compose
Ii. Deploy Fabric 1.0 Beta2.1 Download the official Automation deployment script

We'll start by creating a folder that holds the scripts for automating deployment.

mkdir fabric-samplecd fabric-sample
You can then use the Curl command to download and run the Automated deployment script:
Curl-ssl https://Goo.gl/lqkuoh | bash
This process will be lengthy and will download a large number of X86_64-1.0.0-beta Docker image. After downloading all the mirrors will do again rename, the X86_64-1.0.0-beta changed to latest, so that it is convenient to use.
When all downloads are complete, we run
Docker images
You can see the following image:

REPOSITORY TAG IMAGE ID CREATED SIZE
Hyperledger/fabric-tools latest Ae6b0f53cb70 hours ago 1.32 GB
Hyperledger/fabric-tools X86_64-1.0.0-beta ae6b0f53cb70 hours ago 1.32 GB
Hyperledger/fabric-couchdb latest 31bbbec3d853 hours ago 1.48 GB
Hyperledger/fabric-couchdb X86_64-1.0.0-beta 31bbbec3d853 hours ago 1.48 GB
Hyperledger/fabric-kafka latest c4ac1c9a4797 hours ago 1.3 GB
Hyperledger/fabric-kafka X86_64-1.0.0-beta c4ac1c9a4797 hours ago 1.3 GB
Hyperledger/fabric-zookeeper latest 2c4ebacb6f00 hours ago 1.31 GB
Hyperledger/fabric-zookeeper X86_64-1.0.0-beta 2c4ebacb6f00 hours ago 1.31 GB
Hyperledger/fabric-orderer latest 11ff350dd297 hours ago 179 MB
Hyperledger/fabric-orderer X86_64-1.0.0-beta 11ff350dd297 hours ago 179 MB
Hyperledger/fabric-peer latest E01c2b645f11 hours ago 182 MB
Hyperledger/fabric-peer X86_64-1.0.0-beta e01c2b645f11 hours ago 182 MB
Hyperledger/fabric-javaenv latest 61c188dca542 hours ago 1.42 GB
hyperledger/fabric-javaenv X86_64-1.0.0-beta 61c188dca542 hours ago 1.42 GB
Hyperledger/fabric-ccenv latest 7034cca1918d hours ago 1.29 GB
hyperledger/fabric-ccenv X86_64-1.0.0-beta 7034cca1918d hours ago 1.29 GB
Hyperledger/fabric-ca latest e549e8c53c2e hours ago 238 MB
Hyperledger/fabric-ca X86_64-1.0.0-beta e549e8c53c2e hours ago 238 MB

2.2 Starting a Fabric instance
The script that launches the fabric instance is already included in the officially supplied automated deployment script that was downloaded earlier. Run directly:
CD ~/fabric-sample/release/linux-AMD64. /network_setup. SH up
After the system has finished running, you will see this interface:
The system creates 1 client instances cli,1 a orderer node and 4 peer nodes. In addition, the current script contains an instance of the MYCC we're going to test next, so you might also see 3 instances of code on the chain running.
This is the instance that is seen with the Docker PS command after the command has finished running:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0bfa0ff5e77c dev-peer1.org2.example.com-mycc-1.0 "Chaincode-peer.a ..." 3 minutes ago up 3 minutes DEV-PEER1.ORG2.EXAMPLE.COM-MYCC -1.0
05751dedc36a dev-peer0.org1.example.com-mycc-1.0 "Chaincode-peer.a ..." 4 minutes ago up 4 minutes DEV-PEER0.ORG1.EXAMPLE.COM-MYCC -1.0
7006bcd8e671 dev-peer0.org2.example.com-mycc-1.0 "Chaincode-peer.a ..." 4 minutes ago up 4 minutes DEV-PEER0.ORG2.EXAMPLE.COM-MYCC -1.0
Fd52ef8e4be8 hyperledger/fabric-tools "/bin/bash-c"./s ... " 5 minutes ago up 5 minutes CLI
11e34078645f Hyperledger/fabric-peer "Peer node start" 5 minutes ago up 5 minutes 0.0.0.0:10051->7051/TCP, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
af042ab813ed Hyperledger/fabric-peer "Peer node start" 5 minutes ago up 5 minutes 0.0.0.0:8051->7051/TCP, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
08723b2ec1ec Hyperledger/fabric-peer "Peer node start" 5 minutes ago up 5 minutes 0.0.0.0:7051->7051/TCP, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
e84bc309e09e hyperledger/fabric-orderer "Orderer" 5 minutes ago up 5 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
3ec6e7cf006b Hyperledger/fabric-peer "Peer node start" 5 minutes ago up 5 minutes 0.0.0.0:9051->7051/TCP, 0.0.0.0:9053->7053/tcp peer0.org2.example.com

Test Fabric3.1 in the CLI test EXAMPLE02

First we need to log in to this container in the CLI to execute the CLI command of the fabric.

Docker exec-it CLI Bash
If the entry is successful, we will switch to the root user of the container and get the following command-line directory:
[email protected]:/opt/gopath/src/github.com/hyperledger/fabric/peer#
Unlike the 0.6Fabric, in 1.0, the code on the chain needs to be both install and instantiate two steps. Here we first install EXAMPLE02 and specify a name, for example we use DEVINCC here:
Install 1.0 -P GITHUB.COM/HYPERLEDGER/FABRIC/EXAMPLES/CHAINCODE/GO/CHAINCODE_EXAMPLE02
After running, you can see that the prompt runs successfully and returns 200 status:
Next is instantiate, that is, initialize the instance, set a account has 100 yuan, b account has 200 yuan.
Peer Chaincode instantiate-o orderer.example.com:70501.0'{"Args": ["Init", "a", "100" , "B", "$"]}'"OR (' Org1msp.member ', ' org2msp.member ')"
After successful operation, you can see the following results:
Next we use the query command to look at the balance of a account:
' {"Args": ["Query", "a"]} '
The results returned are:
OK next we need to transfer the $10 from account A to the B account and call the Invoke command:
Peer Chaincode invoke-o orderer.example.com:7050  --tls $CORE _peer_tls_enabled--cafile/opt/gopath/src/ github.com/hyperledger/fabric/peer/crypto/ordererorganizations/example.com/orderers/orderer.example.com/msp/ Cacerts/ca.example.com-cert.pem  '{"Args": ["Invoke", "a", "B", "Ten"]}'
The results returned by the run are:

Finally, we call the query command to check the balance of the B account, if there is no wrong calculation, it should be 210 yuan.

' {"Args": ["Query", "B"]} '

It seems that our Fabric 1.0 beta has been successfully deployed and tested.

Deploy and Test Fabric 1.0 Beta in Ubuntu

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.