Elasticsearch 5.2.1Cluster 搭建

Posted Jt00

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch 5.2.1Cluster 搭建相关的知识,希望对你有一定的参考价值。

1.安装java

  • cd ~
  • wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-x64.rpm"

2.安装elasticsearch:

       现在一台机器上解压:

        tar zxvf elasticsearch-5.2.1.tar.gz

        修改配置文件:

   network.host:对应机器的ip

   cluster.name: production

         node.name: ${HOSTNAME}

         discovery.zen.ping.unicast.hosts: ["node01", "node02", "node03"]

          保存启动

          配置好的直接拷贝到另外两台机器记得修改ip

3.检查:curl -XGET \'http://localhost:9200/_cluster/state?pretty\'

成功:

4.相关配置:

启用内存锁定:

bootstrap.mlockall: true

计算集群中文档的数量:
GET /_count
{
"query": {
"match_all": {}
}
}
索引雇员文档:
PUT /megacorp/employee/1
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}

PUT /megacorp/employee/2
{
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests": [ "music" ]
}

PUT /megacorp/employee/3
{
"first_name" : "Douglas",
"last_name" : "Fir",
"age" : 35,
"about": "I like to build cabinets",
"interests": [ "forestry" ]
}
检索到单个雇员的数据:
GET /megacorp/employee/1
GET /megacorp/employee/_search
查询字符串 (_query-string_) 搜索:

GET /megacorp/employee/_search?q=last_name:Smith
使用查询表达式搜索:(即席搜索)
GET /megacorp/employee/_search
{
"query" : {
"match" : {
"last_name" : "Smith"
}
}
}
更复杂的搜索:
GET /megacorp/employee/_search
{
"query" : {
"bool": {
"must": {
"match" : {
"last_name" : "smith"
}
},
"filter": {
"range" : {
"age" : { "gt" : 30 }
}
}
}
}
}
稍微高级点儿的全文搜索:

GET /megacorp/employee/_search
{
"query" : {
"match" : {
"about" : "rock climbing"
}
}
}

精确匹配一系列单词或者短语:

 

 

 

以上是关于Elasticsearch 5.2.1Cluster 搭建的主要内容,如果未能解决你的问题,请参考以下文章

Redis Cluste部署与Jedis整合Sentinel与Clusterr

elasticsearch-5.2.1在windows下的安装方法

Elasticsearch 5.2.1Cluster 搭建

Different AG groups have the exactly same group_id value if the group names are same and the ‘CLUSTE

elk,centos7,filebeat,elasticsearch-head详细安装步骤

ES获取磁盘使用率情况