ElasticSearch在linux上安裝部署

一.安裝準備工做
安裝參考文檔:javascript

ELK官網:https://www.elastic.co/html

ELK官網文檔:https://www.elastic.co/guide/index.htmljava

ELK中文手冊:https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.htmlnode

ELK中文社區:https://elasticsearch.cn/git

ELK-API :https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.htmlgithub

(1)、規劃安裝目錄web

  /usr/localjson

(2)、下載安裝包bootstrap

訪問elasticSearch官網地址 https://www.elastic.co/api

下載指定版本的安裝包:elasticsearch-6.6.0.tar.gz

(3)、上傳安裝包到指定目錄

     經過FTP工具上傳安裝包到指定目錄,  或者在服務器目錄下直接下載:  wget  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz

(4)、解壓安裝包

tar -zxvf elasticsearch-6.6.0.tar.gz -C /export/servers

(5)、重命名安裝目錄

mv elasticsearch-6.6.0 elasticsearch

(6)、修改配置文件

進入到es安裝目錄下的config文件夾中,修改elasticsearch.yml 文件

修改的主要內容:

#配置es的集羣名稱,默認是elasticsearch,es會自動發如今同一網段下的es,若是在同一網段下有多個集羣,就能夠用這個屬性來區分不一樣的集羣。
cluster.name: my-es
#節點名稱
node.name: node-1
#設置索引數據的存儲路徑
path.data: /usr/local/elasticsearch/data
#設置日誌的存儲路徑
path.logs: /usr/local/elasticsearch/logs
#設置當前的ip地址,經過指定相同網段的其餘節點會加入該集羣中
network.host: 0.0.0.0
#設置對外服務的http端口
http.port: 9200
#設置集羣中master節點的初始列表,能夠經過這些節點來自動發現新加入集羣的節點
discovery.zen.ping.unicast.hosts: ["127.0.0.1","10.10.10.34:9200"]

 

 注:

  一、補齊必要的目錄

  mkdir -p /usr/local/elasticsearch/data

 

  mkdir -p /usr/local/elasticsearch/logs     (目錄可能已經存在,需先肯定清楚)

 

  二、network.host: 0.0.0.0

  修改Elasticsearch的配置,使其支持外網訪問。在瀏覽器中,訪問http://xxxx:9200/(xxxx是運行elasticsearch的服務器的ip地址)便可。不然這能夠在本機使用。

 

二.解決啓動時報錯

(1)、在 root用戶下啓動時報錯

由於安全問題elasticsearch 不讓用root用戶直接運行,因此要建立新用戶。

具體操做以下:
  useradd testuser
  passwd testuser
再輸入兩次密碼(自定義)
  爲用戶賦權限

  chown -R testuser:testuser /usr/local/elasticsearch

而後使用es用戶啓動  :su testuser

  cd  /usr/local/elasticsearch

啓動es命令:bin/elasticsearch

(2)、在testuser用戶下啓動時報錯

爲用戶賦權限

  chown -R testuser:testuser /usr/local/elasticsearch

而後使用es用戶啓動  :su testuser

  cd  /usr/local/elasticsearch

啓動es命令:bin/elasticsearch

(3)、在testuser用戶下啓動時報錯

緣由:Centos6不支持SecComp,而ES默認bootstrap.system_call_filter爲true進行檢測,因此致使檢測失敗,失敗後直接致使ES不能啓動。

詳見 :https://github.com/elastic/elasticsearch/issues/22899

解決方案:

在elasticsearch.yml中新增配置bootstrap.system_call_filter,設爲false。

bootstrap.system_call_filter: false

 

(4)、在testuser用戶下啓動繼續報錯

  a、緣由:沒法建立本地文件問題,用戶最大可建立文件數過小,解決方案:切換到root用戶,編輯limits.conf配置文件, 添加相似以下內容:

    vi /etc/security/limits.conf

  而後添加以下內容: 注意*不要去掉了

    * soft nofile 65536

    * hard nofile 131072

  注:* 表明Linux全部用戶名稱(好比 hadoop)

  須要保存、退出、從新登陸纔可生效。

  b、緣由:最大虛擬內存過小,解決辦法切換到root用戶修改配置sysctl.conf:

   vi /etc/sysctl.conf 

  添加下面配置:

    vm.max_map_count=655360

  最後記得執行:

    sysctl -p

  而後,從新啓動elasticsearch,便可啓動成功。

 

三.測試

切換到testuser用戶執行:

看到這個界面證實已經成功了,能夠用瀏覽器訪問ip:9200查看,會下載一個json文件打開以下:

 

至此Elasticsearch就安裝完成了,固然這只是一臺機器,若是有須要還能夠搭成集羣.

 

三.ES插件安裝

一、安裝head

elasticsearch-head是一個界面化的集羣操做和管理工具,能夠對集羣進行傻瓜式操做。你能夠經過插件把它集成到es(首選方式),也能夠安裝成一個獨立webapp。
es-head主要有三個方面的操做:
  a、顯示集羣的拓撲,而且可以執行索引和節點級別操做
  b、搜索接口可以查詢集羣中原始json或表格格式的檢索數據
  c、可以快速訪問並顯示集羣的狀態
有一個輸入窗口,容許任意調用RESTful API。這個接口包含幾個選項,能夠組合在一塊兒以產生有趣的結果; 
請求方法(get、put、post、delete),查詢json數據,節點和路徑
      支持JSON驗證器
      支持重複請求計時器
      支持使用javascript表達式變換結果
收集結果的能力隨着時間的推移(使用定時器),或比較的結果,能力圖表轉換後的結果在一個簡單的條形圖(包括時間序列)

  1), 直接安裝

./bin/plugin install mobz/elasticsearch-head

       2) ,zip包安裝

1. https://github.com/mobz/elasticsearch-head下載zip 解壓
2. 創建elasticsearch-2.4.0\plugins\head文件
3. 將解壓後的elasticsearch-head-master文件夾下的文件copy到head
4. 運行es

   安裝驗證: 

 2, 安裝其餘插件

 
$ ${ES_HOME}/bin/plugin --install lukas-vlcek/bigdesk
# 安裝完成訪問:http://localhost:9200/_plugin/bigdesk/#nodes

$ ${ES_HOME}/bin/plugin -install royrusso/elasticsearch-HQ
# 安裝完成訪問:http://localhost:9200/_plugin/HQ/

$ ${ES_HOME}/bin/plugin -install lmenezes/elasticsearch-kopf
# 安裝完成訪問:http://localhost:9200/_plugin/kopf/#!/cluster
相關文章
相關標籤/搜索