使用elasticsearchdump迁移elasticsearch数据实战

发布时间:2024-01-18 06:05:19

目录

1.安装nodejs

2.安装elasticsearchdump

3.迁移

4.核对数据

5.注意事项


1.安装nodejs

https://ascendking.blog.csdn.net/article/details/135509838

2.安装elasticsearchdump

npm install elasticdump -g

3.迁移

elasticdump --input=http://用户:密码@源ES地址/源索引 --output=http://用户:密码@目标ES地址/目标索引 --type=settings

elasticdump --input=http://用户:密码@源ES地址/源索引 --output=http://用户:密码@目标ES地址/目标索引 --type=mapping

elasticdump --input=http://用户:密码@源ES地址/源索引 --output=http://用户:密码@目标ES地址/目标索引 --type=data --limit=10000

4.核对数据

核对迁移后数据是否正确

5.注意事项

在3迁移中 --type=mapping,如果es版本不一致可能会报错,如果报错,需要手动创建新es的索引的映射

比如es6迁移数据到es7

es7去掉了_type

只能手动设置映射

直接put设置映射

设置示例

请求方式:PUT

路径:http://ip:端口号/索引名/_mapping

路径组成:http://ip:端口号+ 索引 +_mapping

请求体:

{
    "properties": {
        "abstract": {
            "type": "text",
            "store": true,
            "analyzer": "ik_max_word"
        },
        "content": {
            "type": "text",
            "store": true,
            "analyzer": "ik_max_word"
        },
        "createTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        },
        "documentAppName": {
            "type": "keyword"
        },
        "documentId": {
            "type": "keyword"
        },
        "documentPath": {
            "type": "keyword"
        },
        "modifyTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        },
        "title": {
            "type": "text",
            "analyzer": "ik_max_word"
        }
    }
}

文章来源:https://blog.csdn.net/wangwenzhe222/article/details/135663111
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。