Hyperledger Explorer部署

安装Hyperledger Explorer

1、下载源代码(版本必须与Fabric的版本对应)

git clone https://github.com/hyperledger/blockchain-explorer.git

2、修改配置文件

docker-compose.yaml

version: '2.1'

volumes:
  pgdata:
  credentialstore:

networks:
  mynetwork.com:
    external:
      name: artifacts_default

services:

  explorerdb.mynetwork.com:
    image: hyperledger/explorer-db:latest
    container_name: explorerdb.mynetwork.com
    hostname: explorerdb.mynetwork.com
    environment:
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWORD=password
    volumes:
      - ./app/persistence/fabric/postgreSQL/db/createdb.sh:/docker-entrypoint-initdb.d/createdb.sh
      - pgdata:/var/lib/postgresql/data
    networks:
      - mynetwork.com

  explorer.mynetwork.com:
    image: hyperledger/explorer:latest
    container_name: explorer.mynetwork.com
    hostname: explorer.mynetwork.com
    environment:
      - DATABASE_HOST=explorerdb.mynetwork.com
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - ENROLL_ID=hlbeuser
      - DISCOVERY_AS_LOCALHOST=false
    volumes:
    # 这里修改config.json、crypto-config的路径为我们自己的文件路径
      - /root/blockchain-explorer/examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
      - /root/blockchain-explorer/examples/net1/crypto-config:/tmp/crypto
      - credentialstore:/opt/tmp
      # 添加hosts映射:这个主要原因是explorer与peer通信有问题,所以通过主机端口的方式
      - ./exp-hosts:/etc/hosts
    command: sh -c "sleep 16&& node /opt/explorer/main.js && tail -f /dev/null"
    ports:
      - 8080:8080
    networks:
      - mynetwork.com

examples/net1/config.json

主要修改Path为fabric-network的crypto-config路径和每个Peer的端口

{
  "network-configs": {
    "network-1": {
      "version": "1.0",
      "clients": {
        "client-1": {
          "tlsEnable": true,
          "organization": "Org2",
          "channel": "mychannel",
          "credentialStore": {
            "path": "./tmp/credentialStore_Org2/credential",
            "cryptoStore": {
              "path": "./tmp/credentialStore_Org2/crypto"
            }
          }
        }
      },
      "channels": {
        "mychannel": {
          "peers": {
            "peer0.org1.example.com": {},
            "peer1.org1.example.com": {},
            "peer0.org2.example.com": {},
            "peer1.org2.example.com": {}
          },
          "connection": {
            "timeout": {
              "peer": {
                "endorser": "6000",
                "eventHub": "6000",
                "eventReg": "6000"
              }
            }
          }
        }
      },
      "organizations": {
        "Org1": {
          "mspid": "Org1MSP",
          "fullpath": false,
          "adminPrivateKey": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore"
          },
          "signedCert": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts"
          },
          "certificateAuthorities": ["ca-org1"],
          "peers": ["peer0.org1.example.com", "peer1.org1.example.com"]
        },
        "Org2": {
          "mspid": "Org2MSP",
          "adminPrivateKey": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/msp/keystore"
          },
          "signedCert": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/msp/signcerts"
          },
          "certificateAuthorities": ["ca-org2"],
          "peers": ["peer0.org2.example.com", "peer1.org2.example.com"]
        },
        "OrdererMSP": {
          "mspid": "OrdererMSP",
          "adminPrivateKey": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore"
          }
        }
      },
      "peers": {
        "peer0.org1.example.com": {
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
          },
          "url": "grpcs://peer0.org1.example.com:7051",
          "eventUrl": "grpcs://peer0.org1.example.com:7053",
          "grpcOptions": {
            "ssl-target-name-override": "peer0.org1.example.com"
          }
        },
        "peer1.org1.example.com": {
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
          },
          "url": "grpcs://peer1.org1.example.com:8051",
          "eventUrl": "grpcs://peer1.org1.example.com:8053",
          "grpcOptions": {
            "ssl-target-name-override": "peer1.org1.example.com"
          }
        },
        "peer0.org2.example.com": {
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
          },
          "url": "grpcs://peer0.org2.example.com:9051",
          "eventUrl": "grpcs://peer0.org2.example.com:9053",
          "grpcOptions": {
            "ssl-target-name-override": "peer0.org2.example.com"
          }
        },
        "peer1.org2.example.com": {
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt"
          },
          "url": "grpcs://peer1.org2.example.com:10051",
          "eventUrl": "grpcs://peer1.org2.example.com:10053",
          "grpcOptions": {
            "ssl-target-name-override": "peer1.org2.example.com"
          }
        }
      },
      "orderers": {
        "orderer.example.com": {
          "url": "grpcs://orderer.example.com:7050"
        }
      },
      "certificateAuthorities": {
        "ca-org1": {
          "url": "https://ca.org1.example.com:7054",
          "httpOptions": {
            "verify": false
          },
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
          },
          "caName": "ca-org1"
        },
        "ca-org2": {
          "url": "https://ca.org2.example.com:7054",
          "httpOptions": {
            "verify": false
          },
          "tlsCACerts": {
            "path": "/root/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem"
          },
          "caName": "ca-org2"
        }
      }
    },
    "network-2": {}
  },
  "configtxgenToolPath": "fabric-path/fabric-samples/bin",
  "license": "Apache-2.0"
}

3、启动Hyperledger Explorer

docker-compose -f docker-compose.yaml up -d

通过local host:8080访问explorer

4、停止Hyperledger Explorer

docker-compose -f docker-compose.yaml down

你可能感兴趣的:(区块链)