1、参考hyperledger explorer文档 https://github.com/hyperledger/blockchain-explorer
2、参考中文文档(我自己百度看到的)文档 http://blog.hubwiz.com/2020/03/09/hyperledger-explorer-tutorial/
3、帮助很大的一个文章 https://blog.csdn.net/ASN_forever/article/details/88093170
接下来介绍我的过程:
我的环境是Ubuntu 16.04
1)首先我们根据下图安装我们想要的版本 --- 我安装的是hyperledger explorer v0.3.6
2)安装
nodejs 我安装的是v8.11.2
PostgreSQL 9.5 or greater
jq
以下版本的Docker已经验证过支持Hyperledger Explorer:
- Docker CE 18.09.2或更高版本
- Docker Compose 1.14.0
执行以下命令克隆Hyperledger Explorer的Git仓库以获得最新版本:
- git clone https://github.com/hyperledger/blockchain-explorer.git
修改explorer版本的方法
- 通过 git branch -a 查看当前版本
- 通过 git checkout release-3.6 / git checkout v0.3.6
- ---- 我采用的是git checkout v0.3.6 但是我看大家用的都是git checkout release-3.6这种 应该没啥影响
3)下载完成后 进入这里 赋予一下权限 (否则可能走不了下面的代码,但是我没执行好像也能走)
- cd blockchain-explorer/app/persistence/fabric/postgreSQL
- chmod -R 775 db/
4)接下来运行数据库
- cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
- ./createdb.sh
5)通过以下命令连接数据库查看内容
- sudo -u postgres psql
-
\l:查看创建的fabricexplorer数据库 -
\d:查看创建的数据表
6)接下来就是config.json 修改成对应的你的内容
- cd blockchain-explorer/app/platform/fabric
修改其中的config.json
7)执行以下命令
cd blockchain-explorer
npm install
cd blockchain-explorer/app/test
npm install
npm run test
cd client/
npm install
npm test -- -u --coverage
npm run build
其中cd blockchain-explorer/app/test ---- npm run test --- 这样子就ok啦
其中npm test -- -u --coverage 成功效果图最后大概就是这个样子
- npm install ----- 我最开始由于没有外网这条命令执行不了/我也不确定是不是外网的原因
- npm test -- -u --coverage --- 会抛出一个错误,根据报错的地方注释掉就好啦
8)如果不出现任何问题,到这里一般就成功啦
- cd blockchain-explorer
- ./start.sh
就ok啦 可以看到你想看到的结果啦 -- 对了记得把网络启动了哟
我出现的问题:1)就是没外网npm install执行不了 2)config.json配置出错 -- 这个我修改了通道名字,mspid,organization 3)还有就是版本总是不确定,所以这里我把我用的版本都列出来了方便大家参考啦
emmm 在这方面我还是个菜鸟 如果哪里写错了或者用词错了请多多包含啦