1、安装logstash
$>wget https://artifacts.elastic.co/downloads/logstash/logstash-6.2.4.tar.gz
2、解压logstash:
$>tar -xzvf logstash-6.2.4.tar.gz
3、安装output插件:
进入到bin目录:
执行:
./logstash-plugin install logstash-output-elasticsearch
4、创建conf文件
input{
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "es的数据index值"
type => "es的数据type值"
size => 1000
scroll => "5m"
docinfo => false
}
}
output{
file {
#path为指定文件路径
path => "/tmp/example.json"
}
stdout {
codec => json_lines #console输出,可以注释stdout部分
}
}
5、执行备份命令
在bin目录下:
$>./logstash -f example.conf