elasticsearch7.6.1 不同服务器间索引数据迁移 旧索引数据迁移至新索引数据

该博客介绍了如何在 Elasticsearch 中进行数据迁移,包括获取旧索引结构、创建新索引、配置安全设置(如跨域访问)以及使用 Reindex API 迁移数据的过程。这有助于确保在不中断服务的情况下更新或优化索引结构。
摘要由CSDN通过智能技术生成
举例子:索引A为旧索引,索引B为新索引。

1、获取A索引(旧索引)的数据结构

GET /index_a/_mapping/

mappings.png

2、创建一个新的索引B,结构同A。

POST /index_b/_mapping/
{
      "properties" : {
        "age" : {
          "type" : "long"
        },
        "education" : {
          "type" : "text"
        },
        "other": {
          "type": "text"
        },
        "name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "testedu" : {
          "type" : "text"
        }
      }
}

3、elasticsearch.yml 设置白名单

# 开启跨域
http.cors.enabled: true
# 所有人访问
http.cors.allow-origin: "*"
# network.host: 192.168.1.127
# http.port: 9200
# transport.tcp.port: 9300
reindex.remote.whitelist: "192.168.0.202:9200, 192.168.0.202:9200,127.0.10.*:9200, localhost:*"

4、迁移数据


POST _reindex
{
  "source": {
    "remote": {
      "host": "http://192.168.0.202:9200"
    }, 
    "index": "index_a"
  },
  "dest": {
    "index": "index_b"
  }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值