Prometheus+Grafana 配置Elasticsearch ,Kafka的启动【Windows环境入门】
2026/7/24 3:23:44 网站建设 项目流程

Elasticsearch

  1. 官网下载:elasticsearch-9.4.3-windows-x86_64.zip

  2. 解压

    3.修改config/elasticsearch.yml

# 本地调试开发单机模式 discovery.type:single-node # 集群模式需要设置 #cluster.initial_master_nodes=["node_1"]# 这几个都改成false访问不需要权限,开发环境 xpack.security.enabled:falsexpack.security.enrollment.enabled:falsexpack.security.http.ssl.enabled:falsexpack.security.transport.ssl.enabled:false

4.启动es

cmd cd elasticsearch-9.4.3 bin\elasticsearch.bat # 访问 http://127.0.0.1:9200/ { "name" : "GXF-COMPUTER", "cluster_name" : "elasticsearch", "cluster_uuid" : "3sK5j_5fSxK57kMksm2VOg", "version" : { "number" : "9.4.3", "build_flavor" : "default", "build_type" : "zip", "build_hash" : "45f6a06b1b441b41fe711059b8720013173e7c89", "build_date" : "2026-06-25T14:04:34.316306228Z", "build_snapshot" : false, "lucene_version" : "10.4.0", "minimum_wire_compatibility_version" : "8.19.0", "minimum_index_compatibility_version" : "8.0.0" }, "tagline" : "You Know, for Search" }

5.下载并启动elasticsearch_export

下载地址:https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.10.0/elasticsearch_exporter-1.10.0.windows-amd64.zip

解压后点击执行.\elasticsearch_exporter.exe --es.uri=http://127.0.0.1:9200启动

访问:127.0.0.1:9114/metrics

启动Prometheus

官网下载安装包:prometheus-3.13.0.windows-amd64.zip

点击启动 prometheus.exe

页面状态

启动Grafana

官网下载安装包:grafana-enterprise_12.4.2_23531306697_windows_amd64.tar.gz

点击启动 grafana-server.exe admin/admin登录

添加prometheus的地址

导入dashboard

选择面板数据源prometheus,Save Dashboard,

查看面板

Kafka

下载安装包解压

修改数据目录:
kafka_2.13-3.9.2\config\kraft\server.properties 中log.dirs=/tmp/kafka-logs改为log.dirs=D:/Java/devops/kafka_2.13-3.9.2/kraft-data

生成唯一ID:
bin\windows>kafka-storage.bat random-uuid

B3AmYe6MTz-X1eXekbsiaw

初始化存储目录:bin\windows>kafka-storage.bat format -t B3AmYe6MTz-X1eXekbsiaw --config …\config\kraft\server.properties

Formatting metadata directory D:/Java/devops/kafka_2.13-3.9.2/kraft-data with metadata.version 3.9-IV0.

启动kafka

\bin\windows>kafka-server-start.bat …\…\config\kraft\server.properties

测试kafka正常
打开3个CMD窗口

创建topic:
bin\windows\kafka-topics.bat --create --topic test-demo --bootstrap-server localhost:9092
结果:Created topic test-demo.

创建消费者:

bin\windows\kafka-console-consumer.bat --topic test-demo --from-beginning --bootstrap-server localhost:9092

创建生产者:

bin\windows\kafka-console-producer.bat --topic test-demo --bootstrap-server localhost:9092

生产者回车发送消息,消费者可以看到。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询