首页 > 其他分享 >日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)

时间:2022-10-30 10:36:54浏览次数:83  
标签:node ELK filebeat ## kibana elasticsearch 192.168 logstash


目录

​​ 一、安装es​​

​​ 二、安装Logstash​​

​​三、安装Kibana​​

​​四、安装Filebeat​​

​​五、集群模式​​


搭建日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)

这里先介绍ELK的安装

 

首先下载ELK 在官网下载:​​https://www.elastic.co/cn/downloads/​

如果下载比较慢的同学可以加我Q.我这有下载好的文件。能够分享给你。

这里咱们的环境使用ubuntu 16.04。我这是在虚拟加搭建的。

es日志存储

logstash 采集转换输入 输出

filebeat 日志实时洞察  相关具体介绍可以观看 :  ​​https://www.elastic.co/cn/beats/filebeat​​   

kibana 展示控制面板 让你的使用更加方便

 

软件版本:

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ELK安装

 一、安装es

解压 ES

tar -zxvf elasticsearch-7.7.1.tar.gz

进入文件夹config 修改 /elk/elasticsearch-7.7.1/config$ vim elasticsearch.yml

修改如下:

配置data目录时别忘了建文件夹data

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: elk-test
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/hcy/elk/elasticsearch-7.7.1/data
#
# Path to log files:
#
path.logs: /home/hcy/elk/elasticsearch-7.7.1/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.129
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]

cluster.initial_master_nodes: ["node-1"]

# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

启动bin 文件下的

hcy@ubuntu:~/elk/elasticsearch-7.7.1/bin$ ./elasticsearch &

页面访问 http://192.168.1.129:9200

看看能不能访问到就行了。

至此安装es完成

 

常见问题解决:

1.    报错:

ERROR: bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

首先切换到root 下

root@ubuntu:/home/hcy# vim /etc/sysctl.conf 

添加这一句:

m.max_map_count=655360

 

root@ubuntu:/home/hcy# sysctl -p
vm.max_map_count = 655360

 

切换回去用户。。。。。

 2.    报错:

ERROR: [1] bootstrap checks failed [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

解决办法:配置文件这句放开,改成如下:

cluster.initial_master_nodes: ["node-1"]

 

 二、 安装Logstash

1.解压logstash tar包

tar -zxvf logstash-7.7.1.tar.gz

2.运行logstash最基础的pipeline

bin/logstash -e 'input { stdin { } } output { stdout {} }'

-e:可以直接用命令行配置,无需使用文件配置。当前pipeline从标准输入获取数据stdin,并把结构化数据输出到标准输出stdout。

Pipeline启动之后,控制台输入hello world,可看到对应输出。

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ubuntu_02

3. 安装logstash-input-beats插件

hcy@ubuntu:~/elk/logstash-7.7.1$ ./bin/logstash-plugin install logstash-input-beats


Validating logstash-input-beats
Installing logstash-input-beats
Installation successful

 4.创建pipeline配置文件logstash.conf,配置端口5044监听beats的连接,并创建elasticsearch索引。

如图:下面代码

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ES安装_03

input {
beats {
port => 5044
}
}

output {
elasticsearch {
hosts => "192.168.1.129:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}

 

5.启动logstash服务

./bin/logstash -f config/logstash.conf &

输出:

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ubuntu_04

 

三、安装Kibana

3.1解压kibana tar包

tar -zxvf kibana-7.7.1-linux-x86_64.tar.gz



 3.2. 修改kibana配置

进入config文件夹 修改

hcy@ubuntu:~/elk/kibana-7.7.1-linux-x86_64/config$ vim kibana.yml 

# kibana地址
server.host: "192.168.1.129"
# elasticsearch地址
# elasticsearch.url: "http://192.168.1.129:9200"
elasticsearch.hosts: ["http://192.168.1.129:9200"]

3.3.启动kibana服务

./bin/kibana &

 输出

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_elasticsearch_05

访问 192.168.1.129:5601 

能看到界面

 

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ELK安装_06

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ubuntu_07

 你也可以使用一下 example 数据看一眼

很多的哦

 

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ELK安装_08

 

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ES安装_09

四、 安装Filebeat

 

1.解压filebeat tar包

tar -zxvf filebeat-7.7.1-linux-x86_64.tar.gz

2.配置filebeat

我们这里输出到logstash,需要添加logstash信息,注释elasticsearch信息

hcy@ubuntu:~/elk/filebeat-7.7.1-linux-x86_64$ vim filebeat.yml

filebeat.prospectors:
- type: log
enabled: true
paths:
- /opt/apps/elk/*.log



#output.elasticsearch:
#hosts: ["localhost:9200"]
output.logstash:
hosts: ["192.168.1.129:5044"]

3.启动filebeat

./filebeat -e -c filebeat.yml -d "publish" &
 

输出:跑起来就可以。

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ES安装_10

 至此咱们这套ELK系统搭建完毕!!

 

五、集群模式

如果是安装logstash集群的话。在node filebeat中.  这里要用node的IP

我这里是配置了多个logstash集群这里。使用了两个节点

其中我的192.168.1.129  作为我的一个展示机

192.168.1.131做一个node节点

output.logstash:
  hosts: ["192.168.1.131:5044"]

 看下效果:

日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)_ubuntu_11

 六、ELK常见问题解决办法

1.   Logstash A plugin had an unrecoverable error. Will restart this plugin.

 使用命令查找  ps aux | grep logstash

kill  -9  掉对应的PID 

标签:node,ELK,filebeat,##,kibana,elasticsearch,192.168,logstash
From: https://blog.51cto.com/51souta/5807334

相关文章

  • ELK部署-实现Nginx日志收集
    一、部署ES1、创建网络下载镜像dockernetworkcreateelasticdockerpullelasticsearch:7.17.62、目录准备mkdir/opt/ELK/elastic/{data,config}-pchmod777/o......
  • Docker 安装elasticsearch、kibana
    Docker安装elasticsearch7.101.拉取镜像dockerpulldocker.elastic.co/elasticsearch/elasticsearch:7.102.运行dockerrun--nameelasticsearch7.10.0-p92......
  • 【图文安装教程】在docker中安装kibana
    在上一篇中,我们已经在docker里面安装了ES。kibana可以给我们提供一个elasticsearch的可视化界面,便于我们学习。所以,本篇咱们就在docker里面安装kibana图文教程:我们使用r......
  • kibana 配置修改,解决经常掉线的问题
    kibana.yaml将以下默认值进行修改.kibana官方配置说明1.增加日志#EnablesyouspecifyafilewhereKibanastoreslogoutput.#logging.dest:stdoutlogging.dest:/......
  • ELK 不香了?试试接入这款更轻量的日志框架,真的很省心!
    当我们公司内部部署很多服务以及测试、正式环境的时候,查看日志就变成了一个非常刚需的需求了。是多个环境的日志统一收集,然后使用Nginx对外提供服务,还是使用专用的日志收......
  • 18.Linux下安装Kibana
    1.解压解压安装包并将解压后的目录移动到/usr/local/kibana目录下。tar-zxvfelasticsearch-7.5.1.tgzmvelasticsearch-7.5.1/usr/local/kibanacd2.配置cd/usr/local/k......
  • ansible应用之安装elk框架
    最近在学习ansible,先大致看了下视频,现在需要练习使用了。对照视频中的练习方式,我觉得用处也不是太大,正好现在还要学习elk,以集群方式部署es,需要执行一些批量命令,而且还......
  • Linux /centos- ES(Elasticsearch)-kibana-head安装
    CentOS7.31.在线安装es1、wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip2、解压es.zipunzipelasticsearch-5.5.1.zip目......
  • elasticsearch部署ELKat least one of [discovery.seed_hosts, discovery.seed_provid
    1、ES启动报错1、ERROR:[1]bootstrapchecksfailed.Youmustaddressthepointsdescribedinthefollowing[1]linesbeforestartingElasticsearch.bootstrap......
  • SpringBoot整合ES+Kibana
    前言:最近在写一个HTTP代理服务器,记录日志使用的是ES,所以涉及到SpringBoot和ES的整合,整合完毕后又涉及到数据可视化分析,所以使用了Kibana进行管理,有些坑,需要记录一下Spri......