接:docker部署多节点Tendermint网络
1.拉取Prometheus的Docker镜像
docker image pull prom/prometheus
2.根据拉取的镜像配置dokcer-compose.xml文件
version: '3'
services:
node0:
container_name: node0
image: "tendermint/localnode"
ports:
- "26656-26657:26656-26657"
environment:
- ID=0
- LOG=${LOG:-tendermint.log}
volumes:
- ./build:/tendermint:Z
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.2
node1:
container_name: node1
image: "tendermint/localnode"
ports:
- "26659-26660:26656-26657"
environment:
- ID=1
- LOG=${LOG:-tendermint.log}
volumes:
- ./build:/tendermint:Z
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.3
node2:
container_name: node2
image: "tendermint/localnode"
environment:
- ID=2
- LOG=${LOG:-tendermint.log}
ports:
- "26661-26662:26656-26657"
volumes:
- ./build:/tendermint:Z
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.4
node3:
container_name: node3
image: "tendermint/localnode"
environment:
- ID=3
- LOG=${LOG:-tendermint.log}
ports:
- "26663-26664:26656-26657"
volumes:
- ./build:/tendermint:Z
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.5
node4:
container_name: node4
image: "tendermint/localnode"
environment:
- ID=4
- LOG=${LOG:-tendermint.log}
ports:
- "26665-26666:26656-26657"
volumes:
- ./build:/tendermint:Z
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.6
//配置prometheus服务
node5:
container_name: prometheus
image: "prom/prometheus"
user: root
environment:
- ID=5
ports:
- "9090:9090"
volumes:
- ./Prometheus:/prometheus:Z
- ./Prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /etc/localtime:/etc/localtime
networks:
localnet:
ipv4_address: 192.167.10.7
networks:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.167.10.0/16
问题:运行prometheus服务的时候,会报如下错误:
msg=“Error opening query log file” file=/prometheus/queries.active
err=“open /prometheus/queries.active: permission denied”
解决方法: 在docker-compose.yml文件中增加user: root配置
3.运行多节点网络和Prometheus项目
docker-compose -f docker-compose.yml up
4.测试网络
curl -s ‘localhost:26657/broadcast_tx_commit?tx=“abcd”’
5.查看各节点metrics
http://localhost:9090
如下图所示:
http://localhost:9090/targets
如下图所示: