我正在为Elasticsearch v7.7.0使用开放发行版,我想自动管理索引生命周期,因此在创建新索引时,它将自动附加到ISM策略。
但我收到此错误“源别名未指向写入索引”。
这是我的配置:
1- Logstash输出
output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
#index => "demo"
index => "demo-%{+YYYY.MM.dd.HH-mm}"
ssl => false
ssl_certificate_verification => false
ilm_enabled => false
}
stdout { codec => "dots"}
}
2- ISM政策 {
"policy": {
"policy_id": "hot warm delete workflow",
"description": "hot warm delete workflow",
"last_updated_time": 1595417446751,
"schema_version": 1,
"error_notification": null,
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "1d"
}
}
],
"transitions": [
{
"state_name": "warm"
}
]
},
{
"name": "warm",
"actions": [
{
"replica_count": {
"number_of_replicas": 0
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
],
"transitions": []
}
]
}
}
3-索引模板 PUT _template/my_template
{
"alias": {
"demo": {"is_write_index": true }
},
"index_patterns": ["demo*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"opendistro.index_state_management.policy_id": "hot warm delete workflow",
"opendistro.index_state_management.rollover_alias": "demo"
}
}
我注意到创建别名时不会获得'is_write_index“:true'属性。任何有用的意见,将不胜感激。
最佳答案
我自己解决了这个问题。
对于面临相同问题的人,这里是解决方案。
1-首先创建一个模板:
PUT _template/my_template
{
"index_patterns": ["demo*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"opendistro.index_state_management.policy_id": "hot warm delete workflow",
"opendistro.index_state_management.rollover_alias": "demo"
}
}
2-您需要引导初始索引,并将其指定为索引模板中指定的过渡别名的写索引:PUT demo-000001
{
"aliases": {
"demo": {
"is_write_index": true
}
}
}
3- Logstash输出:output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
index => "demo"
ssl => false
ssl_certificate_verification => false
ilm_enabled => false
}
stdout { codec => "dots"}
}