fabric1.4浏览器搭建

准备工作

explorer 依赖 nodejs 8.11(高版本的不支持)、PostgreSQL 9.5 和以上版本、jq 命令。

启动 PostgreSQL 数据库

这里的数据库使用何种方式启动不重要,自己觉得顺手就行

$ docker run -idt \
    -e POSTGRES_USER="postgres" \
    -e POSTGRES_PASSWORD="password" \
    -p 5432:5432  \
    postgres:latest

本地还需要安装 psql,一个用于连接 postgres 数据库的命令:

$ yum install -y epel-release  postgresql    # CentOS 上安装方法

确定能用下面的命令进入数据库,密码是 password:

$ psql -h 127.0.0.1 -U postgres
Password for user postgres:
psql (11.2, server 12.1 (Debian 12.1-1.pgdg100+1))
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=#

blockchain-explorer配置

把 blockchain-explorer 下载到 ~/hyperledger-fabric-1.4.4 目录中:

$ cd $GOPATH/src/github.com/hyperledger
$ git clone https://github.com/hyperledger/blockchain-explorer.git

这里使用的是 v0.3.9.5 版本,explorer 和 fabric 的版本适配情况见 blockchain-explorer release:

$ cd blockchain-explorer
$ git checkout -b v0.3.9.5    # v0.3.9.5 适配 fabric 1.4

核实配置文件 app/explorerconfig.json

{
  "persistence": "postgreSQL",
  "platforms": ["fabric"],
  "postgreSQL": {
    "host": "127.0.0.1",
    "port": "5432",
    "database": "fabricexplorer",
    "username": "hppoc",
    "passwd": "password"
  },
  "sync": {
    "type": "local",
    "platform": "fabric",
    "blocksSyncTime": "3"
  }
}

初始化 blockchain-explorer 使用的数据库
创建数据库

$ cd app/persistence/fabric/postgreSQL/db
vim createdb.sh
#这里使用的是docker启动的数据库,如果使用物理机方式下面方法方法可能不适用或者不需要
linux*) psql postgres -h 127.0.0.1 -U postgres -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./explorerpg.sql ;
psql postgres -h 127.0.0.1 -U postgres -v dbname=$DATABASE -v user=$USER -v passwd=$PASSWD -f ./updatepg.sql ;;

就是加上 -h 127.0.0.1 -U postgres
./createdb.sh

设置 fabric 对接文件
blockchain-explorer 中的 app/platform/fabric/config.json 是用来连接 fabric 的配置文件:

$ ls app/platform/fabric/config.json

app/platform/fabric/config.json

修改config中的文件路径等信息
下面命令一次性修改全部
Mac 上执行:

$ sed -i "" -e "s#/fabric-path#/Users/lijiao/hyperledger-fabric-1.4.4#" app/platform/fabric/config.json

Linux 上执行:

$ sed -i -e "s#/fabric-path#/Users/lijiao/hyperledger-fabric-1.4.4#" app/platform/fabric/config.json

编译启动 blockchain-explorer
安装依赖包,构建 blockchain-explorer:

$ npm config set registry https://registry.npm.taobao.org  # 添加淘宝镜像源,加快速度
$ cd blockchain-explorer
$ npm install
$ cd client   # 进入 client 目录
$ npm install
$ npm run build

启动

$ cd blockchain-explorer
$ node ./main.js
....显示信息...
write_set size >>>>>>>>> :  0.5014553070068359 MB
Insert sql is INSERT INTO transactions  ( "blockid","txhash","createdt","chaincodename","chaincode_id","status","creator_msp_id","endorser_msp_id","type","read_set","write_set","channel_genesis_hash","validation_code","envelope_signature","payload_extension","creator_nonce","chaincode_proposal_input","endorser_signature","creator_id_bytes","payload_proposal_hash","endorser_id_bytes" ) VALUES( 
... 省略 ...

第二次执行将跳过前面操作(方便自己使用的笔记,请忽略)

cd  $GOPATH/src/github.com/hyperledger/blockchain-explorer
 nohup node ./main.js  &

错误:
如果peer数量显示不对首先需要检查服务发现是否能发现其他的节点
同组织的可以查看boot节点是否指定

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值