Fabric Explore最简单的搭建教程

最简单的搭建方式就是使用官方提供的docker-compose.
通过docker-compose的volumes可以看到,它将net1下的文件挂载到了docker内。那么你就可以修改net1下的文件,或者修改挂载路径;

explorer.example.com:
    image: hyperledger/explorer:latest
    container_name: explorer.example.com
    hostname: explorer.example.com
    environment:
      - DATABASE_HOST=explorerdb.example.com
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - DISCOVERY_AS_LOCALHOST=false
    volumes:
      - ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
      - ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - ./examples/net1/crypto:/tmp/crypto
      - walletstore:/opt/wallet

我是修改net1下的文件。

  1. 将搭建Fabric网络生成的密钥文件copy到./examples/net1/crypto
  2. ./examples/net1/connection-profile/first-network内的adminPrivateKey和peer的urleventUrl换成你自己的。
  3. 运行docker。
    docker-compose -f 你的docker-compose文件 up -d

我在docker-compose up -d后遇到的问题:

  1. Error : [ 'Default client peer is down and no channel details available database' ]
  2. error: [Remote.js]: Error: Failed to connect before the deadline URL:grpcs://orderer0.example.com:7050

产生这两个错误原因都是是explorer和fabric不在同一个网络上,explorer连接不上你的fabric。

我在docker-compose文件内的explorer.example.com下把URL和域名做了映射--extra_hosts,解决了以上问题。

explorer.example.com:
    image: hyperledger/explorer:latest
    container_name: explorer.example.com
    hostname: explorer.example.com
    environment:
      - DATABASE_HOST=explorerdb.example.com
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - DISCOVERY_AS_LOCALHOST=false
    volumes:
      - ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
      - ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - ./examples/net1/crypto:/tmp/crypto
      - walletstore:/opt/wallet
    command: sh -c "sleep 16&& node /opt/explorer/main.js && tail -f /dev/null"
    ports:
      - 8090:8080
    networks:
      - example.com
    extra_hosts:
      - "orderer0.example.com:0.0.0.0:1111"
      - "orderer1.example.com:XXX"
      - "orderer2.example.com:XXX"
      - "peer0.org1.example.com:XXX"
      - "peer0.org2.example.com:XXX"
      - "peer0.org3.example.com:XXX"

你可能感兴趣的:(Fabric Explore最简单的搭建教程)