- Hyperledger Fabric 1.0 实战(三)试运行
- Fabric-Failed to connect to goo.
- Hyperledger Fabric V1.0 开发者快速入门.
- Hyperledger Fabric v1.0alpha mac
- Hyperledger Fabric 1.0架构浅析
- Mac 搭建超级账本(hyperledger )网络
- Hyperledger Fabric 1.0 实战(一)环境准备
- Hyperledger Fabric 1.0 实战 - 集合版本
- 8. Hyperledger Fabric 专题 - Hyper
- 1. Hyperledger Fabric - 介绍
接《Hyperledger Fabric 1.0 实战(一)环境准备》:
https://www.jianshu.com/p/12d8d82305da
有了一定准备后,可以去拉去Fabric开源的镜像和源码进行试运行了。
1. git拉去源代码
a.创建Fabric目录
mkdir -p /opt/gopath/src/github.com/hyperledger
b.进入hyperledger目录
cd /opt/gopath/src/github.com/hyperledger
c.克隆fabric v1.0.0代码
git clone -b v1.0.0 https://github.com/hyperledger/fabric.git
2. 拉取fabric所需要的镜像
脚本自动拉取:
进入./fabric/examples/e2e_cli/目录,后台执行镜像拉取任务。(因为镜像还是比较大的所以放那里自己跑,然后去喝茶)
# nohup ./download-dockerimages.sh &
后续查看nohup.out查看进度就好了;
或者挑战自己,手动去操作:
a.上DockerHub官方镜像网站:
https://hub.docker.com/u/hyperledger/?page=1
b.搜索依赖名称,执行如下命令:
docker pull hyperledger/fabric-tools:x86_64-1.0.0
docker pull hyperledger/fabric-couchdb:x86_64-1.0.0
docker pull hyperledger/fabric-kafka:x86_64-1.0.0
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.0
docker pull hyperledger/fabric-orderer:x86_64-1.0.0
docker pull hyperledger/fabric-javaenv:x86_64-1.0.0
docker pull hyperledger/fabric-ccenv:x86_64-1.0.0
docker pull hyperledger/fabric-ca:x86_64-1.0.0
docker pull hyperledger/fabric-baseos:x86_64-0.3.1
docker pull hyperledger/fabric-baseimage:x86_64-0.3.1
docker pull hyperledger/fabric-membersrvc:latest
c.所有的镜像文件及版本号修改完成后,执行如下命令:
docker images
d.为了方便docker-compose的配置,我们将所有的镜像tag都改为latest,执行如下格式的命令
docker tag IMAGEID(镜像id) REPOSITORY:TAG(仓库:标签)
docker tag 0403fd1c72c7 docker.io/hyperledger/fabric-tools:latest
e.镜像备份和拷贝
1.保存镜像
docker save 6830dcd7b9b5> /tmp/docker/fabric-images/peer.tar
2.加载镜像
docker load < /tmp/docker/fabric-peer.tar
镜像加载完成后,可根据之前的方案,将镜像tag都改为lastest。
查看所有的镜像
docker images
3. 编译cryptogen、configtxgen等工具
1. 进入fabric根目录
# cd opt/gopath/src/github.com/hyperledger/fabric/
2. 执行编译release
# make release
4. e2e_cli单机运行测试
1. 进入e2e_cli 目录
# cd opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli
2. 运行启动脚本
# ./network_setup.sh up
结果:
……
Query Result: 90
2018-04-24 08:49:35.836 UTC [main] main -> INFO 007 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful =====================
===================== All GOOD, End-2-End execution completed =====================
_____ _ _ ____ _____ ____ _____
| ____| | \ | | | _ \ | ____| |___ \ | ____|
| _| | \| | | | | | _____ | _| __) | | _|
| |___ | |\ | | |_| | |_____| | |___ / __/ | |___
|_____| |_| \_| |____/ |_____| |_____| |_____|
看到以上内容说明基础环境一切准备就绪;
3. 停止fabric的e2e_cli
# ./network_setup.sh down
5. fabric-samples 更多试运行
git clone https://github.com/hyperledger/fabrci-samples.git
cd fabric-samples/basic-network
docker-compose f docker-compose.yml up -d
result:
Creating orderer.example.com ... done
Creating peer0.org1.example.com ... done
Creating couchdb ...
Creating orderer.example.com ...
Creating cli ...
Creating peer0.org1.example.com ...
#docker ps ---> for check 可以看到所有启动的镜像
# 切换管理员用户,进入peer节点服务 peer0.org1.example.com 管理员才可以进行创建通道
docker exec -it -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com bash
# 创建通道
peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
# 加入通道
peer channel join -b mychannel.block
# 退出peer节点容器peer0.org1.example.com
exit
#进入cli
docker exec -it cli /bin/bash
#给peer节点容器peer0.org1.example.com安装链码(智能合约),注意其中有两种方式go/node
peer chaincode install -n mycc -v v0 -p github.com/chaincode_example02/go/
#实例化链码
peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n mycc -v v0 -c '{"Args":["init","a","100","b","200"]}'
#链码调用和查询
peer chaincode query -C mychannel -n mycc -v v0 -c '{"Args":["query","a"]}'
接下来就是多机部署:《Hyperledger Fabric 1.0 实战(四)多机部署e2e_cli》
https://www.jianshu.com/p/4a12ef59a489
网友评论