使用 Redis Exporter 服務監控 Redis Droplet
方法一:手動配置
我們繼續本節的手動配置方法。
創建Prometheus係統用戶和組
創建一個名為的係統用戶和組“prometheus”來管理導出器
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
下載並安裝 Redis Exporter
下載從 GitHub 提取最新版本的 Redis Exporter 下載的文件,並將二進製文件移動到 /usr/local/bin/ 目錄。
curl -s https://api.github.com/repos/oliver006/redis_exporter/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
tar xvf redis_exporter-*.linux-amd64.tar.gz
sudo mv redis_exporter-*.linux-amd64/redis_exporter /usr/local/bin/
驗證 Redis 導出器安裝
redis_exporter --version
這是示例輸出:
為 Redis Exporter 配置 systemd 服務
創建 systemd 服務單元文件來管理 Redis Exporter
sudo vim /etc/systemd/system/redis_exporter.service
將以下內容添加到file:
[Unit]Description=Prometheus Redis ExporterDocumentation=https://github.com/oliver006/redis_exporterWants=network-online.targetAfter=network-online.target[Service]Type=simpleUser=prometheusGroup=prometheusExecReload=/bin/kill -HUP $MAINPIDExecStart=/usr/local/bin/redis_exporter --log-format=txt --namespace=redis --web.listen-address=:9121 --web.telemetry-path=/metricsSyslogIdentifier=redis_exporterRestart=always[Install]WantedBy=multi-user.target
重新加載 systemd 並啟動 Redis Exporter服務
sudo systemctl daemon-reload
sudo systemctl enable redis_exporter
sudo systemctl start redis_exporter
配置 Prometheus Droplet(手動方法)
讓我們手動配置 Prometheous Droplet。
備份 prometheus.yml 文件
cp /etc/prometheus/prometheus.yml /etc/prometheus/prometheus.yml-$(date '%d%b%Y-%H:%M')
添加 Redis Exporter 端點scraped
登錄到您的 Prometheus 服務器並添加要抓取的 Redis Exporter 端點。
將 IP 地址和端口替換為您的 Redis Exporter 端點(9121 是 Redis Exporter 的默認端口)服務)。
vi /etc/prometheus/prometheus.yml
scrape_configs: - job_name: server1_db static_configs: - targets: ['10.10.1.10:9121'] labels: alias: db1 - job_name: server2_db static_configs: - targets: ['10.10.1.11:9121'] labels:
手動配置到此結束。現在,讓我們繼續基於腳本的配置。
方法 2:使用腳本進行配置
您還可以通過運行兩個腳本來實現此目的 - 一個用於目標 Droplet,另一個用於 Prometheus Droplet。
讓我們從配置目標 Droplet 開始。
通過 SSH 連接到目標Droplet。
使用以下命令下載目標配置腳本:
wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Target_Config.sh
下載腳本後,確保它具有可執行權限運行:
chmod x DO_Redis_Target_Config.sh
通過運行以下命令執行腳本:
./DO_Redis_Target_Config.sh
配置
注意:如果redis_exporter.service文件已經存在,腳本將不會運行。
配置 Prometheus Droplet(腳本方法)
SSH 到 Prometheus Droplet 並使用以下命令下載腳本:
wget https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Redis_Prometheus_Config.sh
下載腳本後,請確保它具有可執行權限運行:
chmod x DO_Redis_Prometheus_Config.sh
執行腳本running:
./DO_Redis_Prometheus_Config.sh
輸入要添加到監控的 Droplet 數量。
輸入主機名和IP地址。
配置完成。
添加後,通過訪問 URL prometheushostname:9090/targets 檢查目標是否更新。
注意:如果您輸入的 IP 地址已添加到 監控時,您將被要求再次輸入詳細信息。另外,如果 您沒有更多服務器可以添加,可以輸入 0 退出 script
配置 Grafana
通過瀏覽器訪問 Grafana-IP:3000 登錄 Grafana 儀表板。
Go到配置 > 數據來源。
單擊“添加數據源”。
搜索並選擇 Prometheus。
輸入名稱 Prometheus 和 URL (Prometheus主機名:9090)並單擊“保存並測試”。如果看到“數據源正在運行”,則說明您已成功添加數據源。完成後,轉到創建 > 導入。
您可以手動配置儀表板或通過以下方式導入儀表板 上傳 JSON 文件。用於 Redis 監控的 JSON 模板可以是 在以下鏈接中找到:
https://solutions-files.ams3.digitaloceanspaces.com/Redis-Monitoring/DO_Grafana-Redis_Monitoring.json
填寫字段並導入。
Grafana 儀表板是 準備好。選擇主機並檢查是否 指標是可見的。請隨意修改和編輯儀表板 根據需要。
以上是使用 Redis Exporter 服務監控 Redis Droplet的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

MySQL和phpMyAdmin是強大的數據庫管理工具。 1)MySQL用於創建數據庫和表、執行DML和SQL查詢。 2)phpMyAdmin提供直觀界面進行數據庫管理、表結構管理、數據操作和用戶權限管理。

Redis緩存方案如何實現產品排行榜列表的需求?在開發過程中,我們常常需要處理排行榜的需求,例如展示一個�...

Redis在數據存儲和管理中扮演著關鍵角色,通過其多種數據結構和持久化機製成為現代應用的核心。 1)Redis支持字符串、列表、集合、有序集合和哈希表等數據結構,適用於緩存和復雜業務邏輯。 2)通過RDB和AOF兩種持久化方式,Redis確保數據的可靠存儲和快速恢復。

SpringBoot中使用Redis緩存OAuth2Authorization對像在SpringBoot應用中,使用SpringSecurityOAuth2AuthorizationServer...

安全地處理JSON中的函數和正則表達式在前端開發中,經常需要將JavaScript...

在MySQL中,外鍵的作用是建立表與表之間的關係,確保數據的一致性和完整性。外鍵通過引用完整性檢查和級聯操作維護數據的有效性,使用時需注意性能優化和避免常見錯誤。

SpringBoot定時任務在多節點環境下的優化方案在開發Spring...

使用RedisTemplate進行批量查詢時為何返回值為空?在使用RedisTemplate進行批量查詢操作時,可能會遇到返回的結果�...
