## 前言
Oracle Cloud Infrastructure 會自動安裝統一的監控代理,用於收集系統指標和日誌數據。以下係呢個代理既設定與管理方法。
## 系統環境
– Oracle Cloud ARM64 實例
– Ubuntu 22.04 LTS
– Oracle 提供的 unified-monitoring-agent
## 代理簡介
Oracle Cloud 的統一監控代理係基於 Fluentd 既數據收集器,自動收集:
– CPU、記憶體、磁碟使用率
– 網絡流量
– 進程信息
– 自定義日誌
## 查看代理狀態
“`bash
# 查看服務狀態
systemctl status unified-monitoring-agent
# 查看日誌
tail -f /var/log/unified-monitoring-agent/unified-monitoring-agent.log
# 查看記憶體和 CPU 使用
systemctl status unified-monitoring-agent
“`
## 常用管理指令
“`bash
# 停止代理
sudo systemctl stop unified-monitoring-agent
# 啟動代理
sudo systemctl start unified-monitoring-agent
# 重啟代理
sudo systemctl restart unified-monitoring-agent
# 禁用代理(不推薦)
sudo systemctl disable unified-monitoring-agent
“`
## 配置位置
| 類型 | 路徑 |
|——|——|
| 服務定義 | /lib/systemd/system/unified-monitoring-agent.service |
| 配置目錄 | /etc/unified-monitoring-agent/ |
| 日誌目錄 | /var/log/unified-monitoring-agent/ |
| 數據目錄 | /var/lib/unified-monitoring-agent/ |
## 自定義監控
你可以通過配置文件自定義要收集的指標:
“`bash
# 編輯配置
sudo nano /etc/unified-monitoring-agent/agent.conf
# 重啟生效
sudo systemctl restart unified-monitoring-agent
“`
## 疑難排解
| 問題 | 解決方案 |
|——|———-|
| 代理無法啟動 | 檢查日誌 `/var/log/unified-monitoring-agent/` |
| 記憶體佔用高 | Fluentd 可能需要調整緩衝設置 |
| 無法發送數據 | 檢查網絡和防火牆設定 |
## 效能優化
“`bash
# 限制記憶體使用
sudo systemctl edit unified-monitoring-agent
# 添加:
[Service]
MemoryMax=500M
“`
## 與 Oracle Cloud Console 整合
代理收集的數據可以在 Oracle Cloud Console 查看:
1. 登入 Oracle Cloud Console
2. 進入「監控」>「指標」
3. 選擇你的實例
4. 查看收集的指標
## 總結
Oracle 的統一監控代理係 Oracle Cloud 基礎設施既重要組成部分,提供免費且穩定的監控服務。建議保持啟用狀態以便及時發現問題。