亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

window環(huán)境下搭建簡單ELK日志收集

Baaaan / 2300人閱讀

摘要:部署環(huán)境依賴第三方組件下載地址官網(wǎng)簡單的流程示意圖跟都支持集群部署,本文只簡單描述如何多帶帶部署部署步驟三件套版本最好一致,小版本可以高,但是不可以低。

window環(huán)境下搭建簡單ELK日志收集

前言
本文主要介紹如何在window環(huán)境下部署elk日志收集,網(wǎng)絡(luò)上大部分是linux的,剛好這邊服務(wù)需要用到window 環(huán)境,配置方式有點不同,大體是一樣的。

部署環(huán)境
window server 2008 R2
依賴第三方組件
JDK8+
elasticsearch-5.6.14
logstash-5.6.14
kibana-5.6.14-windows-x86
redis-3.2

下載地址官網(wǎng): https://www.elastic.co/

簡單的流程示意圖
redis跟elasticsearch 都支持集群部署,本文只簡單描述如何多帶帶部署

部署步驟

elk三件套版本最好一致,elasticsearch小版本可以高,但是不可以低。
關(guān)于elasticsearch 的搭建和配置可以參考之前的一篇文章
DUBBO監(jiān)控環(huán)境搭建

啟動redis

redis默認只允許本地訪問,如果要redis可以遠程需要修改redis.windows.conf
bind 127.0.0.1 注釋掉,在redis3.2版本以上增加了一個保護模式,所以還需要修改protected-mode no

#bind 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode no

配置logstash

logstash的作用是將redis中的日志信息收集并保存到elasticsearch中,redis只是作為緩存保存數(shù)據(jù),logstash取完之后會刪除redis中的數(shù)據(jù)信息。

1.指定啟動JDK

指定JDK信息,如果有多個JDK需要指定,如果系統(tǒng)默認1.8可以跳過
在 logstash-5.6.14bin的setup.bat 中加入這句
set JAVA_HOME=C:Program FilesJavajdk1.8.0_181

set JAVA_HOME=C:Program FilesJavajdk1.8.0_181
rem ### 1: determine logstash home

rem  to do this, we strip from the path until we
rem find bin, and then strip bin (there is an assumption here that there is no
rem nested directory under bin also named bin)

2.配置輸入輸出源

在 logstash-5.6.14bin中新建 logback.config(名字任意) 配置文件,定義輸入輸出
input接受數(shù)據(jù)的輸入,這邊指定到redis;
output輸出文件到指定的地方, elasticsearch;這邊的index索引會在kibana那邊配置用到
這個輸入和輸出的配置支持的類型比較多,有興趣專研的可以參考官網(wǎng)配置
logstash輸入配置
logstash輸出配置
另外logstash還支持filter過濾器設(shè)置

input {

    redis {
        data_type => "list"
        key => "logstash"
        host => "127.0.0.1"
        port => 6379
        threads => 5
        codec => "json"
    }
}
filter {

}
output {

    elasticsearch {
        hosts => ["127.0.0.1:9200"]
        index => "logstash-%{type}-%{+YYYY.MM.dd}"
        document_type => "%{type}"
        workers => 1
        flush_size => 20
        idle_flush_time => 1
        template_overwrite => true
    }
    stdout{}
}

啟動logstash命令 logstash.bat -f logback.config

配置kibana

找到kibana-5.6.14-windows-x86config 中kibana.yml,1.配置host 0.0.0.0,運行外網(wǎng)訪問,默認只能本地訪問 2.配置es的地址。

server.host: "0.0.0.0"

# Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects
# the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests
# to Kibana. This setting cannot end in a slash.
#server.basePath: ""

# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576

# The Kibana server"s name.  This is used for display purposes.
#server.name: "your-hostname"

# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://localhost:9200"

啟動Kibana.bat

跟logback的結(jié)合

添加maven支持,引入logback-redis-appender.jar包

        
            com.cwbase
            logback-redis-appender
            1.1.3
            
                
                    redis.clients
                    jedis
                
            
        

配置logback.xml,這里的key需要跟上面配置的logback.config配置文件中配置的key相匹配

    
        demo
        dubbo
        127.0.0.1
        logstash
        dev
        true
        true
        0
    
    
        
    
        
        
        
        
    

啟動服務(wù)工程,logback會將日志發(fā)送到redis,打開kibana的頁面,第一次打開會提示創(chuàng)建索引規(guī)則,就是logback.config中es配置的索引logstash-*,創(chuàng)建好之后就可以看到日志已經(jīng)被采集到elasticsearch中,我們在頁面就可以查看日志信息。
kibana默認端口http://127.0.0.1:5601

結(jié)尾

最后說明下關(guān)于清除日志,ElasticSearch 5.x版本中刪除過期ttl屬性,所以我們需要定時清理es的索引,在服務(wù)中建一個bat定時執(zhí)行,以下為刪除30天前的全部索引。
http://{Elasticsearch IP}:9200/_cat/indices?v 查看es的所有索引

set DATA=`date -d "-30 days" +%Y.%m.%d`
curl -XDELETE http://127.0.0.1:9200/*-${DATA}

以上

參考文檔
http://www.cnblogs.com/ASPNET...
https://blog.csdn.net/xuezhan...

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://www.ezyhdfw.cn/yun/73115.html

相關(guān)文章

  • ELK結(jié)合logback搭建日志中心

    摘要:日志監(jiān)控和分析在保障業(yè)務(wù)穩(wěn)定運行時,起到了很重要的作用。本文搭建的的是一個分布式的日志收集和分析系統(tǒng)。對于隊列上的這些未處理的日志,有不同的幾臺進行接收和分析。再由統(tǒng)一的進行日志界面的展示。如等配置文件可以配置,等日志報表可視化熟練 ELK簡介ELKStack即Elasticsearch + Logstash + Kibana。日志監(jiān)控和分析在保障業(yè)務(wù)穩(wěn)定運行時,起到了很重要的作用。比...

    tracy 評論0 收藏0
  • 利用ELK搭建Docker容器化應(yīng)用日志中心

    摘要:概述應(yīng)用一旦容器化以后,需要考慮的就是如何采集位于容器中的應(yīng)用程序的打印日志供運維分析。 showImg(https://segmentfault.com/img/remote/1460000014146680); 概述 應(yīng)用一旦容器化以后,需要考慮的就是如何采集位于Docker容器中的應(yīng)用程序的打印日志供運維分析。典型的比如 SpringBoot應(yīng)用的日志 收集。本文即將闡述如何利...

    周國輝 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<