Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | About

8.2. 管理

查看节点信息

		
root@netkiller /var/log/elasticsearch % curl -XGET localhost:9200/
{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "I7jirJ2yTr-f2qrBNorQYA",
  "version" : {
    "number" : "5.6.0",
    "build_hash" : "781a835",
    "build_date" : "2017-09-07T03:09:58.087Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}
		
		
		

8.2.1. 查看索引

root@netkiller ~ % curl 'http://localhost:9200/_cat/indices?v'         
health status index        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   information  oygxIi-dR1eB9NoIZtJrxQ   5   1         45           42      731kb          731kb
green  open   .kibana      9jBBaOomTO2EakZlZqnE-g   1   1          5            1     62.5kb         31.2kb
green  open   logstash-api WHXZhn3vRWiuVbhR8rGoEg   5   1        565            0      3.8mb          1.9mb			
			

8.2.2. 节点健康状态

root@netkiller ~ % curl 'http://localhost:9200/_cat/health?v' 
epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1502445967 18:06:07  my-application yellow          2         2     17  11    0    0        5             0                  -                 77.3%			
			
root@netkiller ~ % curl 'http://localhost:9200/_cluster/health'  
{"cluster_name":"my-application","status":"yellow","timed_out":false,"number_of_nodes":2,"number_of_data_nodes":2,"active_primary_shards":11,"active_shards":17,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":77.27272727272727} 			
			

8.2.3. 节点http状态

root@netkiller ~ % curl 'localhost:9200/_nodes/stats/http?pretty'
{
  "_nodes" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "cluster_name" : "my-application",
  "nodes" : {
    "-lnKCmBXRpiwExLns0jc9g" : {
      "timestamp" : 1502446878773,
      "name" : "node-1",
      "transport_address" : "10.104.3.2:9300",
      "host" : "10.104.3.2",
      "ip" : "10.104.3.2:9300",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "http" : {
        "current_open" : 4,
        "total_opened" : 29
      }
    },
    "WVsgYi2HT8GWnZU1kUwFwA" : {
      "timestamp" : 1502446878782,
      "name" : "node-2",
      "transport_address" : "10.186.7.221:9300",
      "host" : "10.186.7.221",
      "ip" : "10.186.7.221:9300",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "http" : {
        "current_open" : 0,
        "total_opened" : 2
      }
    }
  }
}
			
			

8.2.4. 查看master节点

root@netkiller ~ % curl 'http://localhost:9200/_cat/nodes?v'      
ip           heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.104.3.2             31          98  50    0.20    0.55     0.61 mdi       -      node-1
10.186.7.221           25          99   0    0.00    0.01     0.05 mdi       *      node-2
			

8.2.5. 查看索引的节点分布

root@netkiller ~ % curl 'http://localhost:9200/_cat/shards?v'
index        shard prirep state      docs   store ip           node
logstash-api 1     p      STARTED     103   342kb 10.186.7.221 node-2
logstash-api 1     r      STARTED     103   342kb 10.104.3.2   node-1
logstash-api 3     p      STARTED     104 404.1kb 10.186.7.221 node-2
logstash-api 3     r      STARTED     104 404.1kb 10.104.3.2   node-1
logstash-api 4     p      STARTED     117 349.2kb 10.186.7.221 node-2
logstash-api 4     r      STARTED     117 349.2kb 10.104.3.2   node-1
logstash-api 2     p      STARTED     113 405.8kb 10.186.7.221 node-2
logstash-api 2     r      STARTED     113 405.8kb 10.104.3.2   node-1
logstash-api 0     p      STARTED     128 488.4kb 10.186.7.221 node-2
logstash-api 0     r      STARTED     128 488.4kb 10.104.3.2   node-1
.kibana      0     p      STARTED       5  31.2kb 10.186.7.221 node-2
.kibana      0     r      STARTED       5  31.2kb 10.104.3.2   node-1
information  1     p      STARTED      10 122.3kb 10.104.3.2   node-1
information  1     r      UNASSIGNED                           
information  3     p      STARTED       7 159.6kb 10.104.3.2   node-1
information  3     r      UNASSIGNED                           
information  4     p      STARTED       8  86.1kb 10.104.3.2   node-1
information  4     r      UNASSIGNED                           
information  2     p      STARTED      11   160kb 10.104.3.2   node-1
information  2     r      UNASSIGNED                           
information  0     p      STARTED       9 202.8kb 10.104.3.2   node-1
information  0     r      UNASSIGNED                           
			

8.2.6. 索引的开启与关闭

POST /{index}/_close		关闭索引
POST /{index}/_open		打开索引                                                                                                                                                                      
			

8.2.6.1. _open

root@netkiller /var/log/elasticsearch % curl 'http://localhost:9200/_cat/indices?v'   
health status index           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
       close  information     oygxIi-dR1eB9NoIZtJrxQ                                                          
green  open   logstash-spring 9xXtt_L0QvKHibXFH5gjJQ   5   1       4622            0     62.9mb         31.4mb
green  open   .kibana         9jBBaOomTO2EakZlZqnE-g   1   1         10            0     36.6kb         18.3kb				
				
root@netkiller /var/log/elasticsearch % curl -XPOST 'http://localhost:9200/information/_open'
{"acknowledged":true}#  				
				
root@netkiller /var/log/elasticsearch % curl 'http://localhost:9200/_cat/indices?v'         
health status index           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   information     oygxIi-dR1eB9NoIZtJrxQ   5   1       2417            5     34.5mb         17.3mb
green  open   logstash-spring 9xXtt_L0QvKHibXFH5gjJQ   5   1       4622            0     62.9mb         31.4mb
green  open   .kibana         9jBBaOomTO2EakZlZqnE-g   1   1         10            0     36.6kb         18.3kb					
				

8.2.6.2. _close

root@netkiller /var/log/elasticsearch % curl -XPOST 'http://localhost:9200/information/_close'
{"acknowledged":true}#