11

Hyperledger Explorer 环境搭建详解

 3 years ago
source link: https://learnblockchain.cn/article/1420
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Hyperledger Explorer是一个简单,功能强大,易于使用,高度可维护的开源区块链浏览器,用于查看底层区块链网络上的活动。

网络上很多教程按着操作是不行得,今天抽空记录一下详细教程。...

Hyperledger Explorer是一个简单,功能强大,易于使用,高度可维护的开源区块链浏览器,用于查看底层区块链网络上的活动。

网络上很多教程按着操作是不行得,今天抽空记录一下详细教程。

前提条件

  • nodejs 8.11.x (Note that v9.x is not yet supported)
  • PostgreSQL 9.5 or greater
  • Jq [https://stedolan.github.io/jq/]
  • gcc-c++
  • 非root用户下操做,pg数据库用户同服务器用户,需要sudo权限

1、nodejs安装

参考 https://blog.csdn.net/tiansheng1225/article/details/83899808

2、PostgreSQL安装

参考 https://www.linuxidc.com/Linux/2017-10/147536.htm

3、jq安装

参考 https://blog.csdn.net/markximo/article/details/80449626

4、gcc-c++安装

yum install -y gcc-c++

5、下载源码

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

6、修改数据库配置

cd blockchain-explorer/app

vi  explorerconfig.json

修改username跟passwd

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

7、PostgreSQL数据库用户创建、表创建,建议使用工具

按官网文档提示得执行createdb.sh脚本来创建用户、数据库及表,但是执行会报错,所以此处建议自己创建。

本人用得是navicat premium来创建

先创建一个角色同上面得配置,此处为chenjf,密码123456

AZN7ZnZ.png!mobile

创建数据库命名同上面配置,此处为fabricexplorer

创建表,需要切换到刚才创建的用户下操作,脚本在blockchain-explorer/app/persistence/fabric/postgreSQL/db目录下的explorerpg.sql,可以拷贝出来在navicat premium上执行,其中:user需要改成对应的用户名,如下面这张表创建完指定所属用户时:ALTER table blocks owner to chenjf;记得要有分号。

B3iiy2.png!mobile

8、全部创建完后启动first-network,执行./byfn.sh up启动fabric环境

9、修改Explorer里面的fabric配置,以first-network为例,如果自己搭建的就根据实际调整。

主要是替换fabric-path为实际first-network的路径,cd blockchain-explorer-bak/app/platform/fabric

编辑配置文件:vi config.json,替换文中所有的fabric-path为fabric-samples所在的路径即可,其他的均可不做修改

6nQ7biz.png!mobile

10、编译

cd blockchain-explorer
npm install
cd client/
npm install
npm run build

编译过程如果权限不足的记得给指定目录下的所有文件添加可读权限

chmod  -R 755 所在目录

11、启动执行

cd blockchain-explorer ./start.sh

启动后看下日志是否正常,日志位于blockchain-explorer/logs/console/目录下,出现以下类似日志说明已经成功部署。

eIfUVbf.png!mobile

12、打开浏览器预览

eAB3qiz.png!mobile

zErQn2U.png!mobile

7ZJjArB.png!mobileqemAFjZ.png!mobile

jeyQneq.png!mobile

RNBnqma.png!mobile

Hyperledger Explorer是一个简单,功能强大,易于使用,高度可维护的开源区块链浏览器,用于查看底层区块链网络上的活动。

网络上很多教程按着操作是不行得,今天抽空记录一下详细教程。

前提条件

  • nodejs 8.11.x (Note that v9.x is not yet supported)
  • PostgreSQL 9.5 or greater
  • Jq [ https://stedolan.github.io/jq/ ]
  • gcc-c++
  • 非root用户下操做,pg数据库用户同服务器用户,需要sudo权限

1、nodejs安装

参考 https://blog.csdn.net/tiansheng1225/article/details/83899808

2、PostgreSQL安装

参考 https://www.linuxidc.com/Linux/2017-10/147536.htm

3、jq安装

参考 https://blog.csdn.net/markximo/article/details/80449626

4、gcc-c++安装

yum install -y gcc-c++

5、下载源码

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

6、修改数据库配置

cd blockchain-explorer/app

vi  explorerconfig.json

修改username跟passwd

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

7、PostgreSQL数据库用户创建、表创建,建议使用工具

按官网文档提示得执行createdb.sh脚本来创建用户、数据库及表,但是执行会报错,所以此处建议自己创建。

本人用得是navicat premium来创建

先创建一个角色同上面得配置,此处为chenjf,密码123456

AZN7ZnZ.png!mobile

创建数据库命名同上面配置,此处为fabricexplorer

创建表,需要切换到刚才创建的用户下操作,脚本在blockchain-explorer/app/persistence/fabric/postgreSQL/db目录下的explorerpg.sql,可以拷贝出来在navicat premium上执行,其中:user需要改成对应的用户名,如下面这张表创建完指定所属用户时:ALTER table blocks owner to chenjf;记得要有分号。

B3iiy2.png!mobile

8、全部创建完后启动first-network,执行./byfn.sh up启动fabric环境

9、修改Explorer里面的fabric配置,以first-network为例,如果自己搭建的就根据实际调整。

主要是替换fabric-path为实际first-network的路径,cd blockchain-explorer-bak/app/platform/fabric

编辑配置文件:vi config.json,替换文中所有的fabric-path为fabric-samples所在的路径即可,其他的均可不做修改

6nQ7biz.png!mobile

10、编译

cd blockchain-explorer
npm install
cd client/
npm install
npm run build

编译过程如果权限不足的记得给指定目录下的所有文件添加可读权限

chmod  -R 755 所在目录

11、启动执行

cd blockchain-explorer ./start.sh

启动后看下日志是否正常,日志位于blockchain-explorer/logs/console/目录下,出现以下类似日志说明已经成功部署。

eIfUVbf.png!mobile

12、打开浏览器预览

eAB3qiz.png!mobile

zErQn2U.png!mobile

7ZJjArB.png!mobileqemAFjZ.png!mobile

jeyQneq.png!mobile

RNBnqma.png!mobile

本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

  • 发表于 17分钟前
  • 阅读 ( 5 )
  • 学分 ( 0 )
  • 分类:Fabric

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK