M2-Macbook安装hyperledger explorer-docker方式,手把手安装

M2芯片按官方教程安装有一些问题,记录分享各类坑的解决方式

官方教程如下

GitHub - hyperledger-labs/blockchain-explorer

本文为docker方式

1、先决条件

按官方

docker相关依赖、hyperfavric ledger等

2、启动fabric网络

官方指导:Hyperledger Fabric official tutorial
这里默认你已经配置好了fabric测试网络(test-network)

3、参考官方及该博主分享

http://t.csdn.cn/hMj4y

3.1配置文件

a.创建一个新目录(例如explorer)

直接在test-network 文件夹下面建立explorer文件夹:

mkdir explorer
cd explorer

b.从存储库复制以下文件

wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/docker-compose.yaml

c.从您的fabric网络(例如/fabric-samples/test-network)复制整个加密工件目录(organizations/)

cp -rf organizations explorer

把test-network中的organizations文件复制进来explorer(我的目录如下)

d. explorer配置好后,您应该拥有以下文件和目录结构。

3.2修改文件

a. 编辑docker-compose中的环境变量。与您的环境保持一致

# SPDX-License-Identifier: Apache-2.0
version: '2.1'

volumes:
  pgdata:
  walletstore:

networks:
  mynetwork.com:
      external:
          name: fabric_test

services:

  explorerdb.mynetwork.com:
    image: hyperledger/explorer-db:latest
    container_name: explorerdb.mynetwork.com
    platform: linux/amd64
    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: hyperledger/explorer:latest

    container_name: explorer.mynetwork.com

    platform: linux/amd64

    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

      - ./organizations:/tmp/crypto

      - walletstore:/opt/explorer/wallet

    ports:

      - ${PORT:-8080}:${PORT:-8080}

    depends_on:

      explorerdb.mynetwork.com:

        condition: service_healthy

    networks:

      - mynetwork.com

注意标红部分,m2芯片需要注明platform,不然会启动docker时会报错。

name部分要与你的网络名名称一致,如果你的网络默认是net_test,则不需要修改。
(查看docker网络命令:docker network ls)

 

我这里是fabric_test

b.在连接配置文件(test-network.json)中用管理证书和秘密(私有)密钥替换用户的证书。您需要指定Explorer容器上的绝对路径。

修改connection profile
cd connection-profile
vim test-network.json

{

        "name": "test-network",

        "version": "1.0.0",

        "client": {

                "tlsEnable": true,

                "adminCredential": {

                        "id": "exploreradmin",

                        "password": "exploreradminpw"

                },

                "enableAuthentication": true,

                "organization": "Org1MSP",

                "connection": {

                        "timeout": {

                                "peer": {

                                        "endorser": "300"

                                },

                                "orderer": "300"

                        }

                }

        },

        "channels": {

                "mychannel": {

                        "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/Admin@org1.example.com-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://peer0.org1.example.com:7051"

                }

        }

}

标蓝处为用户名及密码

标红处注意修改

4.启动容器

docker-compose up -d

5.访问使用explorer

在地址栏输入:http://localhost:8080/

登陆后即可

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值