Hyperledger-fabric 源码解析2——Install Samples

1.下载docker 各种镜像

存放工具的目录:/fabric/scripts

执行下载工具以及镜像的命令

curl -sSL https://goo.gl/fMh2s3 | bash、

执行结果

REPOSITORY                      TAG                    IMAGE ID            CREATED             SIZE
hello-world                     latest                 e38bc07ac18e        6 days ago          1.85kB
hyperledger/fabric-peer         x86_64-1.1.0           b023f9be0771        4 weeks ago         187MB
hyperledger/fabric-ca           latest                 2736904862db        5 months ago        218MB
hyperledger/fabric-ca           x86_64-1.1.0-preview   2736904862db        5 months ago        218MB
hyperledger/fabric-tools        latest                 c584c20ac82b        5 months ago        1.42GB
hyperledger/fabric-tools        x86_64-1.1.0-preview   c584c20ac82b        5 months ago        1.42GB
hyperledger/fabric-couchdb      latest                 5b8a15e6e972        5 months ago        1.57GB
hyperledger/fabric-couchdb      x86_64-1.1.0-preview   5b8a15e6e972        5 months ago        1.57GB
hyperledger/fabric-kafka        latest                 cf09c5534ef9        5 months ago        1.37GB
hyperledger/fabric-kafka        x86_64-1.1.0-preview   cf09c5534ef9        5 months ago        1.37GB
hyperledger/fabric-zookeeper    latest                 ac127485fdc7        5 months ago        1.37GB
hyperledger/fabric-zookeeper    x86_64-1.1.0-preview   ac127485fdc7        5 months ago        1.37GB
hyperledger/fabric-orderer      latest                 2fccc91736df        5 months ago        159MB
hyperledger/fabric-orderer      x86_64-1.1.0-preview   2fccc91736df        5 months ago        159MB
hyperledger/fabric-peer         latest                 337f3d90b452        5 months ago        165MB
hyperledger/fabric-peer         x86_64-1.1.0-preview   337f3d90b452        5 months ago        165MB
hyperledger/fabric-javaenv      latest                 cd459b218651        5 months ago        1.49GB
hyperledger/fabric-javaenv      x86_64-1.1.0-preview   cd459b218651        5 months ago        1.49GB
hyperledger/fabric-ccenv        latest                 82489d1c11e8        5 months ago        1.35GB
hyperledger/fabric-ccenv        x86_64-1.1.0-preview   82489d1c11e8        5 months ago        1.35GB
hyperledger/fabric-membersrvc   latest  

2. 设置环境变量

上面命令执行完成后,我们需要把上一步生成的bin目录设置环境变量:

sudo gedit ~/.bashrc

3.在文件末尾添加如下(路径换成你的):

# hyper path
export PATH=$PATH:/work/project/hyper/bin
 /root/fabric/scripts

4.下载samples

git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples

检查版本,确保接下来下载的二进制版本跟这个相符

git tag

3.下载平台特定的二进制文件

curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0

运行结果

[email protected]:/home/fabric-samples# curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0

Installing hyperledger/fabric-samples repo

===> Checking out v1.1.0 branch of hyperledger/fabric-samples
D	first-network/eyfn.sh
Note: checking out 'v1.1.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b 

HEAD is now at 1252c7a... [FAB-8920] Pin fabric-samples to node.js "~1.1.0"

Installing Hyperledger Fabric binaries

===> Downloading version x86_64-1.1.0 platform specific fabric binaries
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 35.4M  100 35.4M    0     0  1432k      0  0:00:25  0:00:25 --:--:--  872k
===> Downloading version x86_64-1.1.0 platform specific fabric-ca-client binary
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6109k  100 6109k    0     0   791k      0  0:00:07  0:00:07 --:--:-- 1217k

Installing Hyperledger Fabric docker images

===> Pulling fabric Images
==> FABRIC IMAGE: peer

x86_64-1.1.0: Pulling from hyperledger/fabric-peer
Digest: sha256:57417699ddf50c5ebd47a9a2cc74c0324fbba0281eb1104b9ddd05a67776b01f
Status: Image is up to date for hyperledger/fabric-peer:x86_64-1.1.0
==> FABRIC IMAGE: orderer

4.部署网络

cd first-network
./byfn.sh -m up

看到下面输出,就说明网络启动成功了。它会自动执行了如下几个操作:1. 创建区块链网络(4个peer+1个order)2. 创建channel 把peer加入到channel中 3. 部署/ 执行chaincode 。

2018-04-18 11:59:18.206 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-04-18 11:59:18.206 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Query Result: 90
2018-04-18 11:59:28.139 UTC [main] main -> INFO 003 Exiting.....
===================== Query on peer1.org2 on channel 'mychannel' is successful ===================== 

========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  

日志将继续。然后启动所有容器,驱动一个端到端的应用场景。成功以后,在终端窗口中会报告以下内容

CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED             STATUS              PORTS                                              NAMES
501c06a19703        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.a..."   5 minutes ago       Up 5 minutes                                                           dev-peer1.org2.example.com-mycc-1.0
1924ba2e2127        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.a..."   5 minutes ago       Up 5 minutes                                                           dev-peer0.org1.example.com-mycc-1.0
287291cc2f92        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.a..."   5 minutes ago       Up 5 minutes                                                           dev-peer0.org2.example.com-mycc-1.0
f38fe712f94b        hyperledger/fabric-tools:latest                                                                        "/bin/bash"              6 minutes ago       Up 6 minutes                                                           cli
a7accd692d7d        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
50f183c9bdeb        hyperledger/fabric-orderer:latest                                                                      "orderer"                6 minutes ago       Up 6 minutes        0.0.0.0:7050->7050/tcp                             orderer.example.com
77cdd82e60c9        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
565eef967b6f        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
d96264880b08        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com

5.关闭网络

最后,让我们把它全部停下来,这样我们可以一步一步地探索网络设置。以下操作将关闭你的容器,移除加密材料和4个配置信息,并且从Docker仓库删除chaincode镜像。你将再一次被提示是否继续,回答y:

./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 ...
Stopping cli                    ... done
Stopping peer1.org2.example.com ... done
Stopping orderer.example.com    ... done
Stopping peer0.org2.example.com ... done
Stopping peer1.org1.example.com ... done
Stopping peer0.org1.example.com ... done
Removing cli                    ... done
Removing peer1.org2.example.com ... done
Removing orderer.example.com    ... done
Removing peer0.org2.example.com ... done
Removing peer1.org1.example.com ... done
Removing peer0.org1.example.com ... done
Removing network net_byfn
Removing volume net_peer0.org2.example.com
Removing volume net_peer1.org2.example.com
...




你可能感兴趣的:(Hyperledger-fabric 源码解析2——Install Samples)