0

我用于调试日志的 Graylog2 服务器上存在一些磁盘问题。现在有未分配的分片:

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

graylog_292 1 p STARTED    751733  648.4mb 127.0.1.1 Doctor Leery 
graylog_292 1 r UNASSIGNED                                        
graylog_292 2 p STARTED    756663  653.2mb 127.0.1.1 Doctor Leery 
graylog_292 2 r UNASSIGNED                                        
graylog_290 0 p STARTED    299059  257.2mb 127.0.1.1 Doctor Leery 
graylog_290 0 r UNASSIGNED                                        
graylog_290 3 p STARTED    298759  257.1mb 127.0.1.1 Doctor Leery 
graylog_290 3 r UNASSIGNED                                        
graylog_290 1 p STARTED    298314  257.3mb 127.0.1.1 Doctor Leery 
graylog_290 1 r UNASSIGNED                                        
graylog_290 2 p STARTED    297722  257.1mb 127.0.1.1 Doctor Leery 
graylog_290 2 r UNASSIGNED 
....

它有400多个碎片。我可以删除它们而不会丢失数据,因为它是单节点设置。为了做到这一点,我需要遍历索引(graylog_xxx)和分片(1,2,...)。

如何用 Bash 循环这个(2 个变量)?删除 API 调用有 2 个变量,我需要替换(afaik):

curl -XPOST 'host:9200/_cluster/reroute' -d '{
        "commands" : [ {
              "allocate" : {
                  "index" : "$index", 
                  "shard" : $shard, 
                  "node" : "Doctor Leery", 
                  "allow_primary" : true
              }
            }
        ]
    }'

让我感到困扰的是,未分配的分片没有节点。但是在 API 调用中我需要指定一个。

4

1 回答 1

2

从您共享的_cat/shards输出中,看起来那些是未分配的副本,您可以通过更新集群设置并将副本计数设置为 0 来简单地删除它们,如下所示:

curl -XPUT 'localhost:9200/_settings' -d '{
    "index" : {
        "number_of_replicas" : 0
    }
}'

运行上述 curl 后,您的集群将再次变为绿色。

于 2016-01-05T12:36:27.573 回答