分片數量
總分片數=主分片數 *(副分片數+1)
如下創建索引配置表示,總分片數=1 *(1+4),表示總共5個分片。
"settings": {
"number_of_shards": 1,
"number_of_replicas": 4
}
number_of_shards:每個索引的主分片數,默認值是 5 。這個配置在索引創建后不能修改。
number_of_replicas:每個主分片的副本數,默認值是 1 。對於活動的索引庫,這個配置可以隨時修改。
例如,我們可以創建只有 一個主分片,沒有副本的小索引:
PUT /my_temp_index
{
"settings": {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
然后,我們可以用 update-index-settings API 動態修改副本數:
PUT /my_temp_index/_settings
{
"number_of_replicas": 1
}