ELK6.0環境搭建及配置

ELK環境搭建及配置

ElasticSearch在5.x後的安裝和插件的官方執行更好了,head插件官方默認集成在kibana的dev tools裏,支持rpm包方式安裝,x-pack安裝後支持權限及各類報表功能。html

1、安裝ES

1. 安裝JAVA SDK

相似阿里雲和aws通常默認的操做系統都自帶了java環境,檢查java安裝環境使用java -version查看。java

目前安裝的ELK版本是5.6.4版本,須要java8以上(java有兩個版本,sdk版本和外部版本,sdk版本是1.8.x)就知足要求了。node

# yum install java-1.8.0-openjdk
2. 安裝elasticsearch

下載地址: https://www.elastic.co/downloads/elasticsearchshell

下載對應的版本,下載後解壓到想安裝的文件夾中,由於es是綠色版本因此解壓後就可使用vim

./bin/elasticsearch實際上是一個shell腳本,最終仍是啓動在java的虛擬機環境中,並加入了必定參數。windows

# rpm -ivh elasticsearch-5.6.4.rpm
# chkconfig --add elasticsearch
# chkconfig elasticsearch on 
# vim etc/elasticsearch/elasticsearch.yml
# /etc/init.d/elasticsearch.rpmnew start

可執行文件目錄:/usr/share/elasticsearch/api

配置文件目錄: /etc/elasticsearch/服務器

日誌文件目錄:/var/log/elasticsearch/網絡

data文件目錄:/var/lib/elasticsearch/架構

pid文件路徑:/var/run/elasticsearch/

日誌文件:/var/log/elasticsearch/

3. 啓動elasticsearch

守護進程 ./bin/elasticsearch -d

前臺運行 ./bin/elasticsearch

配合elasticsearch-servicewrapper 插件將腳本服務化更易管理 (2.x加再也不支持,棄用)

運行日誌在../log/下,每個索引一個文件,每日一個文件,包括運行的慢日誌和服務日誌。

4. 測試elasticsearch

curl -XGET http://xxx:9200/?pretty

5. 集羣配置

https://www.ibm.com/support/knowledgecenter/zh/SSFPJS_8.5.6/com.ibm.wbpm.main.doc/topics/rfps_esearch_configoptions.html

discovery.zen.ping.unicast.hosts : ["17.16.0.1:9300", "172.16.2.1:9300"]

默認通訊的TCP端口是9300,也能夠自定義修改,若是集羣鏈接失敗可查看是否啓動成功,並在elasticsearch/kibana的日誌中查看具體緣由並排查,配置定義在加入的新服務器裏,使用_cat/nodes?v可查看節點信息。

6. 經常使用api

_cat/health?v 查看集羣監控狀況

_cat/nodes?v 集羣節點狀況

_cat/indices 索引狀況

2、安裝Kibana

下載頁面:https://www.elastic.co/cn/downloads/kibana

安裝rpm包,個人電腦是x64的因此下載64位的安裝包,rpm包安裝完畢後會自動在/etc/init.d/下生成執行腳本,提供給service/chkconfig,更方便咱們使用

# wget https://artifacts.elastic.co/downloads/kibana/kibana-5.6.4-x86_64.rpm
# rpm -ivh kibana-5.6.4-x86_64.rpm
# vim /etc/kibana/kibana.yml

3、安裝Beats

Beats與Logstash的主要區別是Beats是輕量級的數據採集器,Beats包含Filebeat(普通文件採集)、

Metricbeat(系統和服務指標收集)、Packetbeat(網絡相關數據採集)、Winlogbeat(windows日誌)、

Heartbeat(運行時間監控、ping檢測)、Auditbeat 、Topbeat等。

1. 安裝Heartbeat客戶端

安裝Heartbeat並將數據寫入到ES中,並結合Kibana平臺進行數據展現報表和檢索功能

下載地址:https://www.elastic.co/downloads/beats/heartbeat

項目介紹:https://www.elastic.co/cn/products/beats/heartbeat

啓動 /etc/init.d/heartbeat start

4、安裝x-pack插件

官方下載地址:https://www.elastic.co/downloads/x-pack

官方文檔地址:https://www.elastic.co/guide/en/x-pack/current/xpack-introduction.html

https://www.elastic.co/gu ide/en/x-pack/6.0/setting-up-authentication.html#set-built-in-user-passwords

1. elasticsearch安裝x-pack插件
  • 若是是集羣架構,則每一臺新機器都須要安裝插件
  • kibana安裝了x-pack,elasticsearch也必需要安裝
# /usr/share/elasticsea     rch/bin/elasticsearch-plugin install x-pack
# /usr/share/kibana/bin/kibana-plugin install x-pack
2. 編輯配置文件
# vim /etc/elasticsearch/x-pack/
3. 用戶管理
# /usr/share/elasticsearch/bin/x-pack/users useradd test -p 123456 -r superuser

Installation overview on Elasticsearch

若是設置的密碼不能登陸,則能夠建立內置用戶,登陸成功後再修改密碼。

官方說明:https://www.elastic.co/guide/en/x-pack/current/security-getting-started.html

/usr/share/elasticsearch/bin/x-pack/users useradd test -p 123456 -r superuser
vim /etc/kibana/kibana.yml

x-pack有不少內置角色,具體能夠看官方說明superuser是最高權限,詳見:

https://www.elastic.co/guide/en/x-pack/current/built-in-roles.html

Kibana支持在elasticsearch、kibana、logstath都安裝,可是各個支持的功能點不同,設置也不太同樣,

好比es的x-pack就不支持Graph,具體參考如下連接:

https://www.elastic.co/guide/en/elasticsearch/reference/6.0/settings-xpack.html

常見問題及注意
  1. Elasticsearch is still initializing the Monitoring indices

    解決:刪除相關索引

    http://www.4wei.cn/archives/1002492

  2. transport.tcp.port 自定義discovery集羣發行端口

  3. 若是安裝了x-pack,則集羣每臺機器都須要安裝

  4. 若是shell執行則須要注意目錄的每一個文件的所屬者都要是執行用戶的,不然java會拋出AccessDenied錯誤

相關文章
相關標籤/搜索