本文件說明 Apigee Edge for Private Cloud 地端部署支援的元件監控技術。
總覽
Edge 支援多種方式,可取得服務詳細資料及檢查服務狀態。下表列出您可對各項適用服務執行的檢查類型:
| 管理 API | |||||||
| 元件 | 記憶體用量 [JMX*] | 服務檢查 | 使用者/機構/ 部署狀態 | axstatus | 資料庫檢查 | 「apigee-service」狀態 |
apigee-monit** |
| 管理伺服器 | |||||||
| 訊息處理器 | |||||||
| 路由器 | |||||||
| Qpid | |||||||
| Postgres | |||||||
| 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | |
|
* 如要使用 JMX,請務必先啟用這項功能,詳情請參閱「啟用 JMX」一文。 ** |
|||||||
監控通訊埠和設定檔
每個元件都支援 Java 管理擴充功能 (JMX) 和管理 API 監控呼叫 (位於不同連接埠)。下表列出各類型伺服器的 JMX 和 Management API 連接埠,以及設定檔位置:
| 元件 | JMX 連接埠 | Management API 通訊埠 | 設定檔位置 |
|---|---|---|---|
| 管理伺服器 | 1099 | 8080 | $APIGEE_ROOT/customer/application/management-server.properties |
| 訊息處理器 | 1101 | 8082 | $APIGEE_ROOT/customer/application/message-processor.properties |
| 路由器 | 1100 | 8081 | $APIGEE_ROOT/customer/application/router.properties |
| Qpid | 1102 | 8083 | $APIGEE_ROOT/customer/application/qpid-server.properties |
| Postgres | 1103 | 8084 | $APIGEE_ROOT/customer/application/postgres-server.properties |
使用 JMX 監控元件
以下各節說明如何使用 JMX 監控 Edge 元件。
啟用 JMX
如要啟用 JMX,但不要驗證或以 SSL 為基礎的通訊,請按照下列步驟操作。 注意:在正式環境系統中,應同時啟用加密驗證和 SSL,以確保安全性。
- 編輯適當的設定檔 (請參閱
設定檔參考資料)。如果設定檔不存在,請建立該檔案。
conf_system_jmxremote_enable=true
- 儲存設定檔,並確認擁有者為
apigee:apigee。 - 重新啟動適當的 Edge 元件
apigee-service edge-management-server restart
如要停用 JMX,請移除 conf_system_jmxremote_enable 屬性,或將其值變更為 false。然後重新啟動適當的 Edge 元件。
JMX 中的驗證
Edge for Private Cloud 支援以密碼為基礎的驗證,並使用儲存在檔案中的詳細資料。您可以將密碼儲存為雜湊值,進一步提升安全性。
- 如要在 edge-* 元件中啟用 JMX 驗證,請編輯適當的設定檔 (請參閱「
設定檔參考資料」)。如果設定檔不存在,請建立設定檔:
儲存設定檔,並確認擁有者為conf_system_jmxremote_enable=true conf_system_jmxremote_authenticate=true conf_system_jmxremote_encrypted_auth=true conf_system_jmxremote_access_file=/opt/apigee/customer/application/management-server/jmxremote.access conf_system_jmxremote_password_file=/opt/apigee/customer/application/management-server/jmxremote.password
apigee:apigee。 - 建立密碼的 SHA256 雜湊:
echo -n '
' | openssl dgst -sha256 - 建立含有 JMX 使用者憑證的
jmxremote.password檔案:- 將下列檔案從
$JAVA_HOME目錄複製到/opt/apigee/customer/application/<component>/目錄:cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/customer/application/management-server/jmxremote.password - 編輯檔案,並使用下列語法新增 JMX 使用者名稱和密碼:
USERNAME <HASH-PASSWORD>
- 確認檔案擁有者為
apigee,且檔案模式為 400:chown apigee:apigee $APIGEE_ROOT/customer/application/management-server/jmxremote.password chmod 400 $APIGEE_ROOT/customer/application/management-server/jmxremote.password
- 將下列檔案從
- 建立具有 JMX 使用者權限的
jmxremote.access檔案:- 將 $JAVA_HOME 目錄中的下列檔案複製到
/opt/apigee/customer/application/<component>/目錄:cp ${JAVA_HOME}/lib/management/jmxremote.access $APIGEE_ROOT/customer/application/management-server/jmxremote.access - 編輯檔案,並依序新增 JMX 使用者名稱和權限 (READONLY/READWRITE)
USERNAME READONLY
- 請確認檔案擁有者為
apigee,且檔案模式為 400:chown apigee:apigee $APIGEE_ROOT/customer/application/management-server/jmxremote.access chmod 400 $APIGEE_ROOT/customer/application/management-server/jmxremote.access
- 將 $JAVA_HOME 目錄中的下列檔案複製到
- 重新啟動適當的 Edge 元件:
apigee-service edge-management-server restart
如要停用 JMX 驗證,請移除 conf_system_jmxremote_authenticate 屬性,或將值變更為 false,然後重新啟動適當的 Edge 元件。
JMX 中的 SSL
如要在 edge-* 元件中啟用以 SSL 為基礎的 JMX,請按照下列步驟操作:
- 編輯適當的設定檔 (請參閱「
設定檔參考資料」)。如果設定檔不存在,請建立設定檔:
儲存設定檔,並確認擁有者為conf_system_jmxremote_enable=true conf_system_jmxremote_ssl=true conf_system_javax_net_ssl_keystore=/opt/apigee/customer/application/management-server/jmxremote.keystore conf_system_javax_net_ssl_keystorepassword=<keystore-password>
apigee:apigee。 - 準備包含伺服器金鑰的 KeyStore,並將其放在上述設定
conf_system_javax_net_ssl_keystore中提供的路徑。確認apigee:apigee可讀取金鑰存放區檔案。 - 重新啟動適當的 Edge 元件:
apigee-service edge-management-server restart
如要停用 SSL 型 JMX,請移除 conf_system_jmxremote_ssl 屬性,或將值變更為 false。重新啟動適當的 Edge 元件。
使用 JConsole 監控
使用 JConsole (符合 JMX 規範的工具) 管理及監控健康狀態檢查和程序統計資料。 您可以使用 JConsole 擷取伺服器公開的 JMX 統計資料,並以圖形介面顯示這些資料。詳情請參閱「使用 JConsole」。
如果為 JMX 啟用 安全資料傳輸層:SSL,您必須使用 信任儲存庫 和 信任儲存庫 密碼啟動 JConsole。請參閱「 使用 JConsole」。
JConsole 會使用下列服務網址,監控透過 JMX 提供的 JMX 屬性 (MBeans):
service:jmx:rmi:///jndi/rmi://IP_address:port_number/jmxrmi
其中:
- IP_address 是要監控的伺服器 IP 位址。
- port_number 是要監控的伺服器 JMX 通訊埠編號。
舉例來說,如要監控管理伺服器,請發出類似下列的指令 (假設伺服器的 IP 位址為 216.3.128.12):
service:jmx:rmi:///jndi/rmi://216.3.128.12:1099/jmxrmi
請注意,這個範例指定了通訊埠 1099,也就是管理伺服器 JMX 通訊埠。如需其他通訊埠,請參閱「JMX 和 Management API 監控通訊埠」。
下表列出一般 JMX 統計資料:
| JMX MBean | JMX 屬性 |
|---|---|
|
記憶體 |
HeapMemoryUsage |
|
NonHeapMemoryUsage |
|
|
用量 |
|
設定檔參考資料
以下各節說明您可能需要對 Edge 元件設定檔進行的變更,以設定 JMX 相關設定。詳情請參閱「監控通訊埠和設定檔」。
要新增至適當元件設定檔的 JMX 設定
- 在邊緣元件上啟用 JMX 代理程式。預設為 False。
conf_system_jmxremote_enable=true
密碼驗證設定
- 啟用密碼驗證。預設為 False。
conf_system_jmxremote_authenticate=true
- 存取檔案的路徑。只能由 Apigee 使用者擁有及讀取。
conf_system_jmxremote_access_file=/opt/apigee/customer/application/management-server/jmxremote.access
- 密碼檔案的路徑。僅限 Apigee 使用者擁有及讀取。
conf_system_jmxremote_password_file=/opt/apigee/customer/application/management-server/jmxremote.password
- 啟用以加密格式儲存密碼的功能。預設值為 False。
conf_system_jmxremote_encrypted_auth=true
以 SSL 為基礎的 JMX 設定
- 啟用 JMX 通訊的 SSL。預設為 False。
conf_system_jmxremote_ssl=true
- KeyStore 的路徑。只能由 Apigee 使用者擁有及讀取。
conf_system_javax_net_ssl_keystore=/opt/apigee/customer/application/management-server/jmxremote.keystore
- 金鑰儲存庫密碼:
conf_system_javax_net_ssl_keystorepassword=changeme
選用 JMX 設定
列出的值為預設值,可以變更。
- JMX 通訊埠。預設值列於下表。
conf_system_jmxremote_port=
- JMX RMI 通訊埠。根據預設,Java 程序會選取隨機通訊埠。
conf_system_jmxremote_rmi_port=
- 遠端虛設常式的主機名稱。localhost 的預設 IP 位址。
conf_system_java_rmi_server_hostname=
- 使用 SSL 保護 JMX 登錄檔。預設值為 false。只有在啟用 SSL 時才適用。
conf_system_jmxremote_registry_ssl=false
使用 Management API 監控
Edge 包含多個 API,可用於對伺服器執行服務檢查,以及檢查使用者、機構和部署作業。本節將說明這些 API。
執行服務檢查
Management API 提供多個端點,可用於監控及診斷服務問題。這些端點包括:
| 端點 | 說明 |
|---|---|
/servers/self/up |
檢查服務是否正在執行。您不需要驗證即可呼叫這個 API。 如果服務正在執行,這個端點會傳回下列回應: <ServerField> <Up>true</Up> </ServerField> 如果服務未執行,您會收到類似下列的回應 (視服務和檢查方式而定): curl: Failed connect to localhost:port_number; Connection refused |
/servers/self |
傳回服務相關資訊,包括:
您必須使用 Apigee 管理員憑證進行驗證,才能呼叫這個 API。 |
如要使用這些端點,請叫用 curl 等公用程式,並使用下列語法的指令:
curl http://host:port_number/v1/servers/self/up -H "Accept: [application/json|application/xml]"
curl http://host:port_number/v1/servers/self -u username:password -H "Accept: [application/json|application/xml]"其中:
- host 是要檢查的伺服器 IP 位址。如果已登入伺服器,可以使用「localhost」;否則請指定伺服器的 IP 位址,以及使用者名稱和密碼。
- port_number 是要檢查的伺服器 Management API 通訊埠。每種元件的通訊埠都不同。舉例來說,管理伺服器的 Management API 連接埠為 8080。如需可使用的 Management API 埠號清單,請參閱「JMX 和 Management API 監控埠」。
如要變更回應格式,可以將 Accept 標頭指定為「application/json」或「application/xml」。
以下範例會取得 localhost (通訊埠 8081) 上的路由器狀態:
curl http://localhost:8081/v1/servers/self/up -H "Accept: application/xml"
以下範例會取得 216.3.128.12 (通訊埠 8082) 的訊息處理器相關資訊:
curl http://216.3.128.12:8082/v1/servers/self -u sysAdminEmail:password -H "Accept: application/xml"
監控使用者、機構和部署狀態
您可以發出下列指令,使用 Management API 監控管理伺服器和訊息處理器的 Proxy 使用者、機構和部署狀態:
curl http://host:port_number/v1/users -u sysAdminEmail:passwordcurl http://host:port_number/v1/organizations -u sysAdminEmail:passwordcurl http://host:port_number/v1/organizations/orgname/deployments -u sysAdminEmail:password
其中 port_number 是管理伺服器的 8080,或是訊息處理器的 8082。
這項呼叫需要您使用系統管理使用者名稱和密碼進行驗證。
伺服器應為所有呼叫傳回「已部署」狀態。如果上述方法無效,請按照下列步驟操作:
- 查看伺服器記錄,瞭解是否有任何錯誤。記錄檔位於:
- 管理伺服器:
opt/apigee/var/log/edge-management-server - 訊息處理器:
opt/apigee/var/log/edge-message-processor
- 管理伺服器:
- 呼叫伺服器,檢查是否正常運作。
- 從 ELB 移除伺服器,然後重新啟動:
/opt/apigee/apigee-service/bin/apigee-service service_name restart
其中 service_name 為:
edge-management-serveredge-message-processor
使用 apigee-service 指令檢查狀態
登入執行服務的伺服器後,即可使用 apigee-service 指令排解 Edge 服務問題。
如要使用 apigee-service 檢查服務狀態,請按照下列步驟操作:
- 登入伺服器並執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service service_name status
其中 service_name 為下列其中一項:
- 管理伺服器:
edge-management-server - 訊息處理器:
edge-message-processor - Postgres:
edge-postgres-server - Qpid:
edge-qpid-server - 路由器:
edge-router
例如:
/opt/apigee/apigee-service/bin/apigee-service edge-message-processor status
- 管理伺服器:
- 如果服務未執行,請啟動服務:
/opt/apigee/apigee-service/bin/apigee-service service_name start
- 重新啟動服務後,請使用先前用過的
apigee-service status指令,或「使用 Management API 監控」一節所述的 Management API,確認服務是否正常運作。例如:
curl -v http://localhost:port_number/v1/servers/self/up
其中 port_number 是服務的Management API 通訊埠。
這個範例假設您已登入伺服器,且可以使用「localhost」做為主機名稱。如要使用 Management API 遠端檢查狀態,您必須指定伺服器的 IP 位址,並在 API 呼叫中加入系統管理員使用者名稱和密碼。
Postgres 監控
Postgres 支援多種公用程式,可用於檢查狀態。後續章節將說明這些公用程式。
檢查 Postgres 上的組織和環境
您可以發出下列 curl 指令,檢查 Postgres 伺服器上已上線的組織和環境名稱:
curl -v http://postgres_IP:8084/v1/servers/self/organizations
系統應會顯示組織和環境名稱。
驗證數據分析狀態
您可以發出下列 curl 指令,驗證 Postgres 和 Qpid 分析伺服器的狀態:
curl -u userEmail:password http://host:port_number/v1/organizations/orgname/environments/envname/provisioning/axstatus
系統應會顯示所有數據分析伺服器的成功狀態,如以下範例所示:
{
"environments" : [ {
"components" : [ {
"message" : "success at Thu Feb 28 10:27:38 CET 2013",
"name" : "pg",
"status" : "SUCCESS",
"uuid" : "[c678d16c-7990-4a5a-ae19-a99f925fcb93]"
}, {
"message" : "success at Thu Feb 28 10:29:03 CET 2013",
"name" : "qs",
"status" : "SUCCESS",
"uuid" : "[ee9f0db7-a9d3-4d21-96c5-1a15b0bf0adf]"
} ],
"message" : "",
"name" : "prod"
} ],
"organization" : "acme",
"status" : "SUCCESS"
}PostgreSQL 資料庫
本節說明專門用於監控 Postgres 資料庫的技術。
使用 check_postgres.pl 指令碼
如要監控 PostgreSQL 資料庫,可以使用標準監控指令碼 check_postgres.pl。詳情請參閱 http://bucardo.org/wiki/Check_postgres。
執行指令碼前的注意事項:
- 您必須在每個 Postgres 節點上安裝 check_postgres.pl 指令碼。
- 確認您已安裝
perl-Time-HiRes.x86_64,這是一個 Perl 模組,可實作高解析度鬧鐘、睡眠、gettimeofday 和間隔計時器。舉例來說,您可以使用下列指令安裝:
yum install perl-Time-HiRes.x86_64
- CentOS 7:在 CentOS 7 版上使用 check_postgres.pl 之前,請先安裝
perl-Data-Dumper.x86_64RPM。
check_postgres.pl 輸出
使用 check_postgres.pl 的 API 呼叫預設輸出內容與 Nagios 相容。安裝指令碼後,請進行下列檢查:
- 檢查資料庫大小:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -include=apigee -action database_size --warning='800 GB' --critical='900 GB'
- 檢查資料庫的傳入連線數量,並與允許的連線數量上限進行比較:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action backends
- 檢查資料庫是否正在執行且可用:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action connection
- 檢查磁碟空間:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action disk_space --warning='80%' --critical='90%'
- 檢查 Postgres 節點中已上線的組織和環境數量:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action=custom_query --query="select count(*) as result from pg_tables where schemaname='analytics' and tablename like '%fact'" --warning='80' --critical='90' --valtype=integer
執行資料庫檢查
您可以確認 PostgreSQL 資料庫中是否已建立適當的資料表。使用下列指令登入 PostgreSQL 資料庫:
psql -h /opt/apigee/var/run/apigee-postgresql/ -U apigee -d apigee
接著執行下列指令:
\d analytics."org.env.fact"
檢查 postgres 程序健康狀態
您可以在 Postgres 機器上叫用下列 curl 指令,執行 API 檢查:
curl -v http://postgres_IP:8084/v1/servers/self/health
如果 postgres 程序處於啟用狀態,這個指令會傳回 ACTIVE 狀態。如果 Postgres 程序未啟動並執行,則會傳回 INACTIVE 狀態。
Postgres 資源
如要進一步瞭解如何監控 Postgres 服務,請參閱下列文章:
- http://www.postgresql.org/docs/9.0/static/monitoring.html
- http://www.postgresql.org/docs/9.0/static/diskusage.html
- http://bucardo.org/check_postgres/check_postgres.pl.html
Apache Cassandra
Cassandra 預設會啟用 JMX,且遠端 JMX 存取 Cassandra 時不需要密碼。
為 Cassandra 啟用 JMX 驗證
您可以為 Cassandra 啟用 JMX 驗證。完成後,您必須將使用者名稱和密碼傳遞至 nodetool 公用程式的所有呼叫。
如要為 Cassandra 啟用 JMX 驗證:
- 建立及編輯
cassandra.properties檔案:- 編輯
/opt/apigee/customer/application/cassandra.properties檔案。如果檔案不存在,請建立檔案。 - 在檔案中新增下列內容:
conf_cassandra_env_com.sun.management.jmxremote.authenticate=true conf_cassandra_env_com.sun.management.jmxremote.password.file=${APIGEE_ROOT}/customer/application/apigee-cassandra/jmxremote.password conf_cassandra_env_com.sun.management.jmxremote.access.file=${APIGEE_ROOT}/customer/application/apigee-cassandra/jmxremote.access
- 儲存
cassandra.properties檔案。 - 將檔案擁有者變更為
apigee:apigee,如以下範例所示:chown apigee:apigee /opt/apigee/customer/application/cassandra.properties
如要進一步瞭解如何使用屬性檔案設定權杖,請參閱「如何設定 Edge」。
- 編輯
- 建立及編輯
jmx_auth.sh:- 如果下列位置沒有檔案,請建立檔案:
/opt/apigee/customer/application/jmx_auth.sh
- 在檔案中新增下列屬性:
export CASS_JMX_USERNAME=JMX_USERNAME export CASS_JMX_PASSWORD=JMX_PASSWORD
- 儲存
jmx_auth.sh檔案。 - 取得檔案來源:
source /opt/apigee/customer/application/jmx_auth.sh
- 如果下列位置沒有檔案,請建立檔案:
- 複製並編輯
jmxremote.password檔案:- 將下列檔案從
$JAVA_HOME目錄複製到/opt/apigee/customer/application/apigee-cassandra/:cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.password - 編輯
jmxremote.password檔案,並使用下列語法新增 JMX 使用者名稱和密碼:JMX_USERNAME JMX_PASSWORD
其中 JMX_USERNAME 和 JMX_PASSWORD 是您先前設定的 JMX 使用者名稱和密碼。
- 確認檔案擁有者為「apigee」,且檔案模式為 400:
chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/jmxremote.password
chmod 400 /opt/apigee/customer/application/apigee-cassandra/jmxremote.password
- 將下列檔案從
- 複製並編輯
jmxremote.access檔案:- 將
$JAVA_HOME目錄中的下列檔案複製到/opt/apigee/customer/application/apigee-cassandra/:cp ${JAVA_HOME}/lib/management/jmxremote.access$APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.access - 編輯
jmxremote.access檔案,並新增下列角色:JMX_USERNAME readwrite
- 確認檔案擁有者為「apigee」,且檔案模式為 400:
chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/jmxremote.access
chmod 400 /opt/apigee/customer/application/apigee-cassandra/jmxremote.access
- 將
- 在 Cassandra 上執行
configure:/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
- 重新啟動 Cassandra:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
- 對所有其他 Cassandra 節點重複執行這個程序。
啟用 JMX 密碼加密
如要啟用 JMX 密碼加密功能,請按照下列步驟操作:
- 開啟
source/conf/casssandra-env.sh檔案。 - 建立及編輯
cassandra.properties檔案:- 編輯
/opt/apigee/customer/application/cassandra.properties檔案。如果檔案不存在,請建立該檔案。 - 在檔案中新增下列內容:
conf_cassandra_env_com.sun.management.jmxremote.encrypted.authenticate=true
- 儲存 cassandra.properties 檔案。
- 將檔案擁有者變更為 apigee:apigee,如以下範例所示:
chown apigee:apigee /opt/apigee/customer/application/cassandra.properties
- 編輯
- 在指令列中輸入
echo -n 'Secret' | openssl dgst -sha1,產生所需密碼的 SHA1 雜湊 - 在
$APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.password中,針對使用者名稱設定密碼 (在上一個章節中建立)。 - 在 Cassandra 上執行設定:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
- 重新啟動 Cassandra:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
- 對所有其他 Cassandra 節點重複執行這個程序。
為 Cassandra 啟用 JMX (搭配 SSL)
啟用 JMX 並搭配 SSL,可為與 Cassandra 進行的 JMX 通訊提供額外的安全性和加密。如要啟用 JMX 搭配 SSL,您必須提供金鑰和憑證給 Cassandra,才能接受以 SSL 為基礎的 JMX 連線。您也需要為 nodetool (以及透過 JMX 與 Cassandra 通訊的任何其他工具) 設定 SSL。
啟用 SSL 的 JMX 支援明文和加密的 JMX 密碼。
如要為 Cassandra 啟用 JMX 搭配 SSL,請按照下列程序操作:
- 啟用 JMX。 視需要啟用密碼加密功能。
- 為 Cassandra 啟用 JMX 驗證。
(如上所述)。確認 nodetool 可搭配設定的使用者名稱和密碼運作。
/opt/apigee/apigee-cassandra/bin/nodetool -u <JMX_USER> -pw <JMX_PASS> ring
準備 KeyStore 和信任儲存庫。
KeyStore 應包含金鑰和憑證,並用於設定 Cassandra 伺服器。如果金鑰庫包含多個金鑰組,Cassandra 會使用第一個金鑰組啟用 SSL。
請注意,KeyStore 和金鑰的密碼應相同 (使用 keytool 產生金鑰時的預設密碼)。
- 信任儲存庫應只包含憑證,並由用戶端 (以 apigee-service 為基礎的指令或 nodetool) 用於透過 JMX 連線。
確認符合上述規定後:
- 將 KeyStore 檔案放在
/opt/apigee/customer/application/apigee-cassandra/中。 - 輸入下列指令,確保只有 Apigee 使用者可以讀取 KeyStore 檔案
chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/keystore.node1
chmod 400 /opt/apigee/customer/application/apigee-cassandra/keystore.node1
- 請按照下列步驟,為 JMX 設定 Cassandra 並啟用 SSL:
- 輸入下列指令,停止 Cassandra 節點:
apigee-service apigee-cassandra stop
- 如要在 Cassandra 中啟用 SSL,請開啟
/opt/apigee/customer/application/cassandra.properties檔案,並新增下列幾行內容:conf_cassandra_env_com.sun.management.jmxremote.ssl=true conf_cassandra_env_javax.net.ssl.keyStore=/opt/apigee/customer/application/apigee-cassandra/keystore.node1 conf_cassandra_env_javax.net.ssl.keyStorePassword=keystore-password
- 將檔案擁有者變更為 apigee:apigee,如下例所示:
chown apigee:apigee /opt/apigee/customer/application/cassandra.properties
- 在 Cassandra 上執行設定:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
- 重新啟動 Cassandra:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
- 對所有其他 Cassandra 節點重複執行這個程序。
- 輸入下列指令,啟動 Cassandra 節點:
apigee-service apigee-cassandra start
- 輸入下列指令,停止 Cassandra 節點:
- 設定
apigee-serviceCassandra 指令。 執行apigee-service指令時,您需要設定特定環境變數,包括下列變數:apigee-service apigee-cassandra stop apigee-service apigee-cassandra wait_for_ready apigee-service apigee-cassandra ring apigee-service apigee-cassandra backup
您可以透過多種方式設定 JMX 驗證和 SSL 的
apigee-service。請根據可用性和安全性做法選擇選項。選項 1 (SSL 引數儲存在檔案中)
請設定下列環境變數:
export CASS_JMX_USERNAME=ADMIN # Provide encrypted password here if you have setup JMX password encryption export CASS_JMX_PASSWORD=PASSWORD export CASS_JMX_SSL=Y
在 Apigee 使用者的主目錄 (
/opt/apigee) 中建立檔案。$HOME/.cassandra/nodetool-ssl.properties
編輯檔案並新增下列幾行:
-Djavax.net.ssl.trustStore=<path-to-truststore.node1> -Djavax.net.ssl.trustStorePassword=<truststore-password> -Dcom.sun.management.jmxremote.registry.ssl=true -Djavax.net.ssl.trustStoreType=PKCS12
請確認 Apigee 使用者可以讀取信任儲存庫檔案。
執行下列
apigee-service指令。 如果沒有錯誤,表示設定正確無誤。apigee-service apigee-cassandra ring
方法 2 (SSL 引數儲存在環境變數中)
請設定下列環境變數:
export CASS_JMX_USERNAME=ADMIN # Provide encrypted password here if you have setup JMX password encryption export CASS_JMX_PASSWORD=PASSWORD export CASS_JMX_SSL=Y # Ensure the truststore file is accessible by Apigee user. export CASS_JMX_TRUSTSTORE=<path-to-trustore.node1> export CASS_JMX_TRUSTSTORE_PASSWORD=<truststore-password> # If you are using a non standard truststore type, export truststore type as well # Possible values are JKS, PKCS12, BCFKS export CASS_JMX_TRUSTSTORE_TYPE=PKCS12
執行下列
apigee-service指令。如果執行時沒有錯誤,表示設定正確。apigee-service apigee-cassandra ring
選項 3 (SSL 引數直接傳遞至
apigee-service)執行任何
apigee-service指令,例如下列指令。 您不需要設定任何環境變數。CASS_JMX_USERNAME=ADMIN CASS_JMX_PASSWORD=PASSWORD CASS_JMX_SSL=Y CASS_JMX_TRUSTSTORE=<path-to-trustore.node1> CASS_JMX_TRUSTSTORE_PASSWORD=<trustore-password> CASS_JMX_TRUSTSTORE_TYPE=PKCS12 /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra ring
設定 nodetool。Nodetool 需要傳遞 JMX 參數。您可以透過兩種方式設定 nodetool,以便與啟用 SSL 的 JMX 搭配執行,如下列設定選項所述:
這兩個選項的差異在於,SSL 相關設定傳遞至 nodetool 的方式不同。在這兩種情況下,執行 nodetool 的使用者都應具備信任儲存區檔案的 READ 權限。請根據可用性和安全性做法,選擇適當的選項。
如要進一步瞭解 nodetool 參數,請參閱 Apache Cassandra nodetool 說明文件。
設定選項 1
在執行 nodetool 的使用者主目錄中建立檔案。
$HOME/.cassandra/nodetool-ssl.properties
在檔案中新增下列幾行內容:
-Djavax.net.ssl.trustStore=<path-to-truststore.node1> -Djavax.net.ssl.trustStorePassword=<truststore-password> -Dcom.sun.management.jmxremote.registry.ssl=true -Djavax.net.ssl.trustStoreType=PKCS12
任何執行 nodetool 的使用者都應能存取上述信任存放區路徑。
執行
nodetool並加上--ssl選項。/opt/apigee/apigee-cassandra/bin/nodetool --ssl -u <jmx-user-name> -pw <jmx-user-password> -h localhost ring
設定選項 2
執行
nodetool做為單一指令,並加入下列額外參數。/opt/apigee/apigee-cassandra/bin/nodetool -Djavax.net.ssl.trustStore=<path-to-truststore.node1> -Djavax.net.ssl.trustStorePassword=<truststore-password> -Dcom.sun.management.jmxremote.registry.ssl=true -Djavax.net.ssl.trustStoreType=PKCS12 -Dssl.enable=true -u <jmx-user-name> -pw <jmx-user-password> -h localhost ring
還原 SSL 設定
如需還原上述程序中的 SSL 設定,請按照下列步驟操作:
- 輸入以下指令,停止
apigee-cassandra:apigee-service apigee-cassandra stop
- 從
/opt/apigee/customer/application/cassandra.properties檔案中移除conf_cassandra-env_com.sun.management.jmxremote.ssl=true行。 - 在
/opt/apigee/apigee-cassandra/source/conf/cassandra-env.sh中註解排除下列程式碼行:# JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/opt/apigee/data/apigee-cassandra/keystore.node0" # JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=keypass" # JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.registry.ssl=true”
- 輸入以下指令,啟動
apigee-cassandra - 如果已設定環境變數
CASS_JMX_SSL,請移除。unset CASS_JMX_SSL
- 確認
ring、stop、backup等apigee-service指令可正常運作。 - 停止使用 nodetool 的
--ssl切換鍵
apigee-service apigee-cassandra start
停用 Cassandra 的 JMX 驗證
如要停用 Cassandra 的 JMX 驗證:
- 編輯
/opt/apigee/customer/application/cassandra.properties。 - 移除檔案中的下列程式碼行:
conf_cassandra-env_com.sun.management.jmxremote.authenticate=true
- 在 Cassandra 上執行設定:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
- 重新啟動 Cassandra:
/opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
- 對所有其他 Cassandra 節點重複執行這個程序。
使用 JConsole:監控工作統計資料
使用 JConsole 和下列服務網址,監控透過 JMX 提供的 JMX 屬性 (MBeans):
service:jmx:rmi:///jndi/rmi://IP_address:7199/jmxrmi
其中 IP_address 是 Cassandra 伺服器的 IP。
Cassandra JMX 統計資料
| JMX MBean | JMX 屬性 |
|---|---|
|
ColumnFamilies/apprepo/environments ColumnFamilies/apprepo/organizations ColumnFamilies/apprepo/apiproxy_revisions ColumnFamilies/apprepo/apiproxies ColumnFamilies/audit/audits ColumnFamilies/audit/audits_ref |
PendingTasks |
|
MemtableColumnsCount |
|
|
MemtableDataSize |
|
|
ReadCount |
|
|
RecentReadLatencyMicros |
|
|
TotalReadLatencyMicros |
|
|
WriteCount |
|
|
RecentWriteLatencyMicros |
|
|
TotalWriteLatencyMicros |
|
|
TotalDiskSpaceUsed |
|
|
LiveDiskSpaceUsed |
|
|
LiveSSTableCount |
|
|
BloomFilterFalsePositives |
|
|
RecentBloomFilterFalseRatio |
|
|
BloomFilterFalseRatio |
使用 nodetool 管理叢集節點
nodetool 公用程式是 Cassandra 的指令列介面,可管理叢集節點。您可以在 /opt/apigee/apigee-cassandra/bin 找到這項公用程式。
您可以在所有 Cassandra 叢集節點上進行下列呼叫:
- 一般環狀資訊 (也適用於單一 Cassandra 節點):尋找所有節點的「Up」和「Normal」。
nodetool [-u username -pw password] -h localhost ring
只有在為 Cassandra 啟用 JMX 驗證時,才需要傳遞使用者名稱和密碼。
上述指令的輸出內容如下所示:
Datacenter: dc-1 ========== Address Rack Status State Load Owns Token 192.168.124.201 ra1 Up Normal 1.67 MB 33,33% 0 192.168.124.202 ra1 Up Normal 1.68 MB 33,33% 5671...5242 192.168.124.203 ra1 Up Normal 1.67 MB 33,33% 1134...0484
- 節點一般資訊 (每個節點呼叫)
nodetool [-u username -pw password] -h localhost info
上述指令的輸出內容如下所示:
ID : e2e42793-4242-4e82-bcf0-oicu812 Gossip active : true Thrift active : true Native Transport active: true Load : 273.71 KB Generation No : 1234567890 Uptime (seconds) : 687194 Heap Memory (MB) : 314.62 / 3680.00 Off Heap Memory (MB) : 0.14 Data Center : dc-1 Rack : ra-1 Exceptions : 0 Key Cache : entries 150, size 13.52 KB, capacity 100 MB, 1520781 hits, 1520923 requests, 1.000 recent hit rate, 14400 save period in seconds Row Cache : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds Counter Cache : entries 0, size 0 bytes, capacity 50 MB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds Token : 0
- Thrift 伺服器狀態 (提供用戶端 API)
nodetool [-u username -pw password] -h localhost statusthrift
上述指令的輸出內容如下所示:
running
- 資料串流作業狀態:觀察 Cassandra 節點的流量:
nodetool [-u username -pw password] -h localhost netstats
上述指令的輸出內容如下所示:
Mode: NORMAL Not sending any streams. Read Repair Statistics: Attempted: 151612 Mismatch (Blocking): 0 Mismatch (Background): 0 Pool Name Active Pending Completed Dropped Commands n/a 0 0 0 Responses n/a 0 0 n/a
如要進一步瞭解如何使用 nodetool,請參閱「 關於 nodetool 公用程式」。
Cassandra 資源
請參閱下列網址: Cassandra 監控。
監控 Apache Qpid Broker-J
您可以透過 Qpid 管理控制台監控 Qpid Broker-J。本節說明如何存取控制台,以及如何使用控制台執行基本監控功能。如要進一步瞭解如何使用管理控制台,請參閱 Apache Qpid 說明文件中的「 Web Management Console」(網頁管理控制台)。
存取管理控制台
預設的管理控制台通訊埠為 8090。如要透過這個預設通訊埠存取控制台,請在網路瀏覽器中前往:
http://QPID_NODE_IP:8090
如要登入控制台,請使用 Apigee 設定的預設憑證,或 Edge 設定檔中設定的憑證。詳情請參閱「Edge 設定檔參考資料」。
監控佇列和訊息
在左側導覽面板中,依序前往「Java-Broker」>「virtualhosts」>「queues」。選取佇列,即可在 UI 的主要部分查看詳細資料。在詳細資料檢視畫面中,您可以查看佇列屬性和統計資料,包括已傳送、已加入佇列的郵件資訊,以及郵件傳送速率等。
查看及下載記錄檔
在左側導覽面板中,依序前往「Java-Broker」>「brokerloggers」>「logfile」。在主要 UI 詳細資料檢視畫面中,您可以查看記錄檔詳細資料並下載記錄檔。
使用 Qpid 管理 API
您可以使用 Apache Qpid Broker-J REST API 自動執行管理工作及監控訊息代理。詳情請參閱 Apache Qpid Broker REST API 說明文件。
您也可以使用指令列工具監控代理程式。例如:
curl "QPID_NODE_IP":"8090"/api/latest/broker -u "USERNAME":"PASSWORD"
啟用 Qpid 的 SSL 監控功能
如要進一步確保監控和管理作業的安全,請在 Qpid 的管理入口網站和管理 API 中啟用 SSL。請按照下列規範提供金鑰和憑證。
Qpid 提供檔案 KeyStore 選項,可在 Apigee 中啟用。這個型別接受 Java 和 Java 工具 (例如 keytool) 可辨識的標準 JKS 金鑰儲存區格式。此外,這個指令也接受 PKCS12 KeyStore,您可以使用 OpenSSL 等工具產生這類 KeyStore。
準備金鑰儲存庫
如要瞭解如何產生 KeyStore,請參閱 Java Keytool 說明文件。
如要瞭解如何產生 PKCS12 鍵盤,請參閱 OpenSSL 說明文件。
驗證規定後
- 將 KeyStore 檔案放在
/opt/apigee/customer/application/apigee-qpidd中。 - 確認只有 Apigee 使用者可以讀取金鑰儲存區檔案:
chown apigee:apigee /opt/apigee/customer/application/apigee-qpidd/qpidd.keystore chmod 400 /opt/apigee/customer/application/apigee-qpidd/qpidd.keystore
在 Qpid 中啟用 SSL
請一次在一個 Qpid 節點上執行下列步驟:
開啟 /opt/apigee/customer/application/qpidd.properties 檔案,並新增下列幾行內容:
conf_qpidd_qpid_management.https.enabled=true conf_qpidd_qpid.keystore.storeUrl=/opt/apigee/customer/application/apigee-qpidd/qpidd.keystore conf_qpidd_qpid.keystore.password=keystore-password conf_qpidd_qpid.keystore.certificateAlias=certificate-alias ## If you are using a PKCS12 keystore, specify the keystore type conf_qpidd_qpid.keystore.keyStoreType=PKCS12
- 將檔案擁有者變更為 apigee:apigee:
chown apigee:apigee /opt/apigee/customer/application/qpidd.properties
- 設定 Qpidd:
apigee-service apigee-qpidd configure
- 重新啟動 Qpidd:
apigee-service apigee-qpidd restart
- 使用 wait_for_ready 檢查狀態:
apigee-service apigee-qpidd wait_for_ready
還原 SSL 設定
從 /opt/apigee/customer/application/qpidd.properties 檔案中移除或註解排除屬性:
conf_qpidd_qpid_management.https.enabled=true conf_qpidd_qpid.keystore.storeUrl=/opt/apigee/customer/application/apigee-qpidd/keystore
- 設定 Qpidd:
apigee-service apigee-qpidd configure
- 重新啟動 Qpidd:
apigee-service apigee-qpidd restart
- 使用 wait_for_ready 檢查狀態:
apigee-service apigee-qpidd wait_for_ready
Apache ZooKeeper
檢查 ZooKeeper 狀態
- 確認 ZooKeeper 程序正在執行。ZooKeeper 會將 PID 檔案寫入
opt/apigee/var/run/apigee-zookeeper/apigee-zookeeper.pid。 - 測試 ZooKeeper 連接埠,確保您可以在每個 ZooKeeper 伺服器上建立與連接埠 2181 和 3888 的 TCP 連線。
- 確認您可以從 ZooKeeper 資料庫讀取值。使用 ZooKeeper 用戶端程式庫 (或
/opt/apigee/apigee-zookeeper/bin/zkCli.sh) 連線,並從資料庫讀取值。 - 查看狀態:
/opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper status
使用 ZooKeeper 四字母指令
您可以使用 netcat (nc) 或 telnet,將一小組指令 (四個字母的字詞) 傳送至通訊埠 2181,藉此監控 ZooKeeper。
如要進一步瞭解 ZooKeeper 指令,請參閱「 Apache ZooKeeper 指令參考資料」。
例如:
srvr:列出伺服器的完整詳細資料。stat:列出伺服器和已連線用戶端的簡要詳細資料。
您可以對 ZooKeeper 通訊埠發出下列指令:
- 執行四個字母的 ruok 指令,測試伺服器是否處於非錯誤狀態。成功的回應會傳回「imok」。
echo ruok | nc host 2181
傳回值:
imok
- 執行四字母指令
stat,列出伺服器效能和已連線用戶端的統計資料:echo stat | nc host 2181
傳回值:
Zookeeper version: 3.8.5-19f1842d4b6ee1f82cc8b05284959b26c6ae507d, built on 2025-09-18 17:23 UTC Clients: /0:0:0:0:0:0:0:1:33467[0](queued=0,recved=1,sent=0) /192.168.124.201:42388[1](queued=0,recved=8433,sent=8433) /192.168.124.202:42185[1](queued=0,recved=1339,sent=1347) /192.168.124.204:39296[1](queued=0,recved=7688,sent=7692) Latency min/avg/max: 0/0/128 Received: 26144 Sent: 26160 Connections: 4 Outstanding: 0 Zxid: 0x2000002c2 Mode: follower Node count: 283
- 如果無法使用 netcat (nc),可以改用 Python。建立名為
zookeeper.py的檔案,並加入下列內容:import time, socket, sys c = socket.socket(socket.AF_INET, socket.SOCK_STREAM) c.connect((sys.argv[1], 2181)) c.send(sys.argv[2]) time.sleep(0.1) print c.recv(512)
現在請執行下列 Python 程式碼行:
python zookeeper.py 192.168.124.201 ruok
python zookeeper.py 192.168.124.201 stat
LDAP 層級測試
您可以監控 SymasLDAP,確認特定要求是否正常處理。換句話說,請檢查特定搜尋是否傳回正確結果。
- 使用
ldapsearch(yum install symasldap-clients) 查詢系統管理員的項目。這個項目用於驗證所有 API 呼叫。/opt/symas/bin/ldapsearch -b "uid=admin,ou=users,ou=global,dc=apigee,dc=com" -x -W -D "cn=manager,dc=apigee,dc=com" -H ldap://localhost:10389 -LLL
系統會提示您輸入 LDAP 管理員密碼:
Enter LDAP Password:
輸入密碼後,您會看到以下形式的回應:
dn: uid=admin,ou=users,ou=global,dc=apigee,dc=com objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top uid: admin cn: admin sn: admin userPassword:: e1NTSEF9bS9xbS9RbVNXSFFtUWVsU1F0c3BGL3BQMkhObFp2eDFKUytmZVE9PQ= = mail: opdk@google.com
- 使用下列指令,檢查管理伺服器是否仍連線至 LDAP:
curl -u userEMail:password http://localhost:8080/v1/users/ADMIN
傳回值:
{ "emailId" : ADMIN, "firstName" : "admin", "lastName" : "admin" }
您也可以監控 SymasLDAP 快取,這有助於減少磁碟存取次數,進而提升系統效能。監控並調整 SymasLDAP 伺服器的快取大小,可能會大幅影響目錄伺服器的效能。您可以查看記錄檔 (opt/apigee/var/log),取得快取相關資訊。