一.Hyperledger Fabric环境搭建
参考博客 https://blog.csdn.net/tiandiwuya/article/details/78767244 Hyperledger Fabric 1.0 实战开发系列 第一课 系统环境搭建
https://blog.csdn.net/tiandiwuya/article/details/78771475 Hyperledger Fabric 1.0 实战开发系列 第二课 Fabric环境搭建
二. 运行 Blockchain for Insurance
官方github : https://github.com/IBM/build-blockchain-insurance-app
官方环境配置要求:
- Docker - v1.13 以上
- Docker Compose - v1.8 以上
- NPM - v5.6.0 以上
- nvm - v8.11.3 (用于下载nodejs和npm,同时也可以选择你要运行的版本。没有也可以)
- Node.js- node v8.11.3 不要用SUDO模式安装
- Git client- v 2.9.x 以上
- Python - 2.7.x
Clone项目源码:
git clone https://github.com/IBM/build-blockchain-insurance-app.git
打开VPN,***
登录你的docker账户:
docker login
如果没有docker账号,需要注册docker,注册网址 https://hub.docker.com/
若注册按钮为灰色,则vpn未连接成功。
登录成功会显示
login succeed
进入项目文件夹,运行.sh文件
cd build-blockchain-insurance-app
./build_ubuntu.sh
因为要下载镜像,配置等,过程会很慢(期间要保持VPN畅通)
最后出现以下代码,说明启动成功
Creating repairshop-ca ...
Creating insurance-ca ...
Creating shop-ca ...
Creating police-ca ...
Creating orderer0 ...
Creating repairshop-ca
Creating insurance-ca Creating police-ca Creating shop-ca Creating orderer0 ... done Creating insurance-peer ... Creating insurance-peer ... done Creating shop-peer ... Creating shop-peer ... done Creating repairshop-peer ... Creating repairshop-peer ... done Creating web ... Creating police-peer ... Creating web Creating police-peer ... done
打开日志:
docker logs web
出现如下代码说明启动成功:
> blockchain-for-insurance@2.1.0 serve /app
> cross-env NODE_ENV=production&&node ./bin/server /app/app/static/js Server running on port: 3000 Default channel not found, attempting creation... Successfully created a new default channel. Joining peers to the default channel. Chaincode is not installed, attempting installation... Base container image present. info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins info: [packager/Golang.js]: packaging GOLANG from bcins Successfully installed chaincode on the default channel. Successfully instantiated chaincode on all peers.
打开 localhost:3000 即完成项目运行。
关闭项目(否则再次开机后无法直接运行项目):
cd build-blockchain-insurance-app/web
docker-compose down
查看已启动项目:
docker ps
再次开启项目:
docker-compose up -d