Skip to content

How to install Hyperledger Fabric on ubuntu 16.04

TonyCai edited this page May 3, 2018 · 1 revision

Table of Contents

References

Git代码库

 cd /home/tonycai/go/src/github.com/hyperledger/fabric
 sudo make
 tonycai@frog:~/workspace/golang/src$ git clone -b master https://github.com/hyperledger/fabric.git

Host

  • frog
  • cd /home/tonycai/go/src/github.com/hyperledger/fabric

Install Docker

  • sudo apt-get install software-properties-common
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • sudo apt-get update && sudo apt-get upgrade
  • sudo apt-get install -y docker-ce
  • //sudo apt-get install docker-compose docker (ubuntu 16.04)
  • sudo usermod -aG docker tonycai && sudo su - tonycai
tonycai@frog:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK

tonycai@frog:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
tonycai@frog:~$ sudo apt-get update
Hit:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]            
Get:3 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]                                           
Get:4 https://download.docker.com/linux/ubuntu xenial InRelease [49.8 kB]                                                                                         
Get:5 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages [3150 B]                                                                               
Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:7 http://ppa.launchpad.net/gophers/archive/ubuntu xenial InRelease
Hit:8 http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial InRelease                                           
Fetched 359 kB in 1s (251 kB/s)                   
Reading package lists... Done
tonycai@frog:~$ sudo apt-get install -y docker-ce
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils containerd libpython3.5 linux-aws-headers-4.4.0-1031 linux-aws-headers-4.4.0-1032 linux-aws-headers-4.4.0-1035 linux-aws-headers-4.4.0-1038
  linux-aws-headers-4.4.0-1039 linux-aws-headers-4.4.0-1041 linux-aws-headers-4.4.0-1043 linux-headers-4.4.0-1031-aws linux-headers-4.4.0-1032-aws
  linux-headers-4.4.0-1035-aws linux-headers-4.4.0-1038-aws linux-headers-4.4.0-1039-aws linux-headers-4.4.0-1041-aws linux-headers-4.4.0-1043-aws
  linux-image-4.4.0-1031-aws linux-image-4.4.0-1032-aws linux-image-4.4.0-1035-aws linux-image-4.4.0-1038-aws linux-image-4.4.0-1039-aws linux-image-4.4.0-1041-aws
  linux-image-4.4.0-1043-aws runc ubuntu-fan xxd
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  aufs-tools
The following packages will be REMOVED:
  docker.io
The following NEW packages will be installed:
  aufs-tools docker-ce
0 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
Need to get 30.3 MB of archives.
After this operation, 86.4 MB of additional disk space will be used.
Get:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
Get:2 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 17.12.0~ce-0~ubuntu [30.2 MB]
Fetched 30.3 MB in 1s (23.3 MB/s)    
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 295045 files and directories currently installed.)
Removing docker.io (1.13.1-0ubuntu1~16.04.2) ...
'/usr/share/docker.io/contrib/nuke-graph-directory.sh' -> '/var/lib/docker/nuke-graph-directory.sh'
Processing triggers for man-db (2.7.5-1) ...
Selecting previously unselected package aufs-tools.
(Reading database ... 294952 files and directories currently installed.)
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_17.12.0~ce-0~ubuntu_amd64.deb ...
Unpacking docker-ce (17.12.0~ce-0~ubuntu) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Setting up docker-ce (17.12.0~ce-0~ubuntu) ...
Installing new version of config file /etc/default/docker ...
Installing new version of config file /etc/init.d/docker ...
Installing new version of config file /etc/init/docker.conf ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
tonycai@frog:~$ sudo apt-get install docker-compose
Reading package lists... Done
Building dependency tree       
Reading state information... Done
docker-compose is already the newest version (1.8.0-2~16.04.1).
The following packages were automatically installed and are no longer required:
  bridge-utils containerd libpython3.5 linux-aws-headers-4.4.0-1031 linux-aws-headers-4.4.0-1032 linux-aws-headers-4.4.0-1035 linux-aws-headers-4.4.0-1038
  linux-aws-headers-4.4.0-1039 linux-aws-headers-4.4.0-1041 linux-aws-headers-4.4.0-1043 linux-headers-4.4.0-1031-aws linux-headers-4.4.0-1032-aws
  linux-headers-4.4.0-1035-aws linux-headers-4.4.0-1038-aws linux-headers-4.4.0-1039-aws linux-headers-4.4.0-1041-aws linux-headers-4.4.0-1043-aws
  linux-image-4.4.0-1031-aws linux-image-4.4.0-1032-aws linux-image-4.4.0-1035-aws linux-image-4.4.0-1038-aws linux-image-4.4.0-1039-aws linux-image-4.4.0-1041-aws
  linux-image-4.4.0-1043-aws runc ubuntu-fan xxd
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
tonycai@frog:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-01-11 17:57:49 CST; 24s ago
     Docs: https://docs.docker.com
 Main PID: 29090 (dockerd)
   CGroup: /system.slice/docker.service
           ├─29090 /usr/bin/dockerd -H fd://
           └─29096 docker-containerd --config /var/run/docker/containerd/containerd.toml

Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.640310346+08:00" level=warning msg="Your kernel does not support swap memory limit"
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.640525064+08:00" level=warning msg="Your kernel does not support cgroup rt period"
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.640719663+08:00" level=warning msg="Your kernel does not support cgroup rt runtime"
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.641646742+08:00" level=info msg="Loading containers: start."
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.734428528+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.765467806+08:00" level=info msg="Loading containers: done."
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.814889713+08:00" level=info msg="Docker daemon" commit=c97c6d6 graphdriver(s)=aufs version=17.12.0-ce
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.815263007+08:00" level=info msg="Daemon has completed initialization"
Jan 11 17:57:49 frog systemd[1]: Started Docker Application Container Engine.
Jan 11 17:57:49 frog dockerd[29090]: time="2018-01-11T17:57:49.826478188+08:00" level=info msg="API listen on /var/run/docker.sock"
lines 1-19/19 (END)

tonycai@frog:~$ sudo usermod -aG docker tonycai && sudo su - tonycai

重新安装docker on ubuntu16

  • 卸载Docker
 sudo apt-get remove docker docker-engine
 卸载Docker后,/var/lib/docker/目录下会保留原Docker的镜像,网络,存储卷等文件. 如果需要全新安装Docker,需要删除/var/lib/docker/目录
  • 在 Linux上 安装 Docker
 curl -sSL https://get.daocloud.io/docker | sh
curl -L https://get.daocloud.io/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
  • 授权用户组
 sudo usermod -aG docker tonycai # 退出terminal后,重新登录
  • docker version
tonycai@bee:~$ docker version
Client:
 Version:	18.01.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	03596f5
 Built:	Wed Jan 10 20:11:05 2018
 OS/Arch:	linux/amd64
 Experimental:	false
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.01.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	03596f5
  Built:	Wed Jan 10 20:09:37 2018
  OS/Arch:	linux/amd64
  Experimental:	false
  • 添加阿里云的Docker Hub镜像
sudo gedit /etc/docker/daemon.json 
{
 "registry-mirrors": ["https://obou6wyb.mirror.aliyuncs.com"]
}
保存并退出

sudo systemctl daemon-reload
sudo systemctl restart docker

Restart Docker

  • sudo service docker stop / start

Clean network cached

  • docker network prune

Install HyperLedger Fabric by Docker

 $> docker pull yeasy/hyperledger-peer

Docker 常用命令

1)删除一个容器

docker rm <containerID>

2)强制删除一个容器

docker rm -f <containerID>

3)强制删除全部容器

docker rm -f $(docker ps -aq)

4)删除一个镜像:

docker rmi <imageID>

5)强制删除一个镜像:

docker rmi -f <imageID>

6)强制删除全部镜像

docker rmi -f $(docker images -q)

超级账本1.0的架构

超级账本1.0的架构,将节点进行了拆分,分为endorser、orderer和committer三类节点,节点各司其职。其中orderer节点负责共识,目前从官方文档看,支持Solo(单节点共识)、kafka(分布式队列)和SBFT(简单拜占庭容错)三种共识方式。本文主要介绍基于kafka实现的共识机制。

ZooKeeper

ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。

应用层调度室

2018-01-15 docker hyperledger-fabric

  • hyperledger-fabric
 cd ~/workspace
 git clone -b master https://github.com/hyperledger/fabric-samples.git
  • fabric platform-specific binaries | MacOS Download, hyperledger-fabric.tar.gz
 mkdir -p /usr/local/hyperledger-fabric
 cd /usr/local/hyperledger-fabric/
 exec download : $> curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-preview
 export PATH=/usr/local/hyperledger-fabric/bin:$PATH
  • Docker Hub
 https://hub.docker.com/u/hyperledger/
  • docker pull
 $ docker pull hyperledger/fabric-peer:x86_64-1.1.0-preview
 x86_64-1.1.0-preview: Pulling from hyperledger/fabric-peer
 Digest: sha256:95d38cc34e092806af4d12a8be6a6a8784d0917d6ca8714b936d819a8467fb18
 Status: Image is up to date for hyperledger/fabric-peer:x86_64-1.1.0-preview
  • docker run image
  docker image list
  docker run hyperledger/fabric-peer:x86_64-1.0.5
  docker container list
  • docker run 常驻内存模式
 docker run -d hyperledger/fabric-peer:x86_64-1.0.5
  • docker container rm -f 删除一个容器
 docker container rm -f vp0
  • docker references
 https://docs.docker.com/engine/reference/run/#detached--d
 https://hub.docker.com/u/hyperledger/
  • hyperledger-fabric images
tonycai@frog:~$ docker images| grep -i  latest
hyperledger/fabric-ca              latest                                2736904862db        2 months ago        218MB
hyperledger/fabric-tools           latest                                c584c20ac82b        2 months ago        1.42GB
hyperledger/fabric-couchdb         latest                                5b8a15e6e972        2 months ago        1.57GB
hyperledger/fabric-kafka           latest                                cf09c5534ef9        2 months ago        1.37GB
hyperledger/fabric-zookeeper       latest                                ac127485fdc7        2 months ago        1.37GB
hyperledger/fabric-orderer         latest                                2fccc91736df        2 months ago        159MB
hyperledger/fabric-peer            latest                                337f3d90b452        2 months ago        165MB
hyperledger/fabric-javaenv         latest                                cd459b218651        2 months ago        1.49GB
hyperledger/fabric-ccenv           latest                                82489d1c11e8        2 months ago        1.35GB

Building Your First Network

  • ubuntu 14
  338  sudo pip install -U docker-compose
  340  sudo chmod +x /usr/local/bin/docker-compose
  365  sudo apt-get remove python-urllib3 
  366  sudo pip install urllib3==1.13.1
  369  sudo pip install --upgrade urllib3
  • host: frog
 cd /home/tonycai/workspace/fabric-samples/first-network
  • byfn.sh 强大的bash shell
  • Typically Operations
Typically, one would first generate the required certificates and 
genesis block, then bring up the network. e.g.:

	byfn.sh -m generate -c mychannel
	byfn.sh -m up -c mychannel -s couchdb
	byfn.sh -m up -l node
	byfn.sh -m down -c mychannel

Taking all defaults:
	byfn.sh -m generate
	byfn.sh -m up
	byfn.sh -m down
  • generate
tonycai@frog:~/workspace/fabric-samples/first-network$ ./byfn.sh -m generate
Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue (y/n)? y
proceeding ...
/usr/local/hyperledger-fabric/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.com

/usr/local/hyperledger-fabric/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2018-01-16 15:51:45.682 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 15:51:45.691 CST [common/tools/configtxgen] doOutputBlock -> INFO 002 Generating genesis block
2018-01-16 15:51:45.692 CST [common/tools/configtxgen] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-01-16 15:51:45.699 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 15:51:45.706 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-01-16 15:51:45.707 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2018-01-16 15:51:45.714 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 15:51:45.721 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-01-16 15:51:45.722 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2018-01-16 15:51:45.729 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 15:51:45.736 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-01-16 15:51:45.736 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
  • down
tonycai@frog:~/workspace/fabric-samples/first-network$ ./byfn.sh -m down
Stopping with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue (y/n)? y
proceeding ...
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Stopping orderer.example.com    ... done
Stopping peer1.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Removing cli                    ... done
Removing orderer.example.com    ... done
Removing peer1.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing network net_byfn
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Removing network net_byfn
WARNING: Network net_byfn not found.
b859063b5d11
58faaba6acb0
6608975a17af
e93a8a3690e0
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:55bb4430b27ea2d6777ce02ea17566d2202aa208a73ce2759fb03f8d2b77244f
Deleted: sha256:e17e2eb37be84f9670b4629042a74f72a8ba8c9e4bfbed34d758b47d4510bd4d
Deleted: sha256:6963dd25ce880d696eab650bb23842d447d6e1377250451ccaf9c180892db2d0
Deleted: sha256:0780842a5883ccf28ac77bf9429758327f19ab77f7bf436c53fabad1dea0cd96
Deleted: sha256:ae215e4096f86feebaa4b59005d2a4091e5698bfd3c54334352b52628628812c
Deleted: sha256:21d4ee74a22551b6ec26a187a938f23dc763a8387080061694ef41b85e4b775a
Deleted: sha256:12121659dc422c2499165e7305066797ea2fe20f5b963dbf1bc7313f756d1c61
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:6695f69aa0abdc4ee963499cdd874c59bb701371fc7355d12b919a119cbeb1cc
Deleted: sha256:ff55598568992dbe613e0f9f56f48c3f1ceeb0a74f929bd2ce76086ebe35b081
Deleted: sha256:0c92fb9cfdeabfd3e05837eb545e3d7f7076dee8673044c507c5e3bc896789dc
Deleted: sha256:73de49b046e0251773ace73638b8a994c254e829b4915b0cf637b34a736df0ce
Deleted: sha256:8301751d94d2fc52f9e291c9a3ab0b56733abeaf3f8347ee23e276b6bbc6a7bf
Deleted: sha256:c437059359cd4fbd4f7aa2566336d26f6c9db33f5fafdf6a138539a723d7e791
Deleted: sha256:311fcd4b1ee238c22d9f54b5dab1cc624088861081269fa86e02aaf66a625e14
tonycai@frog:~/workspace/fabric-samples/first-network$ docker container list
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

生成证书

  • cryptogen
 cd /home/tonycai/workspace/fabric-samples/first-network
 cryptogen generate --config=./crypto-config.yaml

生成创始区块

  • cd /home/tonycai/workspace/fabric-samples/first-network
  • export FABRIC_CFG_PATH=$PWD
tonycai@frog:~/workspace/fabric-samples/first-network$ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2018-01-16 17:41:21.283 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 17:41:21.295 CST [common/tools/configtxgen] doOutputBlock -> INFO 002 Generating genesis block
2018-01-16 17:41:21.301 CST [common/tools/configtxgen] doOutputBlock -> INFO 003 Writing genesis block
  • Create a Channel Configuration Transaction
tonycai@frog:~/workspace/fabric-samples/first-network$ export CHANNEL_NAME=mychannel  && configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
2018-01-16 17:45:36.823 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 17:45:36.839 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-01-16 17:45:36.839 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

define the anchor peer

tonycai@frog:~/workspace/fabric-samples/first-network$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
2018-01-16 17:47:44.486 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 17:47:44.500 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-01-16 17:47:44.501 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
tonycai@frog:~/workspace/fabric-samples/first-network$ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
2018-01-16 17:50:13.092 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-01-16 17:50:13.106 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-01-16 17:50:13.107 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

查看交易记录

  • tonycai@frog:~/workspace/fabric-samples/first-network$ docker logs -f cli
 ____    _____      _      ____    _____ 
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |  
 ___) |   | |    / ___ \  |  _ <    | |  
|____/    |_|   /_/   \_\ |_| \_\   |_|  

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-01-16 08:41:14.511 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-16 08:41:14.511 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-16 08:41:14.519 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-01-16 08:41:14.519 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-01-16 08:41:14.519 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-01-16 08:41:14.519 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-01-16 08:41:14.519 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-01-16 08:41:14.519 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AA2060A074F7267314D53501296062D...53616D706C65436F6E736F727469756D 
2018-01-16 08:41:14.519 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: A17D16E2717B08E3560BFDD308BEAACED5A23636B46194575EB727BA4B2B380F 
2018-01-16 08:41:14.519 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-01-16 08:41:14.519 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-01-16 08:41:14.519 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-01-16 08:41:14.519 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-01-16 08:41:14.519 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AD9060A1508021A0608AAF5F6D20522...0FF15746244C7343B164206FF966F2F6 
2018-01-16 08:41:14.519 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: E8C9E150DA969C291F6920EE7F7D3119A2D9D57A5173CFB126FE106FE5749666 
2018-01-16 08:41:14.634 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
2018-01-16 08:41:14.634 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
2018-01-16 08:41:14.634 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
2018-01-16 08:41:14.634 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
2018-01-16 08:41:14.634 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AD9060A1508021A0608AAF5F6D20522...70B52029E4A312080A021A0012021A00 
2018-01-16 08:41:14.634 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 00D6B7D01144BA6774FE77B24DF97680A22A5D95903847C96910565D22E53219 
2018-01-16 08:41:14.637 UTC [channelCmd] readBlock -> DEBU 016 Got status: &{NOT_FOUND}
2018-01-16 08:41:14.637 UTC [msp] GetLocalMSP -> DEBU 017 Returning existing local MSP
2018-01-16 08:41:14.638 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
2018-01-16 08:41:14.665 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized
2018-01-16 08:41:14.865 UTC [msp] GetLocalMSP -> DEBU 01a Returning existing local MSP
2018-01-16 08:41:14.866 UTC [msp] GetDefaultSigningIdentity -> DEBU 01b Obtaining default signing identity
2018-01-16 08:41:14.866 UTC [msp] GetLocalMSP -> DEBU 01c Returning existing local MSP
2018-01-16 08:41:14.866 UTC [msp] GetDefaultSigningIdentity -> DEBU 01d Obtaining default signing identity
2018-01-16 08:41:14.866 UTC [msp/identity] Sign -> DEBU 01e Sign: plaintext: 0AD9060A1508021A0608AAF5F6D20522...07384F00A5C912080A021A0012021A00 
2018-01-16 08:41:14.866 UTC [msp/identity] Sign -> DEBU 01f Sign: digest: BA0E06C1A2247A0507BB9846B7FC0959A9444E4A712D43093F4DE67E3039A616 
2018-01-16 08:41:14.872 UTC [channelCmd] readBlock -> DEBU 020 Received block: 0
2018-01-16 08:41:14.873 UTC [main] main -> INFO 021 Exiting.....
......
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
Attempting to Query PEER0 ...3 secs

ShowContainerID

  • CONTAINER ID
  • tonycai@frog:~/workspace/fabric-samples/fabcar$ docker ps -qa
499f382757d1
7cafb9fe440a
c6c7994a603a
bea1281380ac
7594a04f13e6
7c2d55e37046
1e4872ce920b
59ba1cacccfe

Writing Your First Application

tonycai@frog:~/workspace$ cd fabric-samples/fabcar/
tonycai@frog:~/workspace/fabric-samples/fabcar$ ll
total 36
drwxrwxr-x  2 tonycai tonycai 4096 Jan 16 19:04 ./
drwxrwxr-x 12 tonycai tonycai 4096 Jan 16 15:35 ../
-rw-rw-r--  1 tonycai tonycai 2809 Jan 16 15:35 enrollAdmin.js
-rw-rw-r--  1 tonycai tonycai 6353 Jan 16 15:35 invoke.js
-rw-rw-r--  1 tonycai tonycai  537 Jan 16 15:35 package.json
-rw-rw-r--  1 tonycai tonycai 2606 Jan 16 15:35 query.js
-rw-rw-r--  1 tonycai tonycai 3132 Jan 16 15:35 registerUser.js
-rwxrwxr-x  1 tonycai tonycai 2070 Jan 16 15:35 startFabric.sh*
tonycai@frog:~/workspace/fabric-samples/fabcar$ npm install

> [email protected] install /home/tonycai/workspace/fabric-samples/fabcar/node_modules/pkcs11js
> node-gyp rebuild

make: Entering directory '/home/tonycai/workspace/fabric-samples/fabcar/node_modules/pkcs11js/build'
  CXX(target) Release/obj.target/pkcs11/src/main.o
  CXX(target) Release/obj.target/pkcs11/src/dl.o
  CXX(target) Release/obj.target/pkcs11/src/const.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/error.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/v8_convert.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/template.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/mech.o
../src/pkcs11/mech.cpp: In member function 'void Mechanism::Free()':
../src/pkcs11/mech.cpp:121:15: warning: deleting 'void*' is undefined [-Wdelete-incomplete]
   delete(param);
               ^
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_aes.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_rsa.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/param_ecdh.o
  CXX(target) Release/obj.target/pkcs11/src/pkcs11/pkcs11.o
  CXX(target) Release/obj.target/pkcs11/src/async.o
  CXX(target) Release/obj.target/pkcs11/src/node.o
  SOLINK_MODULE(target) Release/obj.target/pkcs11.node
  COPY Release/pkcs11.node
make: Leaving directory '/home/tonycai/workspace/fabric-samples/fabcar/node_modules/pkcs11js/build'

> [email protected] install /home/tonycai/workspace/fabric-samples/fabcar/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

[grpc] Success: "/home/tonycai/workspace/fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary/node-v59-linux-x64-glibc/grpc_node.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.

added 287 packages in 39.407s

┌───────────────────────────────────────────────────────────┐
│                  npm update check failed                  │
│            Try running with sudo or get access            │
│           to the local update config store via            │
│ sudo chown -R $USER:$(id -gn $USER) /home/tonycai/.config │
└───────────────────────────────────────────────────────────┘
tonycai@frog:~/workspace/fabric-samples/fabcar$ sudo npm install
npm WARN [email protected] No repository field.

up to date in 1.59s
tonycai@frog:~/workspace/fabric-samples/fabcar$ sudo chown -R $USER:$(id -gn $USER) /home/tonycai/.config
tonycai@frog:~/workspace/fabric-samples/fabcar$ ls -l /home/tonycai/.config
total 8
drwxrwxr-x 2 tonycai tonycai 4096 Dec 18 16:20 composer
drwx------ 2 tonycai tonycai 4096 Jan 18 17:39 configstore
tonycai@frog:~/workspace/fabric-samples/fabcar$ npm update
tonycai@frog:~/workspace/fabric-samples/fabcar$ sudo npm install
npm WARN [email protected] No repository field.

up to date in 1.576s
tonycai@frog:~/workspace/fabric-samples/fabcar$ npm install
npm WARN [email protected] No repository field.

up to date in 1.569s
  • npm install fabcar
  cd /home/tonycai/workspace/fabric-samples/fabcar
  sudo npm init
  sudo npm install
tonycai@frog:~/workspace/fabric-samples/fabcar$ sudo npm install
up to date in 1.553s
Have you run npm init? That command runs you through everything...

hyperledger fabric network statup

  • ./byfn.sh -m up -l node

docker logs

  • $ docker logs -f ca.example.com

HyperLedger Fabric 实例代码

  • https://github.com/yeasy/docker-compose-files/tree/master/hyperledger_fabric/latest
  • cd /home/tonycai/workspace/docker-compose-files/hyperledger_fabric/latest
  • $ docker-compose -f docker-compose-1orgs-1peers-dev.yaml pull
  • $ sudo docker container stop f551d9b7c117