安装 Elasticsearch

安装 Elasticsearch

下载 Elasticsearch 的 Windows 版本(ZIP 包)并解压。进入解压目录的 bin 文件夹,运行 elasticsearch.bat 启动服务。默认监听 9200 端口,可通过浏览器访问 http://localhost:9200 验证是否启动成功。

修改 config/elasticsearch.yml 文件以配置集群名称、节点名称和网络设置:

yaml 复制代码
cluster.name: my-elasticsearch  
node.name: node-1  
network.host: 0.0.0.0  
http.port: 9200  

安装 Logstash

下载 Logstash 的 Windows 版本(ZIP 包)并解压。创建配置文件(如 logstash.conf),定义输入、过滤和输出。例如,从文件读取日志并输出到 Elasticsearch:

conf 复制代码
input {
  file {
    path => "C:/logs/*.log"
    start_position => "beginning"
  }
}
output {
  elasticsearch {
    hosts => ["http://localhost:9200"]
    index => "logs-%{+YYYY.MM.dd}"
  }
}

bin 目录下运行 logstash.bat -f ../config/logstash.conf 启动 Logstash。

安装 Kibana

下载 Kibana 的 Windows 版本(ZIP 包)并解压。修改 config/kibana.yml 文件:

yaml 复制代码
server.port: 5601  
server.host: "0.0.0.0"  
elasticsearch.hosts: ["http://localhost:9200"]  

运行 bin/kibana.bat 启动 Kibana,访问 http://localhost:5601 进入可视化界面。

配置 Filebeat(可选)

若需轻量级日志采集,下载 Filebeat 并修改 filebeat.yml

yaml 复制代码
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - C:/logs/*.log
output.elasticsearch:
  hosts: ["localhost:9200"]

运行 filebeat.exe -e -c filebeat.yml 启动 Filebeat,将日志直接发送到 Elasticsearch。

验证数据

在 Kibana 的 Management > Stack Management > Index Patterns 中创建索引模式(如 logs-*),随后在 Discover 页面查看日志数据。

注意事项

  • 确保 Java 环境已安装(JDK 8 或 11)。
  • 防火墙需放行 9200(Elasticsearch)、5601(Kibana)等端口。
  • 生产环境建议配置安全模块(如 X-Pack 或 OpenSearch Security)。
相关推荐
虎头金猫17 小时前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
AI职业加油站19 小时前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
此冬歌咏19 小时前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
-梅20 小时前
linux(8) 软硬链接
linux·运维·服务器
张洛闻Eren20 小时前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github
其实防守也摸鱼21 小时前
内网穿透与反向代理:原理、工具与实战指南
android·大数据·运维·安全·网络安全·自动化·渗透
布裘21 小时前
【银河麒麟】V4桌面图标消失,右击鼠标没反应排查
运维·银河麒麟·桌面环境
懂软件的胡子个哥1 天前
微信机器人为什么需要“回复候选”而不是所有 AI 内容直接发送
运维·微信·自动化·wechatapi·个人微信号二次开发
云贝贝贝1 天前
腾讯云 TDSQL(MySQL 版)性能优化与慢查询排障实战 6 招
运维·腾讯云
Lsetea1 天前
证书没到期却报certificate has expired:OpenSSL定位中间证书与系统时间
运维·https·ssl证书·openssl·证书链