Hyperledger Explorer与Hyperledger Fabric1.4.1结合使用

1 搭建Hyperledger Explorer

1.1 获取Hyperledger Explorer项目

git clone https://github.com/hyperledger/blockchain-explorer

该项目需要依赖:
Nodejs 8.11.x (Note that v9.x is not yet supported)
PostgreSQL 9.5 or greater
jq

1.2 搭建运行环境

在centos7虚拟机上安装jq

yum -y install jq

在虚拟机上安装nodejs 8.11.3

在虚拟机上安装postgresql

yum  -y install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm
yum -y install postgresql95-server postgresql95-contrib
/usr/pgsql-9.5/bin/postgresql95-setup initdb #初始化数据库
systemctl enable postgresql-9.5.service #设置开机启动
systemctl start postgresql-9.5.service  #启动服务

修改postgresql密码

su - postgres
psql -U postgres #默认用户
ALTER USER postgres WITH PASSWORD '123456' #密码
\q  #退出
exit

开启远程访问

vim  /var/lib/pgsql/9.5/data/postgresql.conf
修改#listen_addresses = 'localhost'  为  listen_addresses='*'

信任远程连接

vim /var/lib/pgsql/9.5/data/pg_hba.conf
# IPv4 local connections:
host    all            all      127.0.0.1/32      trust #可以设置其他,该处只是示意例子
host    all            all      0.0.0.0/0         trust #可以设置其他,该处只是示意例子

重启服务

systemctl restart postgresql-9.5.service

1.3 启动Hyperledger Fabric1.4.1 byfn的例子

进入first-network的例子

cd /opt/gopath/src/github.com/hyperledger/fabric-samples/first-network
./byfn.sh generate 
./byfn.sh up

具体参考:hyperledger-fabric

1.4 修改blockchain-explorer配置信息

cd  /opt/gopath/src/github.com/hyperledger/blockchain-explorer
vim appconfig.json   #修改"host": "localhost", 为"host": "虚拟机ip", 也可以修改端口
cd app
vim explorerconfig.json #修改postgresql相关连接信息

其他参数参考:blockchain-explorer

1.5 导入数据库相关脚本

cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh

会创建fabricexplorer库以及相关表和索引。

1.6 explorer与fabric1.4.1 byfn例子结合

cd /opt/gopath/src/github.com/hyperledger/blockchain-explorer/app/platform/fabric
vim config.json #设置blockchain network的名称,connectionProfile的路径

在这里插入图片描述
编辑first-network.json文件

vim  ./connection-profile/first-network.json #可以设置explorer登录账号密码

在这里插入图片描述
fabric的byfn例子所在路径是/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network替换掉first-network.json文件中/fabric-path/first-network,并且替换9b5e1e91c5e7ca0c0e83799586e729d027e4c1275f079b6c59584f50c7df1faa_sk成真实的私钥文件名称(去具体路径下查看)。
poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzMyNjc1NDI3,size_16,color_FFFFFF,t_70)
fabric的byfn例子中peer节点都暴露了地址所以通过服务发现可以自动补全网络拓扑,找寻相关网络中节点等信息。

1.7 构建项目

cd blockchain-explorer
./main.sh install #安装、测试、构建项目

#./main.sh clean #清空各种依赖和构建的项目

1.8 启动项目

cd blockchain-explorer/
./start.sh debug #debug模式启动项目

#./stop.sh #关闭项目
启动日志:
在这里插入图片描述

1.9 访问explorer界面

访问http://虚拟机ip:8080 (端口可以修改默认8080) 用户名密码可以配置,默认admin/adminpw
在这里插入图片描述
具体功能菜单(主要是方便查看数据):
在这里插入图片描述

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值