美文网首页
elasticsearch7.6.1 不同服务器间索引数据迁移

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

作者: 曼昱的小蓝毛巾 | 来源:发表于2021-12-09 09:11 被阅读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"
      }
    }
    
    
    

    相关文章

      网友评论

          本文标题:elasticsearch7.6.1 不同服务器间索引数据迁移

          本文链接:https://www.haomeiwen.com/subject/pwxtfrtx.html