elasticsearch7.x 设置默认副本 和默认分片
elasticsearch7.x 设置默认副本 和默认分片number_of_shards每个索引的主分片数,默认值是 5 。这个配置在索引创建后不能修改。number_of_replicas每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改。修改现有的副本数为0: 现存所有索引副本数变为0命令行运行curl -X PUT "192.xxx.x.xxx:9200/_sett
·
elasticsearch7.x 设置默认副本 和默认分片
number_of_shards
每个索引的主分片数,默认值是 1 。这个配置在索引创建后不能修改。
number_of_replicas
每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改。
修改现有的副本数为0: 现存所有索引副本数变为0
命令行运行
curl -X PUT "192.xxx.x.xxx:9200/_settings" -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":0}}'
创建测试 索引
curl -X PUT "192.xxx.x.xxx:9200/?pretty"
浏览器输入:
http://192.xxx.x.xxx:9200/_settings
查看新建索引是否副本为0
结果:不为0 因为是只改之前存在索引 之后创建还是 es7默认的副本数:1
设置elasticsearch默认模板(之后创建索引副本为0)
curl -X PUT 192.168.1.195:9200/_template/log -H 'Content-Type: application/json' -d '{
"template": "*",
"settings": {
"number_of_shards": 1,
"number_of_replicas": "0"
}
}'
"template": "*" 代表所有 索引
"template": "apple*" 代表生成apple*的索引都会按照这个模板来了
浏览器输入:
http://192.xxx.x.xxx:9200/_settings
查看新建索引是否副本为0
插入数据测试
curl -XPUT -H 'content-Type:application/json' http://192.168.1.195:9200/my_new_index/user/1?pretty -d '{"name":"张三","age":"23"}'
{
"_index" : "my_new_index",
"_type" : "user",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
更多推荐
已为社区贡献11条内容
所有评论(0)