ElasticSearch 基础和集群搭建(2)

{
  "status" : 200,
  "name" : "Server1",
  "cluster_name" : "HFELK-Server1",
  "version" : {
    "number" : "1.7.0",
    "build_hash" : "929b9739cae115e73c346cb5f9a6f24ba735a743",
    "build_timestamp" : "2015-07-16T14:31:07Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

三:ES 概念和集群:

1、基于http的RESTful API

以jsop返回查询结果:

[root@elk-server1 config]# curl  -XGET  'http://192.168.0.251:9200/_count?pretty' -d '
> {
>    "query":{
>            "match_all":{}
>      }
> }
>
> '
{
  "count" : 1,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  }
}

curl -i:

[root@elk-server1 config]# curl  -i -XGET  'http://192.168.0.251:9200/_count?pretty' -d '
{
    "query":{
          "match_all":{}
      }
}

'
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 95

{
  "count" : 1,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  }
}

2、安装ELS监控管理插件:

[root@elk-server1 service]# /usr/local/elasticsearch/bin/plugin  -i elasticsearch/marvel/latest/
-> Installing elasticsearch/marvel/latest/...
Trying
Downloading ......................................................................................................................................................................................................................................................DONE
Installed elasticsearch/marvel/latest/ into /usr/local/elasticsearch/plugins/marvel

3、web访问::9200/_plugin/marvel/

选选免费试用:

ElasticSearch 基础和集群搭建

4、进入测试界面:

ElasticSearch 基础和集群搭建

5、界面效果:

ElasticSearch 基础和集群搭建

提交内容:

ElasticSearch 基础和集群搭建

6、提交的代码如下:

POST  /index-demo/test
{
  "user":"jack",
  "message":"hello word"
  }
}

7、 查看和删除指定文档内容:

GET  /index-demo/test/AVP0y8ANAZWiuuxBK3mq/_source
DELETE  /index-demo/test/AVP0y8ANAZWiuuxBK3mq/_source

8、搜索文档:

GET  /index-demo/test/_search?q=hello

{
  "took": 97,
  "timed_out": false,
  "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
  },
  "hits": {
      "total": 1,
      "max_score": 0.15342641,
      "hits": [
        {
            "_index": "index-demo",
            "_type": "test",
            "_id": "AVP0y8ANAZWiuuxBK3mq",
            "_score": 0.15342641,
            "_source": {
              "user": "jack",
              "message": "hello word"
            }
        }
      ]
  }
}

四:elasticsearch集群管理程序之head:

1、安装集群的管理插件head:

集群更换了虚拟机环境,所以主机名不一样,安装的时候要多安装几次,有的时候会因为网络问题无法一次 安装完成。

[root@node6 local]#  /usr/local/elasticsearch/bin/plugin  -i mobz/elasticsearch-head/
-> Installing mobz/elasticsearch-head/...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip...
Downloading ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Installed mobz/elasticsearch-head/ into /usr/local/elasticsearch/plugins/head

2、打开web管理端,查看是否已经有本机被管理了:

ElasticSearch 基础和集群搭建

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/015d51c70c646a7fcdf8bb243b5198a5.html