Elasticsearch及其head插件安裝

一、Elasticsearch下載
官網地址:https://www.elastic.co/
進去之後點右上角download,然後選歷史版本。
在這裏插入圖片描述
然後搜索Elasticsearch選擇要下載的版本,進行下載,zip爲windows版本,tar爲linux版。
二、安裝
1、建立安裝目錄並上傳elasticsearch-2.4.3.tar.gz在這裏插入圖片描述

 [hadoop@djt002 elasticsearch]$ pwd
/usr/local/elasticsearch
[hadoop@djt002 elasticsearch]$ rz

在這裏插入圖片描述
(如果上傳時出現zmodem transfer cancled by remote side 問題,解決方法:
1、首先使用rz -e 來試下
2、如果上個操作沒有成功,則需要df -h看下所在目錄磁盤佔用情況
果然我上傳文件的所在目錄分區使用率已達到100%,因此,我便使用du命令一層一層的查看是哪個文件佔用空間那麼大,看是否是有用的,沒用的直接rm 幹掉即可。
在這裏插入圖片描述
2、解壓
在這裏插入圖片描述

[hadoop@djt002 elasticsearch]$ ls
elasticsearch-2.4.3.tar.gz
[hadoop@djt002 elasticsearch]$ tar -zxvf elasticsearch-2.4.3.tar.gz

3、啓動es
方式一(不建議,只能在本機訪問)在這裏插入圖片描述注意:es啓動之後啊,會綁定兩個端口,9200和9300.

bin/elasticsearch 注意: 這樣啓動只能通過 127.0.0.1:9200 訪問
在這裏插入圖片描述方式二(建議,既能在本機訪問,也能在內網訪問)
建議修改 es 的配置文件 (一般建議這種)
vi config/elasticsearch.yml
network.host: 192.168.80.200
這個屬性要頂格寫, 並且冒號和值之間要有一個空格
bin/elasticsearch
這樣再啓動, 就可以通過 192.168.80.200:9200 訪問
或者可以這樣設置
vi config/elasticsearch.yml
network.host: 0.0.0.0
這樣再啓動, 可以通過 127.0.0.1:9200 和 192.168.80.200:9200 訪問在這裏插入圖片描述在這裏插入圖片描述在這裏插入圖片描述在這裏插入圖片描述

[hadoop@djt002 elasticsearch-2.4.3]$ pwd
/usr/local/elasticsearch/elasticsearch-2.4.3
[hadoop@djt002 elasticsearch-2.4.3]$ bin/elasticsearch     或者    bin/elasticsearch  -d (後臺運行)

[2017-02-20 23:10:43,674][WARN ][bootstrap ] unable to install syscall filter: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
[2017-02-20 23:10:45,361][INFO ][node ] [Pisces] version[2.4.3], pid[2182], build[d38a34e/2016-12-07T16:28:56Z]
[2017-02-20 23:10:45,372][INFO ][node ] [Pisces] initializing ...
[2017-02-20 23:10:48,431][INFO ][plugins ] [Pisces] modules [lang-groovy, reindex, lang-expression], plugins [], sites []
[2017-02-20 23:10:48,629][INFO ][env ] [Pisces] using [1] data paths, mounts [[/ (/dev/sda5)]], net usable_space [28.7gb], net total_space [34.7gb], spins? [possibly], types [ext4]
[2017-02-20 23:10:48,629][INFO ][env ] [Pisces] heap size [1015.6mb], compressed ordinary object pointers [true]
[2017-02-20 23:10:48,631][WARN ][env ] [Pisces] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2017-02-20 23:10:54,940][INFO ][node ] [Pisces] initialized
[2017-02-20 23:10:54,940][INFO ][node ] [Pisces] starting ...
[2017-02-20 23:10:55,046][INFO ][transport ] [Pisces] publish_address {192.168.80.200:9300}, bound_addresses {192.168.80.200:9300}
[2017-02-20 23:10:55,057][INFO ][discovery ] [Pisces] elasticsearch/EEZfZRE4S6GceAe-paQJPQ
[2017-02-20 23:10:58,360][INFO ][cluster.service ] [Pisces] new_master {Pisces}{EEZfZRE4S6GceAe-paQJPQ}{192.168.80.200}{192.168.80.200:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2017-02-20 23:10:58,536][INFO ][http ] [Pisces] publish_address {192.168.80.200:9200}, bound_addresses {192.168.80.200:9200}
[2017-02-20 23:10:58,542][INFO ][node ] [Pisces] started
[2017-02-20 23:10:59,072][INFO ][gateway ] [Pisces] recovered [0] indices into cluster_state

在這裏插入圖片描述修改方式的總結:

1、修改config/elasticsearch.yml

2、或者在啓動es的時候指定參數 (也可以是0.0.0.0,即任何主機)

如bin/elasticsearch -Dnetwork.host=192.168.80.200 (但這樣,每次很麻煩!)

3、es 安裝注意事項, 以及容易出現問題的地方
  (1): 關閉服務器防火牆
     service iptables stop
     chkconfig iptables off
  (2): network.host 屬性需要設置【 如果不設置的話只能通過 127.0.0.1 來進行訪問】
     network.host: 192.168.80.200 【注 意 : 冒 號 後 面 必 須 要 有 空 格 , 這 樣 只 能 通 過192.168.80.200 訪問 es】
     或者 network.host: 0.0.0.0 【 這樣可以通過此服務器的所有 ip 訪問 es, 包括 127.0.0.1】
  (3): es 的訪問端口問題
    默認 es 會監聽 9200 端口, 可以通過 http 請求進行訪問。
    但是要注意: 如果在一個節點上連續啓動多個 es 實例的話, es 監聽的端口號會遞增,
  9201,9202…
  (4): 如果發現 es 啓動之後在瀏覽器無法正常訪問
    建議查看 es 的啓動日誌, 確認 es 啓動的時候是否報錯, 以及綁定的 ip 和端口是多少。
    前臺方式啓動 es 的話, 可以直接在控制檯查看 es 的啓動日誌、
    後臺方式啓動 es 的話, 可以到 ES_HOME/logs/elasticsearch.log 文件中查看日誌

在這裏插入圖片描述
推薦 Elasticsearch筆記一之簡介與安裝

三、head插件的安裝與使用
1、插件安裝方式(推薦)

#在Elasticsearch目錄下
$/bin/plugin -install mobz/elasticsearch-head

如果出現ERROR: unknown command [-install]. Use [-h]錯誤,是因爲好像2.0以上的版本-install 變成了 install了。

elasticsearch/bin/plugin install mobz/elasticsearch-head

2、插件下載方式安裝:從https://download.csdn.net/download/xiaolong2230/11209538下載或者https://github.com/mobz/elasticsearch-head下載ZIP包。
在 elasticsearch 目錄下創建目錄/plugins/head 並且將剛剛解壓的elasticsearch-head-master目錄下所有內容COPY到當前創建的/plugins/head/下面。
3、重啓Elasticsearch。訪問。
訪問地址是http://{你的ip地址}:9200/_plugin/head/
4、Elasticsearch-head 插件界面介紹。
在這裏插入圖片描述因爲我是單點的,所以健康度直接是yellow,黃色不影響使用,紅色就有問題了,不過具體看問題是什麼問題。

我這個不知道怎麼回事,直接是中文的,是根據地區IP默認識別安裝的。所以其他功能我不講了,我就直說一下看索引(index)的 Mapping 在哪看。在這裏插入圖片描述這個可以看到當前索引(index)下所有類型(Type) 的 Mapping ,當然你不創建,就會根據你數據類型來自動生成 Mapping ,我後面會講到 Mapping 生成的方式方法。
5、數據瀏覽
在這裏插入圖片描述查看命中數據詳情。
在這裏插入圖片描述.基本查詢
在這裏插入圖片描述複合查詢。在這裏插入圖片描述6、安全問題(嚴重)
因爲該插件可以對數據進行,增刪改查。故生產環境儘量不要使用,如果要使用,最少要限制IP地址。儘量不要使用。

注:高版本(5.0以上)的es在安裝head插件的時候如果按上面方式造成es啓動錯誤,則可以參照以下方式來安裝head插件https://blog.csdn.net/xiaolong2230/article/details/90694022

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章