ELK日志分析平台搭建全程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ELK日志分析平台搭建全程相关的知识,希望对你有一定的参考价值。
环境:
OS:Centos 6.6
elasticsearch-5.6.3.tar.gz
jdk-8u151-linux-x64.tar.gz
kibana-5.6.3-linux-x86_64.tar.gz
logstash-5.6.3.tar.gz
node-v6.11.4-linux-x64.tar.xz
一、准备环境:
1、创建用户,并给安装目录设置权限
[[email protected] ~]# groupadd elk [[email protected] ~]# useradd -g elk elk [[email protected] ~]# mkdir /elk [[email protected] ~]# chown -R elk:elk /elk
修改系统某些参数值:【如不修改启动时会报错】
[[email protected] ~]# vim /etc/security/limits.conf //添加一下内容 --------------------------- * soft nofile 65536 * hard nofile 65536 * soft nproc 2048 * hard nproc 4096 ---------------------------- [[email protected] elk]# vim /etc/security/limits.d/90-nproc.conf //添加如下内容 * soft nproc 2048 [[email protected] ~]# vim /etc/sysctl.conf // 添加一下内容 ------------------ vm.max_map_count=655360 ---------------------- [[email protected] ~]# sysctl -p // 查看vm.max_map_count 值是否修改成功
安装Java
[[email protected] elk]# mkdir /usr/local/Java
[[email protected] elk]# tar -zxvf jdk-8u151-linux-x64.tar.gz -C /usr/local/Java
添加环境变量:
[[email protected] jdk1.8.0_151]# vim /etc/profile
添加如下:
export JAVA_HOME=/usr/local/Java/jdk1.8.0_151 export PATH=$PATH:$JAVA_HOME/bin exportCLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPAT
重新加载
[[email protected] jdk1.8.0_151]# source /etc/profile
查看是否安装成功:
[[email protected] jdk1.8.0_151]# java -version java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
二:安装ELK
1、安装elasticsearch
# tar -zxvf elasticsearch-5.6.3.tar.gz 修改配置文件: vim ./elasticsearch-5.6.3/config/elasticsearch.yml //设置监听IP及监听端口: network.host: 0.0.0.0 // 设置监听IP http.port: 9200 //设置监听端口
注:elasticsearch不能使用root用户启动
启动elasticsearch //第一次启动有点慢:
[[email protected] root]$ cd /elk/elasticsearch-5.6.3/bin [[email protected] bin]$ ./elasticsearch 然后查看端口: [[email protected] ~]# ss -tnl | grep 9200 LISTEN 0 128 ::ffff:192.168.159.130:9200 :::* [[email protected] ~]#
2、安装kibana
[[email protected] elk]# tar -zxvf kibana-5.6.3-linux-x86_64.tar.gz
解压后编辑配置文件; [[email protected] bin]# vim ../config/kibana.yml //修改为 elasticsearch 的访问地址及端口如下 #server.host: "localhost" server.host: "192.168.159.130" #elasticsearch.url: "http://localhost:9200" elasticsearch.url: "
然后保存启动如下;
[[email protected] bin]# ./kibana log [15:45:26.952] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready log [15:45:27.067] [info][status][plugin:[email protected]] Status changed from uninitialized to yellow - Waiting for Elasticsearch log [15:45:27.118] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready log [15:45:27.136] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready log [15:45:27.566] [info][status][plugin:[email protected]] Status changed from uninitialized to green - Ready log [15:45:27.697] [info][listening] Server running at http://localhost:5601 log [15:45:27.699] [info][status][ui settings] Status changed from uninitialized to yellow - Elasticsearch plugin is yellow
3、安装 logstash-5.6.3.tar.gz
[[email protected] elk]# tar -zxvf logstash-5.6.3.tar.gz 解压后编辑配置文件,然后就可以使用了
报错:
1、
[[email protected] elk]# ./elasticsearch-5.6.3/bin/elasticsearch [2017-10-25T06:29:04,996][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
解决方案:使用elk用户启动
问题二、
ERROR: [4] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max number of threads [1024] for user [elk] is too low, increase to at least [2048] [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters k 参考上面系统修改
本文出自 “无常” 博客,请务必保留此出处http://1inux.blog.51cto.com/10037358/1976229
以上是关于ELK日志分析平台搭建全程的主要内容,如果未能解决你的问题,请参考以下文章
搭建ELK日志分析平台(下)—— 搭建kibana和logstash服务器
Elasticsearch + Logstash + Filebeat + Kibana搭建ELK日志分析平台(官方推荐的BEATS架构)