1. 程式人生 > >Elastic search(1) 基礎命令

Elastic search(1) 基礎命令

索引分片設定

PUT /_template/shard_template
{
"order" : 1,
"index_patterns": [
"dq2_orm*",
"dq2_dq_orm*",
"dq2_frontend*",
"dq2_session*"
],
"settings": {
"index": {
"number_of_shards": "8"
}
}
}

獲取主節點資訊

    GET /_cat/master?v 

獲取叢集健康狀態

    GET /_cat/health?v 

獲取節點資訊

    GET /_cat/nodes?v 

獲取節點磁碟資訊

    GET /_cat/allocation?v 

GET /_cat/health?v&pretty

檢視所有的索引

    GET /_cat/indices?v&&s=index

刪除索引資料

    DELETE /dq2_chat-2017.06.02 

檢視模板分片相關操作通過設定模板來設定分片數量

    GET /_template 

    PUT /_template/shard_template
    {
    "order" : 1,
    "index_patterns": [
    "dq2_orm*",
    "dq2_dq_orm*",
    "dq2_frontend*",
    "dq2_session*"
    ],
    "settings": {
    "index": {
    "number_of_shards": "10"
    }
    }
    }

檢視索引對應的分片數

    GET /_cat/shards/hwsjus_grand-2018.11.01?v&s=node

如果分片分佈不均勻採用如下命令手動分片

    POST /_cluster/reroute
    {
    "commands" : [
    {
    "move" : {
    "index" : "hwsjus_session-2018.11.01",
    "shard" :4,
    "from_node" : "es_d4",
    "to_node" : "es_d1"
    }
    }
    ]
    }

沒有分片的

    POST /_cluster/reroute
    {
        "commands" : [
            {
              "allocate_replica" : {
                    "index" : "hwsj_grand-2018.10.25", 
                    "shard" : 6,
                    "node" : "es_d7"
              }
            }
        ]
    }