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

2021-12-09  本文已影响0人  曼昱的小蓝毛巾

举例子:索引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"
  }
}


上一篇下一篇

猜你喜欢

热点阅读