fabric-explorer快速搭建(dockercompose)
作者:互联网
本文内的配置文件配套的fabric网络项目地址https://github.com/Provence9654/citizens
docker-compose搭建方式非常简单,只需要修改几个配置文件即可,请按照自己的网络修改配置文件(笔者很久不搭test-network了,所以配置是按照自己的网络改的
预准备
dockercompose环境
已正常运行的fabric网络
配置文件内容
创建一个目录,例如,fabric-explorer
进入该目录,将fabric网络的crypto-config复制到该目录下,之后执行一系列创建命令:
touch docker-compose.yaml
touch config.json
touch connection-profile/test-network.json
[root@VM-0-5-centos explorer]# ls
config.json connection-profile crypto-config docker-compose.yaml
docker -compose.yaml文件内容如下:
version: '2.2'
volumes:
pgdata:
walletstore:
networks:
default:
external:
name: provence_default //这个地方一定保证和你的fabric网络一致
services:
explorerdb.provence.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.provence.com
hostname: explorerdb.provence.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:
default:
aliases:
- explorerdb.provence.com
explorer.provence.com:
image: hyperledger/explorer:latest
container_name: explorer.provence.com
hostname: explorer.provence.com
environment:
- DATABASE_HOST=explorerdb.provence.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
- ./crypto-config:/opt/explorer/crypto-config
- walletstore:/opt/explorer/wallet
ports:
- 8080:8080
depends_on:
explorerdb.provence.com:
condition: service_healthy
networks:
default:
aliases:
- explorer.provence.com
可使用docker network ls命令查看你的fabric容器的网络名称。
这个配置文件主要就是网络名称,还有卷别配错了。
config.json的内容:
{
"network-configs": {
"provence-network": {
"name": "Provence Network",
"profile": "./connection-profile/test-network.json"
}
},
"license": "Apache-2.0"
}
没啥好说的路径改一下就完了
connection-profile/test-network.json的内容:
{
"name": "provence-network",
"version": "1.0.0",
"client": {
"tlsEnable": true,
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "YJHMSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"provence3": {
"peers": {
"peer0.yjh.provence.com": {}
}
}
},
"organizations": {
"YJHMSP": {
"mspid": "YJHMSP",
"adminPrivateKey": {
"path": "/opt/explorer/crypto-config/peerOrganizations/yjh.provence.com/users/Admin@yjh.provence.com/msp/keystore/priv_sk"
},
"peers": ["peer0.yjh.provence.com"],
"signedCert": {
"path": "/opt/explorer/crypto-config/peerOrganizations/yjh.provence.com/users/Admin@yjh.provence.com/msp/signcerts/Admin@yjh.provence.com-cert.pem"
}
}
},
"peers": {
"peer0.yjh.provence.com": {
"tlsCACerts": {
"path": "/opt/explorer/crypto-config/peerOrganizations/yjh.provence.com/peers/peer0.yjh.provence.com/tls/ca.crt"
},
"url": "grpcs://peer0.yjh.provence.com:7051"
}
}
}
需要注意的是路径指的都是容器的绝对路径,不是容器外的路径,按照自己的网络配就完了。
执行
$ docker-compose up -d
关闭
$ docker-compose down -v
访问
在浏览器里访问 容器所在主机的地址:8080 即可
效果
可以查看块数,交易数,节点数量,链码数量
也可以查看详细信息
标签:explorer,yjh,config,provence,fabric,com,dockercompose 来源: https://blog.csdn.net/qq_21553301/article/details/116948043