docker方式简单部署blockchain-explorer

本文的环境为Ubuntu18.04,fabric v2.2.0,hyperledger explorer1.1.4。
在这里插入图片描述

一、环境依赖

  • Docker
  • Docker-compose

二、启动Hyperledger Fabric网络

启动Fabric官方测试网络test-network,fabric安装过程见Hyperledger Fabric official tutorial.:

./network.sh up createChannel

三、配置文件

  1. 将blockchain-explorer目录下面的/examples/net1/config.json和examples/net1/connection-profile拷贝到blockchain-explorer目录下。

  2. 将fabric-samples/test-network/organizations拷贝到blockchain-explorer目录下。
    使得blockchain目录下面存在以下几个文件:

    docker-compose.yaml
    config.json
    connection-profile/test-network.json
    organizations/ordererOrganizations/
    organizations/peerOrganizations/
    
  3. 编辑docker-compose.yaml
    编辑docker-compose.yaml的name和路径(volumes),以与自己本机的环境一致
    查看网络使用docker network ls和docker network inspect {network_name}命令。

        networks:
        mynetwork.com:
            external:
                name: net_test
    
        ...
    
        services:
          explorer.mynetwork.com:
    
            ...
    
            volumes:
              - ./config.json:/opt/explorer/app/platform/fabric/config.json
              - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
              - ./organizations:/tmp/crypto
              - walletstore:/opt/explorer/wallet
    
  4. 当通过bridge方式连接到fabric网络时,需要设置docker-compose.yaml中的DISCOVERY_AS_LOCALHOST为false来禁用主机名映射到本地主机。

    services:
    
      ...
    
      explorer.mynetwork.com:
    
        ...
    
        environment:
          - DISCOVERY_AS_LOCALHOST=false
    
  5. 在连接配置文件(test-network.json)中编辑admin证书和密钥的路径,此处需要指定资源管理器容器上的绝对路径。

    "organizations": {
        "Org1MSP": {
          "adminPrivateKey": {
            "path": "/tmp/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
    

四、启动容器服务

启动fabric网络后,运行以下命令启动explore和explorer-db服务:

$ docker-compose -d

访问地址:http://localhost:8080
用户名:exploreradmin
密码:exploreradminpw

五、关闭

  1. 停止服务时,但不删除持久化数据时,运行如下命令:
    $ docker-compose down
    
  2. docker-compose.yaml为持久化数据(Postgres数据和用户钱包)分配了两个命名卷,如果彻底想清除这些命名卷,运行以下命令:
    $ docker-compose down -v
    

使用docker方式部署blockchain-explorer时,出现了如下问题:
在这里插入图片描述
问题一:

Error: Failed to connect before the deadline on Endorser- name: peer0.org1.example.com, url:grpcs://peer0.org1.example.com:7051, connected:false, connectAttempted:true
Failed to connect to remote gRPC server peer0.org1.example.com url:grpcs://peer0.org1.example.com:7051 timeout:3000

原因:
是因为身份证书有误。由于我重新启动了fabric网络,因此身份证书更换了,而我没有更换blockchain-explorer目录下的organizations文件,因此出现了问题。

问题二:

error: [DiscoveryService]: send[mychannel] - Channel:mychannel received discovery error:access denied
[ERROR] FabricClient - Error: DiscoveryService: mychannel error: access denied

原因:
因为“钱包”是不正确的,或者过时了。
需要删除原来Postgres数据和用户钱包。运行以下命令:

docker-compose down -v

成功了!!!
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值