好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > 在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法

在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法

熱門標簽:地圖標注黃河的位置 濮陽好的聯通400電話申請 百度地圖標注公司位置要多少錢 地圖標注如何改成微信號 山東企業外呼系統公司 虛假地圖標注 400電話號碼辦理多少錢 承德地圖標注公司 靈圖uu電子寵物店地圖標注

Elastic stack 俗稱 ELK stack,是一組包括 Elasticsearch、Logstash 和 Kibana 在內的開源產品。Elastic Stack 由 Elastic 公司開發和維護。使用 Elastic stack,可以將系統日志發送到 Logstash,它是一個數據收集引擎,接受來自可能任何來源的日志或數據,并對日志進行歸一化,然后將日志轉發到 Elasticsearch,用于分析、索引、搜索和存儲,最后使用 Kibana 表示為可視化數據,使用 Kibana,我們還可以基于用戶的查詢創建交互式圖表。

在本文中,我們將演示如何在 RHEL 8 / CentOS 8 服務器上設置多節點 elastic stack 集群。以下是我的 Elastic Stack 集群的詳細信息:

Elasticsearch:

  • 三臺服務器,最小化安裝 RHEL 8 / CentOS 8
  • IP & 主機名 – 192.168.56.40(elasticsearch1.linuxtechi.local)、192.168.56.50 (elasticsearch2.linuxtechi.local)、192.168.56.60(elasticsearch3.linuxtechi.local`)

Logstash:**

  • 兩臺服務器,最小化安裝 RHEL 8 / CentOS 8
  • IP & 主機 – 192.168.56.20(logstash1.linuxtechi.local)、192.168.56.30(logstash2.linuxtechi.local

Kibana:

一臺服務器,最小化安裝 RHEL 8 / CentOS 8IP & 主機名 – 192.168.56.10(kibana.linuxtechi.local

Filebeat:

  • 一臺服務器,最小化安裝 CentOS 7
  • IP & 主機名 – 192.168.56.70(web-server

讓我們從設置 Elasticsearch 集群開始,

設置3個節點 Elasticsearch 集群

正如我已經說過的,設置 Elasticsearch 集群的節點,登錄到每個節點,設置主機名并配置 yum/dnf 庫

使用命令 hostnamectl 設置各個節點上的主機名:

[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch1.linuxtechi. local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#
[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch2.linuxtechi. local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#
[root@linuxtechi ~]# hostnamectl set-hostname "elasticsearch3.linuxtechi. local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#

對于 CentOS 8 系統,我們不需要配置任何操作系統包庫,對于 RHEL 8 服務器,如果你有有效訂閱,那么用紅帽訂閱以獲得包存儲庫就可以了。如果你想為操作系統包配置本地 yum/dnf 存儲庫,請參考以下網址:

如何使用 DVD 或 ISO 文件在 RHEL 8 服務器上設置本地 Yum / DNF 存儲庫

在所有節點上配置 Elasticsearch 包存儲庫,在 /etc/yum.repo.d/ 文件夾下創建一個包含以下內容的 elastic.repo 文件:

~]# vi /etc/yum.repos.d/elastic.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

保存文件并退出。

在所有三個節點上使用 rpm 命令導入 Elastic 公共簽名密鑰。

~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

在所有三個節點的 /etc/hosts 文件中添加以下行:

192.168.56.40  elasticsearch1.linuxtechi.local
192.168.56.50  elasticsearch2.linuxtechi.local
192.168.56.60  elasticsearch3.linuxtechi.local

使用 yum/dnf 命令在所有三個節點上安裝 Java:

[root@linuxtechi ~]# dnf install java-openjdk -y
[root@linuxtechi ~]# dnf install java-openjdk -y
[root@linuxtechi ~]# dnf install java-openjdk -y

使用 yum/dnf 命令在所有三個節點上安裝 Elasticsearch:

root@linuxtechi ~]# dnf install elasticsearch -y
[root@linuxtechi ~]# dnf install elasticsearch -y
[root@linuxtechi ~]# dnf install elasticsearch -y

注意: 如果操作系統防火墻已啟用并在每個 Elasticsearch 節點中運行,則使用 firewall-cmd 命令允許以下端口開放:

~]# firewall-cmd --permanent --add-port=9300/tcp
~]# firewall-cmd --permanent --add-port=9200/tcp
~]# firewall-cmd --reload

配置 Elasticsearch, 在所有節點上編輯文件 /etc/elasticsearch/elasticsearch.yml 并加入以下內容:

~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: opn-cluster
node.name: elasticsearch1.linuxtechi.local
network.host: 192.168.56.40
http.port: 9200
discovery.seed_hosts: ["elasticsearch1.linuxtechi.local", "elasticsearch2.linuxtechi.local", "elasticsearch3.linuxtechi.local"]
cluster.initial_master_nodes: ["elasticsearch1.linuxtechi.local", "elasticsearch2.linuxtechi.local", "elasticsearch3.linuxtechi.local"]

注意: 在每個節點上,在 node.name 中填寫正確的主機名,在 network.host 中填寫正確的 IP 地址,其他參數保持不變。

現在使用 systemctl 命令在所有三個節點上啟動并啟用 Elasticsearch 服務:

~]# systemctl daemon-reload
~]# systemctl enable elasticsearch.service
~]# systemctl start elasticsearch.service

使用下面 ss 命令驗證 elasticsearch 節點是否開始監聽 9200 端口:

[root@linuxtechi ~]# ss -tunlp | grep 9200
tcp LISTEN 0 128 [::ffff:192.168.56.40]:9200  *:* users:(("java",pid=2734,fd=256))
[root@linuxtechi ~]#

使用以下 curl 命令驗證 Elasticsearch 群集狀態:

[root@linuxtechi ~]# curl http://elasticsearch1.linuxtechi.local:9200
[root@linuxtechi ~]# curl -X GET http://elasticsearch2.linuxtechi.local:9200/_cluster/health?pretty

命令的輸出如下所示:

以上輸出表明我們已經成功創建了 3 節點的 Elasticsearch 集群,集群的狀態也是綠色的。

注意: 如果你想修改 JVM 堆大小,那么你可以編輯了文件 /etc/elasticsearch/jvm.options,并根據你的環境更改以下參數

  • -Xms1g
  • -Xmx1g

現在讓我們轉到 Logstash 節點。

安裝和配置 Logstash

在兩個 Logstash 節點上執行以下步驟。

登錄到兩個節點使用 hostnamectl 命令設置主機名:

[root@linuxtechi ~]# hostnamectl set-hostname "logstash1.linuxtechi.local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#
[root@linuxtechi ~]# hostnamectl set-hostname "logstash2.linuxtechi.local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#

在兩個 logstash 節點的 /etc/hosts 文件中添加以下條目:

~]# vi /etc/hosts
192.168.56.40  elasticsearch1.linuxtechi.local
192.168.56.50  elasticsearch2.linuxtechi.local
192.168.56.60  elasticsearch3.linuxtechi.local

保存文件并退出。

在兩個節點上配置 Logstash 存儲庫,在文件夾 /ete/yum.repo.d/ 下創建一個包含以下內容的文件 logstash.repo

~]# vi /etc/yum.repos.d/logstash.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

保存并退出文件,運行 rpm 命令導入簽名密鑰:

~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

使用 yum/dnf 命令在兩個節點上安裝 Java OpenJDK:

~]# dnf install java-openjdk -y

從兩個節點運行 yum/dnf 命令來安裝 logstash:

[root@linuxtechi ~]# dnf install logstash -y
[root@linuxtechi ~]# dnf install logstash -y

現在配置 logstash,在兩個 logstash 節點上執行以下步驟,創建一個 logstash 配置文件,首先我們在 /etc/logstash/conf.d/ 下復制 logstash 示例文件:

# cd /etc/logstash/
# cp logstash-sample.conf conf.d/logstash.conf

編輯配置文件并更新以下內容:

# vi conf.d/logstash.conf
input {
 beats {
 port => 5044
 }
}
output {
 elasticsearch {
 hosts => ["http://elasticsearch1.linuxtechi.local:9200", "http://elasticsearch2.linuxtechi.local:9200", "http://elasticsearch3.linuxtechi.local:9200"]
 index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
 #user => "elastic"
 #password => "changeme"
 }
}

output 部分之下,在 hosts 參數中指定所有三個 Elasticsearch 節點的 FQDN,其他參數保持不變。

使用 firewall-cmd 命令在操作系統防火墻中允許 logstash 端口 “5044”:

~ # firewall-cmd --permanent --add-port=5044/tcp
~ # firewall-cmd –reload

現在,在每個節點上運行以下 systemctl 命令,啟動并啟用 Logstash 服務:

~]# systemctl start logstash
~]# systemctl eanble logstash

使用 ss 命令驗證 logstash 服務是否開始監聽 5044 端口:

[root@linuxtechi ~]# ss -tunlp | grep 5044
tcp LISTEN 0 128    *:5044  *:* users:(("java",pid=2416,fd=96))
[root@linuxtechi ~]#

以上輸出表明 logstash 已成功安裝和配置。讓我們轉到 Kibana 安裝。

安裝和配置 Kibana

登錄 Kibana 節點,使用 hostnamectl 命令設置主機名:

[root@linuxtechi ~]# hostnamectl set-hostname "kibana.linuxtechi.local"
[root@linuxtechi ~]# exec bash
[root@linuxtechi ~]#

編輯 /etc/hosts 文件并添加以下行:

192.168.56.40  elasticsearch1.linuxtechi.local
192.168.56.50  elasticsearch2.linuxtechi.local
192.168.56.60  elasticsearch3.linuxtechi.local

使用以下命令設置 Kibana 存儲庫:

[root@linuxtechi ~]# vi /etc/yum.repos.d/kibana.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
[root@linuxtechi ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

執行 yum/dnf 命令安裝 kibana:

[root@linuxtechi ~]# yum install kibana -y

通過編輯 /etc/kibana/kibana.yml 文件,配置 Kibana:

[root@linuxtechi ~]# vim /etc/kibana/kibana.yml
…………
server.host: "kibana.linuxtechi.local"
server.name: "kibana.linuxtechi.local"
elasticsearch.hosts: ["http://elasticsearch1.linuxtechi.local:9200", "http://elasticsearch2.linuxtechi.local:9200", "http://elasticsearch3.linuxtechi.local:9200"]
…………

啟用并啟動 kibana 服務:

root@linuxtechi ~]# systemctl start kibana
[root@linuxtechi ~]# systemctl enable kibana

在系統防火墻上允許 Kibana 端口 “5601”:

[root@linuxtechi ~]# firewall-cmd --permanent --add-port=5601/tcp
success
[root@linuxtechi ~]# firewall-cmd --reload
success
[root@linuxtechi ~]#

使用以下 URL 訪問 Kibana 界面:http://kibana.linuxtechi.local:5601

從面板上,我們可以檢查 Elastic Stack 集群的狀態。

這證明我們已經在 RHEL 8 /CentOS 8 上成功地安裝并設置了多節點 Elastic Stack 集群。

現在讓我們通過 filebeat 從其他 Linux 服務器發送一些日志到 logstash 節點中,在我的例子中,我有一個 CentOS 7服務器,我將通過 filebeat 將該服務器的所有重要日志推送到 logstash。

登錄到 CentOS 7 服務器使用 yum/rpm 命令安裝 filebeat 包:

[root@linuxtechi ~]# rpm -ivh https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-x86_64.rpm
Retrieving https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-x86_64.rpm
Preparing...    ################################# [100%]
Updating / installing...
 1:filebeat-7.3.1-1   ################################# [100%]
[root@linuxtechi ~]#

編輯 /etc/hosts 文件并添加以下內容:

192.168.56.20  logstash1.linuxtechi.local
192.168.56.30  logstash2.linuxtechi.local

現在配置 filebeat,以便它可以使用負載平衡技術向 logstash 節點發送日志,編輯文件 /etc/filebeat/filebeat.yml,并添加以下參數:

filebeat.inputs: 部分將 enabled: false 更改為 enabled: true,并在 paths 參數下指定我們可以發送到 logstash 的日志文件的位置;注釋掉 output.elasticsearchhost 參數;刪除 output.logstash:hosts: 的注釋,并在 hosts 參數添加兩個 logstash 節點,以及設置 loadbalance: true

[root@linuxtechi ~]# vi /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
 enabled: true
 paths:
 - /var/log/messages
 - /var/log/dmesg
 - /var/log/maillog
 - /var/log/boot.log
#output.elasticsearch:
 # hosts: ["localhost:9200"]
output.logstash:
 hosts: ["logstash1.linuxtechi.local:5044", "logstash2.linuxtechi.local:5044"]
 loadbalance: true

使用下面的 2 個 systemctl 命令 啟動并啟用 filebeat 服務:

[root@linuxtechi ~]# systemctl start filebeat
[root@linuxtechi ~]# systemctl enable filebeat

現在轉到 Kibana 用戶界面,驗證新索引是否可見。

從左側欄中選擇管理選項,然后單擊 Elasticsearch 下的索引管理:

正如我們上面看到的,索引現在是可見的,讓我們現在創建索引模型。

點擊 Kibana 部分的 “Index Patterns”,它將提示我們創建一個新模型,點擊 “Create Index Pattern” ,并將模式名稱指定為 “filebeat”:

點擊下一步。

選擇 “Timestamp” 作為索引模型的時間過濾器,然后單擊 “Create index pattern”:

現在單擊查看實時 filebeat 索引模型:

這表明 Filebeat 代理已配置成功,我們能夠在 Kibana 儀表盤上看到實時日志。

以上就是本文的全部內容,對這些幫助你在 RHEL 8 / CentOS 8 系統上設置 Elastic Stack 集群的步驟,請不要猶豫分享你的反饋和意見。

via: https://www.linuxtechi.com/setup-multinode-elastic-stack-cluster-rhel8-centos8/

總結

以上所述是小編給大家介紹的在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

標簽:樂山 福州 淮安 德宏 鷹潭 安康 上海 泰安

巨人網絡通訊聲明:本文標題《在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法》,本文關鍵詞  在,RHEL8,CentOS8,上,建立,多,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法》相關的同類信息!
  • 本頁收集關于在 RHEL8 /CentOS8 上建立多節點 Elastic stack 集群的方法的相關信息資訊供網民參考!
  • 推薦文章