ES 调整分片和副本数

一、调整副本数

如调整副本数为0

curl -XPUT 'node3:9205/downloads/_settings' -d '{
    "index": {
       "number_of_replicas": "0"
    }
}'

返回

{"acknowledged":true}

二、调整索引分片

索引分片数在索引创建好了之后就不能调整了,只能重建索引

(ES 5.X 版本中有一个缩小分片的api,需要先设置为只读,然后缩减过程需要大量的IO)

先创建索引

curl -XPUT 'http://localhost:9200/wwh_test2/' -d '{
    "settings" : {
        "index" : {
            "number_of_shards" : 2, 
            "number_of_replicas" : 2 
        }
    }
}'

或者同时指定mappings

curl -XPOST localhost:9200/test -d '{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "string", "index" : "not_analyzed" }
            }
        }
    }
}'

之后再进行重新索引

curl -XPOST 'http://localhost:9200/_reindex' -d '{
  "source": {
    "index": "twitter"
  },
  "dest": {
    "index": "new_twitter"
  }
}'

开关索引

关闭

curl -XPOST 'localhost:9200/lookupindex/_close'

打开

curl -XPOST 'localhost:9200/lookupindex/_open'

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容