在Ubuntu18.04中搭建Hyperledger Explorer

本文详细介绍了Hyperledger Explorer的环境准备、具体部署步骤及注意事项,包括Node.js与PostgreSQL安装、数据库初始化、源码下载、配置修改、网络启动、包引入测试及服务启动等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、环境准备(本节是紧接着上一篇博客编写:https://note.youdao.com/share/?id=08cba7c7957649ad31049483b42f3067&type=note#/

参考官方文档:https://github.com/hyperledger/blockchain-explorer

1、nodejs安装(nodejs 8.11.x (Note that v9.x is not yet supported)),由于上一篇博客已经安装了nvm,所以只需用nvm安装指定版本即可(此处安装8.11.4版本)

root@ubuntu:~# nvm install 8.11.4
Downloading and installing node v8.11.4...
Downloading https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz...
################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v8.11.4 (npm v5.6.0)
root@ubuntu:~# node -v
v8.11.4
root@ubuntu:~# 

2、postgresql安装(PostgreSQL 9.5 or greater),这里以docker的形式进行安装

docker pull postgres:9.5
docker run --name postgres1 -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:9.5 #postgres镜像默认的用户名为postgres,设置一个密码postgres

3、安装jq

sudo apt-get install jq

二、具体步骤

1、下载blockchain-explorer源码

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

2、数据库初始化

root@iZq0c7mivu8vrvZ:~# docker exec -it b88997d1aad3 /bin/bash    #进入postgresql容器:b88997d1aad3
root@b88997d1aad3:/# su postgres   #切换用户
postgres@b88997d1aad3:/$ psql   #进入命令行客户端
psql (9.5.15)
Type "help" for help.

postgres=# CREATE DATABASE fabricexplorer owner postgres; #创建fabricexplorer数据库并指定用户fabricexplorer

数据库创建好后执行初始化sql语句(也可以用postgresql相关桌面客户端连接数据库),以下数据库脚本参考官方https://github.com/hyperledger/blockchain-explorer/blob/master/app/persistence/fabric/postgreSQL/db/explorerpg.sql:
-- ----------------------------
--  Table structure for `blocks`
-- ----------------------------
DROP TABLE IF EXISTS blocks;

CREATE TABLE blocks (
  id SERIAL PRIMARY KEY,
  blocknum integer DEFAULT NULL,
  datahash character varying(256) DEFAULT NULL,
  prehash character varying(256) DEFAULT NULL,
  txcount integer DEFAULT NULL,
  createdt Timestamp DEFAULT NULL,
  prev_blockhash character varying(256) DEFAULT NULL,
  blockhash character varying(256) DEFAULT NULL,
  channel_genesis_hash character varying(256) DEFAULT NULL
);

ALTER table blocks owner to postgres;

-- ----------------------------
--  Table structure for `chaincodes`
-- ----------------------------
DROP TABLE IF EXISTS chaincodes;

CREATE TABLE chaincodes (
  id SERIAL PRIMARY KEY,
  name character varying(255) DEFAULT NULL,
  version character varying(255) DEFAULT NULL,
  path character varying(255) DEFAULT NULL,
  chan
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值