Fabric区块链浏览器搭建

news/2024/7/5 8:16:27

目录

    • 一、创建区块链浏览器相关目录
    • 二、配置docker-compose
    • 三、配置区块链浏览器
    • 四、启动区块链浏览器

书接这一回 Fabric二进制建链,在建好链之后,将为这条链部署一个区块链浏览器。

  • Hyperledger Fabric区块链浏览器地址:https://github.com/hyperledger-labs/blockchain-explorer

一、创建区块链浏览器相关目录

mkdir -p /home/songzehao/fabric/explorer/connection-profile

二、配置docker-compose

vim /home/songzehao/fabric/explorer/docker-compose.yaml

内容如下:

# SPDX-License-Identifier: Apache-2.0
version: '2.1'
​
volumes:
  pgdata:
  walletstore:
​
networks:
  mynetwork.com:
    external: false
    name: fabric_dev
​
services:
​
  explorerdb.mynetwork.com:
    image: ghcr.io/hyperledger-labs/explorer-db:latest
    container_name: explorerdb.mynetwork.com
    hostname: explorerdb.mynetwork.com
    environment:
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWORD=password
    healthcheck:
      test: "pg_isready -h localhost -p 5432 -q -U postgres"
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - mynetwork.com
​
  explorer.mynetwork.com:
    image: ghcr.io/hyperledger-labs/explorer:latest
    container_name: explorer.mynetwork.com
    hostname: explorer.mynetwork.com
    environment:
      - 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:
      - ./config.json:/opt/explorer/app/platform/fabric/config.json
      - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - /home/songzehao/fabric/organizations:/tmp/crypto
      - walletstore:/opt/explorer/wallet
    ports:
      - ${PORT:-8080}:${PORT:-8080}
    depends_on:
      explorerdb.mynetwork.com:
        condition: service_healthy
    networks:
      - mynetwork.com

三、配置区块链浏览器

创建配置文件config.json

vim /home/songzehao/fabric/explorer/config.json

内容如下:

{
    "network-configs": {
        "fabric_dev": {
            "name": "Fabric for dev",
            "profile": "./connection-profile/fabric_dev.json"
        }
    },
    "license": "Apache-2.0"
}

继续配置节点证书相关fabric_dev.json

vim /home/songzehao/fabric/explorer/connection-profile/fabric_dev.json

内容如下:

{
    "name": "fabric_dev",
    "version": "1.0.0",
    "client": {
        "tlsEnable": true,
        "adminCredential": {
            "id": "exploreradmin",
            "password": "exploreradminpw"
        },
        "enableAuthentication": false,
        "organization": "Org1MSP",
        "connection": {
            "timeout": {
                "peer": {
                    "endorser": "300"
                },
                "orderer": "300"
            }
        }
    },
    "channels": {
        "channel1": {
            "peers": {
                "peer0.org1.example.com": {}
            }
        }
    },
    "organizations": {
        "Org1MSP": {
            "mspid": "Org1MSP",
            "adminPrivateKey": {
                "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/6ac25f833930b9ac48f4598ccc2f0b3c30868296accfd0bf6ca4d27082c1cfea_sk"
            },
            "peers": ["peer0.org1.example.com"],
            "signedCert": {
                "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/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://192.168.3.128:7051"
        }
    }
}

最终的目录:

/home/songzehao/fabric/explorer
├── config.json
├── connection-profile
│   └── fabric_dev.json
└── docker-compose.yaml
​
1 directory, 3 files

四、启动区块链浏览器

$ cd /home/songzehao/fabric/explorer && docker-compose -f docker-compose.yaml up -d
Creating network "fabric_dev" with the default driver
Creating explorerdb.mynetwork.com ... done
Creating explorer.mynetwork.com   ... done

启动完成,查看docker容器:

$ docker ps
CONTAINER ID   IMAGE                                            COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
431be406c069   ghcr.io/hyperledger-labs/explorer:latest         "docker-entrypoint.s…"   27 seconds ago   Up 26 seconds             0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   explorer.mynetwork.com
59bc641d507e   ghcr.io/hyperledger-labs/explorer-db:latest      "docker-entrypoint.s…"   58 seconds ago   Up 57 seconds (healthy)   5432/tcp                                    explorerdb.mynetwork.com

打开区块链浏览器地址http://192.168.3.128:8080
fabric-exlporer


http://lihuaxi.xjx100.cn/news/1766965.html

相关文章

Pandas - 数据合并

DataFrame数据合并主要使用merge()方法和concat()方法。 1.数据合并(merge()方法) Pandas模块的merge()进行数据合并时,两个DataFrame对象必须有相同的列。 1.常规合并 import pandas as pddf1 pd.DataFrame({编号:[mr001,mr002,mr003],语…

(六)库存超卖案例实战——使用mysql分布式锁解决“超卖”问题

前言 本节内容是关于使用分布式锁解决并发访问“超卖”问题的最终篇,在前面的章节中我们介绍了使用mysql的行锁、乐观锁、悲观锁解决并发访问导致的超卖问题,存在的问题是行锁、乐观锁、悲观锁不太灵活,需要和具体的业务耦合到一起&#xff…

【PTE-day05 宽字节注入】

1、函数 过滤输入的函数: addslashes mysql_real_escape_string mysql_escape_string当字符的大小为一个字节时,称之为窄字节 例如ascii编码 当字符的大小为两个字节时,称之为宽字节 例如GB2312、GBK、GB8030 mysql使用GBK编码时,默认的会认为两个字符为一个汉字,前一个字…

省钱兄短剧短视频小程序是如何运营的?

随着短视频的兴起,越来越多的人热衷于在闲暇时间刷短视频。在这种背景下,省钱兄短剧短视频小程序应运而生,以一种新颖、有趣的方式满足了用户的观看需求。本文将详细介绍这个小程序的成功运营策略。 产品特点 内容丰富:省钱兄短…

1212. 地宫取宝

题目&#xff1a; 1212. 地宫取宝 - AcWing题库 思路&#xff1a;dp&#xff08;最长上升子序列和摘花生的结合&#xff09; 代码&#xff1a; #include<iostream> using namespace std; const int N 55; const int MOD 1000000007;int n, m, k; int w[N][N];//每个坐…

图形界面应用案例——关灯游戏(以及扩展)(python)

7.8 图形界面应用案例——关灯游戏 题目: [案例]游戏初步——关灯游戏。 关灯游戏是很有意思的益智游戏,玩家通过单击关掉(或打开)一盏灯。如果关(掉(或打开)一个电灯,其周围(上下左右)的电灯也会触及开关,成功地关掉所有电灯即可过关。 图7-43 关灯游戏运行效…

Gerrit lfs安装及配置

Gerrit版本&#xff1a;3.1.4 lfs下载&#xff1a;Zuul Gerrit CI界面已经没有3.1.4对应版本的lfs.jar了&#xff0c;需要从上面的页面下载。 一、安装配置lfs 将上面下载的lfs.jar放到$GERRIT_SITE/plugins目录。 修改配置文件&#xff1a;$GERRIT_SITE/etc/gerrit.config …

2023/11/8JAVA学习

多个条件也可以&&放在一块,支持链式编程 map()数据加工,一个对象转化为另一个 不能这样写 不会去重报错