安装 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)。
相关推荐
grrrr_18 小时前
【工具类】虚拟机 + Ubuntu 安全部署 OpenClaw,联动 Ollama 零成本解锁云端大模型
linux·运维·ubuntu·#openclaw·#小龙虾
HealthScience8 小时前
github怎么授权ssh(私人库授权)
运维·ssh·github
HABuo8 小时前
【linux线程(一)】线程概念、线程控制详细剖析
linux·运维·服务器·c语言·c++·ubuntu·centos
gjc5929 小时前
踩坑实录:MySQL服务器CPU爆高,元凶竟是SELinux的setroubleshootd?
运维·服务器·数据库·mysql·adb
我才是一卓9 小时前
linux 安装简易 git 服务端并使用
linux·运维·git
德彪稳坐倒骑驴9 小时前
MySQL Server 5.5 win端安装,安装SQLyog
运维·服务器
乔宕一10 小时前
windows SSH服务修改SSH登陆后的默认终端
运维·windows·ssh
bwz999@88.com11 小时前
联想SR5507X04安装ubuntu-24.04.4 server,采用 Linux 原生mdadm(mdraid)软 RAID+LVM分区
运维·服务器
Canicer11 小时前
OpenClaw搭配Coze工作流实现全自动发布文章至WordPress网站!
运维·服务器
王小义笔记11 小时前
WSL(Linux)如何安装conda
linux·运维·conda