ELK日志系统:Elasticsearch+Logstash+Kibana+Filebeat搭建教程
ELK日志系统:Elasticsearch + Logstash + Kibana 搭建教程
系统架构
安装配置JDK环境
JDK安装(不能安装JRE)
JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载包:jdk-8u131-linux-x64.rpm
yum localinstall jdk-8u131-linux-x64.rpm
mvn 安装
cd /usr/local
wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar xzf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 maven
vi /etc/profile.d/maven.sh
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
source /etc/profile.d/maven.sh
mvn -version
安装ElasticSearch
yum install epel-release
yum install npm nodejs
# centos7 若安装nodejs失败,请执行如下命令再重试
rpm -ivh https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.rpm
yum localinstall elasticsearch-6.2.3.rpm
# 修改network.host: 0.0.0.0
vim /etc/elasticsearch/elasticsearch.yml
systemctl start elasticsearch
systemctl enable elasticsearch
systemctl status elasticsearch
# elasticsearch工具目录
/usr/share/elasticsearch/bin/
# 系统要求
vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
vim /etc/sysctl.conf
vm.max_map_count=262144
# 临时生效命令
sysctl -w vm.max_map_count=262144
安装elasticsearch-head
# 增加新的参数,这样head插件可以访问es
vim /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
cd /usr/share/elasticsearch
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
# elasticsearch-head访问地址
http://localhost:9100/
# 若head插件无法连接到es,编辑app.js查找9200修改参数localhost为本机ip
vim _site/app.js
安装filebeat
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.3-x86_64.rpm
yum localinstall filebeat-6.2.3-x86_64.rpm
vim /etc/filebeat/filebeat.yml
# 修改paths配置路径
# 将enabled设置为true!!
# 将Filebeat和Logstash连接起来
# 将output.elasticsearch注释掉#
# 打开Logstash的注释
# 修改完成后的配置如下:
grep -vE "^$|#|;" /etc/filebeat/filebeat.yml
filebeat.prospectors:
- type: log
enabled: true
paths:
- /var/log/*.log
exclude_lines: ['^DBG', '^OK','^$'] #排查DBG、OK和空行
include_lines: ['^ERR', '^WARN']
exclude_files: ['.gz$', '*error.log']
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.template.settings:
index.number_of_shards: 3
setup.kibana:
output.logstash:
hosts: ["localhost:5044"]
# 启动filebeat
systemctl start filebeat
systemctl enable filebeat
systemctl status filebeat
安装logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.2.3.rpm
yum localinstall logstash-6.2.3.rpm
vim /etc/logstash/logstash.yml
# 修改path.config配置
path.config: /etc/logstash/conf.d
vim /etc/logstash/conf.d/logstash.conf
input {
beats {
port => 5044
}
}
filter {
grok {
match => {
"request" => "\s+(?<api_path>.+?)(\?.*)?\s+"
}
}
grok {
match => {
"agent" => "(?<browser>Maxthon|QQBrowser|Chrome|Safari|Firefox|Opera|MSIE?)(/[0-9.]+)?"
}
}
grok {
match => {
"agent" => "(?<os>Android|SymbianOS|Macintosh|iPad|iPhone|iPod|Linux|Windows?)"
}
}
mutate {
split => [ "upstreamtime", "," ]
}
}
output {
elasticsearch {
hosts => ["192.168.1.216:9200"]
index => "logstash-%{+YYYY.MM.dd}_log"
}
stdout { codec => rubydebug }
}
# 给logstash做软连接
ln -s /usr/share/logstash/bin/logstash /usr/bin/logstash
systemctl start logstash
systemctl enable logstash
systemctl status logstash
cd /usr/share/logstash/bin
# 解析配置文件并报告任何出现错误的错误
logstash -f logstash.conf --config.test_and_exit
# 窗口启动 (以下启动方式不推荐,服务启动即可)
logstash -f /etc/logstash/conf.d/logstash.conf
# 后台运行
nohup logstash -f /etc/logstash/conf.d &
nohup logstash -f /etc/logstash/conf.d > logstash.log 2>&1 &
安装kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.3-x86_64.rpm
yum localinstall kibana-6.2.3-x86_64.rpm
vim /etc/kibana/kibana.yml
# 修改elasticsearch.url参数
server.host: "0.0.0.0"
elasticsearch.url: "http://localhost:9200"
systemctl start kibana
systemctl enable kibana
systemctl status kibana
安装nginx
yum install nginx httpd-tools
htpasswd -c /etc/nginx/htpasswd.users XXX
vi /etc/nginx/conf.d/kibana.conf
server {
listen 80;
server_name 192.168.1.216;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
systemctl enable nginx
systemctl start nginx
验证
echo "hello world" >/var/opt/log/a.log
curl http://localhost:9200/_search?pretty 查看输出
删除索引
curl -XDELETE http://localhost:9200/twitter
curl -XDELETE http://localhost:9200/_all
列出所有索引
curl -u elastic:changeme 'http://localhost:9200/_cat/indices?v'
查看节点个数
curl http://localhost:9200/_cluster/health?pretty
已知bug
Chrome浏览器插件可能导致kibana显示存在bug,可通过禁用浏览器插件浏览
ELK日志系统:Elasticsearch+Logstash+Kibana+Filebeat搭建教程的更多相关文章
- 【linux】【ELK】搭建Elasticsearch+Logstash+Kibana+Filebeat日志收集系统
前言 ELK是Elasticsearch.Logstash.Kibana的简称,这三者是核心套件,但并非全部. Elasticsearch是实时全文搜索和分析引擎,提供搜集.分析.存储数据三大功能:是 ...
- ELK (Elasticsearch , Logstash, Kibana [+FileBeat])
ELK 简述: ELK 是: Elasticsearch , Logstash, Kibana 简称, 它们都是开源软件. Elasticsearch[搜索]是个开源分布式基于Lucene的搜索引擎, ...
- ELK系列(1) - Elasticsearch + Logstash + Kibana + Log4j2快速入门与搭建用例
前言 最近公司分了个ELK相关的任务给我,在一边学习一边工作之余,总结下这些天来的学习历程和踩坑记录. 首先介绍下使用ELK的项目背景:在项目的数据库里有个表用来存储消息队列的消费日志,这些日志用于开 ...
- Centos7下使用ELK(Elasticsearch + Logstash + Kibana)搭建日志集中分析平台
日志监控和分析在保障业务稳定运行时,起到了很重要的作用,不过一般情况下日志都分散在各个生产服务器,且开发人员无法登陆生产服务器,这时候就需要一个集中式的日志收集装置,对日志中的关键字进行监控,触发异常 ...
- ELK(elasticsearch+logstash+kibana)入门到熟练-从0开始搭建日志分析系统教程
#此文篇幅较长,涵盖了elk从搭建到运行的知识,看此文档,你需要会点linux,还要看得懂点正则表达式,还有一个聪明的大脑,如果你没有漏掉步骤的话,还搭建不起来elk,你来打我. ELK使用elast ...
- 【转】ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
[转自]https://my.oschina.net/itblog/blog/547250 摘要: 前段时间研究的Log4j+Kafka中,有人建议把Kafka收集到的日志存放于ES(ElasticS ...
- 【Big Data - ELK】ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
摘要: 前段时间研究的Log4j+Kafka中,有人建议把Kafka收集到的日志存放于ES(ElasticSearch,一款基于Apache Lucene的开源分布式搜索引擎)中便于查找和分析,在研究 ...
- 02篇ELK日志系统——升级版集群之kibana和logstash的搭建整合
[ 前言:01篇LK日志系统已经把es集群搭建好了,接下来02篇搭建kibana和logstash,并整合完成整个ELK日志系统的初步搭建. ] 1.安装kibana 3台服务器: 192.168.2 ...
- 搭建Elasticsearch Logstash Kibana 日志系统
分布式系统下由于日志文件分布在不同的系统上,分析比较麻烦,通过搭建elk日志系统,可快速排查日志信息. Elasticsearch是大数据处理框架,使用的分布式存储,可存储海量数据:基于Lucense ...
随机推荐
- C#工具:加密解密帮助类
using System; using System.IO; using System.Security.Cryptography; using System.Text; //加密字符串,注意strE ...
- PostgreSQL相关整理
PostgreSQL权限管理之创建可更新表的普通用户 https://my.oschina.net/aven92/blog/528943 PostgreSQL学习手册(角色和权限) http://ww ...
- Java虚拟机垃圾收集算法
1.标记-清除算法 标记-清除算法分为 "标记" 和 "清除" 两个步骤:首先标记出所有需要回收的对象,然后在标记完成后统一回收所有被标记的对象,是垃圾收集算法 ...
- spring2.0 mybatis JDBC配置
mybatis 搭建 <!--连接池--> <dependency> <groupId>org.springframework.boot</groupId&g ...
- html 微信video放大后无法返回问题
android video播放视频放大后无法返回,先debug下debugx5.qq.com 发现用的不是X5内核 直接激活 debugmm.qq.com/?forcex5=true 问题解决 ...
- 《JavaScript高级程序设计》笔记:事件(十三)
事件流 事件冒泡 IE的事件流叫做事件冒泡,即事件开始时由最具体的元素接收,然后逐级向上传播到较为不具体的节点(文档).如下代码: <body> <div id="myDi ...
- Dynamics CRM项目实例之七:站点地图修改,联系人-订单-积分管理
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复138或者20141229可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 前面文章发表后,不 ...
- SAP MM 采购ERP顾问咨询费限制总金额的框架协议实现方案
SAP MM 采购ERP顾问咨询费限制总金额的框架协议实现方案 [业务场景] 采购部门与ERP咨询公司签订了一个框架协议,只规定不同级别顾问的人天费用,不限定这些不同级别咨询顾问的具体采购的人天数,但 ...
- Android Material Design控件使用(一)——ConstraintLayout 约束布局
参考文章: 约束布局ConstraintLayout看这一篇就够了 ConstraintLayout - 属性篇 介绍 Android ConstraintLayout是谷歌推出替代PrecentLa ...
- swing Jframe 界面风格
用法:在jframe里面 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel" ...