Hyperledger Fabric快速上手

安装go

curl -O https://storage.googleapis.com/golang/go1.10.2.linux-amd64.tar.gz
tar -xvf go1.10.2.linux-amd64.tar.gz && mv go /usr/local
yum install -y libsnappy-dev zlib1g-dev libbz2-dev libltdl-dev libtool glibc-static libtool-ltdl-devel

修改环境变量:vi /etc/profile,完成后source /etc/profile

export GOROOT=/usr/local/go
export GOPATH=/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

常用工具

go get github.com/golang/protobuf/protoc-gen-go \
&& go get github.com/kardianos/govendor \
&& go get github.com/golang/lint/golint \
&& go get golang.org/x/tools/cmd/goimports \
&& go get github.com/onsi/ginkgo/ginkgo \
&& go get github.com/client9/misspell/cmd/misspell \
&& go get github.com/AlekSi/gocov-xm

安装docker和docker-compose

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce
vi /etc/docker/daemon.json # { "registry-mirrors": [ "http://18817714.m.daocloud.io" ] }
vi /usr/lib/systemd/system/docker.service # ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
systemctl daemon-reload # systemctl restart docker docker run hello
-world curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose

获取fabric、fabric-samples,工具包建议直接下载:https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/

mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric
make cryptogen
make configtxgen
# 生成证书和通道配置需要这两个工具,orderer和peer通常是在docker容器运行

 获取镜像,运行示例

cd $GOPATH/src/github.com/hyperledger/fabric-samples/scripts
bash fabric-preload.sh 1.1.0
cd $GOPATH/src/github.com/hyperledger/fabric-samples/basic-network
bash startup.sh
bash teardown.sh
cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
bash byfn.sh -m up
bash byfn.sh -m down
#windows CRLF
#dos2unix preload.sh && chmod +x preload.sh

 镜像清理

docker rm -f $(docker ps -qa)
docker system prune

 

posted @ 2018-05-10 18:44  xlongwei  阅读(229)  评论(0编辑  收藏  举报
xlongwei