• 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

  • 相关阅读:
    Debian 9 Stretch APT问题
    『现学现忘』Git基础 — 22、Git中文件重命名
    Q-Learning
    Day22——二叉搜索树最近的公共祖先、二叉搜索树中的插入操作、删除二叉搜索树中的节点
    Oracle根据时间查询
    Java并发编程面经1
    【LeetCode】Day187-分割回文串
    LINUX之文件
    大话设计模式——2.简单工厂模式(Simple Factory Pattern)
    【打卡】牛客网:BM37 二叉搜索树的最近公共祖先
  • 原文地址:https://blog.csdn.net/songzehao/article/details/134299067