Apigee Edge for Private Cloud 包含 apigee-monit,這是以開放原始碼為基礎的工具
monit 公用程式。定期apigee-monit
輪詢 Edge 服務如果某項服務無法使用,則 apigee-monit 會嘗試重新啟動。
如要使用 apigee-monit,您必須手動安裝。但不屬於
標準安裝
根據預設,apigee-monit 每 60 秒會檢查 Edge 服務的狀態。
快速入門
本節說明如何快速開始使用 apigee-monit。
如果您使用的是 Amazon Linux,請先安裝 Fedora。否則請略過這個步驟。
sudo yum install -y https://kojipkgs.fedoraproject.org/packages/monit/5.25.1/1.el6/x86_64/monit-5.25.1-1.el6.x86_64.rpm
如要安裝 apigee-monit,請按照下列步驟操作:
安裝「apigee-monit」 |
|
/opt/apigee/apigee-service/bin/apigee-service apigee-monit install 在預設情況下,系統會安裝 |
|
| 停止監控元件 | |
/opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c component_name /opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c all |
|
| 開始監控元件 | |
/opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor -c component_name /opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor -c all |
|
| 取得摘要狀態資訊 | |
/opt/apigee/apigee-service/bin/apigee-service apigee-monit report /opt/apigee/apigee-service/bin/apigee-service apigee-monit summary |
|
查看 apigee-monit 記錄檔 |
|
cat /opt/apigee/var/log/apigee-monit/apigee-monit.log |
以下各節將詳細說明這些主題和其他資訊。
Apigee-monit 簡介
apigee-monit 可確保節點上的所有元件都能正常運作。做法是
提供服務,包括:
- 重新啟動失敗的服務
- 顯示摘要資訊
- 記錄監控狀態
- 傳送通知
- 監控非邊緣服務
Apigee 建議您監控 apigee-monit,確保它正在執行。如需更多資訊
請參閱監控 apigee-monit。
Apigee-monit 架構
在 Apigee Edge for Private Cloud 安裝和設定期間,您可以選擇安裝個別執行個體
叢集內每個節點的 apigee-monit 權限。這些獨立的 apigee-monit 執行個體獨立於 1 個執行個體中運作
另一個:容器不會將其元件狀態傳送給其他節點,也不會
將監控公用程式本身的故障狀態傳送到任何中央服務。
下圖顯示 5 節點叢集中的 apigee-monit 架構:
apigee-monit 的獨立執行個體會在叢集中的每個節點獨立執行
叢集支援的平台
apigee-monit 支援下列私有雲叢集的平台。(支援的作業系統
apigee-monit 會因 Private Cloud 的版本而異。)
| 作業系統 | 私有雲版本 | ||
|---|---|---|---|
| v4.50.00 | v4.51.00 | v4.52.00 | |
| CentOS | 7.5、7.6、7.7、7.8 | 7.5、7.6、7.7、7.8 | 7.5、7.6、7.7、7.8 |
| RedHat Enterprise Linux (RHEL) | 7.5、7.6、7.7、7.8 | 7.5、7.6、7.7、7.8、7.9、8.0 | 7.5、7.6、7.7、7.8、7.9、8.0 |
| Oracle Linux | 7.5、7.6、7.7、7.8 | 7.5、7.6、7.7、7.8 | 7.5、7.6、7.7、7.8 |
* 雖然我們不提供技術支援,但您可以安裝並使用
apigee-monit (適用於 Apigee Edge 私有雲版本 4.19.01) 的 CentOS/RHEL/Oracle 6.9 版。 |
|||
元件設定
apigee-monit 會根據元件設定判斷要監控的元件,
要檢查的元件各方面,以及發生錯誤時要採取的行動。
根據預設,apigee-monit 會使用預先定義的元件監控節點上的所有 Edge 元件
儲存空間設定如要查看預設設定,您可以查看 apigee-monit 元件設定
檔案。您無法變更預設元件設定。
apigee-monit 會根據元件檢查的元件,檢查元件的不同面向。
下表列出 apigee-monit 會檢查每個元件的項目,並列出元件的位置
每個元件都有各自的特性請注意,某些元件是以單一設定定義
檔案,其他電腦則有自己的設定。
| 元件 | 設定位置 | 監控的內容 |
|---|---|---|
| 管理伺服器 | /opt/apigee/edge-management-server/monit/default.conf |
apigee-monit 檢查:
此外,針對這些元件
|
| 訊息處理器 | /opt/apigee/edge-message-processor/monit/default.conf |
|
| Postgres 伺服器 | /opt/apigee/edge-postgres-server/monit/default.conf |
|
| Qpid 伺服器 | /opt/apigee/edge-qpid-server/monit/default.conf |
|
| 路由器 | /opt/apigee/edge-router/monit/default.conf |
|
| Cassandra Edge UI OpenLDAP Postgres Qpid 動物守護者 |
/opt/apigee/data/apigee-monit/monit.conf |
apigee-monit 檢查:
|
以下範例顯示 edge-router 的預設元件設定
元件:
check host edge-router with address localhost restart program = "/opt/apigee/apigee-service/bin/apigee-service edge-router monitrestart" if failed host 10.1.1.0 port 8081 and protocol http and request "/v1/servers/self/uuid" with timeout 15 seconds for 2 times within 3 cycles then restart if failed port 15999 and protocol http and request "/v1/servers/self" and status < 600 with timeout 15 seconds for 2 times within 3 cycles then restart
以下範例顯示傳統版 UI (edge-ui) 的預設設定
元件:
check process edge-ui with pidfile /opt/apigee/var/run/edge-ui/edge-ui.pid start program = "/opt/apigee/apigee-service/bin/apigee-service edge-ui start" with timeout 55 seconds stop program = "/opt/apigee/apigee-service/bin/apigee-service edge-ui stop"
這適用於傳統版 UI,不適用於元件名稱如下的新版 Edge UI
edge-management-ui。
您無法變更任何 Apigee Edge for Private Cloud 元件的預設元件設定。你可以
但是,新增您自己的外部服務元件設定,如您的目標端點
或 httpd 服務。若需更多資訊,請參閲
非 Apigee 元件設定。
根據預設,apigee-monit 會監控執行節點的所有元件。您可以選擇啟用或
並為所有元件或個別元件停用這項功能。如需詳細資訊,請參閱:
安裝 apigee-monit
預設未安裝「apigee-monit」。可以在升級或安裝完成後,手動安裝
適用於 Private Cloud 的 Apigee Edge 4.19.01 以上版本。
本節說明如何將 apigee-monit 支援的
平台。
如要瞭解如何解除安裝 apigee-monit,請參閱
解除安裝 apigee-monit。
在支援的平台上安裝 apigee-monit
本節說明如何在支援的平台上安裝 apigee-monit。
如何在支援的平台上安裝「apigee-monit」:
- 使用下列指令安裝
apigee-monit:/opt/apigee/apigee-service/bin/apigee-service apigee-monit install
- 使用下列指令設定
apigee-monit:/opt/apigee/apigee-service/bin/apigee-service apigee-monit configure
- 使用下列指令啟動
apigee-monit:/opt/apigee/apigee-service/bin/apigee-service apigee-monit start
- 對叢集中的每個節點重複這項程序。
停止及開始監控元件
當服務因故停止,apigee-monit 會嘗試重新啟動服務。
如果您要「刻意」停止元件,這可能會造成問題。舉例來說
在需要備份或升級元件時。
如果 apigee-monit 在備份或升級期間重新啟動服務,你的維護程序可能會
也可能因此失敗
下列各節說明停止監控元件的選項。
停止並取消監控元件
如要停止並取消監控元件,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit stop-component -c component_name
apigee-cassandra(Cassandra)apigee-openldap(OpenLDAP)apigee-postgresql(PostgreSQL 資料庫)apigee-qpidd(魁北克)apigee-sso(邊緣單一登入)apigee-zookeeper(ZooKeeper)edge-management-server(管理伺服器)edge-management-ui(新版 Edge UI)edge-message-processor(訊息處理器)edge-postgres-server(Postgres 伺服器)edge-qpid-server(快速伺服器)edge-router(邊緣路由器)edge-ui(傳統版 UI)
請注意,「all」「stop-component」不是有效選項。您可以停止並
使用 stop-component 一次取消監控一個元件。
如要重新啟動元件並繼續監控,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit start-component -c component_name
請注意,「all」「start-component」不是有效選項。
如需停止和取消監控所有元件的操作說明,請參閱 停止所有元件並取消監控。
取消監控元件 (但不要停止)
如要取消監控元件 (但不要停止),請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c component_name
apigee-cassandra(Cassandra)apigee-openldap(OpenLDAP)apigee-postgresql(PostgreSQL 資料庫)apigee-qpidd(魁北克)apigee-sso(邊緣單一登入)apigee-zookeeper(ZooKeeper)edge-management-server(管理伺服器)edge-management-ui(新版 Edge UI)edge-message-processor(訊息處理器)edge-postgres-server(Postgres 伺服器)edge-qpid-server(快速伺服器)edge-router(邊緣路由器)edge-ui(傳統版 UI)
如要繼續監控元件,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor -c component_name
取消監控所有元件 (但不要停止這些元件)
如要取消監控所有元件 (但不停止元件),請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c all
如要繼續監控所有元件,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor -c all
停止所有元件並取消監控
如要停止所有元件並取消監控元件,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c all
/opt/apigee/apigee-service/bin/apigee-all stop如要重新啟動所有元件並繼續監控,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-all start
/opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor -c all如要停止監控所有元件,您也可以停用 apigee-monit,如下所述
停止、啟動及停用 apigee-monit。
停止、啟動及停用 apigee-monit
與任何服務一樣,您可以使用 apigee-service 停止及啟動 apigee-monit。
指令此外,apigee-monit 支援 unmonitor 指令,可讓您
暫時停止監控元件
停止 apigee-monit
如要停止 apigee-monit,請使用下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit stop
啟動 Apigee-monit
如要啟動 apigee-monit,請使用下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit start
停用 apigee-monit
您可以使用下列指令,暫停監控節點上的所有元件:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit unmonitor -c all
或者,您也可以按照所述,永久停用 apigee-monit,將其從節點中解除安裝
請參閱「解除安裝 apigee-monit」一文。
解除安裝 apigee-monit
如何解除安裝 apigee-monit:
- 編輯下列檔案:
/opt/apigee/customer/application/monit.properties
如果檔案不存在,請建立該檔案,並將擁有者設為「apigee」使用者:
chown apigee:apigee /opt/apigee/customer/application/monit.properties
請注意,如果檔案已存在,可能需定義其他設定屬性 。除了 以上列出的各種信號
請使用新的值設定或替換屬性值。
舉例來說,如要將記錄檔的位置變更為
/tmp,請新增或編輯 屬性:conf_monit_monit_logdir=/tmp/apigee-monit.log
- 將變更儲存至
monit.properties檔案。 - 使用下列指令重新載入
apigee-monit:/opt/apigee/apigee-service/bin/apigee-service apigee-monit reload
如果
apigee-monit未重新啟動,請按照 存取apigee-monit記錄檔。 - 針對叢集中的每個節點重複執行這項程序。
- 複製
apigee-monit.cron來新增cron支援 目錄複製到/etc/cron.d目錄,如以下範例所示:cp /opt/apigee/apigee-monit/cron/apigee-monit.cron /etc/cron.d/
- 開啟
apigee-monit.cron檔案進行編輯。apigee-monit.cron檔案會定義要執行的cron工作 以及執行工作的頻率以下範例顯示預設 值:# Cron entry to check if monit process is running. If not start it */2 * * * * root /opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor_monit
此檔案使用下列語法,其中前五個欄位定義了
apigee-monit會執行其動作:min hour day_of_month month day_of_week task_to_execute
例如,預設的執行時間為
*/2 * * * *,會指示cron每隔 2 分鐘檢查apigee-monit程序。每分鐘無法執行超過一次
cron工作。如要進一步瞭解如何使用
cron,請參閱伺服器 OS 的說明文件或管理人員 網頁。 - 請根據貴機構的政策變更
cron設定。舉例來說 請將執行頻率變更為每 5 分鐘一次,並將工作定義設為:*/5 * * * * root /opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor_monit
- 儲存
apigee-monit.cron檔案。 - 針對叢集中的每個節點重複執行這項程序。
cron工作定義後方有空白行。- 檔案中只定義一項
cron工作。(加註行不可 count.) - 刪除
/etc/cron.d/apigee-monit.cron檔案:sudo rm /etc/cron.d/apigee-monit.cron
如果您執行以下動作,必須重新複製副本: 稍後,您想要重新啟用「
cron」才能觀看「apigee-monit」。或
- 編輯
/etc/cron.d/apigee-monit.cron檔案,為工作加上註解 方法是在結尾加上「#」行開頭;例如:# 10 * * * * root /opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor_monit
conf_monit_httpd_porthttpd Daemon 的通訊埠。apigee-monit 使用 httpd 做為資訊主頁
及啟用報告/摘要。預設值為 2812。
conf_monit_httpd_allowhttpd Daemon 的要求限制。apigee-monit 使用
httpd 執行其資訊主頁應用程式並啟用報告/摘要。這個值必須
指向 localhost (執行 httpd 的主機)。
如要規定要求必須包含使用者名稱和密碼,請使用以下語法:
conf_monit_httpd_allow=allow username:"password"\nallow 127.0.0.1
新增使用者名稱和密碼時,請插入「\n」。禁止事項 在值中插入實際的換行符號或回車字元。
conf_monit_monit_datadirconf_monit_monit_delay_timeapigee-monit 首次載入記憶體後,要等待的時間長度
或任何可執行 Knative 的環境中這只會影響第 apigee-monit 項程序檢查。conf_monit_monit_logdirapigee-monit 記錄檔的位置。conf_monit_monit_retry_timeapigee-monit 嘗試檢查每個程序的頻率。預設值為 60
秒內請求驗證碼。conf_monit_monit_rundirapigee-monit 會用來檢查程序。如何自訂預設的 apigee-monit 控制項設定:
請注意,這僅適用於非邊緣元件。您無法自訂元件設定 適用於 Edge 元件
存取 Apigee-monit 記錄檔
apigee-monit 會記錄所有活動,包括事件、重新啟動、設定變更和快訊
檔案。
記錄檔的預設位置為:
/opt/apigee/var/log/apigee-monit/apigee-monit.log
您可以透過自訂 apigee-monit 控制項,變更預設位置
設定。
記錄檔項目格式如下:
'edge-message-processor' trying to restart [UTC Dec 14 16:20:42] info : 'edge-message-processor' trying to restart 'edge-message-processor' restart: '/opt/apigee/apigee-service/bin/apigee-service edge-message-processor monitrestart'
您無法自訂 apigee-monit 記錄檔項目的格式。
透過 Apigee-monit 查看匯總狀態
apigee-monit 包含下列指令,可提供針對
執行節點:
| 指令 | 用量 |
|---|---|
report |
/opt/apigee/apigee-service/bin/apigee-service apigee-monit report |
summary |
/opt/apigee/apigee-service/bin/apigee-service apigee-monit summary |
我們會在下文各節中詳細說明上述每個指令。
報表
report 指令會提供所包含元件的匯總摘要。
當機、目前正在初始化,或目前在節點上未受監控。
下列範例叫用 report 指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit report
以下範例顯示 AIO (全方位功能) 上的 report 輸出內容
設定:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit report up: 11 (100.0%) down: 0 (0.0%) initialising: 0 (0.0%) unmonitored: 1 (8.3%) total: 12 services
在這個例子中,「apigee-monit」回報 12 項服務中有 11 項處於「當機」狀態,一項服務
監控資源
首次執行Connection refused
report 指令。在這種情況下,請等待
conf_monit_monit_delay_time 屬性,然後再試一次。
摘要
summary 指令會列出每個元件並提供其狀態。下列
範例叫用 summary 指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit summary
以下範例顯示 AIO (全方位功能) 上的 summary 輸出內容
設定:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit summary Monit 5.25.1 uptime: 4h 20m Service Name Status Type host_name OK System apigee-zookeeper OK Process apigee-cassandra OK Process apigee-openldap OK Process apigee-qpidd OK Process apigee-postgresql OK Process edge-ui OK Process edge-qpid-server OK Remote Host edge-postgres-server OK Remote Host edge-management-server OK Remote Host edge-router OK Remote Host edge-message-processor OK Remote Host
如果您在首次執行Connection refused
summary 指令,請嘗試等待
conf_monit_monit_delay_time 屬性,然後再試一次。
監控 Apigee-monit
最佳做法是定期檢查 apigee-monit 是否在每個節點上執行。
如要檢查 apigee-monit 是否正在執行,請使用下列指令:
/opt/apigee/apigee-service/bin/apigee-service apigee-monit monitor_monit
Apigee 建議您定期在執行 apigee-monit 的每個節點上發出這個指令。
其中一種方法是利用 cron 等公用程式,在以下時間執行排定的工作:
預先定義的間隔
如何使用 cron 監控 apigee-monit:
如果 cron 並未開始觀看 apigee-monit,請檢查以下事項:
如要停止或暫時停用 apigee-monit,您必須停用這項 cron 工作。
也會使 cron 重新啟動 apigee-monit。
如要停用 cron,請執行下列其中一項操作: