<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          開(kāi)發(fā)必知必會(huì)的幾套方案

          共 5933字,需瀏覽 12分鐘

           ·

          2021-06-17 13:53


          1

          eflk

          elasticsearch+filebeatmetricbeat+logstash+kibana

          用于日志查詢(xún)


          • Elasticsearch是一個(gè)基于Lucene的搜索服務(wù)器。提供一個(gè)分布式多用戶(hù)能力的全文搜索引擎。

          • Kibana是開(kāi)源的分析與可視化平臺(tái),能夠讓您對(duì) Elasticsearch 數(shù)據(jù)進(jìn)行可視化。

          • Logstash是一個(gè)開(kāi)源數(shù)據(jù)收集引擎,具有實(shí)時(shí)管道功能。Logstash可以動(dòng)態(tài)地將來(lái)自不同數(shù)據(jù)源的數(shù)據(jù)統(tǒng)一起來(lái),并將數(shù)據(jù)標(biāo)準(zhǔn)化到你所選擇的目的地。(相當(dāng)于專(zhuān)一而不是通用化的ELT工具)


          • Beats在是一個(gè)輕量級(jí)日志采集器,相比Logstash,Beats所占系統(tǒng)的CPU和內(nèi)存幾乎可以忽略不計(jì)。目前Beats含六種工具:Packetbeat:網(wǎng)絡(luò)數(shù)據(jù)(收集網(wǎng)絡(luò)流量數(shù)據(jù))、Metricbeat:指標(biāo)(收集系統(tǒng)、進(jìn)程和文件系統(tǒng)級(jí)別的CPU和內(nèi)存使用情況等數(shù)據(jù))、Filebeat:日志文件(收集文件數(shù)據(jù))、Winlogbeat:windows事件日志(收集Windows事件日志數(shù)據(jù))、Auditbeat:審計(jì)數(shù)據(jù)(收集審計(jì)日志)、Heartbeat:運(yùn)行時(shí)間監(jiān)控(收集系統(tǒng)運(yùn)行時(shí)的數(shù)據(jù))。

            (Logstash是JVM語(yǔ)言,F(xiàn)ilebeat是Go語(yǔ)言寫(xiě)的,這也能說(shuō)明一點(diǎn)在語(yǔ)言層面的選擇性吧),這里用到Filebeat、Metricbeat。

          1. 程序日志

          2. mysql慢查詢(xún)?nèi)罩?/span>



          3. Nginx日志


          4. 系統(tǒng)指標(biāo)監(jiān)控



          安裝Elasticsearch+Kibana+密碼配置:

          鏡像docker pull docker.elastic.co/elasticsearch/elasticsearch:7.10.0啟動(dòng)docker run --name localEs -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.0
          配置docker exec -it localEs bashcd configvi elasticsearch.yml//配置http.cors.enabled: truehttp.cors.allow-origin: "*"http.cors.allow-headers: Authorizationxpack.security.enabled: truexpack.security.transport.ssl.enabled: true//配置密碼-重啟容器elasticsearch-setup-passwords interactive
          //安裝kibinadocker pull docker.elastic.co/kibana/kibana:7.10.0docker run --name kibana -d --link localEs:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.10.0//配置docker exec -it kibana bashcd configvi kibana.yml//配置server.name: kibanaserver.host: "0.0.0.0"elasticsearch.hosts: [ "http://{IpAddress}:9200" ]//docker inspect es查看es容器內(nèi)部的ip地址monitoring.ui.container.elasticsearch.enabled: trueelasticsearch.username: "elastic"elasticsearch.password: "zmx111222"i18n.locale: "zh-CN"
          重啟容器

          安裝Logstash

          1.下載 https://www.elastic.co/downloads/logstashhttps://artifacts.elastic.co/downloads/logstash/logstash-7.13.1-linux-x86_64.tar.gz
          2.配置編輯 /opt/logstash/logstash-7.13.1/config/logstash.yml配置文件修改如下內(nèi)容:node.name: aliyun2core #設(shè)置節(jié)點(diǎn)名稱(chēng),一般寫(xiě)主機(jī)名path.data: /opt/logstash/plugin-data #創(chuàng)建logstash 和插件使用的持久化目錄config.reload.automatic: true #開(kāi)啟配置文件自動(dòng)加載config.reload.interval: 10 #定義配置文件重載時(shí)間周期http.host: "47.96.74.110" #定義訪問(wèn)主機(jī)名,一般為域名或IP
          3.可以直接讀取日志、也可以從插件讀取-例如Filebeat、Jdbc(logstash 有非常多插件https://www.elastic.co/guide/en/logstash/current/index.html
          3.1安裝logstash-input-jdbc 和logstash-input-beats-master 插件(暫緩測(cè)試)./bin/logstash-plugin install logstash-input-jdbc./logstash-plugin install logstash-input-beats
          3.2 codec插件 codec解決日志換行的問(wèn)題在logstash讀入的時(shí)候,通過(guò)codec編碼解析日志為相應(yīng)格式,從logstash輸出的時(shí)候,通過(guò)codec解碼成相應(yīng)格式。
          3.3 grok插件 支持以正則表達(dá)式的方式提取日志信息用于將非結(jié)構(gòu)化數(shù)據(jù)解析為結(jié)構(gòu)化和可查詢(xún)的數(shù)據(jù)。https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html

          4.啟動(dòng)nohup ./logstash -f ../config/logstash.conf &

          安裝filebeat

          1.下載https://www.elastic.co/cn/downloads/beats/filebeatcurl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.13.1-linux-x86_64.tar.gztar xzvf filebeat-7.13.1-linux-x86_64.tar.gzcd filebeat-7.13.1-linux-x86_64
          2.編輯配置修改 filebeat.yml 以設(shè)置連接信息:output.elasticsearch: hosts: ["<es_url>"] username: "elastic" password: "<password>"setup.kibana: host: "<kibana_url>" monitoring.enabled: true #開(kāi)啟服務(wù)監(jiān)控-需要 Elasticsearch 配合開(kāi)啟xpack monitoring =》編輯輸入log日志路徑:/opt/nifi/nifi-1.13.2/logs/nifi-app.log3.啟用和配置 apache 模塊./filebeat modules enable apache在 modules.d/apache.yml 文件中修改設(shè)置。
          4.啟動(dòng) Filebeat./filebeat setup./filebeat -e
          nohup ./filebeat -e -c filebeat.yml -d "publish" & > nohup.out
          提示:1.fileBeat可以從日志流直接獲取日志信息 2.可以輸出到logstash中

          安裝 metricbeat

          下載:https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.13.1-linux-x86_64.tar.gz配置:修改 /etc/metricbeat/metricbeat.yml 以設(shè)置連接信息:output.elasticsearch:  hosts: ["<es_url>"]  username: "elastic"  password: "<password>"setup.kibana:  host: "<kibana_url>"  啟用和配置 system 模塊(其他模板差不多流程)sudo ./metricbeat modules enable system
          配置系統(tǒng)服務(wù)在 /etc/metricbeat/modules.d/system.yml 文件中修改設(shè)置。
          啟動(dòng)服務(wù)sudo metricbeat setupsudo service metricbeat start
          nohup ./metricbeat -e -c metricbeat.yml -d "publish" & > nohup.out
          kibana上查看數(shù)據(jù)
          1

          Prometheus+grafana

          用于指標(biāo)監(jiān)控


          • Grafana是一款用Go語(yǔ)言開(kāi)發(fā)的開(kāi)源數(shù)據(jù)可視化工具。相比于Kibana和

            Chronograf,Grafana在可視化展示層面更優(yōu)秀非常多。數(shù)據(jù)源支持非常廣,包括InfluxDB和mysql。

          • Prometheus是由SoundCloud開(kāi)發(fā)的開(kāi)源監(jiān)控報(bào)警系統(tǒng)和時(shí)序列數(shù)據(jù)庫(kù)。從字面上理解,Prometheus由兩個(gè)部分組成,一個(gè)是監(jiān)控報(bào)警系統(tǒng),另一個(gè)是自帶的時(shí)序數(shù)據(jù)庫(kù)(TSDB)。



              可以看出EFLK和普羅米修斯(Prometheus)+Grafana在日志查詢(xún)和監(jiān)控領(lǐng)域是有重疊的,不過(guò),目前來(lái)選的話,EFLK用于日志監(jiān)控檢索,PG用于系統(tǒng)監(jiān)控是不錯(cuò)的選擇。

          1. 系統(tǒng)監(jiān)控



          2. JVM監(jiān)控



          安裝node-exporter、prometheus、grafana

          啟動(dòng)node-exporter  =》僅僅提取系統(tǒng)指標(biāo)docker run -d -p 9100:9100 \  -v "/proc:/host/proc:ro" \  -v "/sys:/host/sys:ro" \  -v "/:/rootfs:ro" \  --net="host" \  prom/node-exporter
          啟動(dòng)prometheus =》elt轉(zhuǎn)移、存儲(chǔ)指標(biāo)mkdir /opt/prometheuscd /opt/prometheus/vim prometheus.yml
          配置global: scrape_interval: 60s evaluation_interval: 60s scrape_configs: - job_name: prometheus static_configs: - targets: ['localhost:9090'] labels: instance: prometheus - job_name: linux static_configs: - targets: ['ip:9100'] labels: instance: localhost 啟動(dòng)docker docker run -d \ -p 9090:9090 \ -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus

          展示:docker run -d --name=grafana -p 3000:3000 grafana/grafana

          1

          TICK

          Telegraf + influxdb+Chronograf+Kapacitor

          用于時(shí)序數(shù)據(jù)存儲(chǔ)和監(jiān)控

          • influxdb是一個(gè)開(kāi)源分布式時(shí)序、時(shí)間和指標(biāo)數(shù)據(jù)庫(kù),使用 Go 語(yǔ)言編寫(xiě),無(wú)需外部依賴(lài)。其設(shè)計(jì)目標(biāo)是實(shí)現(xiàn)分布式和水平伸縮擴(kuò)展。

          • Telegraf 是收集和報(bào)告指標(biāo)和數(shù)據(jù)的代理。有非常多的插件。Go語(yǔ)言編寫(xiě)。

          • Kapacitor 是一個(gè)用來(lái)處理、監(jiān)控和警告時(shí)間序列數(shù)據(jù)的開(kāi)源框架。

          • Chronograf是InfluxData的TICK堆棧的用戶(hù)界面組件。

            這一套可視化能力弱于grafana和Kibana,但優(yōu)勢(shì)在于時(shí)序數(shù)據(jù)庫(kù)influxdb以及Telegraf 、Kapacitor。用于物聯(lián)設(shè)備數(shù)據(jù)的存儲(chǔ)還是非常香的。

          1. 集成哨兵Sentinel

          安裝InfluxDB-默認(rèn)集成其他組件

          docker run -d -p 8083:8083 -p 8086:8086   --name  my_influxdb    influxdb:latest
          1

          Nifi  or  Kettle

          ELT技術(shù)棧,用于業(yè)務(wù)數(shù)據(jù)流轉(zhuǎn)

           Nifi和Kettle應(yīng)該都?xì)w屬于ELT工具,Nifi修改了不少處理器的源碼,才得以走通大部分流程,備好模板,熟練之后還是覺(jué)得不錯(cuò)的。

          1. 處理http請(qǐng)求

          2. 訂閱binlog實(shí)時(shí)同步

          3. 消息中間件交互


          4. 文件系統(tǒng)

          5. 其他

            這里還想整理下Nifi整合Flink的模板,只能以后再搞了。


             整理完上述組件,發(fā)現(xiàn)Go語(yǔ)言寫(xiě)的叫得上名的應(yīng)用又增加了不少。Go優(yōu)勢(shì)還是不少呀。這里以后可以看看Go插件化方案,Grafana的前端大屏方案。


          往日文章:

          數(shù)據(jù)流轉(zhuǎn)工具Nifi介紹1

          數(shù)據(jù)流轉(zhuǎn)工具Nifi介紹2

          瀏覽 86
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  男女舞夜操逼视频一区二区 | 欧美网站在线观看 | 91牛视频 | 无码人妻精品一区二区蜜桃网站文 | 亚洲成AV人影院在线观看 |