Help us improve the AWS re:Post Knowledge Center by sharing your feedback in a brief survey. Your input can influence how we create and update our content to better support your AWS journey.
为什么我的 ISM 策略中的翻转索引操作在 OpenSearch Service 中一直失败?
我想要使用索引状态管理(ISM)将我在 Amazon OpenSearch Service 集群上的索引翻转。但我的索引翻转失败,我还收到了一个错误。
简短描述
以下原因可能会导致“翻转失败”索引错误:
- 翻转目标不存在。
- 翻转别名丢失。
- 索引名称与索引模式不匹配。
- 翻转别名指向索引模板中重复的别名。
- 您的集群上的资源利用率已达到最大。
要解决此问题,请使用 explain API 来确定错误的原因。然后,检查您的 ISM 策略。有关设置翻转操作的详细信息,请参阅如何使用 ISM 管理 OpenSearch Service 中的存储空间不足问题?
**注意:**以下解决方法仅适用于 OpenSearch API。有关传统 Open Distro API,请参阅 Open Distro 网站上的 ISM API。
解决方法
使用 explain API 来确定原因
要确定您的“翻转索引失败”错误的根本原因,请使用 explain API:
GET _plugins/_ism/explain/logs-000001?pretty
explain API 的输出示例:
{ "logs-000001": { "index.plugins.index_state_management.policy_id": "rollover-workflow", "index": "logs-000001", "index_uuid": "JUWl2CSES2mWYXqpJJ8qlA", "policy_id": "rollover-workflow", "policy_seq_no": 2, "policy_primary_term": 1, "rolled_over": false, "state": { "name": "open", "start_time": 1614738037066 }, "action": { "name": "rollover", "start_time": 1614739372091, "index": 0, "failed": true, "consumed_retries": 0, "last_retry_time": 0 }, "retry_info": { "failed": false, "consumed_retries": 0 }, "info": { "cause": "rollover target [rolling-indices] does not exist", "message": "Failed to rollover index [index=logs-000001]" } } }
此示例输出显示索引未能翻转,因为目标翻转别名 rolling-index 不存在。
翻转目标不存在
如果原因是“翻转目标 [rolling-indices] 不存在”,则检查索引是否已使用翻转别名引导:
GET _cat/aliases
输出列出了集群中的所有当前别名及其关联索引。如果 ISM 表示您的翻转目标不存在,则会缺少翻转别名和失败的索引关联。
要解决索引关联失败的问题,请将翻转别名附加到索引:
POST /_aliases { "actions": [{ "add": { "index": "logs-000001", "alias": "my-data" } }] }
附加翻转别名之后,在 OpenSearch Service 中对托管的索引重试翻转操作:
POST _plugins/_ism/retry/logs-000001
有关详细信息,请参阅 OpenSearch 网站上的重试失败索引。
重试失败的索引时,可能会收到“正在尝试重试”状态消息。等待下一个 ISM 周期运行。ISM 周期每 30 到 48 分钟运行一次。如果翻转操作成功,则您会收到以下消息: “成功翻转索引”。
翻转别名缺失
如果翻转失败的原因是缺少翻转别名,请检查失败索引的设置:
GET <failed-index-name>/_settings
如发现 index.plugins.index_state_management.rollover_alias 设置缺失,请手动将该设置添加到您的索引中:
PUT /<failed-index-name>/_settings { "index.plugins.index_state_management.rollover_alias" : "<rollover-alias>" }
使用 retry failed index API,对失败的索引重试翻转操作。重试翻转操作时,更新您的策略模板:
PUT _index_template/<template-name>
确保使用现有策略模板中的相同设置,以便将翻转别名应用于新创建的索引。
示例:
PUT _index_template/<existing-template> { "index_patterns": [ "<index-pattern*>" ], "template": { "settings": { "plugins.index_state_management.rollover_alias": "<rollover-alias>" } } }
索引名称与索引模式不匹配
如果 ISM 策略表明由于索引名称与索引模式不匹配而导致翻转操作失败,请检查失败的索引的名称。为了成功进行翻转,索引名称必须与如下正则表达式模式匹配:
`^.*-\d+$`
此正则表达式模式要求索引名称必须包含文本,然后是连字符(-)以及一个或多个数字。如果索引名称不遵循此模式,并且您的第一个索引上写有数据,则重新索引数据。当您重新索引数据时,请为新索引使用正确的名称。
示例:
POST _reindex { "source": { "index": "<failed-index>" }, "dest": { "index": "my-new-index-000001" } }
当数据 API 重新索引时,将翻转别名与失败的索引分离。然后,将翻转别名添加到新索引,以便数据源可以继续将传入数据写入新索引。有关详细信息,请参阅 OpenSearch 网站上的重新索引文档 API。
示例:
POST /_aliases { "actions": [{ "remove": { "index": "<failed-index>", "alias": "<rollover-alias>" } }, { "add": { "index": "my-new-index-000001", "alias": "<rollover-alias>" } }] }
使用以下 API 调用将 ISM 策略手动附加到新索引:
POST _plugins/_ism/add/my-new-index-* { "policy_id": "<policy_id>" }
更新现有模板以反映新的索引模式名称。例如:
PUT _index_template/<existing-template> { "index_patterns": ["<my-new-index-pattern*>"], }
**注意:**您的 ISM 策略和滚动别名必须反映使用相同索引模式创建的连续索引。
翻转别名指向索引模板中重复的别名
如果由于翻转别名指向重复的别名而导致索引滚转失败,请检查您的索引模板设置:
GET _index_template/<template-name>
检查您的模板是否包含其他别名部分,其中包含指向相同索引的另一个别名:
{ "index_patterns": ["my-index*"], "settings": { "index.plugins.index_state_management.rollover_alias": "<rollover-alias>" }, "aliases": { "another_alias": { "is_write_index": true } } }
多个别名会导致翻转失败。要解决此故障,请在不指定任何别名的情况下更新模板设置:
PUT _index_template/<template-name>
然后,对失败的索引执行重试 API:
POST _plugins/_ism/retry/logs-000001
**重要事项:**如果别名指向多个索引,请确保只有一个索引激活了写入访问权限。rollover API 自动为翻转别名指向的索引提供写入权限。在 ISM 中执行翻转操作时,无需为 is_write_index 设置指定任何别名。
您的集群上的资源利用率已达到最大值
断路器异常或存储空间不足可能会导致集群上的资源利用率达到最大。
断路器异常
如果原因是断路器异常,则调用 rollover API 时,您的集群可能遇到过高的 JVM 内存压力。要解决 JVM 内存压力高的问题,请参阅如何解决 Amazon OpenSearch Service 集群上的高 JVM 内存压力问题?
在 JVM 内存压力降至 75% 以下之后,您可以通过以下 API 调用对失败索引进行重试活动:
POST _plugins/_ism/retry/<failed-index-name>
**注意:**使用索引模式(*)在多个失败的索引上重试活动。
如果集群上不频繁出现 JVM 峰值,那么还可以使用以下重试数据块更新 ISM 策略,以进行翻转操作:
{ "actions": { "retry": { "count": 3, "backoff": "exponential", "delay": "10m" } } }
在 ISM 策略中,每个操作都具有基于 count 参数的自动重试。如果您之前的操作失败,请检查 delay 参数以查看必须等待 ISM 多长时间才能重试该操作。有关详细信息,请参阅 OpenSearch 网站上的操作。
存储空间不足
如果您的集群存储空间不足,则 OpenSearch Service 会在集群上启动写入块。写入块会导致所有写入操作在您的集群上返回 ClusterBlockException。您的 ClusterIndexWritesBlocked 指标显示值“1”,这表示集群正在阻止请求。因此,任何创建新索引的尝试都会失败。explain API 调用还返回 403 IndexCreateBlockException,表示集群的存储空间不足。要排查集群数据块异常问题,请参阅如何解决 OpenSearch Service 中的 403“index_create_block_exception”错误?
在 ClusterIndexWritesBlocked 指标返回到“0”后,请对失败的索引重试 ISM 操作。如果您的 JVM 内存压力超过 92% 超过 30 分钟,则可能会启动写入块。如果遇到写入数据块,请对 JVM 内存压力问题进行排查。有关如何排查 JVM 内存压力的详细信息,请参阅如何排查 OpenSearch Service 集群的高 JVM 内存压力问题?
- 语言
- 中文 (简体)
