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

0 0 投票数
Article Rating
订阅评论
提醒
guest
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x