fabric 开发环境

Git client(https://git-scm.com/downloads)
Go - 1.8(https://golang.org/)
Vagrant - 1.7.4 or later(https://www.vagrantup.com/)
VirtualBox - 5.0 or later(https://www.virtualbox.org/)

go安装目录:D:/Go/

1,处理LF字符
git config --get core.autocrlfgit
git config --global core.autocrlf false

2,拉源码
cd D:\Go\src\github.com\hyperledger
git clone https://github.com/hyperledger/fabric.git
git clone https://github.com/hyperledger/fabric-ca.git
cd D:\Go\src\github.com\hyperledger\fabric
git checkout -b v1.0.0-rc1 refs/tags/v1.0.0-rc1

3,用Vagrant来配置虚拟机
cd D:/Go/src/github.com/hyperledger/fabric/devenv
vagrant up
……真的好长时间

手动输入vagrant ssh,会默认进入ubuntu下的fabric目录如下
ubuntu@hyperledger-devenv:b17afeb:/opt/gopath/src/github.com/hyperledger/fabric$

4,使用工具登陆vagrant
①执行下面命令
D:\Go\src\github.com\hyperledger\fabric\devenv>vagrant ssh-config
②执行结果
HostName 127.0.0.1
 User ubuntu
 Port 2222
PasswordAuthentication no
 IdentityFile D:/Go/src/github.com/hyperledger/fabric/devenv/.vagrant/machines/default/virtualbox/private_key
③用上面信息ssh登陆vagrant
HostName 127.0.0.1
 Port 2222
 IdentityFile D:/Go/src/github.com/hyperledger/fabric/devenv/.vagrant/machines/default/virtualbox/private_key

5,编译源码
运行make dist-clean all
ubuntu@hyperledger-devenv:b17afeb:/opt/gopath/src/github.com/hyperledger/fabric$ make dist-clean all

制作ca镜像
ubuntu@hyperledger-devenv:b17afeb:/opt/gopath/src/github.com/hyperledger/fabric-ca$ make docker

7,运行e2e

ubuntu@hyperledger-devenv:b17afeb:/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli$ ./network_setup.sh up


参照下面网页

https://segmentfault.com/a/1190000009072224

http://8btc.com/article-3815-1.html

------------------------------------------------------------------------------------

各种问题

1,在环境变量中,goroot和gopath不要设成一个目录。

2,go build时出现下面错误时,安装MinGW-w64就好了。

exec: "gcc": executable file not found in %PATH%

参照http://www.cnblogs.com/zsy/p/5958170.html

3,LiteIDE设置
http://studygolang.com/articles/02618

4,build出现异常
# github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
..\..\vendor\github.com\miekg\pkcs11\pkcs11.go:29:10: fatal error: ltdl.h: No such file or directory
 #include <ltdl.h>
命令行解决方法:go build -tags nopkcs11
LiteIDE解决办法:编译环境-》自定义-》BUILDARGS:-i -tags nopkcs11

5,修改文件时,要把文件头注释改成下面这样。因为make dist-clean all的时候会在check_license.sh中做check
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

6,改变git commit -a时的编辑模式为vim
git config --global core.editor vim

7,git config --global user.name ubuntu
git config --global user.email ubuntu@domain.com

8,把修改的内容反应到镜像文件(这块我没做出来,每次修改底层代码,都无法形成新镜像,哪位大神可以指点一下)
由于整个环境编译都是基于makefile文件的,在[D:\Go\src\github.com\hyperledger\fabric]下面的Makefile里面,

最上面定义了可以使用的命令,在这里,我使用了下面组合命令,但是感觉每次都要把所有清空,然后再一个一个的创建镜像文件,很麻烦。

①修改代码并go build

②make docker-clean 或者  make clean 或者  make peer-docker clean

③make peer-docker / make orderer-docker / make tools-docker

9,可以设置本地端口映射虚拟机端口

teraterm
设定->ssh转送->追加->设置本地端口和目的地端口

---------------------------------------------------------------------------------------------------------

从ibm关注账号得到的消息

编译和测试
大部分编译和安装过程都可以利用 Makefile 来执行,包括如下常见操作。

安装 go tools
执行
$ makegotools

语法格式检查
执行
$ makelinter

编译 peer
执行
$ make peer

会自动编译生成 Docker 镜像,并生成本地 peer 可执行文件。
注意:有时候会因为获取安装包不稳定而报错,需要执行 make clean,然后再次执行。

生成 Docker 镜像
执行
$ makeimages

执行所有的检查和测试
执行
$ makechecks

执行单元测试
执行
$ makeunit-test

如果要运行某个特定单元测试,则可以通过类似如下格式。
$ go test -v -run=TestGetFoo

执行 BDD 测试
需先生成本地 Docker 镜像。
执行
$ makebehave

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值