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.8 | 4G以上 | 4核以上 | 可访问互联网 |
docker环境搭建
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
**备注:**启动区块链网络的操作,详见《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/[email protected]/msp/keystore/c578a6d8ed736023a0a8abb84c8fb1b6d31e39efbf9b4878af7a90132c4fec3c_sk"
},
"peers": ["peer0.org1.example1.com"],
"certificateAuthorities": ["ca-org1"],
"signedCert": {
"path": "/tmp/crypto/peerOrganizations/org1.example1.com/users/[email protected]/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