ElasticSearch入门(3) —— head插件

#### 安装ES head插件

具体请参考github地址:https://github.com/mobz/elasticsearch-head

使用

安装Install

# 在线安装head插件

$ cd /letv/elasticsearch-1.7.3/bin

$ ./plugin --install mobz/elasticsearch-head

# 离线安装head插件

# 从github下载head插件对应版本的zip包

$ cd /letv/elasticsearch-1.7.3/bin

$ ./plugin --install head --url file:///letv/elasticsearch-head-master.zip

集群中的es服务器都安装一下。安装完成之后,在浏览器输入:http://ip:9200/_plugin/head/ ,可以查看显示效果。如下图:

主界面中可以看到集群的情况:

1.主分片与副本的区别是粗细边框

2.界面的右边有些按钮,如:node stats, cluster nodes,这些是直接请求es的相关状态的api,返回结果为json,如下图:

 【节点状态】

curl http://localhost:8200/_cluster/nodes?pretty  
结果:
 
{
  "ok" : true,  // 集群状态
  "cluster_name" : "if2c", //集群名称
  "nodes" : {
    "bT7UoS9nR4aVowpZ7KSQXQ" : {  //节点UID
      "name" : "test123", //节点名称
      "transport_address" : "inet[10.0.2.226/10.0.2.226:8300]", TCP交流IP及端口
      "hostname" : "memcached-2", //机器名称
      "version" : "0.90.9", ES版本
      "http_address" : "inet[/10.0.2.226:8200]", //HTTP查询端口,为插件提供监控
      "attributes" : {
        "rack" : "racktest123", //机柜ID,跨机柜部署集群,以防某一个机柜断电影响ES服务
        "master" : "true" //是否是主节点
      }
    }
  }
}

也可以查询集群中某台机器的状态:根据IP

curl http://localhost:8200/_cluster/nodes/10.0.2.226?pretty 

也可以使用通配符查询

curl http://localhost:8200/_cluster/nodes/10.0.2.2*?pretty   

3.在索引下面有info和action两个按钮。info是可以查看索引的状态和mapping的定义。action是对索引进行操作,如:添加别名、刷新、关闭索引,删除索引等。

4.browser浏览界面,这个界面可以同时查看多个索引的数据,也可以查询指定字段的数据。

 

5.Structured Query查询界面,这个界面可以对某个索引进行一些复杂查询,如下面这个例子是查询product索引,构造boolquery,title字段里查询“产品”关键词,price范围为10到100的记录。

 

6.Any Request任意请求界面,这个界面可以说是个rest的客户端,可以通过它来对es进行一些请求操作或测试api接口,下面这个例子是把product索引的副本数设置为1,更多的api可以到es官网查询。

原文地址:https://www.cnblogs.com/Dhouse/p/5795030.html