前言:新机器上新建集群+logstash迁移原ES集群数据到目标机器。
- 安装logstash,新建迁移配置文件
# 后台下载logstash
[lsy@test ~]$ wget -b https://artifacts.elastic.co/downloads/logstash/logstash-5.6.1.tar.gz
# 查看安装进度
[lsy@test ~]$ tail -f wget-log
# 解压安装包
[lsy@test ~]$ tar -zxvf logstash-5.6.1
# 重命名
[lsy@test ~]$ mv logstash-5.6.1 logstash
[lsy@test ~]$ cd logstash
# 新建并编辑logstash输入输出文件
[lsy@test logstash]$ vim es.conf
/*
input {
elasticsearch {
# 原机器节点
hosts => ["http://127.0.0.1:8200", "http://127.0.0.1:8200"]
# 数据库用户名
# user => ""
# 数据库密码
# password => ""
# * 代表同步所有索引,可以具体到一个索引
index => "*"
size => 1000
scroll => "1m"
#会提取ES文档的元信息metadata
docinfo => true
}
}
# 过滤信息(可不写)
filter {
mutate {
remove_field => ["@timestamp", "@version"]
}
}
output {
elasticsearch {
hosts => ["http://127.0.0.1:8200", "http://127.0.0.1:8200"]
# user => ""
# password => ""
document_id => "%{[@metadata][_id]}"
document_type => "%{[@metadata][_type]}"
index => "%{[@metadata][_index]}"
}
}
*/
# 启动es.conf配置文件
[lsy@test logstash]$ ./bin/logstash -f es.conf (& 后台启动)