WDlinux官方论坛's Archiver

chainke 发表于 2020-9-17 12:07

Hyperledger Explorer 环境搭建详解

[p=30, 2, left]Hyperledger Explorer 是一个简单,功能强大,易于使用,高度可维护的开源区块链浏览器,用于查看底层区块链网络上的活动。[/p][p=30, 2, left]网络上很多教程按着操作是不行得,今天抽空记录一下详细教程。[/p][p=30, 2, left]前提条件[/p][list][*]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 权限[/list][p=30, 2, left]1、nodejs 安装[/p][p=30, 2, left]参考
https://blog.csdn.net/tiansheng1225/article/details/83899808[/p][p=30, 2, left]2、PostgreSQL 安装[/p][p=30, 2, left]参考
https://www.linuxidc.com/Linux/2017-10/147536.htm[/p][p=30, 2, left]3、jq 安装[/p][p=30, 2, left]参考
https://blog.csdn.net/markximo/article/details/80449626[/p][p=30, 2, left]4、gcc-c++ 安装[/p]yum install -y gcc-c++
[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]5、下载源码[/p]git clone https://github.com/hyperledger/blockchain-explorer.git
[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]6、修改数据库配置[/p]cd blockchain-explorer/appvi  explorerconfig.json


[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]修改 username 跟 passwd[/p]{  "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"  }}















[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]7、PostgreSQL 数据库用户创建、表创建,建议使用工具[/p][p=30, 2, left]按官网文档提示得执行 createdb.sh 脚本来创建用户、数据库及表,但是执行会报错,所以此处建议自己创建。[/p][p=30, 2, left]本人用得是 navicat premium 来创建[/p][p=30, 2, left]先创建一个角色同上面得配置,此处为 chenjf,密码 123456[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/339134626.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left]创建数据库命名同上面配置,此处为 fabricexplorer[/p][p=30, 2, left]创建表,需要切换到刚才创建的用户下操作,脚本在 blockchain-explorer/app/persistence/fabric/postgreSQL/db 目录下的 explorerpg.sql,可以拷贝出来在 navicat premium 上执行,其中:user 需要改成对应的用户名,如下面这张表创建完指定所属用户时:ALTER table blocks owner to chenjf;记得要有分号。[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/731840943.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left]8、全部创建完后启动 first-network,执行。/byfn.sh up 启动 fabric 环境[/p][p=30, 2, left]9、修改 Explorer 里面的 fabric 配置,以 first-network 为例,如果自己搭建的就根据实际调整。[/p][p=30, 2, left]主要是替换 fabric-path 为实际 first-network 的路径,cd blockchain-explorer-bak/app/platform/fabric[/p][p=30, 2, left]编辑配置文件:vi config.json,替换文中所有的 fabric-path 为 fabric-samples 所在的路径即可,其他的均可不做修改[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/615140145.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left]10、编译[/p]cd blockchain-explorernpm installcd client/npm installnpm run build




[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]编译过程如果权限不足的记得给指定目录下的所有文件添加可读权限[/p]chmod  -R 755 所在目录
[p=30, 2, left][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img][/p][p=30, 2, left]11、启动执行[/p][p=30, 2, left]cd blockchain-explorer
./start.sh[/p][p=30, 2, left]启动后看下日志是否正常,日志位于 blockchain-explorer/logs/console/目录下,出现以下类似日志说明已经成功部署。[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/759623062.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left]12、打开浏览器预览[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/139019934.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/547022332.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/492252427.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[img=100,0]https://img-blog.csdnimg.cn/20190430113208130.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTA4NTcwNTI=,size_16,color_FFFFFF,t_70[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/865127117.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p][p=30, 2, left][img=100,0]https://img.learnblockchain.cn/2020/09/02_/978380748.png[/img][img=100,0]data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==[/img]​[/p]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.