git fabric 1.0.0 官方源码进行编译,生成 docker images(rc2 版本2017年6月26日)
来源:互联网 发布:数控车螺纹编程 编辑:程序博客网 时间:2024/05/19 05:38
git fabric 1.0.0 官方源码进行编译,生成 docker images(rc2 版本2017年6月26日)
系统环境:centos 7 64位
docker
docker-compose
不要使用 centos yum 仓库带的 docker,版本过低。
安装docker 官方的repo 里面的版本
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'[dockerrepo]name=Docker Repositorybaseurl=https://yum.dockerproject.org/repo/main/centos/7/enabled=1gpgcheck=1gpgkey=https://yum.dockerproject.org/gpgEOFyum updateyum install docker-enginesystemctl enable dockersystemctl restart docker
一.添加 fabric 用户和设置存放源码的目录
useradd fabric# 建立如下项目目录.mkdir /home/fabric/fabric
二.安装 go 的开发环境和必须的组件
以 root 用户安装
wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gztar -xzvf go1.8.1.linux-amd64.tar.gzmv ./go /usr/local//修改 etc/profile,增加 一下内容export GOROOT=/usr/local/goexport PATH=$PATH:$GOROOT/binsource /etc/profile
#安装后,确认 go 1.8 安装成功go versiongo version go1.8 darwin/amd64#如果无法科学上网,使用如下步骤:# 1. 以 root安装 gopm export GOPATH=/usr/local go get -u github.com/gpmgo/gopm #确认在/usr/local/bin 目录下有 gopm# 2. 以 fabric 用户,通过 gopm 安装 goimports export GOPATH=/home/fabric/fabric gopm get -g -d golang.org/x/tools/cmd/goimports #再使用 go install 安装 goimports go install golang.org/x/tools/cmd/goimports #确认在/home/fabric/fabric/bin 目录下有 goimports
以 fabric 用户 安装 gocov
GOPATH=/home/fabric/fabricgopm get -g -d golang.org/x/tools/covergopm get -g -d github.com/axw/gocov/gocovgo install github.com/axw/gocov/gocov# 确认 /home/fabric/fabric/bin 目录下有 gocov
安装 gocov-xml
GOPATH=/home/fabric/fabricgopm get -g -d github.com/AlekSi/gocov-xmlgo install github.com/AlekSi/gocov-xml#确认 /home/fabric/fabric/bin 目录下有 gocov-xml
三. 安装其他必须的组件
以 root 用户安装
#centos 下需要安装yum install -y gcc libtool libltdl-dev libtool-ltdl-devel openssl
四.设置fabric环境变量
vim ~/.bashrcexport GOPATH=/home/fabric/fabric# 使得环境变量生效source ~/.bashrc
五.进入项目目录
cd $GOPATH
六. 建立 go 源码目录结构(一定要建立 src/github.com/hyperledger ,否则无法使用 go 进行编译)
cd $GOPATHmkdir -p src/github.com/hyperledger
七.拉取 fabric 的源码
cd $GOPATH/src/github.com/hyperledgergit clone https://github.com/hyperledger/fabric.git
八.编译生成 protoc-gen-go
#编译生成 protoc-gen-go cd $GOPATHgopm get -g -d github.com/golang/protobuf/protoc-gen-gogo install github.com/golang/protobuf/protoc-gen-go#确认在$GOPATH/bin出现protoc-gen-go执行文件
九. 编译 fabric docker 环境
cd $GOPATH/src/github.com/hyperledger/fabricmake docker
如果出现 Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock 这个错误。
解决方案:
1. 把 fabric 用户加入到 sudo 组
a. 以 root 用户登录
b. vim /etc/sudoers
c. 增加 fabric ALL=(ALL) ALL 一行到root ALL=(ALL) ALL下面
2. sudo usermod -a -G docker $USER
3. newgrp - docker
4. newgrp - groups ${USER} | cut -d' ' -f1
参考:
https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/
十.如果出现文件或者命令没找到的错误,复制go 的相关文件到 fabric 编译环境
cp $GOPATH/bin/protoc-gen-go $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/ cp $GOPATH/bin/gocov $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/
十一.编译 fabric ca 环境
cd /rootgit clone https://github.com/hyperledger/fabric-ca.gitcd fabric-camake docker
十二. 部署和测试 e2e 应用
一键启动
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli
./network_setup.sh up mytestchannel
A. 生成配置文件
cd $GOPATH/src/github.com/hyperledger/fabricmake configtxgen
B. 执行后,控制台的输出内容如下:
build/bin/configtxgenCGO_CFLAGS=" " GOBIN=/root/fabric/src/github.com/hyperledger/fabric/build/bin go install -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0-snapshot-eba4a20 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.0 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/common/configtx/tool/configtxgenBinary available as build/bin/configtxgen
C. Run the generateCfgTrx.sh shell script
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli./generateCfgTrx.sh mytestchannel
D.控制台输出
[root@fabric e2e_cli]# ./generateCfgTrx.sh mytestchannelChannel name - mytestchannelBuilding configtxgenbuild/bin/configtxgenCGO_CFLAGS=" " GOBIN=/root/fabric/src/github.com/hyperledger/fabric/build/bin go install -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0-snapshot-eba4a20 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.0 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/common/configtx/tool/configtxgenBinary available as build/bin/configtxgenGenerating genesis block2017/04/19 16:14:03 Loading configuration2017/04/19 16:14:03 Looking for configtx.yaml in: /root/fabric/src/github.com/hyperledger/fabric/common/configtx/tool2017/04/19 16:14:03 Found configtx.yaml there2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Generating genesis block2017/04/19 16:14:03 Writing genesis blockGenerating channel configuration transaction2017/04/19 16:14:03 Loading configuration2017/04/19 16:14:03 Looking for configtx.yaml in: /root/fabric/src/github.com/hyperledger/fabric/common/configtx/tool2017/04/19 16:14:03 Found configtx.yaml there2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Checking for MSPDir at: .2017/04/19 16:14:03 Generating new channel configtx2017/04/19 16:14:03 Creating no-op MSP instance2017/04/19 16:14:03 Obtaining default signing identity2017/04/19 16:14:03 Creating no-op signing identity instance2017/04/19 16:14:03 Serialinzing identity2017/04/19 16:14:03 signing message2017/04/19 16:14:03 signing message2017/04/19 16:14:03 Writing new channel tx
E.启动 fabric 网络
先把make 出的 image 进行 tag 到 latest
docker tag hyperledger/fabric-orderer:x86_64-1.0.0-snapshot-<xxxxxxx> hyperledger/fabric-ordererdocker tag hyperledger/fabric-peer:x86_64-1.0.0-snapshot-<xxxxxxx> hyperledger/fabric-peer
然后启动 docker 容器
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cliCHANNEL_NAME=mytestchannel docker-compose up -d
十三.问题的解决
A.在 mac os 下出现如下错误:
Error processing tar file(bzip2 data invalid: bad magic value in continuation file):
解决办法 ,更新gnu-tar
brew install gnu-tar --with-default-names
B. 在 mac os 下出现’ltdl.h’ file not found错误
brew install libtool openssl
C. 出现goimports: command not found错误
make linter
出现如下错误:
LINT: Running code checks..Checking ./bccsp./scripts/golinter.sh: line 22: goimports: command not foundmake: *** [linter] 错误 127
但是执行$GOPATH/src/github.com/hyperledger/fabric/scripts/golinter.sh
是可以正常执行的
make gotools#如果无法科学上网,需要使用代理git config --global http.proxy "192.168.0.50:8016"git config --global https.proxy "192.168.0.50:8016"#或者在可以 git 的地方,把 gotools 的源码 git 下来,然后复制到相应目录下git clone https://go.googlesource.com/tools #当前目录下生成 tools 目录,#把目录复制到$GOPATH/src/github.com/hyperledger/fabric/gotools/build/gopath/src/golang.org/x/目录下。#重新 make gotoolscd $GOPATH/src/github.com/hyperledger/fabricmake gotools
D. make 过程中出现 IPv4 forwarding is disabled. Networking will not work. 这个警告。
sysctl -w net.ipv4.ip_forward=1#重启 docker 服务systemctl restart docker
E. 运行 e2e 例子的时候出现如下错误:
1.无法创建 channel
vim $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/docker-compose.yaml#修改 docker-compose.yaml 文件。在 cli 部分增加 host 映射 extra_hosts: - "orderer0:10.211.55.8" - "peer0:10.211.55.8" - "peer1:10.211.55.8" - "peer2:10.211.55.8" - "peer3:10.211.55.8"#修改 script.sh 脚本,进行 peer 的判断,映射端口号:if [ $1 -eq 0 ]; then CORE_PEER_ADDRESS=peer$1:7051elif [ $1 -eq 1 ]; then ORE_PEER_ADDRESS=peer$1:8051elif [ $1 -eq 2 ]; then ORE_PEER_ADDRESS=peer$1:9051elif [ $1 -eq 3 ]; then ORE_PEER_ADDRESS=peer$1:10051fi
F. 相关知识点
1. git 拉取某个特定版本
git reset --hard <commitlevel号>
- git fabric 1.0.0 官方源码进行编译,生成 docker images(rc2 版本2017年6月26日)
- git fabric 1.0.0 官方源码进行编译,生成 docker images
- 编译hyperledger fabric官方源码
- 在 hyperledger fabric 新增 User后重新编译 Docker 开发环境所需 Images
- 如何编译docker 1.2.0版本的源码
- 转载 2014年04月22日 09:01:19 VC6.0工程在编译时由于设置问题有时不会生成release版本,只有debug版本。 解决犯非法如下: 工程——设置,将Setting for
- TEQC最新版本2015年6月23日版本
- Fabric源码编译及示例
- 2017年6月26日
- 使用Git进行源码版本控制
- 2015年6月23日-7月12日,进行54小时,剩3651小时
- MPlayer-1.0rc2编译选项
- Cocos2d3.0RC2 Android编译
- 2017年10月20日提高T3 编译优化
- Ubuntu下升级git版本(源码编译安装git)
- Ubuntu下升级git版本(源码编译安装git)
- 6月26日
- FlashDevelop 3.0.0 Rc2 版本下载
- 分析包信息
- 17-6-26前端电子书籍出处分享
- java基础:对象
- 自定义的spinnerView
- js语法深入四:史上最简洁最准确的闭包描述
- git fabric 1.0.0 官方源码进行编译,生成 docker images(rc2 版本2017年6月26日)
- JavaScript学习总结——Javascript原型链的原理
- 买房子还是朝南的好
- BufferedImage 类使用
- 高可用复用对象的设计
- Thinkphp网站全真静态解决方案
- 各种效果
- 【JVM】线程安全与锁优化
- Android:手把手带你深入剖析 Retrofit 2.0 源码