国产睡熟迷奷白丝护士系列精品,中文色字幕网站,免费h网站在线观看的,亚洲开心激情在线

      <sup id="hb9fh"></sup>
          1. 千鋒教育-做有情懷、有良心、有品質(zhì)的職業(yè)教育機(jī)構(gòu)

            手機(jī)站
            千鋒教育

            千鋒學(xué)習(xí)站 | 隨時隨地免費(fèi)學(xué)

            千鋒教育

            掃一掃進(jìn)入千鋒手機(jī)站

            領(lǐng)取全套視頻
            千鋒教育

            關(guān)注千鋒學(xué)習(xí)站小程序
            隨時隨地免費(fèi)學(xué)習(xí)課程

            當(dāng)前位置:首頁  >  技術(shù)干貨  > 輕量級日志系統(tǒng)Loki--安裝配置

            輕量級日志系統(tǒng)Loki--安裝配置

            來源:千鋒教育
            發(fā)布人:yyy
            時間: 2023-06-27 13:19:00 1687843140

              Loki對標(biāo)EFK/ELK,由于其輕量的設(shè)計(jì),備受歡迎,Loki相比EFK/ELK,它不對原始日志進(jìn)行索引,只對日志的標(biāo)簽進(jìn)行索引,而日志通過壓縮進(jìn)行存儲,通常是文件系統(tǒng)存儲,所以其操作成本更低,數(shù)量級效率更高

              由于Loki的存儲都是基于文件系統(tǒng)的,所以它的日志搜索時基于內(nèi)容即日志行中的文本,所以它的查詢支持LogQL,在搜索窗口中通過過濾標(biāo)簽的方式進(jìn)行搜索和查詢。

              Loki分兩部分,Loki是日志引擎部分,Promtail是收集日志端,然后通過Grafana進(jìn)行展示.

              1.安裝grafana

            wget https://dl.grafana.com/oss/release/grafana-8.2.5.linux-amd64.tar.gz
            tar -zxvf grafana-8.2.5.linux-amd64.tar.gz
            mv grafana-8.2.5 /usr/local/grafana

               創(chuàng)建Systemd服務(wù)

            cat>/usr/lib/systemd/system/grafana-server.service<<EOF
            [Unit]
            Description=Grafana Server
            After=network.target

            [Service]
            Type=simple
            User=root
            WorkingDirectory=/usr/local/grafana
            ExecStart=/usr/local/grafana/bin/grafana-server

            Restart=on-failure
            LimitNOFILE=65536

            [Install]
            WantedBy=multi-user.target
            EOF

               服務(wù)開機(jī)自啟

            systemctl daemon-reload
            systemctl enable grafana-server.service && systemctl start grafana-server.service

               /usr/local/grafana/conf/defaults.ini為默認(rèn)配置文件

              工作端口,默認(rèn)為3000。

              Loki的官方文檔

              https://grafana.com/docs/loki/latest/installation

              Loki·安裝

              從官方文檔看,Loki支持源碼安裝、Docker、Helm、Local、Tanka

              我選擇local,就是編譯好的二進(jìn)制可執(zhí)行文件

              安裝步驟:

              鏡像網(wǎng)址

              https://hub.fastgit.org/grafana

              1.下載二進(jìn)制可執(zhí)行文件

              https://hub.fastgit.org/grafana/loki/releases/download/v2.4.1/loki-linux-amd64.zip

              unzip loki-linux-amd64.zip && mv loki-linux-amd64 /usr/bin/loki

              chmod o+x /usr/bin/loki

              創(chuàng)建工作目錄并下載配置文件

              mkdir -p /data/loki

              參考配置文件

              https://hub.fastgit.org/grafana/loki/blob/main/cmd/loki/loki-local-config.yaml

              最終lok.yml如下

            vim /data/loki/lok.yml

            auth_enabled: false

            server:
            http_listen_port: 3100
            grpc_listen_port: 9096

            common:
            path_prefix: /data/loki
            storage:
            filesystem:
            chunks_directory: /data/loki/chunks
            rules_directory: /data/loki/rules
            replication_factor: 1
            ring:
            instance_addr: 127.0.0.1
            kvstore:
            store: inmemory

            schema_config:
            configs:
            - from: 2020-10-24
            store: boltdb-shipper
            object_store: filesystem
            schema: v11
            index:
            prefix: index_
            period: 24h
            ##報警地址
            ruler:
            alertmanager_url: http://localhost:9093

            #啟用Redis緩存配置
            auth_enabled: false

            server:
            http_listen_port: 3100
            grpc_listen_port: 9096

            common:
            path_prefix: /data/loki
            storage:
            filesystem:
            chunks_directory: /data/loki/chunks
            rules_directory: /data/loki/rules
            replication_factor: 1
            ring:
            instance_addr: 127.0.0.1
            kvstore:
            store: inmemory

            schema_config:
            configs:
            - from: 2020-10-24
            store: boltdb-shipper
            object_store: filesystem
            schema: v11
            index:
            prefix: index_
            period: 24h

            frontend:
            compress_responses: true

            query_range:
            split_queries_by_interval: 24h
            results_cache:
            cache:
            redis:
            endpoint: 192.168.1.6:6379
            expiration: 10s
            db: 1
            cache_results: true

            chunk_store_config:
            chunk_cache_config:
            redis:
            endpoint: 192.168.1.6:6379
            expiration: 10s
            db: 1
            write_dedupe_cache_config:
            redis:
            endpoint: 192.168.1.6:6379
            expiration: 1h
            db: 2

            ruler:
            alertmanager_url: http://localhost:9093

               創(chuàng)建相關(guān)目錄

              mkdir -p /data/loki/{chunks,rules,logs}

              啟動

            nohup  loki  --config.file=/data/loki/loki.yml  > /data/loki/logs/loki.log 2>&1 &

               啟動腳本

            #!/bin/bash
            CONFILE='/data/loki/loki.yml'
            PIDFILE='/data/loki/loki.pid'
            LOGFILE='/data/loki/loki.log'
            OPTS='/usr/bin/loki --config.file='
            PID=`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`
            if [ ! ${PID} ]; then
            nohup ${OPTS}${CONFILE} >${LOGFILE} 2>&1 & echo $! >${PIDFILE} &
            sleep 3
            echo "loki PID:`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`"
            PID=`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`
            if [ ! ${PID} ] ; then echo "loki config error, tail -f ${LOGFILE}!"
            fi
            else
            echo "loki is running,PID:`cat ${PIDFILE}`"
            fi

               安裝promtail進(jìn)行收集日志

              Promtail是收集日志端

              下載安裝

            wget  https://hub.fastgit.org/grafana/loki/releases/download/v2.4.1/promtail-linux-amd64.zip
            unzip promtail-linux-amd64.zip && mv promtail-linux-amd64 /usr/bin/promtail && chmod o+x /usr/bin/promtail

               配置參考文件

              官網(wǎng)配置文件文檔

            https://hub.fastgit.org/grafana/loki/blob/main/clients/cmd/promtail/promtail-local-config.yaml

              

            server:
            http_listen_port: 9080
            grpc_listen_port: 0

            positions:
            filename: /tmp/positions.yaml

            clients:
            - url: http://localhost:3100/loki/api/v1/push

            scrape_configs:
            - job_name: system
            static_configs:
            - targets:
            - localhost
            labels:
            job: varlogs
            __path__: /var/log/*log

               參數(shù)說明

            server部分定義監(jiān)聽端口,positions定義讀取的文件偏移量存儲位置,clients定義loki接口地址,最后一部分scrape_configs是重點(diǎn)部分
            promtail通過scrape_configs部分配置收集日志的相關(guān)信息,以測試配置文件為例:
            job_name 用來區(qū)分日志組
            static_configs 收集日志的靜態(tài)配置
            targets 收集日志的節(jié)點(diǎn),這個參數(shù)其實(shí)是在自動發(fā)現(xiàn)的時候使用的
            labels 定義一個要收集的日志文件和一組可選的附加標(biāo)簽
            job 標(biāo)簽名稱,在grafana索引的時候用到的標(biāo)簽名稱
            __path__ 定義日志收集的文件或路徑,支持正則
            配置文件修改完成后,就可以啟動promtail了,和loki啟動方法一樣,通過--config.file指定配置文件啟動

               promtail,類似于tail,它只監(jiān)聽新增日志,不會像filebeat一樣,讀取日志所有內(nèi)容,這是和filebeat的一個區(qū)別

              最終配置,啟用靜態(tài)與文件自動發(fā)現(xiàn)

              mkdir -p /data/promtail

              vim /data/promtail/promtail.yml

            server:
            http_listen_port: 9080
            grpc_listen_port: 0

            positions:
            filename: /tmp/positions.yaml

            clients:
            - url: http://192.168.1.6:3100/loki/api/v1/push

            scrape_configs:
            - job_name: system
            static_configs:
            - targets:
            - localhost
            labels:
            job: varlogs
            __path__: /var/log/*log
            file_sd_configs:
            - files:
            - /data/promtail/log_file/*.json
            refresh_interval: 1m

               啟動

              創(chuàng)建相關(guān)文件 

            mkdir -p /data/promtail/log_file/

              

            文件自動發(fā)現(xiàn)配置
            vim /data/promtail/log_file/mail.json
            [
            {
            "targets": [ "localhost" ],
            "labels": {
            "__path__": "/var/log/maillog",
            "job": "mailserver"
            }
            }
            ]

              開機(jī)自啟動

            nohup  promtail --config.file=/data/promtail/promtail.yml  >/data/promtail/promtail.log 2>&1 &

               啟動腳本

              vim /data/promtail/start.sh

            #!/bin/bash
            CONFILE='/data/promtail/promtail.yml'
            PIDFILE='/data/promtail/promtail.pid'
            LOGFILE='/data/promtail/promtail.log'
            OPTS='/usr/bin/promtail --config.file='
            PID=`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`
            if [ ! ${PID} ]; then
            nohup ${OPTS}${CONFILE} >${LOGFILE} 2>&1 & echo $! >${PIDFILE} &
            sleep 3
            echo "promtail PID:`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`"
            PID=`ps -ef | grep ${CONFILE} | grep 'config.file' | awk '{print $2}'`
            if [ ! ${PID} ] ; then echo "promtail config error, tail -f ${LOGFILE}!"
            fi
            else
            echo "promtail is running,PID:`cat ${PIDFILE}`"
            fi

             chmod o+x /data/promtail/start.sh

              查看是否工作

            [root@openrestry promtail]# netstat -ntpl | grep loki
            tcp6 0 0 :::9096 :::* LISTEN 1721/loki
            tcp6 0 0 :::3100 :::* LISTEN 1721/loki
            [root@openrestry promtail]# netstat -ntpl | grep promtail
            tcp6 0 0 :::40210 :::* LISTEN 1833/promtail
            tcp6 0 0 :::9080 :::* LISTEN 1833/promtail

               在Grafana中添加顯示輸出

              登錄http://Grafana:3000,添加loki數(shù)據(jù)源

            聲明:本站稿件版權(quán)均屬千鋒教育所有,未經(jīng)許可不得擅自轉(zhuǎn)載。
            10年以上業(yè)內(nèi)強(qiáng)師集結(jié),手把手帶你蛻變精英
            請您保持通訊暢通,專屬學(xué)習(xí)老師24小時內(nèi)將與您1V1溝通
            免費(fèi)領(lǐng)取
            今日已有369人領(lǐng)取成功
            劉同學(xué) 138****2860 剛剛成功領(lǐng)取
            王同學(xué) 131****2015 剛剛成功領(lǐng)取
            張同學(xué) 133****4652 剛剛成功領(lǐng)取
            李同學(xué) 135****8607 剛剛成功領(lǐng)取
            楊同學(xué) 132****5667 剛剛成功領(lǐng)取
            岳同學(xué) 134****6652 剛剛成功領(lǐng)取
            梁同學(xué) 157****2950 剛剛成功領(lǐng)取
            劉同學(xué) 189****1015 剛剛成功領(lǐng)取
            張同學(xué) 155****4678 剛剛成功領(lǐng)取
            鄒同學(xué) 139****2907 剛剛成功領(lǐng)取
            董同學(xué) 138****2867 剛剛成功領(lǐng)取
            周同學(xué) 136****3602 剛剛成功領(lǐng)取
            相關(guān)推薦HOT
            PUE是什么?

            一、PUE是什么PUE,即功耗比(Power Usage Effectiveness),是數(shù)據(jù)中心的能源效率指標(biāo)。它是數(shù)據(jù)中心總功耗與設(shè)備功耗的比值,用于評估數(shù)據(jù)中...詳情>>

            2023-10-15 07:13:07
            graph cut和graph cuts有什么區(qū)別?

            1.語境不同graph cut”通常在描述一個操作時使用,比如”perform a graph cut”,它指的是在圖中找到一個切割,將圖劃分為兩個...詳情>>

            2023-10-15 07:02:16
            什么是雙機(jī)熱備?

            一、雙機(jī)熱備的原理雙機(jī)熱備是指在系統(tǒng)中配置兩臺服務(wù)器(主服務(wù)器和備份服務(wù)器),兩者通過高速網(wǎng)絡(luò)連接進(jìn)行實(shí)時數(shù)據(jù)同步和狀態(tài)同步。主服務(wù)器...詳情>>

            2023-10-15 06:37:02
            偏最小二乘支持向量機(jī)和支持向量機(jī)回歸的區(qū)別是什么?

            1.模型構(gòu)建的理論基礎(chǔ)不同支持向量機(jī)回歸(SVR)基于統(tǒng)計(jì)學(xué)習(xí)理論,其主要思想是找到一個超平面,使得大部分?jǐn)?shù)據(jù)點(diǎn)都在這個超平面的一定范圍內(nèi),...詳情>>

            2023-10-15 06:30:45
            VAE、GAN和transformer有什么區(qū)別?

            1.模型結(jié)構(gòu)不同VAE(變分自編碼器)是一種生成模型,其基于概率圖模型和自編碼器,能夠?qū)W習(xí)數(shù)據(jù)的潛在分布。GAN(生成對抗網(wǎng)絡(luò))同樣是一種生成...詳情>>

            2023-10-15 06:10:12