Elasticsearch 集群日志收集搭建

这篇具有很好参考价值的文章主要介绍了Elasticsearch 集群日志收集搭建。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Elasticsearch-7.2.0+Logstash-7.2.0+Kibana-7.2.0+-Filebeat-7.6.0

es集群日志,ES搜索,elasticsearch,运维,supervisor,logstash,filebeat

第一台集群内网ip:10.0.0.223

ES配置文件:/es_data/es/elasticsearch-7.2.0/config/elasticsearch.yml

ES启动命令:/es_data/es/elasticsearch-7.2.0/bin/elasticsearch

cluster.name: es-search
node.name: node-machine-name

node.master: true
node.data: true

path.data: /es_data/data/es
path.logs: /es_data/log/es

transport.tcp.port: 9300
transport.tcp.compress: true
http.port: 9200
network.host: 10.0.0.223

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

cluster.initial_master_nodes: ["10.0.0.223","10.0.1.9","10.0.1.10"]
discovery.seed_hosts: ["10.0.0.223", "10.0.1.10", "10.0.1.9"]

gateway.recover_after_nodes: 2
gateway.expected_nodes: 2
gateway.recover_after_time: 5m

action.destructive_requires_name: false
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 20gb
cluster.routing.allocation.disk.watermark.high: 10gb
cluster.routing.allocation.disk.watermark.flood_stage: 5gb

# 需求锁住物理内存,是:true、否:false
bootstrap.memory_lock: false
# SecComp检测,是:true、否:false
bootstrap.system_call_filter: false

Kibana配置文件:/es_data/es/kibana-7.2.0/config/kibana.yml

启动命令:/es_data/es/kibana-7.2.0/bin/kibana

server.port: 5601

server.host: "localhost"

server.basePath: ""

server.rewriteBasePath: false

elasticsearch.hosts:["http://10.0.0.223:9200","http://10.0.1.9:9200","http://10.0.1.10:9200"]

kibana.index: ".kibana"

i18n.locale: "zh-CN"

Kibana nginx   代理配置文件

server {
      listen       80;
      server_name www.elasticsearch.com;
      client_max_body_size 1000m;

      location / {
              proxy_read_timeout 300;
              proxy_connect_timeout 300;
              proxy_redirect off;
              proxy_http_version 1.1;
              proxy_set_header Host $http_host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto http;

              proxy_pass http://10.0.0.223:9200;
      }
}

第二台ES集群内网ip:10.0.1.10

ES配置文件:/es_data/es/elasticsearch-7.2.0/config/elasticsearch.yml

cluster.name: es-search
node.name: node-machine-name

node.master: true
node.data: true
path.data: /es_data/data/es
path.logs: /es_data/log/es

transport.tcp.port: 9300
transport.tcp.compress: true

http.port: 9200
network.host: 10.0.1.10

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

cluster.initial_master_nodes: ["10.0.0.223","10.0.1.9","10.0.1.10"]
discovery.seed_hosts: ["10.0.0.223", "10.0.1.10", "10.0.1.9"]

gateway.recover_after_nodes: 2
gateway.expected_nodes: 2
gateway.recover_after_time: 5m

action.destructive_requires_name: false
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 20gb
cluster.routing.allocation.disk.watermark.high: 10gb
cluster.routing.allocation.disk.watermark.flood_stage: 5gb

# 需求锁住物理内存,是:true、否:false
bootstrap.memory_lock: false
# SecComp检测,是:true、否:false
bootstrap.system_call_filter: false


Logstatsh 接收器配置

启动命令:/es_data/es/logstash-7.2.0/bin/logstash -f /es_data/es/logstash-7.2.0/conf.d/es_log.conf --path.data=/es_data/data/logstash/es_log/

配置文件:/es_data/es/logstash-7.2.0/conf.d/es_log.conf

input {
        beats {
                port => 5044
        }
}

filter {
        mutate {
                split => ["message", "|"]
        }

        if [message][3] =~ '[0-9a-z]{40}' {
                mutate {
                        add_field => { "log_time" => "%{[message][0]}"}
                        add_field => { "log_level" => "%{[message][1]}"}
                        add_field => { "log_process_id" => "%{[message][2]}"}
                        add_field => { "log_session" => "%{[message][3]}"}
                        add_field => { "log_file_name" => "%{[message][6]}"}
                        add_field => { "log_func_name" => "%{[message][7]}"}
                        add_field => { "log_line" => "%{[message][8]}"}
                }
                mutate {
                        update => { "message" => "%{[message][9]}" }
                }

        }
        else if [message][2] =~ '[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]' {
                mutate {
                        add_field => { "log_time" => "%{[message][0]}"}
                        add_field => { "log_level" => "%{[message][1]}"}
                        add_field => { "log_process_id" => "%{[message][3]}"}
                        add_field => { "log_session" => "%{[message][2]}"}
                        add_field => { "log_thread_id" => "%{[message][4]}"}
                        add_field => { "log_file_name" => "%{[message][5]}"}
                        add_field => { "log_func_name" => "%{[message][6]}"}
                        add_field => { "log_line" => "%{[message][7]}"}
                }
                mutate {
                        update => { "message" => "%{[message][8]}" }
                }

        }
        else
        {
                mutate {
                        split => ["message", ","]
                }
                mutate {
                        add_field => { "log_time" => "%{[message][0]}"}
                        add_field => { "log_level" => "%{[message][1]}"}
                        add_field => { "log_process_id" => "%{[message][2]}"}
                }
                mutate {
                        update => { "message" => "%{[message][3]}" }
                }
        }

        mutate {
                strip => ["log_time"]
        }
}

output {
        elasticsearch {
                hosts => ["10.0.0.223:9200","10.0.1.10:9200","10.0.1.9:9200"]
                index => "supervisor-log-%{[@metadata][version]}-%{+YYYY.MM.dd}"
        }
}

第三台ES集群内网ip:10.0.1.9

ES配置文件:/es_data/elasticsearch-7.2.0/config/elasticsearch.yml

cluster.name: es-search
node.name: node-machine-name

node.master: true
node.data: true
path.data: /es_data/data/es
path.logs: /es_data/log/es

transport.tcp.port: 9300
transport.tcp.compress: true
http.port: 9200
network.host: 10.0.1.9

# 增加新的参数,这样head插件可以访问es (5.x版本,如果没有可以自己手动加)
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

cluster.initial_master_nodes: ["10.0.0.223","10.0.1.9","10.0.1.10"]
discovery.seed_hosts: ["10.0.0.223", "10.0.1.10", "10.0.1.9"]

gateway.recover_after_nodes: 2
gateway.expected_nodes: 2
gateway.recover_after_time: 5m

action.destructive_requires_name: false
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 20gb
cluster.routing.allocation.disk.watermark.high: 10gb
cluster.routing.allocation.disk.watermark.flood_stage: 5gb

# 需求锁住物理内存,是:true、否:false
bootstrap.memory_lock: false
# SecComp检测,是:true、否:false
bootstrap.system_call_filter: false

第四台具体生产日志的地方

Filebeat配置:/www/filebeat/filebeat.yml

启动命令:/www/filebeat/filebeat -e -c /www/filebeat/filebeat.yml

- type: log
  enabled: true
  document_type: "supervisor"
  exclude_files: ["filebeat-out.log$"]
  paths:
   - /var/log/supervisor/*.log
  fields:
    type: supervisor
  encoding: plain
  input_type: log
  multiline.pattern: '^\s\d{4}\-\d{2}\-\d{2}\s\d{2}:\d{2}:\d{2}'
  multiline.negate: true
  multiline.match: after

# Filebeat modules
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false

# Elasticsearch template setting
setup.template.settings:
  index.number_of_shards: 1
  index.number_of_replicas: 0

setup.template.overwrite: true
setup.template.name: "machine-name"
setup.template.pattern: "machine-name*"

# 生命周期管理
setup.ilm.enabled: true
setup.ilm.rollover_alias: "machine-name"
setup.ilm.pattern: "{now/d}-000001"
setup.ilm.policy_name: "machine-name-policy"

# Logstash output
output.logstash:
    enabled: true
    hosts: ["10.0.1.10:5044"]
    worker: 1
    compression_level: 3
    loadbalance: true
    pipelining: 0
    index: 'log_index'

# Processors
processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

Kibana 配置:

设置-索引模式:创建索引模式 supervisor-log-*

上面的索引管理里面就可以看到已经匹配的索引了

创建生命周期策略-操作匹配索引模版,自动移除周期外的日志,保证集群健康运行文章来源地址https://www.toymoban.com/news/detail-636857.html

到了这里,关于Elasticsearch 集群日志收集搭建的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ES(ElasticSearch)快速入门和集群搭建

    ​ ES作为一个索引及搜索服务,对外提供丰富的REST接口,快速入门部分的实例使用kibana来测试,目的是对ES的使用方法及流程有个初步的认识。 创建index 索引库。包含若干相似结构的 Document 数据,相当于数据库的database。 语法: PUT /index_name 如: number_of_shards - 表示一个索引

    2024年02月07日
    浏览(37)
  • 搜索引擎elasticsearch :安装elasticsearch (包含安装组件kibana、IK分词器、部署es集群)

    kibana可以帮助我们方便地编写DSL语句,所以还要装kibana 因为我们还需要部署kibana容器,因此需要让es和kibana容器互联。这里先创建一个网络: 这里我们采用elasticsearch的7.12.1版本的镜像,这个镜像体积非常大,接近1G。不建议大家自己pull。 课前资料提供了镜像的tar包: 大家将

    2024年02月16日
    浏览(45)
  • 袁庭新ES系列14节 | 搭建Elasticsearch集群

    单节点的Elasticsearch需要在处理大量数据的时候需要消耗大量内存和CPU资源,数据量大到一定程度就会产生处理瓶颈,甚至会出现宕机。 为了解决单节点ES的处理能力的瓶颈及单节点故障问题,我们考虑使用Elasticsearch集群。接下来袁老师带领大家学习如何搭建Elasticsearch的集群

    2024年04月17日
    浏览(104)
  • Elasticsearch--01.ES8.1.0集群搭建

    一、搭建ES集群 1.集群环境安装 本集群使用Centos7.5操作系统,2G 2C 60G(如果主机好点的节点配置可以搞高点) 分别修改三台集群服务器配置:  1.1.修改系统配置文件/etc/security/limits.conf 1.2.修改/etc/sysctl.conf 1.3.# sysctl -p  重新加载 集群服务器如下: 机器地址 节点名称 节点角

    2024年02月12日
    浏览(30)
  • 【ElasticSearch系列-06】Es集群架构的搭建以及集群的核心概念

    ElasticSearch系列整体栏目 内容 链接地址 【一】ElasticSearch下载和安装 https://zhenghuisheng.blog.csdn.net/article/details/129260827 【二】ElasticSearch概念和基本操作 https://blog.csdn.net/zhenghuishengq/article/details/134121631 【三】ElasticSearch的高级查询Query DSL https://blog.csdn.net/zhenghuishengq/article/details/1

    2024年02月04日
    浏览(50)
  • 磐基2.0搭建es集群 k8s安装elasticsearch集群

    参考: k8s安装elasticsearch集群_k8s部署elasticsearch集群_MasonYyp的博客-CSDN博客 1 环境简述搭建es集群需要使用的技术如下:k8s集群、StatefulSet控制器、Service(NodePort)服务、PV、PVC、volumeClaimTemplates(存储卷申请模板)。StatefulSet控制器创建的Pod适合用于分布式存储系统,它最大的特

    2024年02月09日
    浏览(32)
  • 访问elasticsearch集群提示ERROR 新增es数据失败,后台日志返回413 Request Entity Too Larg

    在运维paas云平台时有研发反馈客户端访问elasticsearch服务偶发性的出现报错,提示报错如下: 报错日志内容核心点如下: 根据日志报错内容及研发反馈的信息得到如下有用信息: 1、连接elasticsearch服务并请求处理业务是偶发性的提示报错,也就是说明elasticsearch服务是正常的

    2024年04月17日
    浏览(38)
  • 【Elasticsearch】从零开始搭建ES8集群并且集成到Springboot,更好的服务电商类等需要全文索引的项目(一)

    最近公司的电商项目越来越庞大,功能需求点也越来越多,各种C端对查询和检索的要求也越来越高,是时候在项目中引入全文检索了。 ElasticSearch 是一个基于 Lucene 的搜索服务器,它提供了一个分布式多用户能力的全文搜索引擎,并且是基于Java 开发的,我记得很久之前ES还不

    2024年02月15日
    浏览(39)
  • 【ES专题】ElasticSearch搜索进阶

    丑话说在前头 ,说实在这篇笔记写的不是很好,确实很多没有实操。 系列上一篇文章:《【ES专题】ElasticSearch 高级查询语法Query DSL实战》 系列下一篇文章:《【ES专题】ElasticSearch集群架构剖析》 理解ES的核心概念,最最重要的是【索引】和【文档】 理解基本的Query DSL语法

    2024年01月16日
    浏览(50)
  • ElasticSearch(ES) 搜索入门笔记

    ElasticSearch简称ES,经过多年的发展,已是很流行的搜索工具了,无需多介绍,下面就粘一点官方介绍 You know, for search (and analysis) Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it i

    2024年01月22日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包