所需依赖以及安装
- Nodejs 8.11.x (Note that v9.x is not yet supported)
- PostgreSQL 9.5 or greater
- jq
- docker-ce
- docker-compose
- git
在上一篇的《Hyperledger Fabric 多机部署》已经部署好了 Fabric 网络,这里用 CLI 那台机器来部署 Hyperledger Explorer,所以有些依赖已经安装好了。
安装 PostgreSQL
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
##修改密码
sudo -u postgres
psql -c "ALTER USER postgres PASSWORD 'postgres';"
安装 jq
apt-get install jq
jq --version
代码配置
Clone 项目代码
git clone https://github.com/hyperledger/blockchain-explorer.git & cd blockchain-explorer
配置数据库
修改 app/explorerconfig.json
{
"persistence": "postgreSQL",
"platforms": ["fabric"],
"postgreSQL": {
"host": "127.0.0.1",
"port": "5432",
"database": "fabricexplorer",
"username": "postgres",
"passwd": "postgres"
}
}
给 db 目录设置权限
chmod -R 775 app/persistence/fabric/postgreSQL/db
执行数据库脚本
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
su - postgres
./createdb.sh
配置 fabric 网络
这里的配置基于我们上一篇搭建的 fabric 网络,进入blockchain-explorer/app/platform/fabric
目录做响应的修改config.json
:
{
"name": "fabric-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminUser": "admin",
"adminPassword": "adminpw",
"enableAuthentication": false,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {},
"peer0.org2.example.com": {},
"orderer.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/b04f0b81d66a714cb3fcf17206376eaa59dee8853e1cb1b501dca71e63d40fef_sk"
},
"signedCert": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
},
"Org2MSP": {
"mspid": "Org2MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/b1ad20e44fba3b5095119796acb4480eddb5331c4fc42f461f46f3dfcb2334f9_sk"
},
"signedCert": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
},
"OrdererMSP": {
"mspid": "OrdererMSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/root/fabric/fabric-network/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/2cf39d9293b690bcce3b427fde9590240a1f2a4734c05a7612e058ba5ff1de44_sk"
},
"signedCert": {
"path": "/root/fabric/fabric-network/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpc://192.168.11.12:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
},
"peer0.org2.example.com": {
"tlsCACerts": {
"path": "/root/fabric/fabric-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
},
"url": "grpc://192.168.11.14:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org2.example.com"
}
}
},
"orderers": {
"orderer.example.com": {
"url": "grpc://localhost:7050"
}
}
}
打包编译
apt-get install build-essential
cd blockchain-explorer
./main.sh install
启动&停止
直接在项目目录下执行启动脚本:
./start.sh debug #开启debug
通过加上 debug 参数可以在日志文件中查看启动过程中的错误,默认服务器启动端口为8080
,通过浏览器可以直接 ip+端口访问
停止服务
./stop.sh
到此一个可以用于实际生产环境的多机 Hyperledger Fabric 区块链网络部署就完成了。
转载请注明: 转载自Ryan 是菜鸟 | LNMP 技术栈笔记
如果觉得本篇文章对您十分有益,何不 打赏一下
本文链接地址: Hyperledger Fabric Explorer 安装配置
<img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/80x15.png" />
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。