五、Fabric2.4.6 在java应用访问智能合约(ubuntu 22.04)
dongsheng@dongsheng-virtual-machine:~/raft-test$ gedit docker-compose.yaml
# 修改fabric网络docker-compose.yaml文件,order和peer增加下面的监听和端口
orderer0.example.com:
environment:
- ORDERER_METRICS_PROVIDER=prometheus
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8443:8443
-
orderer1.example.com:
environment:
- ORDERER_METRICS_PROVIDER=prometheus
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8444:8443
orderer2.example.com:
environment:
- ORDERER_METRICS_PROVIDER=prometheus
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8445:8443
peer0.org1.supervisor.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8446:8443
peer1.org1.supervisor.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8447:8443
peer0.org2.build.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8448:8443
peer1.org2.build.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8449:8443
peer0.org3.supplier.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8450:8443
peer1.org3.supplier.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8451:8443
peer0.org4.logistics.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8452:8443
peer1.org4.logistics.com:
environment:
- CORE_METRICS_PROVIDER=prometheus
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
ports:
- 8453:8443
# 重启网络
dongsheng@dongsheng-virtual-machine:~/raft-test$ docker-compose -f docker-compose.yaml up -d
dongsheng@dongsheng-virtual-machine:~$ mkdir prometheus
dongsheng@dongsheng-virtual-machine:~$ cd prometheus/
dongsheng@dongsheng-virtual-machine:~/prometheus$ gedit docker-compose-prometheus.yml
version: '2.0'
services:
# prometheus 负责监控fabric网络
prometheus:
image: prom/prometheus:latest
restart: always
container_name: prometheus
ports:
- 9090:9090
extra_hosts:
- "orderer0.example.com:192.168.136.130"
- "orderer1.example.com:192.168.136.130"
- "orderer2.example.com:192.168.136.130"
- "peer0.org1.supervisor.com:192.168.136.130"
- "peer1.org1.supervisor.com:192.168.136.130"
- "peer0.org2.build.com:192.168.136.130"
- "peer1.org2.build.com:192.168.136.130"
- "peer0.org3.supplier.com:192.168.136.130"
- "peer1.org3.supplier.com:192.168.136.130"
- "peer0.org4.logistics.com:192.168.136.130"
- "peer1.org4.logistics.com:192.168.136.130"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
# grafana 负责提供图形化界面
grafana:
image: grafana/grafana
restart: always
container_name: grafana
ports:
- 3000:3000
depends_on:
- prometheus
dongsheng@dongsheng-virtual-machine:~/prometheus$ gedit prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'hyperledger-fabric'
static_configs:
- targets: ['orderer0.example.com:8443','orderer1.example.com:8444','orderer2.example.com:8445','peer0.org1.supervisor.com:8446','peer1.org1.supervisor.com:8447','peer0.org2.build.com:8448','peer1.org2.build.com:8449','peer0.org3.supplier.com:8450','peer1.org3.supplier.com:8451','peer0.org4.logistics.com:8452','peer1.org4.logistics.com:8453']
# 启动服务
dongsheng@dongsheng-virtual-machine:~/prometheus$ docker-compose -f docker-compose-prometheus.yml up -d
# ......拉取prometheus、grafana的镜像
Creating prometheus ... done
Creating grafana ... done
# 访问 http://127.0.0.1:9090/
# 或者 http://192.168.136.130:9090/
# 查看监控的节点
# 访问grafana图形化界面
http://192.168.136.130:3000/login
# 默认账号密码都是 admin , 输入之后会提示更改密码,不改也可以;
# 配置数据源
# HOME--> Data sources ,点击Add data source , 点击 Prometheus;
# 输入prometheus的访问地址 ,拉到最下方,点击 save & test ;
# 获取 Fabric Dashboard ID
访问:https://grafana.com/grafana/dashboards/
# 在search dashboards 中输入fabric ,点击进入 Hyperledger Fabric Monitoring for 1.4
# 点击copy id to clipboard 或者直接记住下面的id 10716都可以;
# 配置Dashboard
# Home --> Dashboards --> Create Dashboard --> import dashboard
# 粘贴上面赋值的ID,点击load
# 点击import
参考:
https://www.bilibili.com/video/BV1f44y1G7dP/?spm_id_from=333.999.0.0&vd_source=ef83736476a46166544cd38458b6b130
https://blog.csdn.net/YourMr/article/details/125221165