不要急,总有办法的

设置cluster.routing.allocation.enable为none,禁用分片分配的问题

Elasticsearch | 作者 sterne vencel | 发布于2018年05月31日 | 阅读数:14590

设置的参数:
curl -X PUT http://0.0.0.0:9200/_cluster/settings?pretty -d '{"transient": {"cluster.routing.allocation.enable": "none"}}'
如果禁用分片分配后,是不是就不能新建索引了?
验证的结果是执行新建索引后,一直收不到返回值。
 
官方给的文档上并没有写用影响索引新建啊
官方文档链接:https://www.elastic.co/guide/e ... .html
文章中提出:
没说会影响到索引的新建啊

15.png

 
已邀请:

rockybean - Elastic Certified Engineer, ElasticStack Fans,公众号:ElasticTalk

赞同来自:

建新索引的过程要分配分片,你禁用分配分片了,自然无法新建索引

hapjin

赞同来自:

刚好在看分片迁移,说一下自己的理解,可能有错。我测试过,如果集群设置了 cluster.routing.allocation.enable:none,执行命令:
PUT test_index
{
"settings": {
"index":{
"number_of_replicas" : 0,
"number_of_shards": 1
}
}
}
会阻塞直至超时。
这个时候,test_index 是创建成功了的。但是,test_index的分片无法分配。因此,集群的状态会变成Red。如下所示:
test_index.jpg

另外,cluster.routing.allocation.enable 和 cluster.routing.rebalance.enable 参数是有区别的:
cluster.routing.allocation.enable 设置成none,主要是影响集群中新创建的索引无法进行分片分配(把分片分配到某个节点上去)。
cluster.routing.rebalance.enable设置成none, 主要是影响集群中已有索引的分片不会rebalance到(迁移)其他节点上去了吧。比如,我已经有一个名为test的索引在node-1,node-2上,如果此时node-2宕机,由于:cluster.routing.rebalance.enable设置成none,那么node-2上的分片是不会自动迁移到node-1上去的,那集群的状态很有可能是Red。
 
另外,看官方文档关于ElasticSearch节点升级(或者说节点重启)的描述:
把 index.unassigned.node_left.delayed_timeout(默认是1分钟) 设置得大一点,因为关闭了一台节点,意味着在这台节点上的所有副本(既包括 primary 也包括replica)都没了,某些索引的副本就达不到number_of_replicas 指定的值了,那么ES会"复制"一个新的副本出来以满足:number_of_replicas 参数所配置的值。但由于是重启节点,而不是真正的故障,因此,应该要避免这种复制操作。index.unassigned.node_left.delayed_timeout 可以推迟这种复制操作的发生。
但是里面提到了 "cluster.routing.allocation.enable": "primaries" 参数,不太明白为什么要设置成 primaries而不是其他参数?

要回复问题请先登录注册