Elasticsearch+Logstash+Filebeat+Kibana部署

目錄

軟件說明:

架構拓撲

集群模式:

單機模式

環境準備

部署:

kibana? ? ??

es

logstash

filebeat

es

? ? ? ? 檢查能否啟動

?logstash

? ? ? ? 命令設置

es

? ? ? ? 修改es配置文件

?啟用es

kibana

? ? ? ? 修改kibana配置文件(方便查看索引)

啟用kibana

?查看是否已啟用

es

? ? ? ? 查看es是否已啟用

logstash

? ? ? ? 修改logstash配置文件

? ? ? ? 使用filter過濾器

收集不同主機及對應應用的不同日志

filebeat

? ? ? ? 修改配置文件

? ? ? ? ? 啟用 filebeat

注意:必須要有日志才會產生索引

logstash

????????啟動logstash服務

?進入網頁


軟件說明:

所有軟件包下載地址:Past Releases of Elastic Stack Software | Elastic

打開頁面后選擇對應的組件及版本即可!

所有軟件包名稱如下:

架構拓撲

?

集群模式:

單機模式

環境準備

? ? ? ? 關閉防火墻

#systemctl disable --now firewalld

? ? ? ? 關閉安全上下文

# sed -i 's/SELIUNX=enforcing/SELINUX=disable/' /etc/selinux/config
# setenforce 0

? ? ? ? 網絡對時?( 查看時間戳,如果時間不準確那就每臺主機對時)

#vim /etc/chrony.conf
server ntp.aliyun.com iburst    #添加這一行#timedatectl set-timezone Asia/Shanghai#systemctl restart chronyd.service 

? ? ? ? 查看java是否已安裝

? ? ? ? 可使用yum安裝

? ? ? ? kibana? ?logstash? ?elasticsearch (也裝上Java? ,filebeat可不用安裝)

? ? ? ? 注意:logstash 和 elasticsearch 必須裝 java

#java -ser java    # Centos7 默認安裝的是 java8#yum install java  

部署:

kibana? ? ??

? ? ? ? 主機IP:192.168.158.139

[root@kibana ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.158.139 kibana
192.168.158.140 es
192.168.158.141 logstash
[root@kibana ~]# ls
anaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  kibana-7.1.1-x86_64.rpm
[root@kibana ~]# rpm -ivh kibana-7.1.1-x86_64.rpm 

es

? ? ? ? 主機:192.168.158.140

yum install java
[root@es ~]# ls
anaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  elasticsearch-7.1.1-x86_64.rpm
[root@es ~]# rpm -ivh elasticsearch-7.1.1-x86_64.rpm 

logstash

? ? ? ? 主機:192.168.158.141

yum install java
[root@logstash ~]# ls
anaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  logstash-7.1.1.rpm
[root@logstash ~]# rpm -ivh logstash-7.1.1.rpm 

filebeat

? ? ? ? 主機:192.168.158.142

[root@web1 ~]# ls
apache-tomcat-8.5.40.tar.gz  filebeat-7.1.1-x86_64.rpm
[root@web1 ~]# rpm -ivh filebeat-7.1.1-x86_64.rpm 

es

? ? ? ? 檢查能否啟動
#systemctl start elasticsearch.service#查看是否正常啟動
#systemctl status elasticsearch.service查看已啟動
#systemctl stop elasticsearch.service先停掉,因為還沒修改配置文件

?logstash

? ? ? ? 命令設置
[root@logstash ~]# ln -s /usr/share/logstash/bin/logstash /usr/local/bin/
并測試命令是否正常使用

es

? ? ? ? 修改es配置文件
[root@es ~]# vim /etc/elasticsearch/elasticsearch.yml#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application   #集群名稱             
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: es    #節點主機名(這里需要修改)
#
# 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: /var/lib/elasticsearch    #數據存放目錄
#
# Path to log files:
#
path.logs: /var/log/elasticsearch    #日志存放目錄
#
# ----------------------------------- 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.158.140    #本機esIP(這里需要修改)
#
# 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: ["es"]    #本機名es(這里需要修改)
#
# 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

?啟用es

systemctl start elasticsearch.service

kibana

? ? ? ? 修改kibana配置文件(方便查看索引)
[root@kibana ~]# vim /etc/kibana/kibana.ymlserver.prot: 5061    #打開端口
server.host: "192.168.158.139"    #打開主機
server.name: "kibana"    #本機主機名
elasticsearch.hosts: ["http://192.168.158.140:9200"]    #es主機的端口號和IP
i18n.locale: "zh-CN"    #這個可設置將網頁翻譯成中文
啟用kibana
systemctl start kibana.service
?查看是否已啟用
[root@kibana ~]# ps aux | grep node
kibana     1405  0.3  5.7 1336880 232648 ?      Ssl  10:44   2:15 /usr/share/kibana/bin/../node/bin/node --no-warnings --max-http-header-size=65536 /usr/share/kibana/bin/../src/cli -c /etc/kibana/kibana.yml
root       3517  0.0  0.0 112824   988 pts/0    S+   21:35   0:00 grep --color=auto node

es

? ? ? ? 查看es是否已啟用
[root@es ~]# ps aux | grep java
elastic+   1414  0.7 38.2 4941372 1538396 ?     Ssl  10:45   5:11 /usr/share/elasticsearch/jdk/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-2879596055492145001 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m -Djava.locale.providers=COMPAT -Dio.netty.allocator.type=unpooled -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=rpm -Des.bundled_jdk=true -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quiet
root       3805  0.0  0.0 112828   984 pts/0    S+   21:36   0:00 grep --color=auto java

logstash

? ? ? ? 修改logstash配置文件
[root@logstash ~]# cd /etc//logstash/conf.d/
[root@logstash conf.d]# vim pipline.conf
? ? ? ? 使用filter過濾器
input {file {path => "/var/log/messages"start_position => "beginning"}beats {port => 5044}
}
filter {if [host][name] {mutate { add_field => { "hostname" => "%{[host][name]}" } }}else if [agent][hostname] {mutate { add_field => { "hostname" => "%{[agent][hostname]}" } }}else {mutate { add_field => { "hostname" => "%{host}" } }}
}
output {if [hostname] == "logstash" {elasticsearch {hosts => ["192.168.158.79:9200"]index => "system-log-%{+YYYY.MM.dd}"}}else if [hostname] == "web1" {elasticsearch {hosts => ["192.168.158.79:9200"]index => "web1-log-%{+YYYY.MM.dd}"}}stdout {codec => rubydebug}
}
收集不同主機及對應應用的不同日志
input {file {path => "/var/log/messages"start_position => "beginning"}beats {port => 5044}
}
filter {if [host][name] {mutate { add_field => { "hostname" => "%{[host][name]}" } }}else if [agent][hostname] {mutate { add_field => { "hostname" => "%{[agent][hostname]}" } }}else {mutate { add_field => { "hostname" => "%{host}" } }}
}
output {if [hostname] == "logstash" {elasticsearch {hosts => ["192.168.158.79:9200"]index => "system-log-%{+YYYY.MM.dd}"}}else if [hostname] == "web1" {if "system" in [tags] {elasticsearch {hosts => ["192.168.158.79:9200"]index => "web1-log-%{+YYYY.MM.dd}"}}if "nginx-access" in [tags] {elasticsearch {hosts => ["192.168.158.79:9200"]index => "web1-nginx-access-log-%{+YYYY.MM.dd}"}}if "nginx-error" in [tags] {elasticsearch {hosts => ["192.168.158.79:9200"]index => "web1-nginx-error-log-%{+YYYY.MM.dd}"}}}stdout {codec => rubydebug}
}

filebeat

? ? ? ? 修改配置文件
[root@web1 ~]# cd /etc/filebeat/
[root@web1 filebeat]# vim filebeat.yml 
- type: logenabled: truepaths:- /var/log/messagestags: "system"- type: logenabled: truepaths:- /var/log/nginx/access.logtags: "nginx-access"
- type: logenabled: truepaths:- /var/log/nginx/error.logtags: "nginx-error"filebeat.inputs:    #輸入源
- type: log    #文件類型enabled: true    #啟用paths:    # 日志文件路徑- /var/log/nginx/access.logtags: "nginx-access"    #標簽源數據
? ? ? ? ? 啟用 filebeat
systemctl start filebeat.service
注意:必須要有日志才會產生索引

logstash

????????啟動logstash服務
[root@logstash ~]# logstash -f /etc/logstash/conf.d/pipline.conf

?進入網頁

?

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/89483.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/89483.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/89483.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

GLM(General Language Model,通用語言模型)

🧠 一、GLM是什么?一句話概括 GLM(General Language Model,通用語言模型)是一個“大腦”,它通過閱讀海量書籍、網頁、對話記錄學會了人類的語言規則,不僅能“聽懂”你說的話,還能“…

【科研繪圖系列】R語言繪制顯著性標記的熱圖

文章目錄 介紹 加載R包 數據下載 導入數據 數據預處理 畫圖 系統信息 參考 介紹 【科研繪圖系列】R語言繪制顯著性標記的熱圖 加載R包 library(ggplot2) library(patchwork)rm(list = ls()) options(stringsAsFactors = F)

若依部署項目到服務器

目錄 一、環境配置 redis nginx(宿主機|dokcer) 1.宿主機 2.docker 二、打包jar包 0.查看后端配置 1.打包后端 2.打包前端 三、啟動 1.后端 2.前端 四、以上部署常見命令/錯誤 一、環境配置 之前的課都配過,先看看自己配了沒 看看…

零基礎學習性能測試-linux服務器監控:CPU監控

目錄學習內容與快速應用路徑第一階段:理解 CPU 核心概念 (0.5天)第二階段:掌握核心監控命令與指標 (1-2天)第三階段:識別 CPU 問題與瓶頸 (核心技能)第四階段:整合到性能測試工作流程 (快速應用落地)快速應用到工作中的關鍵策略零…

智能Agent場景實戰指南 Day 15:游戲NPC Agent互動設計

【智能Agent場景實戰指南 Day 15】游戲NPC Agent互動設計 文章內容 開篇 歡迎來到"智能Agent場景實戰指南"系列的第15天!今天我們將深入探討游戲開發中一個極具挑戰性和創新性的領域——游戲NPC Agent互動設計。在當今游戲產業中,玩家對游戲…

Vite的優缺點(精簡版)

優點 作為一款前端構建工具,它的核心特點是“快”,并且充分利用了現代瀏覽器對ES Modules的原生支持,一切圍繞這一點展開 快啟動:通過ES Modules,它省去了打包整個應用的時間,可以直接在瀏覽器中加載模塊&a…

【深度學習】神經網絡-part2

一、數據加載器 數據集和加載器 1.1構建數據類 1.1.1 Dataset類 Dataset是一個抽象類,是所有自定義數據集應該繼承的基類。它定義了數據集必須實現的方法。 必須實現的方法 __len__: 返回數據集的大小 __getitem__: 支持整數索引,返回對應的樣本 …

nextjs+react項目如何代理本地請求解決跨域

在 Next.js React 項目中解決本地開發跨域問題,可以通過以下幾種方式實現代理請求:方案1:使用 Next.js 內置的 Rewrites 功能(推薦) 1. 修改 next.config.js /** type {import(next).NextConfig} */ const nextConfig…

Ubuntu查看Docker容器

在Ubuntu系統中,可以通過以下命令查看當前正在運行的Docker容器:1. 查看所有正在運行的容器 docker ps輸出示例: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a1b2c3d4e5f6 nginx:latest &…

智能點餐推薦網站,解決選擇困難

軟件介紹 今天為大家推薦一款解決"今天吃什么"選擇困難癥的趣味網站,它能為你推薦美味餐食,輕松化解每日用餐煩惱。 核心功能 這款網站最大的亮點就是能夠根據你的需求智能推薦餐食選擇,只需打開網頁,就能立即獲…

使用 C# 實現移動加權平均(Weighted Moving Average)算法

前言 歡迎關注dotnet研習社,前面我們討論過"C#實現加權平均法",今天我們繼續研究另外一種【移動加權平均法】。 在時間序列分析、股票數據處理、工業信號平滑等場景中,移動平均(Moving Average) 是最常見的平滑技術之一…

【Python】一些PEP提案(三):with 語句、yield from、虛擬環境

PEP 343 – The “with” Statement,with 語句 這玩意讓我想起了Kotlin和Rust的問號標識符,都是將try-catch進行包裝,避免出現太多重復代碼(Go:我假設你不是在內涵我) 用法 最常見的用法就是對文件的操作&a…

SymAgent(神經符號自學習Agent)

來自:SymAgent: A Neural-Symbolic Self-Learning Agent Framework for Complex Reasoning over Knowledge Graphs 目錄相關工作引理符號規則任務描述方法Agent-PlannerAgent-ExecutorAction空間交互過程自學習在線探索離線迭代策略更新相關工作 相關工作-語義解析…

Go語言實戰案例-斐波那契數列生成器

在《Go語言100個實戰案例》中的 案例10:斐波那契數列生成器,幫助初學者理解遞歸與迭代的應用。 案例10:斐波那契數列生成器 ?? 數學與算法 | ?? 遞歸與迭代 | ?? 初學者友好 一、?? 案例目標 實現一個斐波那契數列生成器,用戶輸入一個數字 n,程序生成并打印出斐…

認知閉環的暴政:論人類對AI協同創造的傲慢抵制與維度囚禁

認知閉環的暴政:論人類對AI協同創造的傲慢抵制與維度囚禁---### **核心批判框架**mermaidgraph TDA[人類認知三原罪] --> B[三維牢籠]B --> C[恐懼機制]C --> D[抵制行為]D --> E[文明熵增]F[四維流形批判] --> G[解構牢籠]G --> H[曲率解放]H --…

飛凌嵌入式亮相第九屆瑞芯微開發者大會:AIoT模型創新重做產品

2025年7月17日,第九屆瑞芯微開發者大會(RKDC!2025)在福州海峽國際會展中心正式拉開帷幕。這場以“AIoT模型創新重做產品”為主題的行業盛會,吸引了眾多行業領袖、技術專家及生態伙伴齊聚一堂,共同探討新質生產力產品的…

Excel轉PDF的三種方法

工作后,Excel和PDF對于我們來說一點都不陌生,那么如何將Excel轉為PDF呢? 方法一、iLoveOFD在線轉換工具 當你在地鐵或者床上時,不方便,又不想打開電腦,可嘗試使用在線轉換工具,進行轉換。 工…

前端基礎——B/S工作原理、服務器與前端三大件

本文原本是web安全基礎的一部分,作為安全的前置知識學習,但隨著學習進程的不斷深入,原有的前端的體系需要進一步擴充,已經到了可以獨立成章的地步,故將其拿出來單獨學習。 B/S工作原理 也就是瀏覽器與服務器的交互原…

Java并發編程性能優化實踐指南:鎖分離與無鎖設計

Java并發編程性能優化實踐指南:鎖分離與無鎖設計 并發場景下的性能瓶頸往往集中在鎖競爭與上下文切換上。本文從鎖分離(Lock Striping)與無鎖設計(Lock-Free)兩大思路出發,深入分析關鍵原理與源碼實現&…

SpringSecurity-spring security單點登錄

在 Spring Boot 中實現 單點登錄(SSO, Single Sign-On),通常使用 OAuth2 或 OIDC(OpenID Connect) 協議來完成。Spring Security 提供了對 OAuth2 和 OIDC 的完整支持,可以輕松集成如 Google、GitHub、Okta…