blockchain-explorer可视化工具安装部署

blockchain-explorer可视化工具安装部署

一、介绍

Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open source utility to browse activity on the underlying blockchain network. Users have the ability to configure and build Hyperledger Explorer on MacOS and Ubuntu.

github源码地址:

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

gitee极速镜像地址:

https://gitee.com/ryou5416/blockchain-explorer.git

在这里插入图片描述

二、系统环境要求

操作系统内存CPU网络环境
CentOS7.84G以上4核以上可访问互联网

三、基础环境搭建

docker环境搭建

四、blockchain-explorer并部署

1.we need:

docker-compose.yaml
config.json
connection-profile/first-network.json
organizations/ordererOrganizations/
organizations/peerOrganizations/

目录结构:

[root@chain1 blockchain-explorer]# tree multipeer
multipeer
├── config.json
├── connection-profile
│   ├── connection.json
│   ├── connection.json.ok1 #备份文件(无CA认证)
│   └── connection.json.ok2 # 备份文件(有CA认证)
├── docker-compose.yaml
├── organizations -> /opt/gopath/src/github.com/hyperledger/fabric/multipeer/crypto-config # 软链接
└── ReadMe.txt

2 directories, 6 files

2.下载并复制需要的文件

yum install -y git
mkdir -p /home/blockchain-explorer/multipeer/organization
cd /home/blockchain-explorer
git clone https://gitee.com/ryou5416/blockchain-explorer.git
mkdir -p multipeer/organization
cp /home/blockchain-explorer/blockchain-explorer/app/platform/fabric/config.json /home/blockchain-explorer/multipeer/
cp -r /home/blockchain-explorer/blockchain-explorer/app/platform/fabric/connection-profile /home/blockchain-explorer/multipeer/
cp /home/blockchain-explorer/blockchain-explorer/docker-compose.yaml /home/blockchain-explorer/multipeer/

3.启动区块链网络后,并为组织文件夹(含私匙、签名等连接信息)建立软链接

cd /home/blockchain-explorer/multipeer
ln -s $FABRIC/multipeer/crypto-config organizations

1.png

**备注:**启动区块链网络的操作,详见《Hyperledger Fabric环境搭建》

4.修改docker-compose.yaml 配置文件

cd /home/blockchain-explorer/multipeer
vim docker-compose.yaml

内容如下:


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

volumes:
  pgdata:
  walletstore:

networks:
  mynetwork.com:
    external:
      name: multipeer_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
    healthcheck:
      test: "pg_isready -h localhost -p 5432 -q -U postgres"
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - 5432:5432
    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_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - LOG_LEVEL_APP=debug
      - LOG_LEVEL_DB=debug
      - LOG_LEVEL_CONSOLE=info
      - LOG_CONSOLE_STDOUT=true
      - DISCOVERY_AS_LOCALHOST=false
    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
    command: sh -c "node /opt/explorer/main.js && tail -f /dev/null"
    ports:
      - 80:8080
    depends_on:
      explorerdb.mynetwork.com:
        condition: service_healthy
    networks:
      - mynetwork.com

注意事项:

1).官方说明中卷映射错误问题

 # 官方说明有误,/opt/wallet应该改为/opt/explorer/wallet
 - walletstore:/opt/explorer/wallet

2).blockchain-explorer/examples/net1案例代码过旧,容器启动时,提示缺少properties问题

使用blockchain-explorer/app/platform/fabric

5.修改config.json配置文件

cd /home/blockchain-explorer/multipeer
vim config.json

内容如下:

{
        "network-configs": {
                "multipeer": {
                        "name": "multipeer",
                        "profile": "./connection-profile/connection.json"
                }
        },
        "license": "Apache-2.0"
}

6.修改connection.json配置文件

cd /home/blockchain-explorer/multipeer/connection-profile
vim connection.json

内容如下:

{
        "name": "multipeer",
        "version": "1.0.0",
        "client": {
                "tlsEnable": true,
                "caCredential": {
                        "id": "admin",
                        "password": "adminpw"
                },
                "adminCredential": {
                        "id": "exploreradmin",
                        "password": "exploreradminpw",
                        "affiliation": "org1.department1"
                },
                "enableAuthentication": true,
                "organization": "Org1MSP",
                "connection": {
                        "timeout": {
                                "peer": {
                                        "endorser": "300"
                                },
                                "orderer": "300"
                        }
                }
        },
        "channels": {
                "mychannel": {
                        "peers": {
                                "peer0.org1.example1.com": {}
                        },
                        "connection": {
                                "timeout": {
                                        "peer": {
                                                "endorser": "6000",
                                                "eventHub": "6000",
                                                "eventReg": "6000"
                                        }
                                }
                        }
                }
        },
        "organizations": {
                "Org1MSP": {
                        "mspid": "Org1MSP",
                        "adminPrivateKey": {
                                "path": "/tmp/crypto/peerOrganizations/org1.example1.com/users/Admin@org1.example1.com/msp/keystore/c578a6d8ed736023a0a8abb84c8fb1b6d31e39efbf9b4878af7a90132c4fec3c_sk"
                        },
                        "peers": ["peer0.org1.example1.com"],
                        "certificateAuthorities": ["ca-org1"],
                        "signedCert": {
                                "path": "/tmp/crypto/peerOrganizations/org1.example1.com/users/Admin@org1.example1.com/msp/signcerts/cert.pem"
                        }
                }
        },
        "peers": {
                "peer0.org1.example1.com": {
                        "tlsCACerts": {
                                "path": "/tmp/crypto/peerOrganizations/org1.example1.com/peers/peer0.org1.example1.com/tls/ca.crt"
                        },
                        "url": "grpcs://peer0.org1.example1.com:7051",
                        "eventUrl": "grpcs://peer0.org1.example1.com:7053",
                        "grpcOptions": {
                                "ssl-target-name-override": "peer0.org1.example1.com"
                        }
                }
        },
        "certificateAuthorities": {
                "ca-org1": {
                "url": "https://ca.org1.example1.com:7054",
                "caName": "ca-org1",
                "tlsCACerts": {
                        "path": "/tmp/crypto/peerOrganizations/org1.example1.com/ca/ca.org1.example1.com-cert.pem"
                  },
                "httpOptions": {
                        "verify": false
                 }
        }
    }

}

注意事项:

1.adminCredential在首次启动时,会向CA注册用户exploreradmin,并在客户端留存(保持目录- walletstore:/opt/explorer/wallet)。请不要重复注册(例如移除容器和匿名卷时,丢失exploreradmin.id文件,此时需要换一个id重新注册,或者在ca服务器中删除原有用户),否则浏览器启动失败!!!

 "adminCredential": {
                        "id": "exploreradmin",
                        "password": "exploreradminpw",
                        "affiliation": "org1.department1"
                },

2.配置文件中的域名,使用DNS服务器配置。若未搭建DNS服务器,可以在docker-compose.yml配置文件中增加host地址映射。例如

   extra_hosts: 
      - "ca.org1.example1.com:192.168.1.103"

五、防火墙设置

firewall-cmd --zone=public --add-port= 80/tcp –permanent
firewall-cmd --zone=public --add-port= 5432/tcp –permanent
firewall-cmd reload

六、启动或停止服务

启动(调试时,可以将-d参数去掉,查看控制台实时日志):
# docker-compose -f docker-compose.yaml up -d
查看hyperledger/explorer-db:latest和hyperledger/explorer:latest启动状态
# docker ps -a

关闭:
# docker-compose down

备注:首次启动需要下载docker images,请保持网络畅通,耐心等待!!!

在这里插入图片描述

访问:

访问地址:http://chain1/

用户名:exploreradmin

密码:exploreradminpw

七、备份配置文件

# cd /home/blockchain-explorer
备份成压缩文件
# tar -zcvf multipeer.tar.gz multipeer
解压还原
# tar -zxvf multipeer.tar.gz
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搬山境KL攻城狮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值