当前位置:   article > 正文

Fabric区块链浏览器搭建_fabric浏览器

fabric浏览器


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

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

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

二、配置docker-compose

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

内容如下:

# 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59

三、配置区块链浏览器

创建配置文件config.json

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

内容如下:

{
    "network-configs": {
        "fabric_dev": {
            "name": "Fabric for dev",
            "profile": "./connection-profile/fabric_dev.json"
        }
    },
    "license": "Apache-2.0"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

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

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

内容如下:

{
    "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/priv_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"
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

最终的目录:

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

四、启动区块链浏览器

$ 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
  • 1
  • 2
  • 3
  • 4

启动完成,查看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
  • 1
  • 2
  • 3
  • 4

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/235685
推荐阅读
相关标签
  

闽ICP备14008679号