elasticsearch - 删除第二个elasticsearch节点并添加另一个节点,获取未分配的分片

时间:2015-03-30 16:35:56

标签: elasticsearch logstash

作为Elasticsearch的首发,我只是在两周前使用它而且我刚做了一件傻事。

我的Elasticsearch有一个集群有两个节点,一个是主数据节点(版本1.4.2),一个是非数据节点(版本1.1.1)。使用时有冲突版本,我决定关闭并删除然后,安装另一个数据节点(版本1.4.2)看看我的图像,以便于想象。 node3然后命名为node2 enter image description here

然后,我检查弹性状态

{ 
    "cluster_name":"elasticsearch",
    "status":"yellow",
    "timed_out":false,
    "number_of_nodes":2,
    "number_of_data_nodes":2,
    "active_primary_shards":725,
    "active_shards":1175,
    "relocating_shards":0,
    "initializing_shards":0,
    "unassigned_shards":273
}

检查群集状态

curl -XGET http://localhost:9200/_cat/shards


    logstash-2015.03.25 2 p STARTED       3031  621.1kb 10.146.134.94 node1        
    logstash-2015.03.25 2 r UNASSIGNED
    logstash-2015.03.25 0 p STARTED       3084  596.4kb 10.146.134.94 node1        
    logstash-2015.03.25 0 r UNASSIGNED                                                     
    logstash-2015.03.25 3 p STARTED       3177  608.4kb 10.146.134.94 node1        
    logstash-2015.03.25 3 r UNASSIGNED                                                     
    logstash-2015.03.25 1 p STARTED       3099  577.3kb 10.146.134.94 node1       
    logstash-2015.03.25 1 r UNASSIGNED                      
    logstash-2014.12.30 4 r STARTED                     10.146.134.94 node2 
    logstash-2014.12.30 4 p STARTED         94  114.3kb 10.146.134.94 node1        
    logstash-2014.12.30 0 r STARTED        111  195.8kb 10.146.134.94 node2 
    logstash-2014.12.30 0 p STARTED        111  195.8kb 10.146.134.94 node1       
    logstash-2014.12.30 3 r STARTED        110    144kb 10.146.134.94 node2 
    logstash-2014.12.30 3 p STARTED        110    144kb 10.146.134.94 node1

我已阅读相关问题并试图遵循它但没有运气。我也在答案中评论我得到的错误。

ElasticSearch: Unassigned Shards, how to fix?


https://t37.net/how-to-fix-your-elasticsearch-cluster-stuck-in-initializing-shards-mode.html

elasticsearch - what to do with unassigned shards

http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html#cluster-reroute

curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
    "commands" : [ {
          "allocate" : {
              "index" : "logstash-2015.03.25", 
              "shard" : 4, 
              "node" : "node2", 
              "allow_primary" : true
          }
        }
    ]
}'

我得到了

"routing_nodes":{"unassigned":[{"state":"UNASSIGNED","primary":false,"node":null,
"relocating_node":null,"shard":0,"index":"logstash-2015.03.25"}

我按照https://stackoverflow.com/a/23781013/1920536

中的回答
curl -XPUT 'localhost:9200/_cluster/settings' -d '{
"transient" : {
    "cluster.routing.allocation.enable" : "all"
}
}'

但没有感情。

我该怎么办? 感谢先进。

更新:当我检查待处理任务时,它显示:

{"tasks":[{"insert_order":88401,"priority":"HIGH","source":"shard-failed 
    ([logstash-2015.01.19][3], node[PVkS47JyQQq6G-lstUW04w], [R], s[INITIALIZING]),
    **reason [Failed to start shard, message** [RecoveryFailedException[[logstash-2015.01.19][3]: **Recovery failed from** [node1][_72bJJX0RuW7AyM86WUgtQ]
    [localhost][inet[/localhost:9300]]{master=true} into [node2][PVkS47JyQQq6G-lstUW04w]
    [localhost][inet[/localhost:9302]]{master=false}]; 
    nested: RemoteTransportException[[node1][inet[/localhost:9300]]
    [internal:index/shard/recovery/start_recovery]]; nested: RecoveryEngineException[[logstash-2015.01.19][3] Phase[2] Execution failed];
    nested: RemoteTransportException[[node2][inet[/localhost:9302]][internal:index/shard/recovery/prepare_translog]];
    nested: EngineCreationFailureException[[logstash-2015.01.19][3] **failed to create engine]; 
    nested: FileSystemException**[data/elasticsearch/nodes/0/indices/logstash-2015.01.19/3/index/_0.si: **Too many open files**]; ]]","executing":true,"time_in_queue_millis":53,"time_in_queue":"53ms"}]}

1 个答案:

答案 0 :(得分:0)

如果你有两个节点,如
1)节点-1 - ES 1.4.2
2)节点-2 - Es 1.1.1

现在按照以下步骤进行调试。

1)从Node-2停止所有elasticsearch实例 2)在新的elasticsearch节点中安装elasticsearch 1.4.2。 将elasticsearch.yml更改为主节点配置,特别是这三个配置设置

 cluster.name: <Same as master node>
 node.name: < Node name for Node-2>
 discovery.zen.ping.unicast.hosts: <Master Node IP>

3)重新启动Node-2 Elasticsearch 4)验证节点1日志。