首页 > 其他分享 >ES数据迁移方案,-自己总结 基于REINDEX_API`

ES数据迁移方案,-自己总结 基于REINDEX_API`

时间:2024-01-28 20:35:05浏览次数:18  
标签:index REINDEX http name age reindex API dumpindex ES

 

跨集群ES数据迁移:

1. 设置白名单在目标ES库(新库)
reindex.remote.whitelist: ["192.168.9.201:9200"]

[或者下面参数:
reindex.remote.whitelist: "10.*:*"
http.cors.enabled: true
http.cors.allow-origin: "*"
]
 
 
2.利用kibana修改新ES参数,防止刷新影响性能.

    PUT _settings?pretty
    {
      "index.refresh_interval": -1,
      "index.number_of_replicas": 0
    }

或者:
PUT http://172.16.1.236:9201/topic-new/_settings
{
  "refresh_interval": "-1",
  "number_of_replicas": 0
}

3.需要在目标ES库创建新索引,必须创建,否则无法指定字段属性.
 [如下案例1 ]reindex命令 如下是 更改索引字段的方式迁移,等于是给表改字段属性,需要删index再重建的方法.
POST _reindex
{
  "source": {
    "index": "old_index"
  },
  "dest": {
    "index": "new_index"
  }
}
 或者迁移命令:
POST http://172.16.1.236:9201/_reindex
{
  "source": {
    "index": "topic"
  },
  "dest": {
    "index": "topic-new"
  }
}

4. [如下案例2] 以下是跨集群迁移方案.
POST http://172.16.1.236:9201/_reindex
{
  "source": {
    "index": "topic",
    "remote": {
      "host": "http://172.16.1.236:9200",
      "username": "username",
      "password": "password"
    },
    "query": {
      "match_all": {}
    }
  },
  "dest": {
    "index": "topic-new"
  }
}

5. [如下案例3,增加参数]
POST _reindex
{
  "source": {
    "index": "old_index",
    "size":1000   //可选,每次批量提交1000个,可以提高效率,建议每次提交5-15M的数据
  },
  "dest": {
    "index": "new_index"
  }
}
 
6. 更新配置.[这时候去看数据,是看不到数据的,因为还要刷新才行]

PUT http://172.16.1.236:9201/topic-new/_settings
{
  "refresh_interval": "1s",
  "number_of_replicas": 1
}
 
 
curl -XPUT "http://localhost:9200/my_index/_doc/1" -H 'Content-Type: application/json' -d '
{
  "name": "John Doe",
  "age": 30,
  "city": "New York"
}'

7. 查看参数相关命令.
GET /_settings/

 #查看index数据,默认只能检索10条.
GET /dumpindex/_search


#查看所有数据.size为查询条数.
GET /dumpindex/_search
{
  "query": {
    "match_all": {}
  }
  ,
  "size": 1000
}


##################测试案例###############



#查询所有数据,默认还是10条,需要加条件
GET /dumpindex/_search
{
  "query": {
    "match_all": {}
  },
   "size": 5,   # 这个是增加的size条件
}

#指定size
http://localhost:9200/_search?q=test&size=100


#创建索引在新库中.
PUT dumpindex
{
  "mappings": {
    "properties": {
      "name": {
        "type": "text"
      },
      "age": {
        "type": "integer"
      }
    }
  }
}
 
#在老库中添加数据.
 POST _bulk
   {"index":{"_index":"dumpindex"}}
 {"name": "qrqp", "age": 28}
 
  {"index":{"_index":"dumpindex"}}
 {"name": "gvuo", "age": 27}
  {"index":{"_index":"dumpindex"}}
 {"name": "kznv", "age": 29}
  {"index":{"_index":"dumpindex"}}
 {"name": "smcg", "age": 24}
  {"index":{"_index":"dumpindex"}}
 {"name": "myrg", "age": 25}
  {"index":{"_index":"dumpindex"}}
 {"name": "yzol", "age": 29}
  {"index":{"_index":"dumpindex"}}
 {"name": "swzx", "age": 26}
  {"index":{"_index":"dumpindex"}}
 {"name": "dtoo", "age": 22}
  {"index":{"_index":"dumpindex"}}
 {"name": "rguu", "age": 22}
  {"index":{"_index":"dumpindex"}}
 {"name": "sfod", "age": 24}
  {"index":{"_index":"dumpindex"}}
 {"name": "rdnc", "age": 29}
  {"index":{"_index":"dumpindex"}}
 {"name": "lzpm", "age": 27}
  {"index":{"_index":"dumpindex"}}
 {"name": "qtay", "age": 19}
  {"index":{"_index":"dumpindex"}}
 {"name": "utkw", "age": 24}
 

标签:index,REINDEX,http,name,age,reindex,API,dumpindex,ES
From: https://www.cnblogs.com/mengbin0546/p/17993260

相关文章

  • Codeforces Round 920 (Div. 3)
    A-Square难度:⭐题目大意给定正方形的四个顶点,求该正方形的面积;解题思路根据四个点找出长和宽即可,因为数据范围有负数,为了方便我都进行了移位;神秘代码#include<bits/stdc++.h>#defineintlonglong#defineIOSios::sync_with_stdio(false);cin.tie(0......
  • 2021-2022 ICPC Southwestern European Regional Contest (SWERC 2021-2022)
    Preface这场打的也挺好的,前中期稳定出题,后期还和徐神接力写了一个K最后乱猜还猜对了H题的结论,可惜因为常数以及三分的bound等问题赛事没过最后10题舒服下班A.OrganizingSWERC签到,话说外国场的A基本都是签到啊#include<cstdio>#include<iostream>#defineRIregisterin......
  • OpenIM (Open-Source Instant Messaging) Mac Deployment Guide
    Thisguideprovidesstep-by-stepinstructionsfordeployingOpenIMonaMac,includingbothsourcecodeandDockerdeploymentmethods.##PreliminaryEnvironmentSetupEnsureacleanworkingenvironment:1.**CreateaNewDirectory**:Startinanewdirec......
  • Codeforces Round 921 (Div. 2) A-D
    倒叙讲题预警()传送门:https://codeforces.com/contest/1925D.GoodTrip题意:有n个小盆友,其中m对是好盆友,每队好盆友有友谊度fi。老师要举办k次远足,每次挑一对小盆友去,被挑到的小盆友友谊值+1。如果一对儿童不是朋友,那么他们的友谊值为0,在以后的游览中不会改变。求所有被选中参......
  • es集群配置文件参考
    #集群的名称,同一个集群该值必须设置成相同的cluster.name:clusterName#该节点的名字node.name:node-2#该节点有机会成为master节点node.master:true#该节点可以存储数据node.data:true#shard的数目#设置绑定的IP地址,可以是IPV4或者IPV6network.host:0.0.0.0#节点......
  • Rust学习之Diesel setup报错解决
    Dieselsetup报错解决Diesel是一个安全、可扩展的RustORM和查询生成器。Diesel是Rust中与数据库交互最高效的方式,因为它对查询进行了安全且可组合的抽象。1.报错信息diesel_demoonmaster[?]via......
  • FastAPI学习-31 FastAPI 如何集成 socket.io
    前言socket.io就是基于websocket封装的一个库,主要特点是能够进行实时的双向通讯,主要应用场景有实时的聊天,数据实时分析,数据传输,文件协同合作。有个socket.io的fastapi-socketio官方库,该库依赖传统的python-socketio库环境准备pipinstallfastapi-socketiofastapi服......
  • 《Confusion Graph: Detecting Confusion Communities in Large Scale Image Classifi
    论文标题《ConfusionGraph:DetectingConfusionCommunitiesinLargeScaleImageClassification》混淆图:在大规模图像分类中检测混淆社区作者RuochunJin、YongDou、YueqingWang和XinNiu来自国防科技大学并行和分布式处理国家实验室,和上一篇是姊妹篇。初读摘要......
  • Codeforces Round 921 (Div. 1) 记录(A-D)
    比赛链接:https://codeforces.com/contest/1924官解链接:https://codeforces.com/blog/entry/125137这场整体来说表现还可以,最终performance\(2431\),delta\(+33\)。A.DidWeGetEverythingCovered?还不错的贪心题。进入状态有点慢,写了几个小错误B.SpaceHarbourC.Frac......
  • 洛谷题解-P2888 [USACO07NOV] Cow Hurdles S (Floyd)
    https://www.luogu.com.cn/problem/P2888题目描述FarmerJohnwantsthecowstoprepareforthecountyjumpingcompetition,soBessieandthegangarepracticingjumpingoverhurdles.Theyaregettingtired,though,sotheywanttobeabletouseaslittleene......