本文件說明 Apigee Edge 地端部署部署作業支援的元件。
總覽
Edge 支援多種取得服務詳細資料及查看服務狀態的方法。下表列出每種符合資格的服務可以執行的檢查類型:
管理 API | |||||||
服務 | 記憶體用量 [JMX*] | 服務檢查 | 使用者/機構/ 部署狀態 | axstatus | 資料庫檢查 | 「apigee-service 」狀態 |
apigee-monit ** |
管理伺服器 | |||||||
訊息處理器 | |||||||
Postgres | |||||||
Qpid 值 | |||||||
路由器 | |||||||
更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | 更多資訊 | |
* 您必須先啟用 JMX 才能使用 JMX,詳情請參閱啟用 JMX 一文。 ** |
JMX and Management API 監控通訊埠
每個元件支援在不同通訊埠上使用 JMX 和 Management API 監控呼叫。下表列出各種伺服器類型的 JMX 和 Management API 通訊埠:
元件 | JMX 通訊埠 | Management API 通訊埠 |
---|---|---|
管理伺服器 | 1099 | 8080 |
路由器 | 1100 | 8081 |
訊息處理器 | 1101 | 8082 |
Qpid 值 | 1102 | 8083 |
Postgres | 1103 | 8084 |
使用 JMX 監控
管理伺服器、訊息處理工具、Qpid 和 Postgres 的監控程序均使用 JMX。不過,JMX 預設為僅在 Cassandra 啟用,且所有其他 Edge 元件都會預設停用 JMX。因此,您必須為每個元件分別啟用 JMX 才能進行監控。
根據預設,系統不會啟用 JMX 驗證。您可以為所有元件啟用 JMX 驗證。若是 Cassandra,請按照啟用 Cassandra 的 JMX 驗證中的操作說明。
啟用 JMX
根據預設,只有 Cassandra 會啟用 JMX,其他 Edge 元件會預設停用 JMX。本節說明如何為其他 Edge 元件啟用 JMX。
如何啟用 JMX:
- 編輯元件的設定檔。這個檔案位於
opt/apigee/edge-component_name/bin/start
。在實際工作環境中,設定檔位於不同的機器。在每個伺服器上選擇下列檔案位置:
- 管理伺服器:
/opt/apigee/edge-management-server/bin/start
- 訊息處理器:
/opt/apigee/edge-message-processor/bin/start
- Postgres:
/opt/apigee/edge-postgres-server/bin/start
- Qpid:
/opt/apigee/edge-qpid-server/bin/start
- 路由器:
/opt/apigee/edge-router/bin/start
舉例來說,管理伺服器的設定檔位於
/opt/apigee/edge-management-server/bin/start
。 - 管理伺服器:
- 將下列
com.sun.management.jmxremote
選項新增至啟動元件的exec
行:-Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=port_number \ -Dcom.sun.management.jmxremote.local.only=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false
其中 port_number 是服務的 JMX 通訊埠。如要取得服務的 JMX 通訊埠編號,請參閱 JMX and Management API 監控通訊埠。
舉例來說,如要在管理伺服器中啟用 JMX,請將以下內容新增至管理伺服器的設定檔:
exec $JAVA -classpath "$classpath" -Xms$min_mem -Xmx$max_mem $xx_opts \ -Djava.security.auth.login.config=$conf_path/jaas.config \ -Dinstallation.dir=$install_dir $sys_props -Dconf.dir=$conf_path \ -Ddata.dir=$data_dir \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=1099 \ -Dcom.sun.management.jmxremote.local.only=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ $* $debug_options com.apigee.kernel.MicroKernel
這個範例指定管理伺服器的通訊埠 1099。如前所述,每項服務都有專屬的通訊埠編號。
設定檔中的編輯行如下:
exec $JAVA -classpath "$classpath" -Xms$min_mem -Xmx$max_mem $xx_opts -Djava.security.auth.login.config=$conf_path/jaas.config -Dinstallation.dir=$install_dir $sys_props -Dconf.dir=$conf_path -Ddata.dir=$data_dir -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false $* $debug_options com.apigee.kernel.MicroKernel
- 儲存設定檔。
- 使用
restart
指令重新啟動元件。舉例來說,如要重新啟動管理伺服器,請執行下列指令:
/opt/apigee/apigee-service/bin/apigee-service edge-management-server restart
JMX 驗證預設為停用,如啟用 JMX 驗證中所述,所有元件都能啟用 JMX 驗證。如要啟用 Cassandra 的 JMX 驗證,請參閱為 Cassandra 啟用 JMX 驗證。
啟用 JMX 驗證
根據預設,系統不會啟用 JMX 驗證。您可以為所有元件啟用 JMX 驗證。若是 Cassandra,請按照啟用 Cassandra 的 JMX 驗證中的操作說明。
如要啟用 JMX 驗證,請對所有節點執行下列 change_jmx_auth
動作:
/opt/apigee/apigee-service/bin/apigee-service component_name change_jmx_auth [options|-f config_file]
在此情況下:
- component 是下列其中一項:
edge-management-server
edge-message-processor
edge-postgres-server
edge-qpid-server
edge-router
- options 指定下列項目:
-u username
-p password
-e [y|n]
(啟用或停用)
- config_file 會指定設定檔的定義位置,其中包含:
JMX_USERNAME=username
JMX_ENABLED=y|n
JMX_PASSWORD=password
(如未設定或使用-p
傳入,系統會提示您)
您可以使用指令列選項或設定檔來定義使用者名稱、密碼,以及啟用/停用狀態。但請勿同時指定一組選項和設定檔。
以下範例是使用指令列選項為管理伺服器啟用 JMX 驗證:
/opt/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -u foo -p bar -e y
以下範例使用設定檔而不是指令列選項:
/opt/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -f /tmp/my-config-file
在多個節點上執行 Edge 時,請在所有節點上執行指令,並指定相同的使用者名稱和密碼。
如要在指令列中停用 JMX 驗證,請使用「-e n」選項,如以下範例所示:
/opt/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -e n
使用 JConsole 監控
使用 JConsole (與 JMX 相容的工具) 管理及監控健康狀態檢查與處理統計資料。JConsole 可讓您使用伺服器公開的 JMX 統計資料,並顯示在圖形介面中。詳情請參閱使用 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 MBeans (JMX MBeans) | JMX 屬性 |
---|---|
記憶體 |
堆積記憶體用量 |
非堆積記憶體用量 |
|
使用方式 |
|
使用 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 |
傳回服務相關資訊,包括:
這個 API 呼叫會要求您使用 Apigee 管理員憑證進行驗證。 |
如要使用這些端點,請透過使用下列語法的指令叫用 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 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"
監控使用者、機構和部署狀態
您可以使用管理 API,透過「管理伺服器」和「訊息處理器」監控 Proxy 的使用者、機構和部署狀態:
curl http://host:port_number/v1/users -u sysAdminEmail:passwordcurl http://host:port_number/v1/organizations -u sysAdminEmail:password
curl 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-server
edge-message-processor
使用 apigee-service
指令檢查狀態
如要登入 Edge 服務,請在登入執行服務的伺服器時使用 apigee-service
指令。
使用 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" }
PostgresSQL 資料庫
本節說明專門用來監控 Postgres 資料庫的技術。
使用 check_postgres.pl
指令碼
如要監控 PostgresSQL 資料庫,您可以使用標準監控指令碼 check_postgres.pl
。詳情請參閱 http://bucardo.org/wiki/Check_postgres。
執行指令碼前:
- 您必須在每個 Postgres 節點上安裝 check_postgres.pl 指令碼。
- 確認已安裝
perl-Time-HiRes.x86_64
,這是會實作高解析度鬧鐘、睡眠、取得時間與間隔計時器的 Perl 模組。舉例來說,使用下列指令即可安裝:
yum install perl-Time-HiRes.x86_64
- 編號 7:在 CentOS v7 上使用 check_postgres.pl 前,安裝
perl-Data-Dumper.x86_64
千次曝光收益。
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
執行資料庫檢查
您可以在此驗證是否已在 PostgresSQL 資料庫中建立適當的資料表。使用下列指令登入 PostgreSQL 資料庫:
psql -h /opt/apigee/var/run/apigee-postgresql/ -U apigee -d apigee
然後執行:
\d analytics."org.env.fact"
查看 Postgres 程序的健康狀態
您可以叫用下列 curl
指令,在 Postgres 電腦上執行 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,以及 Cassandra 的遠端 JMX 存取權不需要密碼。
啟用 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}/data/apigee-cassandra/jmxremote.password conf_cassandra-env_com.sun.management.jmxremote.access.file=${APIGEE_ROOT}/data/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/data/apigee-cassandra/
:cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/data/apigee-cassandra/jmxremote.password
- 編輯
jmxremote.password
檔案,並使用以下語法新增 JMX 使用者名稱和密碼:JMX_USERNAME JMX_PASSWORD
其中 JMX_USERNAME 和 JMX_PASSWORD 是您先前設定的 JMX 使用者名稱和密碼。
- 確認檔案為「Apigee」,且檔案模式為 400:
chown apigee:apigee /opt/apigee/data/apigee-cassandra/jmxremote.password
chmod 400 /opt/apigee/data/apigee-cassandra/jmxremote.password
- 將下列檔案從
- 複製並編輯
jmxremote.access
檔案:- 將下列檔案從
$JAVA_HOME
目錄複製到/opt/apigee/data/apigee-cassandra/
:cp ${JAVA_HOME}/lib/management/jmxremote.access $APIGEE_ROOT/data/apigee-cassandra/jmxremote.access
- 編輯 jmxremote.access 檔案並新增下列角色:
JMX_USERNAME readwrite
- 確認檔案為「Apigee」,且檔案模式為 400:
chown apigee:apigee /opt/apigee/data/apigee-cassandra/jmxremote.access
chmod 400 /opt/apigee/data/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
檔案。 - 將檔案中的下列這行取消註解:
-
JVM_OPTS="$JVM_OPTS -Djava.security.auth.login.config={T}conf_cassandra-env_java.security.auth.login.config{/T}"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.login.config=ApigeeSecureFileLoginModule"
-
- 在指令列中輸入
echo -n 'Secret' | openssl dgst -sha1
,產生指定密碼的 SHA1 雜湊碼 - 設定在
jmxremote.password
中的使用者名稱密碼。 - 更新
cassandra-env.sh
檔案,只在更新完成後讀取資料。
為 Cassandra 啟用 JMX
透過 SSL 啟用 JMX,可為 JMX 通訊採用 Cassandra 以提供額外的安全性和加密機制。如要啟用 JMX 與 SSL 的機制,您必須提供金鑰和憑證給 Cassandra,以接受 SSL 型 JMX 連線。您也需要為 SSL 設定 nodetool (以及與 Cassandra over JMX 進行通訊的其他工具)。
支援 SSL 的 JMX 支援純文字和加密的 JMX 密碼。
如要為 Cassandra 啟用 JMX,請按照下列程序操作:
- 啟用 JMX。如有需要,請啟用密碼加密功能。
- 啟用 Cassandra 的 JMX 驗證。
。確保 nodetool 與您設定的使用者名稱和密碼搭配運作。
/opt/apigee/apigee-cassandra/bin/nodetool -u <JMX_USER> -pw <JMX_PASS> ring
準備 KeyStore 和 Truststore。
KeyStore 應含有金鑰和憑證,用於設定 Cassandra 伺服器。如果 KeyStore 包含多個金鑰組,Cassandra 會使用第一個金鑰組來啟用安全資料傳輸層 (SSL)。
請注意,KeyStore 和金鑰的密碼應相同 (使用 keytool 產生金鑰時的預設密碼)。
- Truststore 只含有憑證,可供用戶端 (Apigee-service 指令或 nodetool) 透過 JMX 連線使用。
驗證上述規定後:
- 將 KeyStore 檔案放入
/opt/apigee/data/apigee-cassandra
。 - 輸入
chown apigee:apigee /opt/apigee/data/apigee-cassandra/keystore.node1 chmod 400 /opt/apigee/data/apigee-cassandra/keystore.node1
確保 Apigee 使用者可讀取 KeyStore 檔案
- 按照下列步驟,為使用 SSL 的 JMX 設定 Cassandra:
- 輸入
apigee-service apigee-cassandra stop
即可停止 Cassandra 節點 - 開啟
/opt/apigee/customer/application/cassandra.properties
檔案並新增下列程式碼,即可在 Cassandra 中啟用安全資料傳輸層 (SSL):conf_cassandra-env_com.sun.management.jmxremote.ssl=true
檔案應屬於
apigee:apigee
。 - 在 Cassandra 中啟用安全資料傳輸層 (SSL) 相關設定,方法如下:
開啟
/opt/apigee/apigee-cassandra/source/conf/cassandra-env.sh
檔案,並將以下這行取消註解,然後視需要變更路徑/opt/apigee/data/apigee-cassandra/keystore.node1
和 KeyStore 密碼。JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/opt/apigee/data/apigee-cassandra/keystore.node1" JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=keystore-password" JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.registry.ssl=true"
確認檔案為apigee:apigee
所擁有。 - 輸入
apigee-service apigee-cassandra start
來啟動 Cassandra 節點
- 輸入
- 設定
apigee-service
Cassandra 指令。執行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) 引數)
- 選項 2 (儲存在環境變數中的安全資料傳輸層 (SSL) 引數)
- 選項 3 (直接傳遞至
apigee-service
的 SSL 引數)
選項 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
確保 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>
執行下列
apigee-service
指令。如果執行時沒有錯誤,則設定正確無誤。apigee-service apigee-cassandra ring
選項 3 (直接傳送至
apigee-service
的 SSL 引數)執行任何
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> /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra ring
設定 nodetool。Nodetool 需要將 JMX 參數傳遞至參數。您可以透過兩種方式,將 nodetool 設為使用已啟用 SSL 的 JMX 執行,如以下設定選項所示:
這些選項會因安全資料傳輸層 (SSL) 相關設定傳送至 nodetool 的方式而有所不同。不論是哪一種情況,執行 nodetool 的使用者在 Truststore 檔案上都應該具備 READ 權限。根據可用性和您的安全性做法選擇合適的選項。
如要進一步瞭解 nodetool 參數,請參閱 DataStax 說明文件。
設定選項 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
任何執行 nodetool 的使用者都應存取上述指定的信任儲存庫路徑。
使用
--ssl
選項執行nodetool
。/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 -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
- 檢查
apigee-service
相關指令,例如ring
、stop
、backup
等。 - 停止搭配 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 MBeans (JMX MBeans) | JMX 屬性 |
---|---|
ColumnFamilies/apprepo/environments ColumnFamilies/apprepo/organizations ColumnFamilies/apprepo/apiproxy_revisions ColumnFamilies/apprepo/apiProxy ColumnFamilies/稽核/稽核 ColumnFamilies/audit/audits_ref |
待處理工作 |
記憶體欄數 |
|
記憶體資料大小 |
|
讀取次數 |
|
RecentReadLatencyMicros |
|
TotalReadLatencyMicros |
|
寫入次數 |
|
RecentWriteLatencyMicros |
|
TotalWriteLatencyMicros |
|
磁碟空間用量總計 |
|
LiveDiskSpaceUsed |
|
LiveSSTableCount |
|
開花濾鏡 |
|
RecentBloomFilterFalseRatio |
|
BloomFilterFalseRatio |
使用 nodetool 管理叢集節點
Nodetool 公用程式是 Cassandra 的指令列介面,可用來管理叢集節點。公用工具位於 /opt/apigee/apigee-cassandra/bin
。
下列呼叫適用於所有 Cassandra 叢集節點:
- 一般環形資訊 (也可用於單一 Cassandra 節點):找出所有節點的「Up」和「Regular」。
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
- 二手伺服器狀態 (提供用戶端 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 資源
請前往以下網址:http://www.datastax.com/docs/1.0/Operation/monitoring。
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 傳送至一組簡短的指令 (四個字母),監控 ZooKeeper。
如要進一步瞭解 ZooKeeper 指令,請參閱:Apache ZooKeeper 指令參考資料。
例如:
srvr
:列出伺服器的完整詳細資料。stat
:列出伺服器和已連結的用戶端的簡短詳細資訊。
下列指令可以傳送至 ZooKeeper 通訊埠:
- 執行四個字母的指令快取,以測試伺服器是否處於非錯誤狀態。成功的回應會傳回「imok」。
echo ruok | nc host 2181
退貨:
imok
- 執行四個字母指令
stat
,以列出伺服器效能和已連線的用戶端統計資料:echo stat | nc host 2181
退貨:
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT 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 等級測試
您可以監控 OpenLDAP ,確認特定要求是否正常放送。換句話說,檢查特定搜尋,傳回正確的結果。
- 使用
ldapsearch
(yum install openldap-clients
) 查詢系統管理員的項目。此項目是用來驗證所有 API 呼叫。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" }
您也可以監控 OpenLDAP 快取,這有助於減少磁碟存取次數,進而改善系統效能。監控及調整 OpenLDAP 伺服器中的快取大小可能會大幅影響目錄伺服器的效能。您可以查看記錄檔 (opt/apigee/var/log
),以取得快取相關資訊。