es 加磁盤擴容


elasticsearch多磁盤擴容

1、問題

由於早前elasticsearch集群數據存儲路徑只配置了一個,所以某天磁盤突然爆滿,集群差點當機。需重新配置多路徑存儲路徑,因為在生產環境,得保證集群不死掉,只能一台一台配置重啟。

2、修改配置文件

修改elasticsearch.yml中path.data屬性,添加多路徑以逗號分隔

path.data : /opt/data1,/opt/data2

 

3、查看集群狀態

curl -XGET "http://xxxx:9200/_cat/indices" curl -XGET "http://xxxx:9200/_cat/nodes" curl -XGET "http://xxxx:9200/_cat/health"

 

 

4、關閉索引自動平衡

curl -XPUT "http://xxxx:9200/_cluster/settings" -d' { "transient" : { "cluster.routing.allocation.enable" : "none" } }'

 

5、重啟節點

6、開啟自動平衡

curl -XPUT "http://xxxx.52:9200/_cluster/settings" -d' { "transient": { "cluster.routing.allocation.enable": "all" } }'

 

7、重復4-6步驟

8、遇到的問題

有一個索引的某個分片一直處理UNASSIGNED狀態,需進行手動分配。

curl -XGET 'http://xxxx:9200/_cat/shards' | grep UNASSIGNED #查看未分配的索引分片 curl -XGET "http://xxxx:9200/_cat/shards/index?v" #查看索引分片

 

 

使用reroute接口進行分配。 
reroute 接口支持五種指令:allocate_replica, allocate_stale_primary, allocate_empty_primary,move 和 cancel。 
常用的一般是 allocate 和 move,allocate_* 指令。 
因為負載過高等原因,有時候個別分片可能長期處於 UNASSIGNED 狀態,我們就可以手動分配分片到指定節點上。默認情況下只允許手動分配副本分片(即使用 allocate_replica),所以如果要分配主分片,需要單獨加一個 accept_data_loss 選項

分配主分片

curl -XPOST "http://xxxx:9200/_cluster/reroute" -d '{ "commands" : [ { "allocate_stale_primary" : { "index" : "index", "shard" : 4, "node" : "node56", "accept_data_loss" : true } } ] }'

 

分配副分片

curl -XPOST "http://xxxx:9200/_cluster/reroute" -d '{ "commands" : [ { "allocate_replica" : { "index" : "index", "shard" : 4, "node" : "node56" } } ] }'

 

 

9、kibana進和查詢命令

fuser -n tcp 5601


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM