Elasticsearch - 通用架构和 Elastic Cloud 问题

Elasticsearch - general architecture and Elastic Cloud questions

背景

我们现在正在使用 Elasticsearch 设计一个新系统的架构,并且我们计划根据将他们的服务与 AWS 的服务进行对比的评论来使用 Elastic Cloud,并在 EC2 实例上自托管。在我们设计系统时,我试图从我的团队 6 个月前部署在 Elastic Cloud 上的一个小型测试项目中学习。虽然我花了很多时间阅读 Elasticsearch Docs, Elasticsearch: The Definitive Guide, and Elastic Cloud's Docs,但这里有些概念我仍然不理解。

我们的测试项目的问题

我们的测试项目使用默认的 5 个主分片和每个主分片 1 个副本分片。它是使用 Elastic Cloud 上的默认部署选项配置的,只有一个节点,目前有 2GB 内存。因为只有一个节点,并且因为副本分片永远不会分配给与其主分片相同的节点(reason 2), none of the replicas are getting assigned. Also, this project uses time-based data, and is creating one index per account per day, resulting in about 10 indexes per day (or 100 shards), and over time, the proverbial Kagillion Shards。这个系统本来只是一次要有几个月的数据,所以解决方案已在此部署上的内存用完时手动删除旧数据。

新系统

我们的新系统旨在存储 5 年的基于时间的数据,预计其大小将增长到 250 GB。当前的实现对基于时间的数据使用单个索引,每个主分片有 6 个主分片和 1 个副本。这个决定是基于阅读单个分片的目标是最大 30GB 的大小而做出的。

问题

  1. 我们的旧系统有一个节点有太多索引(超过 100 个)和太多分片(超过 1000 个),而且我们的新系统似乎设计得太少(一个索引用于 5 年以上的数据).根据 time-based data recommendations would be to create one index per week or month? That being said, according to another answer on SO 似乎更好的索引策略每个节点的最佳索引数是 1,那么如果我们只是 [=37,那么首先为基于时间的数据创建多个索引的效用是什么=]在一个节点上?
  2. 如何在Elastic Cloud中为ES部署添加节点?目前测试项目中的所有副本节点都未分配,因为部署只有一个节点。有一个滑块可让您轻松选择部署中每个节点的内存(1GB 到 250B 之间),但我看不到添加多个节点的方法,这令人困惑,因为它似乎是 Elasticsearch 的基本功能。
  3. 我们测试项目的节点已经重启了好几次,总是在节点上有很多旧数据,内存压力大的时候。解决方案是删除旧数据(因为测试项目一次只能有几个月的数据),但节点重启时似乎没有丢失数据。为什么会这样?
  4. 我们的测试项目没有拍摄快照,这应该每 30 分钟在 Elastic Cloud 上自动发生一次。我已经询问过他们对此的支持,但只是想看看是否有人知道是什么原因导致的以及如何解决?

Our test project uses the default of 5 primary shards and 1 replica shard per primary. It was configured using the default deployment options on Elastic Cloud with a single one node

显然,在单个节点上,您不能有副本。因此,您的索引应该配置有 0 个副本,您可以动态地执行此操作以使集群恢复绿色 (PUT index/_settings {"index.number_of_replicas": 0}),就这么简单。

Also, this project uses time-based data, and is creating one index per account per day, resulting in about 10 indexes per day (or 100 shards)

我无法判断每天 50 个新主分片(10 个索引)是否合理,因为您没有提供有关测试项目中数据量的任何信息。但可能太多了。

  1. It seems a better indexing strategy according to the time-based data recommendations would be to create one index per week or month?

在单个索引中拥有五年价值的数据是完全有可能的,这实际上并不取决于数据的年龄,而是取决于它增长的规模。您提到 250GB 并且您知道分片不应增长超过 30GB(这又取决于您的硬件规格,稍后会详细介绍),但是由于该索引只有 6 个分片,这意味着每个分片将增长超过 40GB(根据 this,这是可以的),但为了安全起见,您可能应该增加到 8-9 个分片,或者将数据分成 yearly/monthly 个索引。

每个分片 30GB 左右的限制还取决于您的节点有多少堆。如果您的节点有 2GB 堆,那么 30GB 分片显然太大了。由于您在 ES Cloud 上并且计划拥有 250GB 的数据,因此您必须选择 16GB 堆 + 384GB 存储(或更大)的节点容量。因此,对于 16GB 堆,拥有 30GB 分片是合理的,但我认为您需要多个节点。您可以使用 GET _cat/nodes?v.

验证您有多少个节点
  1. That being said, according to another answer on SO the optimal number of indexes per node is 1...

Chris 所说的是 theoretical/ideal 设置,在现实中几乎 possible/advisable/desired 不会这样做。你确实希望在你的索引中有多个分片,原因是当你的数据增长时,你希望能够扩展到多个节点,这就是 ES 的全部意义,否则你最好嵌入 Lucene库直接在你的项目中。

  1. ..., so what is the utility in creating multiple indices for time-based data in the first place if we're only running on one node?

首先使用 GET _cat/nodes?v 检查您的集群中有多少个节点,但很明显,如果您为 250GB 的数据分配了一个节点,将 250GB 的数据拆分为 6-8 个分片,那么单个节点并不理想,确实。

  1. How does one add a node to an ES deployment in Elastic Cloud?

现在,你不能。但是,在上次 Elastic{ON} 会议上,Elastic announced 可以选择要设置的节点数量或部署类型(hot/warm 等)。

  1. Currently all of the replica nodes in the test project are unassigned, because the deployment only has one node.

在测试项目中你真的不需要副本,对吧?

  1. The solution has been to delete old data (as the test project was only meant to have several months of data at a time), but it appears the node didn't lose data when it restarted. Why would this be?

你是怎么删除数据的?从您删除数据到节点重启之前,您是否见证了数据确实消失了?

  1. Our test project has taken no snapshots, which are supposed to happen automatically on Elastic Cloud every 30 minutes.

这很奇怪,因为在 ES 云上,您的集群通常每 30 分钟获取一次快照。您在 Deployments > cluster-id > Elasticsearch > Snapshots 下看到了什么? ES Cloud 支持对此有何评价?当 运行 GET _cat/repositories?vGET _cat/snapshots/found-snapshots?v 时你会得到什么? (用结果更新你的问题)