Elasticsearch+Logstash+Kibana 實時在線日誌分析系統linux
文件下載地址:https://www.elastic.co/downloads/past-releasesbootstrap
環境瀏覽器
centOS 6.8ruby
jdk1.8curl
1、安裝Elasticsearchelasticsearch
1.下載好安裝包 並解壓安裝oop
[root@linux1 ~]# tar -zxvf elasticsearch-5.0.0.tar.gz測試
[root@linux1 ~]# mv elasticsearch-5.0.0 /usr/local/elasticsearchui
2.運行url
[root@linux1 ~]# cd /usr/local/elasticsearch/
[root@linux1 elasticsearch]# bin/elasticsearch
注意:這裏直接運行會報錯,elasticsearch默認是不容許在root下運行,要新建一個系統用戶
[root@linux1 elasticsearch]# useradd es
[root@linux1 elasticsearch]# chown -R root .
[root@linux1 elasticsearch]# chown -R es .
[root@linux1 elasticsearch]# chgrp -R es .
[root@linux1 elasticsearch]# ls -l
total 48
drwxr-xr-x. 2 es es 4096 Dec 25 00:54 bin
drwxr-xr-x. 2 es es 4096 Oct 26 04:40 config
drwxr-xr-x. 2 es es 4096 Oct 26 04:40 lib
-rw-r--r--. 1 es es 11358 Oct 26 04:35 LICENSE.txt
drwxr-xr-x. 2 es es 4096 Dec 25 05:11 logs
drwxr-xr-x. 12 es es 4096 Oct 26 04:40 modules
-rw-r--r--. 1 es es 150 Oct 26 04:35 NOTICE.txt
-rw-r--r--. 1 es es 9108 Oct 26 04:35 README.textile
並給目錄下的文件賦予權限,不然會報錯permission denied
登陸到用戶
[root@linux1 elasticsearch]# su es
[es@linux1 elasticsearch]$ bin/elasticsearch
3.報錯處理
上網查了一下,說是linux版本較低,只是一個警告,那就能夠忽略,後面還在繼續運行
又發現報錯,此次是真的報錯
繼續上網尋求幫助
摘自http://www.dajiangtai.com/community/18136.do?origin=csdn-blog
(1)error: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
緣由:沒法建立本地文件問題,用戶最大可建立文件數過小
解決方案:
切換到root用戶,編輯limits.conf配置文件, 添加相似以下內容:
vi /etc/security/limits.conf
添加以下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
備註:* 表明Linux全部用戶名稱(好比 hadoop)
保存、退出、從新登陸纔可生效
(2)max number of threads [1024] for user [es] likely too low, increase to at least [2048]
緣由:沒法建立本地線程問題,用戶最大可建立線程數過小
解決方案:切換到root用戶,進入limits.d目錄下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到以下內容:
* soft nproc 1024
#修改成
* soft nproc 2048
(3)max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
緣由:最大虛擬內存過小
解決方案:切換到root用戶下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
而後從新啓動elasticsearch,便可啓動成功。
4.檢測elasticsearch
[root@linux1 config]# curl -X GET http://192.168.1.120:9200/
{
"name" : "QWUKxcz",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "QGD4pcGrQXSobqufKkFZ4Q",
"version" : {
"number" : "5.0.0",
"build_hash" : "253032b",
"build_date" : "2016-10-26T04:37:51.531Z",
"build_snapshot" : false,
"lucene_version" : "6.2.0"
},
"tagline" : "You Know, for Search"
}
安裝完成~
2、安裝Logstash
1.下載安裝包 並解壓安裝
[root@linux1 ~]# tar -zxvf logstash-5.0.0.tar.gz
[root@linux1 ~]# mv logstash-5.0.0 /usr/local/logstash
2.測試
[root@linux1 ~]# cd /usr/local/logstash
[root@linux1 logstash]# bin/logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}}'
回車,而後你會發現終端在等待你的輸入。敲入 hello world,回車,而後看看會返回什麼結果
{
"@timestamp" => 2016-12-25T10:13:03.901Z,
"@version" => "1",
"host" => "linux1.xxxx.com",
"message" => "hello world"
}
3、安裝Kibana
1.下載安裝包 並解壓安裝
[root@linux1 ~]# tar -zxvf kibana-5.0.0-linux-x86_64.tar.gz
[root@linux1 ~]# mv kibana-5.0.0-linux-x86_64 /usr/local/kibana
2.修改配置
[root@linux1 ~]# /usr/local/kibana/config
[root@linux1 config]# ls
kibana.yml
[root@linux1 config]# vi kibana.yml
找到
#server.host: "localhost"
#elasticsearch.url: "http://localhost:9200"
修改成你當前的IP地址,例:
server.host: "192.168.1.120"
elasticsearch.url: "http://192.168.1.120:9200"
3.運行Kibana
[root@linux1 kibana]# bin/kibana
用瀏覽器打開上面的地址
安裝完成~