最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Centos7安裝ElasticSearch 6.4.1入門教程詳解

 更新時(shí)間:2019年05月16日 15:13:23   作者:溯水心生  
這篇文章主要介紹了Centos 7安裝ElasticSearch 6.4.1入門教程詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

1.下載ElasticSearch 6.4.1安裝包 下載地址:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz

2.解壓壓縮包

[root@localhost ElasticSearch]# tar -zxvf elasticsearch-6.4.1.tar.gz

3.啟動(dòng)ElasticSearch

[root@localhost bin]# ./elasticsearch

以后臺(tái)方式啟動(dòng)

[root@localhost bin]# ./elasticsearch -d

TIPS:

[root@localhost bin]# ./elasticsearch
[2018-09-19T19:46:09,817][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
  at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.1.jar:6.4.1]
  at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.1.jar:6.4.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
  at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.1.jar:6.4.1]
  at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.1.jar:6.4.1]

ElasticSearch 不能以root用戶角色啟動(dòng),因此需要將安裝目錄授權(quán)給其他用戶,用其他用戶來啟動(dòng)

啟動(dòng)成功后,驗(yàn)證,打開新的終端,執(zhí)行如下命令:

[root@localhost ~]# curl 'http://localhost:9200/?pretty'
{
 "name" : "O5BAVYE",
 "cluster_name" : "elasticsearch",
 "cluster_uuid" : "rw1yjlzkSgODXkUVgIxmxg",
 "version" : {
  "number" : "6.4.1",
  "build_flavor" : "default",
  "build_type" : "tar",
  "build_hash" : "e36acdb",
  "build_date" : "2018-09-13T22:18:07.696808Z",
  "build_snapshot" : false,
  "lucene_version" : "7.4.0",
  "minimum_wire_compatibility_version" : "5.6.0",
  "minimum_index_compatibility_version" : "5.0.0"
 },
 "tagline" : "You Know, for Search"
}
[root@localhost ~]# 

返回信息則表示安裝成功!

4.安裝Kibana

Sense 是一個(gè) Kibana 應(yīng)用 它提供交互式的控制臺(tái),通過你的瀏覽器直接向 Elasticsearch 提交請求。 這本書的在線版本包含有一個(gè) View in Sense 的鏈接,里面有許多代碼示例。當(dāng)點(diǎn)擊的時(shí)候,它會(huì)打開一個(gè)代碼示例的Sense控制臺(tái)。 你不必安裝 Sense,但是它允許你在本地的 Elasticsearch 集群上測試示例代碼,從而使本書更具有交互性。

下載kibana

Kibana是一個(gè)為 ElasticSearch 提供的數(shù)據(jù)分析的 Web 接口??墒褂盟鼘θ罩具M(jìn)行高效的搜索、可視化、分析等各種操作
https://artifacts.elastic.co/downloads/kibana/kibana-6.4.1-linux-x86_64.tar.gz

下載完成解壓Kibana

[root@localhost ElasticSearch]# tar -zxvf kibana-6.4.1-linux-x86_64.tar.gz 

修改  配置config目錄下的kibana.yml 文件,配置elasticsearch地址和kibana地址信息

server.host: "192.168.92.50" # kibana 服務(wù)器地址
elasticsearch.url: "http://192.168.92.50:9200"  # ES 地址

啟動(dòng) Kibana

[root@localhost bin]# ./kibana

安裝Kibana本機(jī)訪問:http://localhost:5601/

選擇Dev Tools菜單,即可實(shí)現(xiàn)可視化請求

5.安裝LogStash

下載logStash
https://artifacts.elastic.co/downloads/logstash/logstash-7.0.1.tar.gz

下載完成解壓后,config目錄下配置日志收集日志配置文件 logstash.conf

# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.

input {
 tcp {
  mode => "server"
  host => "192.168.92.50"
  port => 4560
  codec => json_lines
 }
}
output {
 elasticsearch {
  hosts => "192.168.92.50:9200"
  index => "springboot-logstash-%{+YYYY.MM.dd}"
 }
}

配置成功后啟動(dòng)logstatsh

[root@localhost bin]# ./logstash -f ../config/logstash.conf 

ES  一些基礎(chǔ)知識(shí):

索引(名詞):

如前所述,一個(gè) 索引 類似于傳統(tǒng)關(guān)系數(shù)據(jù)庫中的一個(gè) 數(shù)據(jù)庫 ,是一個(gè)存儲(chǔ)關(guān)系型文檔的地方。 索引 (index) 的復(fù)數(shù)詞為 indices 或 indexes 。

索引(動(dòng)詞):

索引一個(gè)文檔 就是存儲(chǔ)一個(gè)文檔到一個(gè) 索引 (名詞)中以便它可以被檢索和查詢到。這非常類似于 SQL 語句中的 INSERT 關(guān)鍵詞,除了文檔已存在時(shí)新文檔會(huì)替換舊文檔情況之外。

倒排索引:

關(guān)系型數(shù)據(jù)庫通過增加一個(gè) 索引 比如一個(gè) B樹(B-tree)索引 到指定的列上,以便提升數(shù)據(jù)檢索速度。Elasticsearch 和 Lucene 使用了一個(gè)叫做 倒排索引 的結(jié)構(gòu)來達(dá)到相同的目的。

PUT /megacorp/employee/1
{
  "first_name" : "John",
  "last_name" : "Smith",
  "age" :    25,
  "about" :   "I love to go rock climbing",
  "interests": [ "sports", "music" ]
}

返回結(jié)果:

#! Deprecation: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
{
 "_index": "megacorp",
 "_type": "employee",
 "_id": "1",
 "_version": 1,
 "result": "created",
 "_shards": {
  "total": 2,
  "successful": 1,
  "failed": 0
 },
 "_seq_no": 0,
 "_primary_term": 1
}

路徑 /megacorp/employee/1 包含了三部分的信息:

megacorp 索引名稱

employee  類型名稱

1        特定雇員的ID

放置第二個(gè)雇員信息:

{
 "_index": "megacorp",
 "_type": "employee",
 "_id": "2",
 "_version": 1,
 "result": "created",
 "_shards": {
  "total": 2,
  "successful": 1,
  "failed": 0
 },
 "_seq_no": 0,
 "_primary_term": 1
}

返回結(jié)果:

{
 "_index": "megacorp",
 "_type": "employee",
 "_id": "2",
 "_version": 1,
 "result": "created",
 "_shards": {
  "total": 2,
  "successful": 1,
  "failed": 0
 },
 "_seq_no": 0,
 "_primary_term": 1
}

放置第三個(gè)雇員信息

{
 "_index": "megacorp",
 "_type": "employee",
 "_id": "3",
 "_version": 1,
 "result": "created",
 "_shards": {
  "total": 2,
  "successful": 1,
  "failed": 0
 },
 "_seq_no": 0,
 "_primary_term": 1
}

5.檢索文檔

檢索到單個(gè)雇員的數(shù)據(jù)

GET /megacorp/employee/1

返回結(jié)果:

{
 "_index": "megacorp",
 "_type": "employee",
 "_id": "1",
 "_version": 1,
 "found": true,
 "_source": {
  "first_name": "John",
  "last_name": "Smith",
  "age": 25,
  "about": "I love to go rock climbing",
  "interests": [
   "sports",
   "music"
  ]
 }
}

6.輕量搜索

一個(gè) GET 是相當(dāng)簡單的,可以直接得到指定的文檔。 現(xiàn)在嘗試點(diǎn)兒稍微高級(jí)的功能,比如一個(gè)簡單的搜索!

第一個(gè)嘗試的幾乎是最簡單的搜索了。我們使用下列請求來搜索所有雇員:

GET /megacorp/employee/_search

返回結(jié)果:

{
 "took": 31,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 3,
  "max_score": 1,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "2",
    "_score": 1,
    "_source": {
     "first_name": "Jane",
     "last_name": "Smith",
     "age": 32,
     "about": "I like to collect rock albums",
     "interests": [
      "music"
     ]
    }
   },
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 1,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    }
   },
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "3",
    "_score": 1,
    "_source": {
     "first_name": "Douglas",
     "last_name": "Fir",
     "age": 35,
     "about": "I like to build cabinets",
     "interests": [
      "forestry"
     ]
    }
   }
  ]
 }
}

通過姓名模糊匹配來獲得結(jié)果

GET /megacorp/employee/_search?q=last_name:Smith

返回結(jié)果:

{
 "took": 414,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 2,
  "max_score": 0.2876821,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "2",
    "_score": 0.2876821,
    "_source": {
     "first_name": "Jane",
     "last_name": "Smith",
     "age": 32,
     "about": "I like to collect rock albums",
     "interests": [
      "music"
     ]
    }
   },
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 0.2876821,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    }
   }
  ]
 }
}

7.使用查詢表達(dá)式搜索

領(lǐng)域特定語言 (DSL), 指定了使用一個(gè) JSON 請求

GET /megacorp/employee/_search
{
  "query" : {
    "match" : {
      "last_name" : "Smith"
    }
  }
}

返回結(jié)果:

{
 "took": 7,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 2,
  "max_score": 0.2876821,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "2",
    "_score": 0.2876821,
    "_source": {
     "first_name": "Jane",
     "last_name": "Smith",
     "age": 32,
     "about": "I like to collect rock albums",
     "interests": [
      "music"
     ]
    }
   },
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 0.2876821,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    }
   }
  ]
 }
}

8.更復(fù)雜的搜索

搜索姓氏為 Smith 的雇員,但這次我們只需要年齡大于 30 的,使用過濾器 filter ,它支持高效地執(zhí)行一個(gè)結(jié)構(gòu)化查詢

GET /megacorp/employee/_search
{
  "query" : {
    "bool": {
      "must": {
        "match" : {
          "last_name" : "smith" 
        }
      },
      "filter": {
        "range" : {
          "age" : { "gt" : 30 } 
        }
      }
    }
  }
}

其中:range 過濾器 , 它能找到年齡大于 30 的文檔,其中 gt 表示_大于(_great than)

返回結(jié)果:

{
 "took": 44,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 1,
  "max_score": 0.2876821,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "2",
    "_score": 0.2876821,
    "_source": {
     "first_name": "Jane",
     "last_name": "Smith",
     "age": 32,
     "about": "I like to collect rock albums",
     "interests": [
      "music"
     ]
    }
   }
  ]
 }
}

9.全文搜索

搜索下所有喜歡攀巖(rock climbing)的雇員

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

返回結(jié)果:

{
 "took": 17,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 2,
  "max_score": 0.5753642,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 0.5753642,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    }
   },
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "2",
    "_score": 0.2876821,
    "_source": {
     "first_name": "Jane",
     "last_name": "Smith",
     "age": 32,
     "about": "I like to collect rock albums",
     "interests": [
      "music"
     ]
    }
   }
  ]
 }
}

10.全文搜索

找出一個(gè)屬性中的獨(dú)立單詞是沒有問題的,但有時(shí)候想要精確匹配一系列單詞或者短語 。 比如, 我們想執(zhí)行這樣一個(gè)查詢,僅匹配同時(shí)包含 “rock” 和 “climbing” ,并且 二者以短語 “rock climbing” 的形式緊挨著的雇員記錄。

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

返回結(jié)果:

{
 "took": 142,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 1,
  "max_score": 0.5753642,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 0.5753642,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    }
   }
  ]
 }
}

11.高亮搜索

許多應(yīng)用都傾向于在每個(gè)搜索結(jié)果中 高亮 部分文本片段,以便讓用戶知道為何該文檔符合查詢條件。在 Elasticsearch 中檢索出高亮片段也很容易。

增加參數(shù): highlight

GET /megacorp/employee/_search
{
  "query" : {
    "match_phrase" : {
      "about" : "rock climbing"
    }
  },
  "highlight": {
    "fields" : {
      "about" : {}
    }
  }
}

返回結(jié)果:

{
 "took": 250,
 "timed_out": false,
 "_shards": {
  "total": 5,
  "successful": 5,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": 1,
  "max_score": 0.5753642,
  "hits": [
   {
    "_index": "megacorp",
    "_type": "employee",
    "_id": "1",
    "_score": 0.5753642,
    "_source": {
     "first_name": "John",
     "last_name": "Smith",
     "age": 25,
     "about": "I love to go rock climbing",
     "interests": [
      "sports",
      "music"
     ]
    },
    "highlight": {
     "about": [
      "I love to go <em>rock</em> <em>climbing</em>"
     ]
    }
   }
  ]
 }
}

其中高亮模塊為highlight屬性

12.分析

Elasticsearch 有一個(gè)功能叫聚合(aggregations),允許我們基于數(shù)據(jù)生成一些精細(xì)的分析結(jié)果。聚合與 SQL 中的 GROUP BY 類似但更強(qiáng)大。

舉個(gè)例子,挖掘出雇員中最受歡迎的興趣愛好:

GET /megacorp/employee/_search
{
 "aggs": {
  "all_interests": {
   "terms": { "field": "interests" }
  }
 }
}

返回結(jié)果:

{
  ...
  "hits": { ... },
  "aggregations": {
   "all_interests": {
     "buckets": [
      {
        "key":    "music",
        "doc_count": 2
      },
      {
        "key":    "forestry",
        "doc_count": 1
      },
      {
        "key":    "sports",
        "doc_count": 1
      }
     ]
   }
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Apache本地二級(jí)域名配置方法

    Apache本地二級(jí)域名配置方法

    這篇文章主要介紹了Apache本地二級(jí)域名配置方法,涉及hosts文件設(shè)置與Apache配置文件設(shè)置等相關(guān)技巧,需要的朋友可以參考下
    2016-05-05
  • 安裝ubuntu18.04報(bào):failed to load ldlinux.c32的問題及解決步驟

    安裝ubuntu18.04報(bào):failed to load ldlinux.c32的問題及解決步驟

    這篇文章主要介紹了安裝ubuntu18.04報(bào):failed to load ldlinux.c32的問題,本文通過圖文并茂的形式給大家分享解決方法,需要的朋友可以參考下
    2020-08-08
  • linux之如何殺掉指定端口

    linux之如何殺掉指定端口

    這篇文章主要介紹了linux之如何殺掉指定端口問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • Linux運(yùn)維之如何使用ss命令代替netstat

    Linux運(yùn)維之如何使用ss命令代替netstat

    這篇文章主要給大家介紹了關(guān)于Linux運(yùn)維之如何使用ss命令代替netstat的相關(guān)資料,需要的朋友可以參考下
    2019-07-07
  • Centos7上網(wǎng)及添加靜態(tài)IP方法介紹

    Centos7上網(wǎng)及添加靜態(tài)IP方法介紹

    本文給大家詳細(xì)介紹了Centos7上網(wǎng)及添加靜態(tài)IP的方法,并把步驟做了詳細(xì)說明,需要的朋友跟著學(xué)習(xí)下。
    2018-02-02
  • 解決xampp自啟動(dòng)和mysql.sock問題

    解決xampp自啟動(dòng)和mysql.sock問題

    Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
    2010-10-10
  • Linux環(huán)境變量配置的完整攻略

    Linux環(huán)境變量配置的完整攻略

    這篇文章主要給大家介紹了關(guān)于Linux環(huán)境變量配置的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Linux具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • vsftpd配置虛擬用戶登錄的方法

    vsftpd配置虛擬用戶登錄的方法

    這篇文章主要介紹了vsftpd配置虛擬用戶登錄的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • xmapp環(huán)境搭建注意事項(xiàng)說明

    xmapp環(huán)境搭建注意事項(xiàng)說明

    如果要用其他IP訪問,需要到apache/conf/ext/httpd-xmapp.cf配置文檔下修改最后的一段信息,注釋掉一行拒絕IP的。還有修改一個(gè)允許訪問IP的為(*)
    2013-11-11
  • Linux下查看壓縮文件內(nèi)容的10種方法(小結(jié))

    Linux下查看壓縮文件內(nèi)容的10種方法(小結(jié))

    這篇文章主要介紹了Linux下查看壓縮文件內(nèi)容的10種方法(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11

最新評論

龙陵县| 穆棱市| 仙游县| 凤冈县| 濮阳县| 美姑县| 峨眉山市| 曲松县| 平邑县| 正蓝旗| 定兴县| 疏勒县| 海宁市| 溆浦县| 江孜县| 祥云县| 博客| 泸西县| 当涂县| 金堂县| 栖霞市| 卫辉市| 大足县| 紫阳县| 揭阳市| 湛江市| 平遥县| 宁化县| 荣昌县| 巩留县| 灵川县| 兰坪| 洪江市| 赤峰市| 丹江口市| 开化县| 库车县| 安图县| 宜兴市| 比如县| 环江|