hyperledger fabric部署总结

之前在有道云笔记上分享过,但想想还是搬到这里来吧,以后统一方便整理自己的知识进入正题....

之前在调研 hyperledger fabric,其实部署说明官网都有,只是东西都是国外的照着操作也会遇到许多的坑,这里就提前给大家踩雷了,进入正题...

系统环境 linux 16.04+

安装 curl

安装 docker 和 docker-compse

step 1 : docker官网下载 根据自己环境下载指定版本的 *.deb 包 https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
step 2 : sudo dpkg -i docker-ce_*.deb
step 3 : 通过运行hello-world 映象验证是否安装Docker CE
$ sudo docker run hello-world Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
step 4 : 修改docker 镜像
sudo vim /etc/docker/daemon.json 添加如下内容
{ "registry-mirrors": ["https://registry.docker-cn.com"] }

修改保存后重启docker 使配置生效,

systemctl restart docker
step 5 : 判断是否安装docker,执行 docker --version
docker-compse 安装方法: 参考资料 https://docs.docker.com/compose/install/#install-compose
step 1 : 运行命令下载最新版本的docker-compse
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

step 2 : 对二进制文件应用可执行权限

sudo chmod +x /usr/local/bin/docker-compose

step 3 : 判断是否安装

$ docker-compose --version docker-compose version 1.21.0, build 5920eb0

安装go

go安装方法: 下载最新压缩包 https://golang.org/dl/
step 1 : 解压安装
tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz
使用nano ~/.profile 添加代码
step 2 : 配置
export GOROOT=/usr/local/go export PATH=$GOROOT/bin:$PATH export GOPATH=/opt/gopath
执行 source ~/.profile

安装 Samples, Binaries and Docker Images

创建文件目录
cd /opt sudo mkdir gopath cd gopath/ sudo mkdir src cd src/ sudo mkdir github.com cd github.com/ sudo mkdir hyperledger cd hyperledger/

若能FQ,则执行

curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0
若无法下载,则将该路径的代码拷贝到本地 https://github.com/hyperledger/fabric/blob/master/scripts/bootstrap.sh
将文件中第77行,第80行代码注释掉,且手动下载下面2个文件到目录 /opt/gopath/src/github.com/hyperledger
# curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz # curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz
下载路径 ,根据实际版本选择下载 ,本例为 1.1.0-rcl
解压下载文件,生成文件夹 bin,文件夹下有二进制文件如下
  • cryptogen,
  • configtxgen,
  • configtxlator,
  • peer,
  • orderer, and
  • fabric-ca-client
配置 nano ~/.profile 添加
export PATH=/opt/gopath/src/github.com/hyperledger/bin:$PATH
编译 source ~/.profile
执行 bootstrap.sh
sudo bash bootstrap.sh
docker exec -it cli bash

查询账户a

peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

账户a转10给账户b

peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}'

查看mychannel下的info

 
posted @ 2018-11-19 15:58  q兽兽  阅读(373)  评论(0编辑  收藏  举报