logstash迁移

安装部署

迁移元数据

全量数据迁移

input {
 elasticsearch {
 hosts => "源 ES IP:9200"
 index => "*,-.*" # 如果是分组同步,这里则填入其中一个组的
index list,支持通配,例如:index => "index-a-*, index-b-*"
 user => "elastic"
 password => "xxxxxx"
 docinfo => true
 size => 5000
 slices => 4 #建议设置为源端多数索引的分片数量
 }
}
output {
 elasticsearch {
 hosts => ["http:// ES IP:9200"]
 user => "elastic"
 password => " ES 密码"
 index => "%{[@metadata][_index]}"
 document_type => "%{[@metadata][_type]}"
 document_id => "%{[@metadata][_id]}"
 }
}



(base) [root@rudonx logstash-8.9.0]# cat es2os2.conf 
input {
  elasticsearch {
   # 源集群endpoint
    hosts => "xxxxx-o-00g0kc3iouz3.escloud.ivolces.com:9200"
    # 源集群basicAuth鉴权信息,如果有
    user => "admin"
    password => "xxxxx"
    # 支持通配符,"*" 表示所有索引,如果索引多数据量大可以分开配置
    # "*,-.*" 表示非"."开头的所有索引,"."开头索引通常是系统索引,无需同步
    index => "dumpindex"
    query => '{ "sort": [ "_doc" ] }'
    size => 1000
    # scroll session保持时间
    scroll => "5m"
    docinfo => true
    # 指定docinfo到 @metadata
    docinfo_target => "@metadata"
    # 是否仅用`hosts`配置项数组中的https链接进行请求
    ssl => false
    # ES6以后支持配置,不超过源索引shard数,加速scroll
    slices => 1
  }
}
# 删除logStash自动添加的字段,可选
#filter {
#    mutate {
#       remove_field => ["@version", "@timestamp"]
#   }
#}
output {
  opensearch {
   # 目标集群endpoint
    hosts => "xxxxxx-o-00804qlhr76c.escloud.ivolces.com:9200"
    # 目标集群basicAuth鉴权信息,如果有
    user => "admin"
    password => "xxxxxx"
    # 和源索引名保持一致
    index => "%{[@metadata][_index]}"
    document_id => "%{[@metadata][_id]}"
    # 是否仅用`hosts`配置项数组中的https链接进行请求
    ssl => false
    # 当使用https链接时,是否验证ES服务端证书
    ssl_certificate_verification => false
    # ssl_certificate_verification为true时,验证服务端ca的证书路径,.cer 或 .pem格式
    # cacert => "ca证书路径"
  }
}

增量数据迁移

input {
 elasticsearch {
 # 源端 ES 地址。
 hosts => ["http://源 ES IP:9200"]
 # 安全集群配置登录用户名密码。
 user => "elastic"
 password => "源端 ES 密码"
 # 需要迁移的索引列表,多个索引使用英文逗号(,)分隔,支持通配。
 index => "sample_data"
 # 按时间范围查询差异数据,以下配置表示查询最近 5 分钟更新的数据。
 query => '{"query":{"range":{"update_time":{"gte":"now-
5m","lte":"now/m"}}}}'
 # 定时任务,以下配置表示每分钟执行一次。
 schedule => "* * * * *"
 scroll => "5m"
 docinfo=>true
 size => 5000
}
output {
 elasticsearch {
 hosts => ["http://腾讯云 ES IP:9200"]
 user => "elastic"
 password => "腾讯云 ES 密码"
 index => "%{[@metadata][_index]}"
 document_type => "%{[@metadata][_type]}"
 document_id => "%{[@metadata][_id]}"
 }
logstash 增量同步前建议充分调试,将 input 插件里的 query 语句拿到源端执行,看能否查到数据,例如
GET sample_data/_search
{
 "query": {
 "range": {
 "update_time": {
 "gte": "now-5m",
 "lte": "now/m"
 }
 }
 },
 "_source": "update_time"
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值