(Fabric 超级账本学习【5】)Fabric2.4网络环境下——搭建Hyperledger Fabric区块链浏览器
创始人
2025-05-28 11:50:34
0

博主最近在搭建Hyperledger Fabric区块链浏览器过程中也学习了很多博主的搭建流程,踩了很多雷,踩
了很多坑,现将成功搭建好的Hyperledger Fabric区块链浏览器详细流程分享如下,帮助大家避雷闭坑

fabric浏览器

Hyperledger Explorer 是一个简单,强大,易于使用,维护良好的开源实用程序,可浏览底层区块链网络上的活动。用户可以在MacOS和Ubuntu上配置和构建Hyperledger Explorer。先要保证你之前项目已成功启动。

搭建Hyperledger Fabric区块链浏览器前提

1. 成功搭建部署好Hyperledger Fabric 2.4(2.x)网络

搭建目录结构

在 hyperledger 目录下 新建同级目录 explorer
在这里插入图片描述

然后进入 test-network 目录下启动网络
在这里插入图片描述
启动Fabric网络

./network.sh up createChannel -ca -s couchdb 

在这里插入图片描述
将启动成功网络后生成的证书文件夹 organizations 复制到前面新建的 explorer 文件夹中
在这里插入图片描述

然后下载如下如下三个配置文件(官方推荐) 但是因为网络原因很难下载下来

docker-compose.yaml
config.json
test-network.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml

所以推荐大家先把官方的区块链项目下载下来,然后将需要的三个配置文件放进 explorer 文件夹中
在这里插入图片描述

官方区块链浏览器项目地址 https://github.com/hyperledger-labs/blockchain-explorer

这里需要将 test-network.json 文件 放在 connection-profile 目录下,其它均在 explorer 目录中的同级目录下

至此启动区块链浏览器需要的完整目录结构如下:

docker-compose.yaml
config.json
connection-profile/test-network.json
organizations/ordererOrganizations/     
organizations/peerOrganizations/

虚拟机中的目录结构图如下:
在这里插入图片描述

修改三个配置文件

找到docker网络

docker network ls

我们可以看到 本区块链浏览器的docker网络为 fabric_test 后面在修改配置文件的时候需要修改
在这里插入图片描述

config.json

{"network-configs": {"test-network": {"name": "fabric_test","profile": "./connection-profile/test-network.json"}},"license": "Apache-2.0"
}

test-network.json

{"name": "fabric_test",   "version": "1.0.0","client": {"tlsEnable": true,"adminCredential": {   "id": "hp","password": "123456"},"enableAuthentication": true,"organization": "Org1MSP","connection": {"timeout": {"peer": {"endorser": "300"},"orderer": "300"}}},"channels": {"mychannel": {"peers": {"peer0.org1.example.com": {}}}},"organizations": {"Org1MSP": {"mspid": "Org1MSP","adminPrivateKey": {"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"},"peers": ["peer0.org1.example.com"],"signedCert": {"path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"}}},"peers": {"peer0.org1.example.com": {"tlsCACerts": {"path": "/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"},"url": "grpcs://peer0.org1.example.com:7051"}}
}

docker-compose.yaml


# SPDX-License-Identifier: Apache-2.0
version: '2.1'volumes:pgdata:walletstore:networks:mynetwork.com:name: fabric_testservices:explorerdb.mynetwork.com:image: hyperledger/explorer-db:latestcontainer_name: explorerdb.mynetwork.comhostname: explorerdb.mynetwork.comenvironment:- DATABASE_DATABASE=fabricexplorer- DATABASE_USERNAME=hppoc- DATABASE_PASSWORD=passwordhealthcheck:test: "pg_isready -h localhost -p 5432 -q -U postgres"interval: 30stimeout: 10sretries: 5volumes:- pgdata:/var/lib/postgresql/datanetworks:- mynetwork.comexplorer.mynetwork.com:image: hyperledger/explorer:latestcontainer_name: explorer.mynetwork.comhostname: explorer.mynetwork.comenvironment:- DATABASE_HOST=explorerdb.mynetwork.com- DATABASE_DATABASE=fabricexplorer- DATABASE_USERNAME=hppoc- DATABASE_PASSWD=password- LOG_LEVEL_APP=info- LOG_LEVEL_DB=info- LOG_LEVEL_CONSOLE=debug- LOG_CONSOLE_STDOUT=true- DISCOVERY_AS_LOCALHOST=false- PORT=${PORT:-8080}volumes:- ${EXPLORER_CONFIG_FILE_PATH}:/opt/explorer/app/platform/fabric/config.json- ${EXPLORER_PROFILE_DIR_PATH}:/opt/explorer/app/platform/fabric/connection-profile- ${FABRIC_CRYPTO_PATH}:/tmp/crypto- walletstore:/opt/explorer/walletports:- ${PORT:-8080}:${PORT:-8080}depends_on:explorerdb.mynetwork.com:condition: service_healthynetworks:- mynetwork.com

启动浏览器

依次执行如下命令

假如之前启动过 先停用镜像

sudo docker-compose down 

在 docker-compose.yaml 中为持久性数据(Postgres 数据和用户钱包)分配了两个命名卷。如果要清除这些命名卷

sudo docker-compose down -v   

一定要设置好下面三个环境变量,不然启动浏览器会报错!!!!!!!

export EXPLORER_CONFIG_FILE_PATH=./config.json
export EXPLORER_PROFILE_DIR_PATH=./connection-profile
export FABRIC_CRYPTO_PATH=./organizations

最后启动区块链浏览器

sudo docker-compose up -d 

打开浏览器输入

http://127.0.0.1:8080

成功启动浏览器

默认登录名、密码如下

"id": exploreradmin
"password": exploreradminpw

也可以在 test-network.json 文件中修改登录名和密码

   "adminCredential": {   "id": "hhhhhhh","password": "123456"},

出现如下界面表示启动成功
在这里插入图片描述
登录进入后可以看到fabric 浏览器详细信息:区块信息、通道信息、节点信息等等
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
有效的括号 一、题目 给定一个只包括 '(',')','{','}'...
【Ctfer训练计划】——(三... 作者名:Demo不是emo  主页面链接:主页传送门 创作初心ÿ...