超级账本的环境安装最麻烦的就是墙,很多问题都是墙导致的,越过墙之后一切就非常简单。我找了一个可以直通港岛的网络后几乎没有遇到问题。我是在Mac下安装的,由于有系统洁癖,我使用虚拟机来安装fabric的编译环境。在fabric/devenv目录下其实已经提供了在虚拟机下面配置的脚本,整个操作也非常简单。
配置本地环境
依次安装:
GIT
GO(此处有墙,如果在虚拟机上编译代码此处不是必须的)
Vagrant
VirtualBox
然后设置GOPATH:
vim ~/.bash_profile
加入下面的设置,保存后退出
# GO configuration export GOPATH=/Users/[your_name]/workspace/gopath export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN
使配置生效:
source ~/.bash_profile
至此,环境配置完毕。下面开始下载代码:
cd $GOPATH/src mkdir -p github.com/hyperledger cd github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
此处注意:强烈建议使用最新的代码。因为超级账本依赖很多第三方的库,而第三方库可能已经发生改变,最新的代码是基于这些改变的。
至此,本地环境配置完毕。
使用Vagrant启动并配置虚拟机
cd $GOPATH/src/github.com/hyperledger/fabric/devenv vagrant up
此处有墙,根据网络速度耗时可能会比较长,甚至可能由于网络原因出错中断,出错之后重新开始。完成之后使用下面的命令登录虚拟机:
vagrant ssh
说明一下,vagrant基于Vagrantfile,Vagrantfile会执行setup.sh来完成虚拟机的配置。我们可以根据自己的需要来修改配置,修改完成后执行下面的命令会重新配置虚拟机:
vagrant up --provision
使用vagrant ssh登录后就可以直接编译了
# ------------------------------------------------------------- # This makefile defines the following targets # # - all (default) - builds all targets and runs all tests/checks # - checks - runs all tests/checks # - desk-check - runs linters and verify to test changed packages # - configtxgen - builds a native configtxgen binary # - configtxlator - builds a native configtxlator binary # - cryptogen - builds a native cryptogen binary # - peer - builds a native fabric peer binary # - orderer - builds a native fabric orderer binary # - release - builds release packages for the host platform # - release-all - builds release packages for all target platforms # - unit-test - runs the go-test based unit tests # - verify - runs unit tests for only the changed package tree # - profile - runs unit tests for all packages in coverprofile mode (slow) # - test-cmd - generates a "go test" string suitable for manual customization # - behave - runs the behave test # - behave-deps - ensures pre-requisites are available for running behave manually # - gotools - installs go tools like golint # - linter - runs all code checks # - license - checks go source files for Apache license header # - native - ensures all native binaries are available # - docker[-clean] - ensures all docker images are available[/cleaned] # - docker-list - generates a list of docker images that 'make docker' produces # - peer-docker[-clean] - ensures the peer container is available[/cleaned] # - orderer-docker[-clean] - ensures the orderer container is available[/cleaned] # - tools-docker[-clean] - ensures the tools container is available[/cleaned] # - protos - generate all protobuf artifacts based on .proto files # - clean - cleans the build area # - clean-all - superset of 'clean' that also removes persistent state # - dist-clean - clean release packages for all target platforms # - unit-test-clean - cleans unit test state (particularly from docker) # - basic-checks - performs basic checks like license, spelling and linter # - enable_ci_only_tests - triggers unit-tests in downstream jobs. Applicable only for CI not to # use in the local machine. # - docker-thirdparty - pulls thirdparty images (kafka,zookeeper,couchdb)
第一次直接使用make all,会全部编译所有的模块并生产docker镜像,可以使用docker images查看镜像。编译完成后会有各种测试,可能失败。我没有管它,至少目前的运行还是顺畅的。
可能遇到的问题:
下面是可能遇到的问题,做个记录以备参考
ERROR: /var/run/docker.sock: connect: permission denied 1: Adding current user to Docker group: sudo gpasswd -a ${USER} docker 2: Check whether add successfully: cat /etc/group | grep ^docker 3: Restart docker service: sudo serivce docker restart ERROR: cannot stat 'build/docker/gotools/bin/protoc-gen-go': No such file or directory cp $GOPATH/bin $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/ ERROR: + curl -fsSL http://www.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz + tar -xz curl: (22) The requested URL returned error: 404 Not Found 1: vim ./images/zookeeper/Dockerfile.in 2: Change [ARG DISTRO_NAME=zookeeper-3.4.9] TO [ARG DISTRO_NAME=zookeeper-3.4.11]、 ERROR: http://www-us.apache.org/dist/kafka/0.9.0.1/kafka_ NOT FOUND 1: vim ./images/kafka/Dockerfile.in 2: Change [KAFKA_VERSION=0.9.0.1] TO [KAFKA_VERSION=0.11.0.2] 3: Change [http://www-us.apache.org/dist/kafka/0.9.0.1/] TO [http://www-us.apache.org/dist/kafka/0.11.0.2/] 4: Remove sh1sha checking. ERROR: https://dist.apache.org/repos/dist/release/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz FAILED: 1: vim images/couchdb/Dockerfile.in 2: Change [COUCHDB_VERSION=2.0.0] TO [COUCHDB_VERSION=2.1.1]
参考文档:环境设置:https://blog.csdn.net/zgljl2012/article/details/52896372 关于编译:https://www.cnblogs.com/studyzy/p/8030613.html 问题及解决: https://blog.csdn.net/iflow/article/details/77951610 https://blog.csdn.net/fangoooooooooooo/article/details/78120327
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦