手工方式逐步的安装和运行hyperledger
1、环境准备:centos7.4位,阿里云香港服务器;
2、安装docker
(1) yum install docker python-pip
(2) pip install --upgrade pip
(3) pip install docker-compose
3、启动docker
service docker start
4、安装go
(1) wget https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz
(2) sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
解压缩到 /usr/local 目录
(3) vim /etc/profile
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export GOPKG=$GOROOT/pkg/tool/linux_amd64
export GOARCH=amd64
export GOOS=linux
export GOPATH=/opt/Golang
export PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin
(4) source /etc/profile
mkdir /opt/Golang
5、创建hyperledger目录
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
6、安装git
yum install -y git
7、下载fabric源代码
cd $GOPATH/src/github.com/hyperledger
git clone http://gerrit.hyperledger.org/r/fabric
8、安装相关依赖
go get github.com/golang/protobuf/protoc-gen-go
安装结果在$GOBIN下面
9、编译fabric
cd $GOPATH/src/github.com/hyperledger/fabric
make release
此时遇到了如下错误:
undefined: tar.FormatPAX
vendor/github.com/docker/docker/pkg/archive/archive.go:1166:7: hdr.Format undefined (type *tar.Header has no field or method Format)
vendor/github.com/docker/docker/pkg/archive/archive.go:1166:17: undefined: tar.FormatPAX
make: *** [release/linux-amd64/bin/configtxgen] 错误 2
尝试解决:
fabric要求go版本大于等于1.10
升级go版本到1.10.3
该问题解决!继续执行
make docker
遇到如下错误:
Creating .build/goshim.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
make: *** [.build/goshim.tar.bz2] 错误 141
尝试解决:
缺少bzip2包
yum install -y bzip2
还是报一个剩余的错误:
Error parsing reference: "hyperledger/fabric-baseimage:amd64-0.4.10 as builder" is not a valid repository/tag: invalid reference format
make: *** [.build/image/tools/.dummy-amd64-1.3.0-snapshot-3bad1ec] 错误 1
尝试用 git check out 指定版本来解决
git tag
git checkout v1.0.0-rc1
然后 make docker
+ cd /
+ 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
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
继续报错!
感觉应该是下载地址不对,正确的是下面这个:
http://www.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
cd fabric/images/zookeeper/
vim Dockerfile.in 修改下载地址的前缀
http://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
过了,不过错误又来了!
Makefile:278: recipe for target 'build/image/kafka/.dummy-x86_64-1.0.0' failed
make: *** [build/image/kafka/.dummy-x86_64-1.0.0] Error 22
http://www-us.apache.org/dist/kafka/0.9.0.1/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz" -o kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz
同样怀疑是下载地址错误
修改 fabric/kafka 的下载地址
https://archive.apache.org/dist/kafka/0.9.0.1/kafka_2.11-0.9.0.1.tgz
终于好啦
又出现错误
curl -fSL https://dist.apache.org/repos/dist/release/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz -o couchdb.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
同样的,不要轻易修改下载的版本号,一般改可用的地址
http://archive.apache.org/dist/couchdb/source/2.0.0/apache-couchdb-2.0.0.tar.gz
好了!
小结,很多代码源地址,都已过期,需要修改dockerfile.in中的下载地址
10、准备启动
将可执行程序copy到系统文件夹
cp $GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin/* /usr/local/bin
sudo chmod -R 775 /usr/local/bin
peer version 报错
Unsupported Config Type ""
解决方案:
configtx.yaml 看起来缺少这个文件
find / -name 'configtx.yaml'
找到几个,后面copy应该可以解决,书的描述可能有问题
cd /usr/local/bin
尝试执行下下载脚本
sh get-docker-images.sh
又继续下载,没有解决这个问题,尝试直接执行examples/e2e_cli中的脚本 sh 文件
./network_setup.sh up
2018-07-20 08:14:38.939 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
fatal error: unexpected signal during runtime execution
这个是服务器内存不够的问题,至少>= 2G
再次遇到一个下个错误:
2018-01-26 05:03:26.153 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: A5892BF4C08D07882B34D959932CFA784DE00E1B29D40411B1CF8B59C16DF557
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7ff4023cb259]
解决办法:
修改 /etc/resolv.conf 配置,将 options timeout:2 attempts:3 rotate single-request-reopen 这一行内容注释掉
成功启动
小结,example 中的网络启动成功,说明问题可能是配置文件缺失