1. 安装虚拟机

    虚拟机软件采用:VirtualBox

    操作系统选择:Ubuntu 14.04

    内存:4G

    CPU:2核

    硬盘:20G
   

2.(可选)更改ssh配置使得root可以通过SSH登录

为root设置密码

sudo passwd root

编辑/etc/ssh/sshd_config配置文件,允许root用户通过SSH登录

sudo vi /etc/ssh/sshd_config
修改内容
PermitRootLogin   yes

重启sshd服务

sudo service ssh restart

3. 安装必要的工具

sudo apt-get update

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common git make gcc

4. 安装Docker(17.06.2-ce or greater is required)

4.1 使用国内的阿里源安装Docker

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get -y update

sudo apt-get install docker-ce

4.2 添加阿里云的Docker hub镜像

sudo mkdir -p /etc/docker

vi /etc/docker/daemon.json

在daemon.json中添加

{

    "registry-mirrors" : ["https://obou6wyb.mirror.aliyuncs.com"]  

}

4.3 重新启动Docker服务

5. 安装docker-compose(version 1.14.0 or greater)

curl -L https://get.daocloud.io/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m`>/usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

docker-compose version

6. 安装Golang环境(Go version 1.10.x is required

cd ~

wget https://studygolang.com/dl/golang/go1.10.1.linux-amd64.tar.gz

tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz

mkdir go

Go环境变量设置
vi /etc/profile

添加

           export GOPATH=~/go

           export PATH=$PATH:/usr/local/go/bin

使环境变量生效

source /etc/profile

go version

7. 安装Node.js和NPM(version 8.9.x or greater,但目前不支持9.x)

cd ~

wget https://npm.taobao.org/mirrors/node/v8.11.2/node-v8.11.2-linux-x64.tar.xz

mkdir node

tar xvf node-v*.tar.?z --strip-components=1 -C ./node

rm -rf node-v*

mkdir node/etc

echo 'prefix=/usr/local' > node/etc/npmrc

sudo mv node /opt/

sudo chown -R root: /opt/node

sudo ln -s /opt/node/bin/node /usr/local/bin/node

sudo ln -s /opt/node/bin/npm /usr/local/bin/npm

node -v

npm -v

8. python版本确认(2.7, npm install需要)

python --version

9. hyperledger fabric源代码下载

mkdir -p ~/go/src/github.com/hyperledger

cd ~/go/src/github.com/hyperledger/

git clone https://github.com/hyperledger/fabric.git

cd ~/go/src/github.com/hyperledger/fabric/

git checkout v1.1.0

10. hyperledger fabric docker镜像下载

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/

source download-dockerimages.sh -c x86_64-1.1.0 -f x86_64-1.1.0

docker pull hyperledger/fabric-kafka:latest

docker pull hyperledger/fabric-zookeeper:latest

docker images

11. 启动Fabric网络完成chaincode测试(运行例子:e2e_cli)

注意:修改示例源代码中的一个错误(少了一个下划线)

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/base/

vi peer-base.yaml

将以下内容:
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2ecli_default
修改为:
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2e_cli_default

运行示例

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/

./network_setup.sh up

成功运行后显示:

查看启动的容器

docker ps

可以看到启动了14个容器

root@fabric:~/go/src/github.com/hyperledger/fabric/examples/e2e_cli# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a431c0eb49b dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.addΒ 2 hours ago Up 2 hours dev-peer1.org2.example.com-mycc-1.0
40e46c280dd5 dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "chaincode -peer.addΒ 2 hours ago Up 2 hours dev-peer0.org1.example.com-mycc-1.0
3af964e100dc dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "chaincode -peer.addΒ 2 hours ago Up 2 hours dev-peer0.org2.example.com-mycc-1.0
44d6376c1892 hyperledger/fabric-tools "/bin/bash -c './scrΒ 2 hours ago Up 2 hours cli
fb2560a9f070 hyperledger/fabric-orderer "orderer" 2 hours ago Up 2 hours 0.0.0.0:7050->7050/tcp orderer.example.com
406bf8616a16 hyperledger/fabric-kafka "/docker-entrypoint.Β 2 hours ago Up 2 hours 9093/tcp, 0.0.0.0:32806->9092/tcp kafka2
42c8a52d90fa hyperledger/fabric-kafka "/docker-entrypoint.Β 2 hours ago Up 2 hours 9093/tcp, 0.0.0.0:32805->9092/tcp kafka0
643a2e3d0674 hyperledger/fabric-kafka "/docker-entrypoint.Β 2 hours ago Up 2 hours 9093/tcp, 0.0.0.0:32804->9092/tcp kafka1
3cfb4e12c46d hyperledger/fabric-kafka "/docker-entrypoint.Β 2 hours ago Up 2 hours 9093/tcp, 0.0.0.0:32803->9092/tcp kafka3
dc9006941dae hyperledger/fabric-zookeeper "/docker-entrypoint.Β 2 hours ago Up 2 hours 0.0.0.0:32800->2181/tcp, 0.0.0.0:32798->2888/tcp, 0.0.0.0:32797->3888/tcp zookeeper0
6b38b28db643 hyperledger/fabric-zookeeper "/docker-entrypoint.Β 2 hours ago Up 2 hours 0.0.0.0:32802->2181/tcp, 0.0.0.0:32801->2888/tcp, 0.0.0.0:32799->3888/tcp zookeeper1
8e7879cd3a5e hyperledger/fabric-zookeeper "/docker-entrypoint.Β 2 hours ago Up 2 hours 0.0.0.0:32796->2181/tcp, 0.0.0.0:32795->2888/tcp, 0.0.0.0:32794->3888/tcp zookeeper2
11393db54042 hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:10051->7051/tcp, 0.0.0.0:10052->7052/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
896a220ea3a4 hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:8051->7051/tcp, 0.0.0.0:8052->7052/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
8fa87ebdfcdf hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:7051-7053->7051-7053/tcp peer0.org1.example.com
bce7b0b2ec7b hyperledger/fabric-peer "peer node start" 2 hours ago Up 2 hours 0.0.0.0:9051->7051/tcp, 0.0.0.0:9052->7052/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com

查询测试

打开一个命令行窗口,关联cli节点
docker exec -it cli bash

查询a账户余额:
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' 

查询结果如下:

2018-06-09 20:24:13.850 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-06-09 20:24:13.850 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-06-09 20:24:13.850 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-06-09 20:24:13.850 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-06-09 20:24:13.850 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-06-09 20:24:13.850 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0ABF070A6708031A0C08EDEEF0D80510...6D7963631A0A0A0571756572790A0161
2018-06-09 20:24:13.850 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 09621D7F31527CC5C54040210F606B75B8CBEB132480A46F7175E7526BB2AA01
Query Result: 90
2018-06-09 20:24:13.864 UTC [main] main -> INFO 008 Exiting.....

可以看到账户a中余额为90

查询b账户余额:
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","b"]}' 

结果:

2018-06-09 20:31:34.011 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-06-09 20:31:34.011 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-06-09 20:31:34.011 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-06-09 20:31:34.011 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-06-09 20:31:34.011 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-06-09 20:31:34.011 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0ABE070A6608031A0B08A6F2F0D80510...6D7963631A0A0A0571756572790A0162
2018-06-09 20:31:34.012 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 7E501205104DC7747C820B38E427B7CDFCE985960B7C3648DAC6604D84E3F57C
Query Result: 210

b账户余额为210

转账测试(b向a转账30):

peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["invoke","b","a","30"]}'

返回结果

2018-06-09 20:36:49.199 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-06-09 20:36:49.199 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-06-09 20:36:49.202 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-06-09 20:36:49.202 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-06-09 20:36:49.202 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-06-09 20:36:49.203 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0ABE070A6608031A0B08E1F4F0D80510...696E766F6B650A01620A01610A023330
2018-06-09 20:36:49.203 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: ADBF4A197225417D9EA86D06BEC6FA975029848160158DA7E5BFF1E99A7BA71C
2018-06-09 20:36:49.217 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0ABE070A6608031A0B08E1F4F0D80510...3BE53BB45BA118523F2027F42F0B6929
2018-06-09 20:36:49.217 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 6FC7047121A5D628E5A93AD6F95E6043E4E4E8BA4A8D7931D6CF206EC20F82CC
2018-06-09 20:36:49.351 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00a ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \032@\nMHC\322JD\240\216\325\243\244\363\320\212\036\207\325\211C\010<\211iM\206\357;\321\305\022Z\nF\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\003\022.\n\004mycc\022&\n\007\n\001a\022\002\010\004\n\007\n\001b\022\002\010\004\032\010\n\001a\032\003120\032\010\n\001b\032\003180\032\003\010\310\001\"\013\022\004mycc\032\0031.0" endorsement:<endorser:"\n\007Org1MSP\022\252\006-----BEGIN CERTIFICATE-----\nMIICKTCCAc+gAwIBAgIRAJB4lmWqlHlI2zkXJm58FkAwCgYIKoZIzj0EAwIwczEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh\nLm9yZzEuZXhhbXBsZS5jb20wHhcNMTgwNjA5MTgwODIxWhcNMjgwNjA2MTgwODIx\nWjBqMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN\nU2FuIEZyYW5jaXNjbzENMAsGA1UECxMEcGVlcjEfMB0GA1UEAxMWcGVlcjAub3Jn\nMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABHCfdWvJn2Sp\nJIL3Rvgfdkf2vqRQ9nBPBKlN/cwj6JwgczX28snKmutRNWQcIGw8U1FncR5eFQKB\nKvwZIGFos+CjTTBLMA4GA1UdDwEB/wQEAwIHgDAMBgNVHRMBAf8EAjAAMCsGA1Ud\nIwQkMCKAINea69E1VPRsWH3f7E1BEoSN8o1RiLtLoyHztSAYucMgMAoGCCqGSM49\nBAMCA0gAMEUCIQCB8GLaewodQIZPBbcAvslPKqt0ffCumEQI99Y2YW5NnAIgOehq\nBdz+h+Bj7+SnW+Hg113sgv8sdJmHqfQLQc1ZrsE=\n-----END CERTIFICATE-----\n" signature:"0E\002!\000\360\327\030\t\320\005\376\227\326r\326t\321\367\361E\242\202\251Q\023\302\306\336U]!*\030-\236a\002 3:e\2108$}\214\307\034\323\246\004\315C&;\345;\264[\241\030R? '\364/\013i)" >
2018-06-09 20:36:49.351 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
2018-06-09 20:36:49.352 UTC [main] main -> INFO 00c Exiting.....

说是成功了,那就再查询一下a账户和b账户的余额吧:

peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

2018-06-09 20:38:47.828 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-06-09 20:38:47.828 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-06-09 20:38:47.828 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-06-09 20:38:47.828 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-06-09 20:38:47.828 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-06-09 20:38:47.829 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0ABF070A6708031A0C08D7F5F0D80510...6D7963631A0A0A0571756572790A0161
2018-06-09 20:38:47.829 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: AF7513323F67F783382AF1BA9D1181DB21769E2EC880782CBE6C3EC43AF70116
Query Result: 120
2018-06-09 20:38:47.841 UTC [main] main -> INFO 008 Exiting.....
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","b"]}' 

2018-06-09 20:39:46.775 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-06-09 20:39:46.775 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-06-09 20:39:46.775 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-06-09 20:39:46.775 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-06-09 20:39:46.775 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-06-09 20:39:46.776 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0ABF070A6708031A0C0892F6F0D80510...6D7963631A0A0A0571756572790A0162
2018-06-09 20:39:46.776 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: D4AD6FD26B84F35708093CA84ADB0AFBE49039558DFB4D58AC7048E118AEFF45
Query Result: 180
2018-06-09 20:39:46.789 UTC [main] main -> INFO 008 Exiting.....

a账号剩余120,b账号剩余180元,结果正确

12. 关闭fabric网络,结束测试

先从cli节点的bash退出到宿主系统下
exit

关闭fabric网络:

 cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/

./network_setup.sh down

Hyperledger Fabric v1.1.0安装记录(国内源版)的更多相关文章

  1. Hyperledger Fabric(v1.2.0)代码分析1——channel创建

    Hyperledger Fabric(v1.2.0)代码分析1--channel创建 0. e2e_cli Hyperledger Fabric提供了一个e2e的例子,该例中创建了一个基础的区块链网络 ...

  2. Hyperledger Fabric(v1.1.0)编译时遇到的问题

    Hyperledger Fabric(v1.1.0)编译时遇到的问题 0. 编译过程的坑 编译时,按照如下顺序编译 make release,编译源码生成二进制文件 make docker,生成一系列 ...

  3. 使用docker加载已有镜像安装Hyperledger Fabric v1.1.0

    背景 每次在新的服务器上安装Hyperledger Fabric网络时,通过fabric官方提供的脚本安装时,需要从网络上down下近10G的fabric相关镜像,这个过程是漫长及痛苦的,有时因网络问 ...

  4. 阿里云容器服务区块链解决方案全新升级 支持Hyperledger Fabric v1.1

    摘要: 全球开源区块链领域影响最为广泛的Hyperledger Fabric日前宣布了1.1版本的正式发布,带来了一系列丰富的新功能以及在安全性.性能与扩展性等方面的显著提升.阿里云容器服务区块链解决 ...

  5. 安装hyperledger fabric V1.0.1

      安装文档位置: https://github.com/hyperledger/fabric   fabric代码托管地址 https://hyperledger-fabric.readthedoc ...

  6. 安装hyperledger fabric V1.0.0-beta

      安装文档位置: https://github.com/hyperledger/fabric   fabric代码托管地址 https://hyperledger-fabric.readthedoc ...

  7. Ubuntu下搭建Hyperledger Fabric v1.0环境

      多次尝试才正常启动了Fabric,如遇到各种莫名错误,请参考如下一步步严格安装,特别用户权限需要注意. 一.安装Ubuntu16 虚拟机或双系统,虚拟机有VirtualBox或者VMware,Ub ...

  8. 三、主流区块链技术特点及Hyperledger Fabric V1.0版本特点

    一.Hyperledger fabric V1.0 架构 1.逻辑架构: 2.区块链网络 3.运行时架构 二.架构总结 1.架构要点 分拆Peer的功能,将Blockchain的数据维护和共识服务进行 ...

  9. 003-主流区块链技术特点及Hyperledger Fabric V1.0版本特点

    一.Hyperledger fabric V1.0 架构 1.逻辑架构: 2.区块链网络 3.运行时架构 二.架构总结 1.架构要点 分拆Peer的功能,将Blockchain的数据维护和共识服务进行 ...

随机推荐

  1. MyEclipse免费使用

    import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; im ...

  2. sql注入--基础

    什么是sql注入: 利用SQL语句 在外部 对数据库进行 查询,更新等 动作 sql注入的原理: 输入值可控且带入数据库执行(前提) 接受的变量传值未进行过滤(实质) sql注入的目的: 获取数据(网 ...

  3. 服务器上u盘装机centos7.2

    说明: 截止目前CentOS 7.x最新版本为CentOS 7.2.1511,下面介绍CentOS 7.2.1511的具体安装配置过程 服务器相关设置如下: 操作系统:CentOS 7.2.1511 ...

  4. BZOJ3251:树上三角形(乱搞)

    Description 给定一大小为n的有点权树,每次询问一对点(u,v),问是否能在u到v的简单路径上取三个点权,以这三个权值为边长构成一个三角形.同时还支持单点修改. Input 第一行两个整数n ...

  5. java 计算百分数方法

    俗话说好记性不如烂笔头,故记之. DecimalFormat decimalFormat = new DecimalFormat("##.00%"); System.out.pri ...

  6. 【Java123】JavaWeb Servlet开发

    http://www.runoob.com/servlet/servlet-intro.html https://www.cnblogs.com/xdp-gacl/tag/JavaWeb学习总结/de ...

  7. Ubuntu16.04之开发环境构建

    Ubuntu软件安装相对于centos而言,那真的是要愉快的多啊! 以下安装步骤,本人在公司的测试环境和开发环境以及之前个人虚拟机的测试或生产环境都测验过,基本没有问题,只要按照步骤来,即可马到成功! ...

  8. error occurred at recursive SQL level 1

    ORA-00604: error occurred at recursive SQL level 1出现的错误:java.sql.SQLException: ORA-00604: error occu ...

  9. WorldWind源码剖析系列:表面影像类SurfaceImage

    表面影像类SurfaceImage描述星球类(如地球)表面纹理影像.该类的类图如下. 表面影像类SurfaceImage包含的主要的字段.属性和方法如下: string m_ImageFilePath ...

  10. python不要使用可变对象作为参数的默认值

    幽灵乘客例子: . 如上:如果为空时,bus2和bus3引用的是相同的一个list,就会造成粗错误 实际工作中,如果不想改变某个参数值,那么通过以上这种赋值也会改变 解决方式self.passenge ...