blockchain-explorer配置文档
-
前提
测试平台
- ubuntu 20.04.1(基于VMware Player的虚拟机) amd64架构
先决条件
-
一个可用的fabric网络环境(测试版本:fabric-sample 2.3.0)
为此,你应该已经准备了以下软件:
软件名称 本文测试版本 Docker 19.03.8 docker-compose 1.25.0 Git 2.25.1 cURL 7.75.0 Golang 1.16.2 JQ 1.6 - 对于Docker,请确保你已经运行过以下命令:
- 开启Docker:
sudo systemctl start docker
- 使Docker开机启动:
sudo systemctl enable docker
- 添加你的用户到Docker用户组:
sudo usermod -a -G docker <username>
- 对于blockchain-explorer,你还需准备以下软件:
软件名称 本文测试版本 Nodejs 10.19.0 PostgreSQL 12.6 npm 6.14.4
- 对于Docker,请确保你已经运行过以下命令:
环境部署
克隆代码仓库
git clone https://github.com/hyperledger/blockchain-explorer.git cd blockchain-explorer
配置文件
- 修改
app/explorerconfig.json
配置文件,以更改PostgreSQL数据库设置:"postgreSQL": { "host": "127.0.0.1", "port": "5432", "database": "fabricexplorer", "username": "hppoc", "passwd": "password" }
在每次pull代码仓库后,你需要做以下工作,以调整
db/
文件夹的权限:
在blockchain-explorer目录下:cd app/persistence/fabric/postgreSQL chmod -R 775 db/
更改代码结构
- 修改
app/platform/fabric/config.json
文件,以指定你的fabric网络配置文件路径:{ "network-configs": { "test-network": { "name": "Test Network", "profile": "./connection-profile/test-network.json", "enableAuthentication": false } }, "license": "Apache-2.0" }
test-network
是网络的名称,可以更改为任意名称name
是fabric网络的名称,请将name
的值改为相应fabric网络的名称profile
是fabric配置文件的地址,一般不做修改
- 更改fabric网络配置文件
app/platform/fabric/connection-profile/test-network.json
:- 将文件中所有
fabric-path
更改为相应fabric网络在磁盘中的 绝对路径 - 检查
adminPrivateKey
配置选项,它指向以_sk
结尾的文件,检查文件是否存在,若不存在,将adminPrivateKey
的值改为对应位置的文件名 adminUser
和adminPassword
是浏览器登录时的账号密码,可做相应修改enableAuthentication
的值决定打开页面时是否跳转到登录页面,若该值为false
则跳过身份认证
- 将文件中所有
执行数据库创建脚本
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db sudo -u postgres ./createdb.sh
连接到PostpreSQL数据库并检查DB状态
sudo -u postgres psql -c '\l'
结果如下:
List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ----------------+----------+----------+---------+---------+----------------------- fabricexplorer | hppoc | UTF8 | C.UTF-8 | C.UTF-8 | postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 | template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (4 rows)
另开一个控制台窗口,执行:
sudo -u postgres psql fabricexplorer -c '\d'
结果如下(可能存在不同):
List of relations Schema | Name | Type | Owner --------+---------------------------+----------+------- public | blocks | table | hppoc public | blocks_id_seq | sequence | hppoc public | chaincodes | table | hppoc public | chaincodes_id_seq | sequence | hppoc public | channel | table | hppoc public | channel_id_seq | sequence | hppoc public | orderer | table | hppoc public | orderer_id_seq | sequence | hppoc public | peer | table | hppoc public | peer_id_seq | sequence | hppoc public | peer_ref_chaincode | table | hppoc public | peer_ref_chaincode_id_seq | sequence | hppoc public | peer_ref_channel | table | hppoc public | peer_ref_channel_id_seq | sequence | hppoc public | transactions | table | hppoc public | transactions_id_seq | sequence | hppoc public | write_lock | table | hppoc public | write_lock_write_lock_seq | sequence | hppoc (18 rows)
搭建浏览器
以下命令在每次pull仓库后都需要重新执行:
- 安装,运行测试,并搭建项目
./main.sh install
- 清理
/node_modules
,client/node_modules
,client/build
,client/coverage
,app/test/node_modules
目录./main.sh clean
运行浏览器
- 打开GUI界面
npm start
- 停止服务
./stop.sh