Windows下elasticsearch安装
Windows下elasticsearch安装
下载压缩包,解压
cd bin
# 可以先直接命令行启动一遍,elastic账户的初始密码和kibana的entrollment token会输出在控制台
# 也可以稍后重设密码(自定义)
./elasticsearch.bat
./elasticsearch-service.bat install
./elasticsearch-service.bat start
windows的服务面板中,可以看到一个Elasticsearch 8.7.1 (elasticsearch-service-x64)的服务。
设置密码
参考: https://www.jianshu.com/p/9f33028fa65a
elasticsearch-setup-passwords.bat interactive --url http://127.0.0.1:9200
或者也可以使用https
重设密码
elasticsearch 重设密码
.\bin\elasticsearch-reset-password.bat -u elastic
.\bin\elasticsearch-reset-password.bat -u elastic --url https://127.0.0.1:9200
.\bin\elasticsearch-reset-password.bat -u elastic --url https://127.0.0.1:9200 -i
如果报错: WARN org.elasticsearch.common.ssl.DiagnosticTrustManager – failed to establish trust with server at。。。, 使用后面指定url的形式。
-i
参数进入交互模式,允许指定密码。
-u
参数指定用户.
目前密码:Nova2023
kibana默认账号重设密码
.\elasticsearch-reset-password -u kibana_system -i --url https://127.0.0.1:9200
参数-i
指定交互模式允许自定义密码。
目前密码是: Nova2023
ip变更,重设证书
https://discuss.elastic.co/t/elastic-8-7-enrollement-token-failed-to-establish-trust-with-server/330856/6
I see, it seems your ES node's public IP address changed.
我明白了,看来你的 ES 节点的公网 IP 地址发生了变化。
Again, to get a new certificate from your Elasticsearch central CA follow the link from the previous message and use the ./bin/elasticsearch-certutil http (from where you have ES installed) and follow the prompts.
安全访问: https://codeleading.com/article/12106033759/
Windows下Kibana安装
Windows下Kibana安装
下载压缩包,解压(注意,要和elasticsearch版本一致)
cd bin
./kibana
然后浏览器输入:http://127.0.0.1:5601
进入elasticsearch连接设置界面,
高版本直接输入 elasticsearch生成的kibana 的entrollment token即可,高版本会自动配置连接的。(当elasticsearch为本机的默认端口时。)
若要在elasticsearch中重新生成kibana的entrollment token (30分钟有效期),需要在elasticsearch的bin目录下执行如下命令
# kibana使用的
bin/elasticsearch-create-enrollment-token -s kibana --url "https://localhost:9200"
会在kibana安装目录的config目录下,自动生成如下的配置kibana.yml.
如果entrollment方案不可行(比如elastic stack 整体版本低于 8),也可以直接设置kibana.yml的配置。
# This section was automatically generated during setup.
elasticsearch.hosts: ['https://localhost:9200']
elasticsearch.username: kibana_system
elasticsearch.password: Nova2023
elasticsearch.ssl.certificateAuthorities: ['C:\standalone\kibana-8.7.1\data\ca_1688117593443.crt']
xpack.fleet.outputs: [{id: fleet-default-output, name: default, is_default: true, is_default_monitoring: true, type: elasticsearch, hosts: ['https://localhost:9200'], ca_trusted_fingerprint: 4b7aa8abd7596ca3b7ffc152a7d5fc66820deae15a22ba0588017a7db30604aa}]
kibana安装为服务
默认的kibana是没有服务的(windows下)
下载winsw工具。复制到kibana目录,winsw.exe 改名为 kibana.exe, winsw.xml改名为kibana.xml.
kibana.xml改为如下内容:
<configuration>
<!-- ID of the service. It should be unique accross the Windows system-->
<id>kibana</id>
<!-- Display name of the service -->
<name>kibana</name>
<!-- Service description -->
<description>kibana service</description>
<!-- Path to the executable, which should be started -->
<executable>C:\standalone\kibana-8.7.1\bin\kibana</executable>
<!--<arguments></arguments>-->
<log mode="none"/>
</configuration>
打开cmd / powershell(管理员),进入kibana主目录,执行如下命令
./kibana.exe install
即可安装为服务。
配置服务依赖(elasticsearch启动后启动此服务):
sc config "kibana" depend= "elasticsearch-service-x64"
注意等号后面的空格。注意这条命令需要在cmd中执行,powershell不行。
Windows下logstash安装
elk安装
参考:https://www.cnblogs.com/yylyhl/p/17283794.html
参考: https://blog.51cto.com/zhanjq/5576459
参考: https://www.cnblogs.com/jiangcong/p/14683318.html
Windows下logstash安装
https://www.elastic.co/guide/en/logstash/8.7/installing-logstash.html
https://www.elastic.co/guide/en/logstash/8.7/running-logstash-windows.html
下载,解压, 到bin目录
确认logstash能正常启动
logstash.bat -e "input { stdin { } } output { stdout {} }"
The -e
flag enables you to specify a configuration directly from the command line.
上面的指令会在当前命令行启动logstash, 从 标准输入接收数据, 并输出到 标准输出 (简单的回显).
接收filebeat的输入
参考: https://www.elastic.co/guide/en/logstash/8.7/advanced-pipeline.html
先下载filebeat,
filebeat解压目录下,修改filebeat.yml
filebeat.inputs:
- type: log
paths:
- /path/to/file/logstash-tutorial.log
output.logstash:
hosts: ["localhost:5044"]
启动filebeat
.\filebeat -e -c filebeat.yml -d "publish"
进入logstash解压目录下,
新建logstash.conf文件
input {
beats {
port => "5044"
}
}
#filter {
#}
output {
stdout { codec => rubydebug }
}
进入bin目录,启动logstash
#测试
.\logstash.bat -f logstash.conf --config.test_and_exit
#启动
注意,这里配置文件没有加bin\
前缀, 是因为默认的工作目录在解压目录.
调整logstash.conf文件
input {
beats {
port => "5044"
}
}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
}
output {
stdout { codec => rubydebug }
}
删除filebeat的data\registry目录,重启filebeat,强制重新读取日志
可以发现,http, request, response, address等内容已解析.
多pipeline的使用
https://www.elastic.co/guide/en/logstash/current/multiple-pipelines.html
https://www.elastic.co/guide/en/logstash/8.7/multiple-pipelines.html
When you start Logstash without arguments, it will read the pipelines.yml
file and instantiate all pipelines specified in the file. On the other hand, when you use -e
or -f
, Logstash ignores the pipelines.yml
file and logs a warning about it. 当您不带参数启动 Logstash 时,它将读取 pipelines.yml
文件并实例化文件中指定的所有管道。另一方面,当您使用 -e
或 -f
时,Logstash 会忽略 pipelines.yml
文件并记录有关它的警告。
logstash中pipeline配置
https://www.cnblogs.com/caoweixiong/p/11791396.html
https://blog.csdn.net/fu_huo_1993/article/details/116765492
https://www.cnblogs.com/caoweixiong/p/11791396.html
https://cloud.tencent.com/developer/article/1116059
Windows下logstash安装为服务
默认的logstash是没有服务的(windows下)
下载winsw工具。复制到logstash目录,winsw.exe 改名为 logstash.exe, winsw.xml改名为logstash.xml.
logstash.xml改为如下内容:
<configuration>
<!-- ID of the service. It should be unique accross the Windows system-->
<id>kibana</id>
<!-- Display name of the service -->
<name>kibana</name>
<!-- Service description -->
<description>logstash service</description>
<!-- -->
<workingdirectory>C:\standalone\logstash-8.7.1</workingdirectory>
<!-- Path to the executable, which should be started -->
<executable>C:\standalone\logstash-8.7.1\bin\logstash</executable>
<!--<arguments></arguments>-->
<log mode="none"/>
</configuration>
打开cmd / powershell(管理员),进入kibana主目录,执行如下命令
./logstash.exe install
即可安装为服务。
Windows安装filebeat服务
配置filebeat收集业务日志
filebeat.yml
# filestream is an input for collecting log messages from files.
- type: filestream
# Unique ID among all inputs, an ID is required.
id: my-filestream-id
enabled: true
paths:
#- /var/log/*.log
- C:\project\vivacheckcloud3\logs\*.log
#- c:\programdata\elasticsearch\logs\*
output.logstash:
# The Logstash hosts
hosts: ["localhost:5044"]
Windows安装filebeat服务
参考: https://www.cnblogs.com/urwlcm/p/4333119.html
管理员打开powershell, 更改策略,运行执行ps1脚本:
Set-ExecutionPolicy Unrestricted
powershell中进入logstash解压路径, 执行
.\install-service-filebeat.ps1
其他杂项
ingest pipeline介绍和基本使用
https://www.elastic.co/guide/en/elasticsearch/reference/8.8/ingest.html
我应该使用 Logstash 还是 Elasticsearch 采集节点呢
Example: Parse logs in the Common Log Format
windows下elk安装配置-elasticsearch/kibana/filebeat
windows下elk安装配置-elasticsearch/kibana/filebeat
如何在ELK中解析各类日志文件
https://cloud.tencent.com/developer/article/1116059
发表回复