Fabric区块链浏览器搭建

编程入门 行业动态 更新时间:2024-10-25 04:23:20

Fabric<a href=https://www.elefans.com/category/jswz/34/1769670.html style=区块链浏览器搭建"/>

Fabric区块链浏览器搭建

目录

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

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

  • Hyperledger Fabric区块链浏览器地址:

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

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:external: falsename: fabric_dev
​
services:
​explorerdb.mynetwork:image: ghcr.io/hyperledger-labs/explorer-db:latestcontainer_name: explorerdb.mynetworkhostname: explorerdb.mynetworkenvironment:- 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
​explorer.mynetwork:image: ghcr.io/hyperledger-labs/explorer:latestcontainer_name: explorer.mynetworkhostname: explorer.mynetworkenvironment:- DATABASE_HOST=explorerdb.mynetwork- 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/walletports:- ${PORT:-8080}:${PORT:-8080}depends_on:explorerdb.mynetwork:condition: service_healthynetworks:- mynetwork

三、配置区块链浏览器

创建配置文件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": {"peer01.example": {}}}},"organizations": {"Org1MSP": {"mspid": "Org1MSP","adminPrivateKey": {"path": "/tmp/crypto/peerOrganizations/org1.example/users/Admin@org1.example/msp/keystore/6ac25f833930b9ac48f4598ccc2f0b3c30868296accfd0bf6ca4d27082c1cfea_sk"},"peers": ["peer01.example"],"signedCert": {"path": "/tmp/crypto/peerOrganizations/org1.example/users/Admin@org1.example/msp/signcerts/cert.pem"}}},"peers": {"peer01.example": {"tlsCACerts": {"path": "/tmp/crypto/peerOrganizations/org1.example/peers/peer01.example/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 ... done
Creating explorer.mynetwork   ... 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
59bc641d507e   ghcr.io/hyperledger-labs/explorer-db:latest      "docker-entrypoint.s…"   58 seconds ago   Up 57 seconds (healthy)   5432/tcp                                    explorerdb.mynetwork

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

更多推荐

Fabric区块链浏览器搭建

本文发布于:2023-11-15 20:30:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605886.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区块   浏览器   Fabric

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!