如何将elasticsearch状态从黄色更改为绿色?

Nik*_*l.J 2 json elasticsearch

我只有一个节点,我使用以下脚本将副本设置为 0,将分片设置为 1:

PUT /my_temp_index
{
    "settings": {
        "number_of_shards" :   1,
        "number_of_replicas" : 0
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

{
   "cluster_name": "KMT",
   "status": "yellow",
   "timed_out": false,
   "number_of_nodes": 1,
   "number_of_data_nodes": 1,
   "active_primary_shards": 452,
   "active_shards": 452,
   "relocating_shards": 0,
   "initializing_shards": 0,
   "unassigned_shards": 451,
   "delayed_unassigned_shards": 0,
   "number_of_pending_tasks": 0,
   "number_of_in_flight_fetch": 0,
   "task_max_waiting_in_queue_millis": 0,
   "active_shards_percent_as_number": 50.055370985603545
}
Run Code Online (Sandbox Code Playgroud)

更改后我应该重新启动elasticsearch吗?

Val*_*Val 5

您只更改了单个索引的副本数 + 属性名称错误(缺少index.前缀)。

您需要对所有索引运行相同的查询

PUT /*/_settings
{
    "index": {
        "number_of_replicas" : 0
    }
}
Run Code Online (Sandbox Code Playgroud)