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
用浏览器打开上面的地址
安装完成~