五、Fabric2.4.6 在java應(yīng)用訪問(wèn)智能合約(ubuntu 22.04)
dongsheng@dongsheng-virtual-machine:~/raft-test$ gedit docker-compose.yaml
# 修改fabric網(wǎng)絡(luò)docker-compose.yaml文件,order和peer增加下面的監(jiān)聽(tīng)和端口
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
# 重啟網(wǎng)絡(luò)
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 負(fù)責(zé)監(jiān)控fabric網(wǎng)絡(luò)
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 負(fù)責(zé)提供圖形化界面
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']
# 啟動(dòng)服務(wù)
dongsheng@dongsheng-virtual-machine:~/prometheus$ docker-compose -f docker-compose-prometheus.yml up -d
# ......拉取prometheus、grafana的鏡像
Creating prometheus ... done
Creating grafana ... done
# 訪問(wèn) http://127.0.0.1:9090/
# 或者 http://192.168.136.130:9090/

image.png
# 查看監(jiān)控的節(jié)點(diǎn)

image.png
# 訪問(wèn)grafana圖形化界面
http://192.168.136.130:3000/login
# 默認(rèn)賬號(hào)密碼都是 admin , 輸入之后會(huì)提示更改密碼,不改也可以;
# 配置數(shù)據(jù)源
# HOME--> Data sources ,點(diǎn)擊Add data source , 點(diǎn)擊 Prometheus;
# 輸入prometheus的訪問(wèn)地址 ,拉到最下方,點(diǎn)擊 save & test ;

image.png

image.png

image.png

image.png
# 獲取 Fabric Dashboard ID
訪問(wèn):https://grafana.com/grafana/dashboards/
# 在search dashboards 中輸入fabric ,點(diǎn)擊進(jìn)入 Hyperledger Fabric Monitoring for 1.4
# 點(diǎn)擊copy id to clipboard 或者直接記住下面的id 10716都可以;

image.png

image.png
# 配置Dashboard
# Home --> Dashboards --> Create Dashboard --> import dashboard
# 粘貼上面賦值的ID,點(diǎn)擊load
# 點(diǎn)擊import

image.png

image.png

image.png

image.png

image.png
參考:
https://www.bilibili.com/video/BV1f44y1G7dP/?spm_id_from=333.999.0.0&vd_source=ef83736476a46166544cd38458b6b130
https://blog.csdn.net/YourMr/article/details/125221165