当前位置: 首页> 教育> 幼教 > 山东有哪些网络公司_营销网站认识_工具刷网站排刷排名软件_谷歌优化排名怎么做

山东有哪些网络公司_营销网站认识_工具刷网站排刷排名软件_谷歌优化排名怎么做

时间:2025/7/15 4:18:42来源:https://blog.csdn.net/qq_35640866/article/details/146396719 浏览次数:1次
山东有哪些网络公司_营销网站认识_工具刷网站排刷排名软件_谷歌优化排名怎么做

elasticsearch reindex 索引。

背景:

索引test1 reindex到test2 修改sharding数量
程序是通过别名test1_alias访问索引

1、创建目标索引test2

索引需要手动提前创建自动创建可能会有mapping 不一致性的风险。

The destination should be configured as wanted before calling _reindex. Reindex does not copy the settings from the source or its associated template.Mappings, shard counts, replicas, and so on must be configured ahead of time.

复制test1的创建索引语句,修改sharding数量,

GET test1 查看索引

去掉下面test1属性的部分。

  "test1" : {"aliases" : {"test1_alias" : { }},"provided_name" : "test1","creation_date" : "1742388051938",, #注意前面的","号也要去掉,因为处于底部"uuid" : "LG30E6iGSPu-09Ca5nGbPQ","version" : {"created" : "6070099"}

PUT test2 创建索引
修改后的json文件
“number_of_shards” : 修改到目标数量
执行命令返回的数据

{"acknowledged" : true,"shards_acknowledged" : true,"index" : "test2"
}

2、禁止源索引test1 写

防止reindex期间写入数据,无法同步到目标索引

PUT /test1/_settings
{"index.blocks.write": true
}

对应放开写的命令

PUT /test1/_settings
{"index.blocks.write": false
}

3、 执行reindex 命令

POST _reindex?wait_for_completion=false&requests_per_second=1000
{"source": {"index": "test1"},"dest": {"index": "test2"}
}

返回信息

{"task" : "KsO_WIvXRC2ccMCCxbuF3w:28779984"
}

wait_for_completion=false 后台执行命令,requests_per_second=500限制速度500

调整同步速度命令:
POST _reindex/KsO_WIvXRC2ccMCCxbuF3w:28779984/_rethrottle?requests_per_second=500
取消任务命令
POST _tasks/KsO_WIvXRC2ccMCCxbuF3w:28779984/_cancel
查看reindex任务
GET _tasks?actions=*reindex&detailed

4、 查看任务是否完成

GET _tasks/KsO_WIvXRC2ccMCCxbuF3w:28779984

返回 true的时候就是完成了reindx
“completed” : true

5、修改别名指向新的索引别名

test1_alias指向test2

POST _aliases
{"actions": [{ "remove": { "index": "test1", "alias": "test1_alias" } },{ "add": { "index": "test2", "alias": "test1_alias" } }]
}
6、查看别名
GET test2

删除原来的索引(可以保留归档)

DELETE test1

加速执行速度的方法
1、增加size 默认1000

POST _reindex?wait_for_completion=false
{"source": {"index": "test1","size": 5000},"dest": {"index": "test2"}
}

2、副本改成0

PUT /test2/_settings
{"number_of_replicas": 0
}

3、禁止自动刷新

PUT /test2/_settings
{ "refresh_interval": -1 }

4、提高scroll的并行度


POST _reindex?slices=5&refresh

参考文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

https://blog.csdn.net/wwd0501/article/details/132192692

关键字:山东有哪些网络公司_营销网站认识_工具刷网站排刷排名软件_谷歌优化排名怎么做

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: