elasticsearch机器迁移工具命令

  • 立即分配unassigned节点
curl -XPUT 'http://x.x.x.x:9200/_all/_settings' -H 'Content-Type: application/json' -d '{
 "index.unassigned.node_left.delayed_timeout": 0
}'

  • 延迟分配节点
curl -XPUT 'http://x.x.x.x:9200/_all/_settings' -H 'Content-Type: application/json' -d '{
 "index.unassigned.node_left.delayed_timeout": "5s"
}'
  • 设置自动refresh时间
curl -XPUT 'http://x.x.x.x:9200/_all/_settings' -H 'Content-Type: application/json' -d '{
  "settings": {
    "index": {
        "refresh_interval" : "1s"
    }
  }
}'

  • 手动分配分片
curl -XPOST 'http://x.x.x.x:9200/_cluster/reroute' -H 'Content-Type: application/json' -d '{
  "commands":[
    {
     "move" : {
                "index" : "tns_order_index_v1", "shard" : 2,
                "from_node" : "172.31.82.58", "to_node" : "l-order-es13.rd.cn2"
      }
    }
    ]
}'

  • 开启分片自动rebalance

curl -XPUT 'http://x.x.x.x:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{
  "persistent": {
    "cluster": {
      "routing": {
        "allocation.enable": "all"
      }
    }
  }
}'
  • 失败后重新rebalance

curl  -XPOST http://x.x.x.x:9200/_cluster/reroute?retry_failed=true

  • 查看分片分配失败原因

curl -XGET http://x.x.x.x:9200/_cluster/allocation/explain?pretty

  • 查看分片状态
curl -s "http://x.x.x.x:9200/_cat/shards" 
curl -XGET 'http://x.x.x.x:9200/_cat/shards' | grep UNASSIGNED

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×