ElasticSearch日常维护命令

1. 集群的状态查看

  • 查看es各个节点的状态,包括负载和内存:
    http://IP:9201/_cat/nodes?v
  • 查看es磁盘空间占用情况:
    http://IP:9201/_cat/allocation?v
  • 查看健康状况
    http://IP:9201/_cat/health?v

2. 索引的关闭和打开

  • 查看所有索引
    http://IP:9200/_cat/indices
  • 打开索引
    http://IP:9200/{索引名称}/_open
  • 关闭索引
    http://IP:9200/{索引名称}/_close

3. 索引设置查看

http://IP:9201/{索引名称}/_mappings
http://IP:9201/{索引名称}/_settings

4. 索引设置

PUT http://IP:9201/{索引名称}/_settings
{
    "index": {
        "routing": {
          "allocation": {
            "total_shards_per_node": "5",
            "include": {
              "_name": "node01,node02,node03,node04,node05"
            }
          }
        }
    }
}

PUT http://IP:9201/{索引名称}/_settings
{
    "index": {
        "refresh_interval": "120s"
    }
}

PUT http://IP:9201/{索引名称}/_mappings
{
  "properties": {
      "ad_content": {
          "type": "string",
          "analyzer": "standard"
      },
      "ad_time": {
          "type": "long"
      },
      "ad_id": {
          "type": "string",
          "index": "not_analyzed"
      }
  }
}

5. 移动分片到另外一个节点

POST _cluster/reroute
{
    "commands" : [
        { 
            "move" :  { 
                  "index" : "index_1", "shard" : 6,  
                  "from_node" : "node01", "to_node" : "node06" 
            }
        }
    ]
}

6. 分配分片

POST _cluster/reroute
{
    "commands" : [
        { 
              "allocate" : { 
                  "index" : "index_1", "shard" : 10, "node" : "node08" 
              } 
        }
    ]
}

7. 别名删除和新增

POST http://IP:9200/_aliases
{
    "actions": [
        {
            "remove": {
                "index": "index_v1",
                "alias": "index_v1_alias"
            }
        },
        {
            "add": {
                "index": "index_v1_day_1",
                "alias": "index_v1_day_aiase"
            }
        }
    ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值