首页 > 解决方案 > Elasticsearch 中大型静态数据的分片和节点

问题描述

我有一个大约 1.5T - 2T 的数据集,我想存储在 Elasticsearch 中。这些字段大多是平坦的,文档大小非常小。它仅每 3 个月更新一次,因此相当静态。

主要优先级是搜索性能。

如果上传和更新需要一周时间,那没关系。我意识到很大程度上取决于我如何构建索引和映射,我相信我已经涵盖了这一点。搜索不频繁,但必须快速。考虑到数据的静态性质,即使在阅读了我能找到的所有文档之后,我也不确定分片的数量、节点的数量等。基本上是为静态数据设计的集群。

我还应该坚持每个分片不超过 30-50G 吗?我需要考虑每个分片的 cpu 核心数吗?提前感谢您的指导。

标签: elasticsearchsharding

解决方案


一些建议,并不是每一个都适合实际情况。

第1部分

 1.The data is distributed across at least three nodes (hdd about ~5, ssd about ~3)
 2.And 100G+ per shard (Consider your cluster and disk performance)
 3.Increases the refresh time of the segments

第2部分

 1.The key is mapping, optimize the mapping for each field
 2.Make sure DOC is dense
 3.Set the route key if one exists or useful
 4.Try to use the keyword instead of something like long or int. Term queries are always better than range queries
 5.Take advantage of the 4 Levels cache (RequestCache,LRUQueryCache,MMAPCache,FileSystemCache), use index-sorting to optimize queries
 6.Auto generate _id
 7.Turn off doc values that do not require fields
 8.Filter can be used to turn off the scoring function if not required
 9.index.merge.scheduler.max_thread_count: 1 if use hdd

看到这个

{
    "mappings": {
        "data": {
            "dynamic": "false",
            "_source": {
                "includes": ["XXX"]  # only searchable filed in _source
            },
            "properties": {
                "state": {
                    "type": "keyword",  # state: int, but use keyword
                    "doc_values": false  
                },
                "b": {
                    "type": "long"    # range search
                }
            }
        }
    },
   "settings": {......}
}

推荐阅读