ES集群间数据迁移

1.查看原索引的mapping,我这里通过谷歌插件直接看的

2.点击信息查看索引信息

3.将索引整理好

{
"settings": { "index": { "refresh_interval": "1s","number_of_shards": "5","provided_name": "mcn_sys_log","creation_date": "1578049275728","store": { "type": "fs"},"number_of_replicas": "1","uuid": "Tgnyt9euT2yGEA3_YcPuOw","version": { "created": "5060899"}}},
"mappings": { "sys_log": { "properties": { "logType": { "store": true,"type": "keyword"},"operate_type": { "store": true,"type": "keyword"},"systemCode": { "store": true,"type": "keyword"},"ip": { "store": true,"type": "keyword"},"id": { "type": "text","fields": { "keyword": { "ignore_above": 256,"type": "keyword"}}},"moudleName": { "store": true,"type": "keyword"},"userName": { "store": true,"type": "keyword"},"content": { "search_analyzer": "ik_smart","analyzer": "ik_max_word","store": true,"type": "text"},"gmtActionTime": { "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","store": true,"type": "date"},"userCode": { "store": true,"type": "integer"},"status": { "store": true,"type": "keyword"}}}},
}

4.在新ES集群中通过谷歌的ES插件执行新索引的创建

5.在新ES集群机器上创建好同步文件

vim mcn_sys_log.json
{
  "source": {
    "remote": {
      "host": "http://1.1.1.1:9200",
      "username": "elastic",
      "password": "*****"
    },
    "index": "mcn_xuexi_time",
    "size": 2000
  },
  "dest": {
    "index": "mcn_xuexi_time"
  }
}

6.执行同步文件操作

curl -XPOST  -uelastic:BAGNimgiGBIE5Isu -H 'Content-Type: application/json' 'http://127.0.0.1:9200/_reindex?wait_for_completion=false' -d '@mcn_sys_log.json'

7.通过插件观察两个集群内索引文件数是否一致,一致即可

posted @ 2023-02-28 14:32  caibutou  阅读(128)  评论(0编辑  收藏  举报