网站首页 > 博客文章 正文
操作步骤
- 创建具有满足要求分片数的新索引
- Reindex旧索引到新索引
- 删除旧索引
- 新索引创建旧索引别名
实际操作命令
1、创建具有满足要求分片数的新索引
(1)创建满足数据格式要求及分片要求的索引模板
{ "order": 0, "index_patterns": [ "ts_kv*" ], "settings": { "index": { "number_of_shards": "9", "number_of_replicas": "0", "refresh_interval": "-1" } }, "mappings": { "properties": { "@timestamp": { "type": "date" }, "entity_type": { "type": "text", "fields": { "keyword": { "ignore_above": 256, "type": "keyword" } } }, "str_v": { "type": "text", "fields": { "keyword": { "ignore_above": 256, "type": "keyword" } } }, "@version": { "type": "text", "fields": { "keyword": { "ignore_above": 256, "type": "keyword" } } }, "long_v": { "type": "long" }, "entity_id": { "type": "text", "fields": { "keyword": { "ignore_above": 256, "type": "keyword" } } }, "key": { "type": "text", "fields": { "keyword": { "ignore_above": 256, "type": "keyword" } } }, "ts": { "type": "date" } } }, "aliases": {} } |
1)注意事项:副本暂时设置为0及禁止刷新
。
2)采用cerebro工具创建索引模板
3)采用http API创建索引模板
curl -XPUT http://bigdata-1:9200/_template/ts_kv_template -d '@/path/to/your/ts_kv_templatel.json' |
创建新索引
通过cerebro工具创建索引
注意:
- 填写索引名称即可。
- 分片和副本可以按要求设置,也可以不设置。若不设置,则会根据索引模板来,如果这里设置则会根据这里的设置来
- Setting可将template中的设置拷贝过来,也可不设置。不设置则会根据索引模板来。
通过rest api创建索引
PUT http://bigdata-1:9200/index_name 注意:默认情况下,创建的索引分片数量是 5 个,副本数量是 1 个。 您可以通过如下参数来指定分片数、副本数量: { "settings": { "number_of_shards": 3, "number_of_replicas": 2 } } |
Reindex旧索引到新索引
POST /_reindex?slices=9&refresh { "source": { "index": "product", "size": 10000 }, "dest": { "index": "product1" } } |
注意:slices=9&refresh慎用,slices数量最好和分片数据相同,默认就是分片数
"size": 10000大小谨慎设置,根据集群规模及性能设置,默认1000一般足够
删除旧索引
删除索引的方式很多,在此不再赘述。
新索引创建旧索引别名
POST /_aliases { { "actions" : [ { "add" : { "index" : "index_name", "alias" : "alias_name" } } ] } } |
猜你喜欢
- 2024-10-13 Elasticsearch 入门到高手的成长阶梯-索引的基本操作(1)
- 2024-10-13 黑眼圈大神程序员用5000字带你通透读懂Elasticsearch的注意事项
- 2024-10-13 面试官:Elasticsearch如何设计索引?满分答案来了
- 2024-10-13 架构 - 分布式系统如何设计,看看Elasticsearch是怎么做的
- 2024-10-13 架构成长之路:分布式系统如何设计,看看Elasticsearch是怎么做的
- 2024-10-13 Elasticsearch 创建索引前必须要了解的知识,提前避坑
- 2024-10-13 Elasticsearch-Mapping(elasticsearchmappings数组类型)
- 2024-10-13 这4种Python更新Elasticsearch数据的方法你都会吗?
- 2024-10-13 Elasticsearch: Join数据类型(elasticsearch的数据结构)
- 2024-10-13 从Elasticsearch来看分布式系统架构设计
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)