這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
安裝docker
yum -y install docker
docker version
啟用docker官方中國區加速器:
vim /etc/sysconfig/docker
--registry-mirror=https://registry.docker-cn.com
service docker start
安裝docker-compose(本節暫時未用到)
yum -y install epel-release
yum -y install python-pip
pip install --upgrade pip
pip install docker-compose
安裝go
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar -xvf go1.8.3.linux-amd64.tar.gz
mv go /usr/local/
mkdir -p /root/golang
vim /etc/profile
export GOPATH=/root/golang
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
source /etc/profile
為解決fabric編譯報錯:can't load package: package github.com/hyperledger/fabric/peer: open /opt/gopath/src/github.com/hyperledger/fabric/peer: permission denied
ln -s $GOPATH /opt/gopath
安裝git
yum -y install git
Fabric源碼下載
git clone https://github.com/hyperledger/fabric $GOPATH/src/github.com/hyperledger/fabric
git clone https://github.com/hyperledger/fabric-ca $GOPATH/src/github.com/hyperledger/fabric-ca
或
go get github.com/hyperledger/fabric
go get github.com/hyperledger/fabric-ca
編譯fabric代碼
cd $GOPATH/src/github.com/hyperledger/fabric
make all
cp build/bin/* $GOPATH/bin/
解決編譯fabric過程中報錯
如下為解決:package github.com/golang/lint/golint: mkdir /opt/gotools/obj/gopath: permission denied
git clone https://github.com/golang/tools.git $GOPATH/src/golang.org/x/tools
go get -u github.com/golang/lint/golint
go install github.com/golang/lint/golint
如下為解決:cp: cannot stat ‘build/docker/gotools/bin/protoc-gen-go’: No such file or directory
yum -y install protobuf
go get github.com/golang/protobuf/protoc-gen-go
cd $GOPATH/src/github.com/golang/protobuf/
gmake all
cd $GOPATH/src/github.com/hyperledger/fabric
cp $GOPATH/bin/protoc-gen-go build/docker/gotools/bin/
如下為解決:vendor/github.com/miekg/pkcs11/pkcs11.go:29:18: fatal error: ltdl.h: No such file or directory
yum -y install libtool-ltdl-devel
如下為解決:can't load package: package github.com/hyperledger/fabric-ca/cmd/fabric-ca-client: open /opt/gopath/src/github.com/hyperledger/fabric-ca/cmd/fabric-ca-client: permission denied
臨時關閉selinux:su -c "setenforce 0"
參考文檔:http://www.linuxidc.com/Linux/2015-03/115124.htm
編譯fabric-ca代碼
make all