Centos7.2搭建ELK日志分析系统
一、环境
系统:Centos 7.2
java版本:java version "1.8.0_201"
安装包:logstash-7.0.0.tar.gz
kibana-7.0.0-linux-x86_64.tar.gz
elasticsearch-7.0.0-linux-x86_64.tar.gz
下载地址:https://www.elastic.co/downloads
二、搭建
1、配置java环境
# tar -zxvf jdk1.8.0_181.tar.gz
# mv jdk1.8.0_181 /usr/local/
# vi /etc/profile '''' 文件后添加如下内容,配置环境变量 '''
export JAVA_HOME=/usr/local/jdk1.8.0_181 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib/dt.JAVA_HOME/lib/tools.jar:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:${PATH}
# source /etc/profile
2、安装Elasticsearch
# tar zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz
# mv elasticsearch-7.0.0 /usr/local/elasticsearch
''''备份配置文件'''
# cd /usr/local/elasticsearch/config
# cp elasticsearch.yml elasticsearch.yml.bak
''' 修改配置文件,根据自己的实际情况填写'''
‘’‘添加elasticsearch用户,不能使用root启动’‘’
# groupadd -g 1008 elasticsearch
# useradd -g 1008 -u 1008 elasticsearch
# chown -R elasticsearch:elasticsearch /usr/local/elasticsearch/
'''修改sysctl.conf文件'''
# vi /etc/sysctl.conf
vm.max_map_count = 262144
'''启动'''
# su -s elasticsearch
# cd /usr/local/elasticsearch/bin
'''后台启动'''
# ./elasticsearch &
3 安装Logstash和filebeat
# tar -zxvf logstash-7.0.0.tar.gz
# mv logstash-7.0.0 /usr/local/logstash
4 安装filebeat
# tar zxvf filebeat-6.2.4-linux-x86_64.tar.gz
# mv filebeat-6.2.4-linux-x86_64 /usr/local/filebeat
'''备份配置文件'''
# cd /usr/local/filebeat
# cp filebeat.yml filebeat.yml.bak
'''修改配置文件,千万注意yml的语法'''
filebeat.prospectors:
- input_type: log
paths:
- /var/log/message-log # 测试一个log文件
output.logstash:
hosts: ["192.168.23.134:5044"]
'''启动服务’‘’
# cd /usr/local/filebeat
# ./filebeat &
5 启动logstash
# cd /usr/local/logstash/config
‘’‘修改配置文件’‘’
# cp logstash-sample.conf logstash.conf
# vi logstash.conf
'''启动服务'''
# cd /usr/local/logstash/bin
# nohup ./logstash -f ../config/logstash.conf &
6 安装kibana
# tar zxvf kibana-7.0.0-linux-x86_64.tar.gz
# mv kibana-7.0.0-linux-x86_64 /usr/local/kibana
'''修改配置文件''''
# cd /usr/local/kibana/config
# cp kibana.yml kibana.yml.bak
# vi kibana.yml
server.port: 5601
server.host: "192.168.23.134"
elasticsearch.hosts: "http://192.168.23.134:9200"
‘’‘启动服务'''
#cd ../bin/
#./kibana
启动成功后:
恭喜你,安装成功
本文主要参考此篇博客:
CentOS 7单机部署ELK_服务器应用_Linux公社-Linux系统门户网站相关文章