栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ES数据迁移——reindex

ES数据迁移——reindex

一、在新ES中添加白名单

在elasticsearch.yml 中添加

reindex.remote.whitelist: ["xx.xx.xx.xx:9200"]

重启新集群

二、利用kibana修改新ES参数
PUT _settings?pretty
{
  "index.refresh_interval": -1,
  "index.number_of_replicas": 0
}

三、使用reindex拉取数据

1、索引不拆分,数据迁移

如果有特殊数据类型,需要提前定义好,例如number、date等

PUT basic
{
  "mappings": {
    "properties": {
      "operateTime": {
        "type": "long"
      }
   }
  }
}
POST _reindex?wait_for_completion=false
{
  "source": {
    "remote": {
      "host": "http://xx.xx.xx.xx:9200"
    },
	"size": 5000, 
    "index": "basic"
  },
  "dest": {
    "index": "basic"
  }
}

#查看迁移状态
GET _tasks/xxx?pretty

 

2、索引拆分,数据迁移

按照operateTime,每月存储一个

1)创建索引,并配置operateTime为long类型
PUT basic-2021.02
{
  "mappings": {
    "properties": { 
      "operateTime": {
        "type": "long"
      }
    }
  }
}
POST _reindex?wait_for_completion=false
{
  "source": {
    "remote": {
      "host": "http://10.0.102.12:8920"
    },
	"size": 5000, 
    "index": "basic",
    "query": {
      "bool": {
        "filter": [
        {
          "range": {
            "operateTime": {
              "gte": 1612108800000,
              "lte": 1614528000000
            }
          }
        }
      ]
      }
    }
  },
  "dest": {
    "index": "basic-2021.02"
  }
}
四、查看迁移状况

# 查看所有task
GET _tasks?detailed=true&actions=*reindex

# 使用taskId查看指定task详情
GET _tasks/xxx?pretty

五、利用kibana恢复新es设置
PUT _settings?pretty
{
  "index.refresh_interval": "10m",
  "index.number_of_replicas": 1
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/457656.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号