ELK就是ElasticSearch + LogStash + Kibananode
一、準備工做
ELK下載:https://www.elastic.co/downloads/
jdk version:1.8.0_162bootstrap
平臺:centos6.5
二、環境搭建
ElasticSearch:
(1)不能使用root用戶啓動,需將elasticsearch文件夾放在執行用戶目錄下,不然會報錯:「錯誤: 找不到或沒法加載主類 org.elasticsearch.tools.launchers.JavaVersionChecker」
(2)插件安裝:bin/elasticsearch-plugin install x-pack
(3)修改配置文件 vim config/elasticsearch.yml
cluster.name: myapp
node.name: node0
path.data: /path/to/data
path.logs: /path/to/logs
network.host: 127.0.0.1(若要局域網訪問,須要添加端口或直接關閉防火牆)
http.port: 9200
bootstrap.system_call_filter: false(add)
xpack.security.enabled: false(取消用戶登錄的驗證)
注:儘可能保持冒號前面沒空格,後面一個空格,不要用tab鍵,不然會報錯:「Exception in thread "main" 2017-11-10 06:29:49,106 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.ElasticsearchParseException[malformed, expected settings to start with 'object', instead was [VALUE_STRING]]」
vim /etc/security/limits.d/90-nproc.conf
elasticsearch soft nproc 4096 # 針對 max number of threads
elasticsearch hard nproc 4096
elasticsearch soft nofile 65536 # 針對 max file descriptors (add)
elasticsearch hard nofile 65536 vim
vim /etc/sysctl.conf
vm.max_map_count=262144 # 針對 max virtual memory areas(add) (sysctl -p 使生效)centos
Kiabna
(1)解壓後,執行「./bin/kibana-plugin install x-pack」安裝X-Pack
(2)修改配置文件kibana.yml
elasticsearch.url: "http://192.168.11.13:9200"
server.host: "192.168.11.13"app
logstash
(1)解壓後,執行「./bin/logstash-plugin install x-pack」安裝X-Pack
(2)修改配置文件logstash.yml,添加以下
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.url: ["http://192.168.11.13:9200"]([]中填寫elasticsearch運行後能訪問到的IP和端口)
(3)添加配置文件:logstash.conf
input {
file {
path => "/home/elsearch/error.log"
type => "error"
start_position => "beginning"
}
}elasticsearch
output {
elasticsearch {
hosts => ["192.168.11.13:9200"]
index => "error-%{+YYYY.MM.DD}"
}
}url