如何監控

Edge for Private Cloud 4.19.01 版

本文說明地端部署 Apigee Edge 支援的元件監控技術。

總覽

Edge 支援多種方式,可取得服務詳細資料及檢查服務狀態。下表列出您可對各項適用服務執行的檢查類型:

Mgmt API
服務 記憶體用量 [JMX*] 服務檢查 使用者/機構/ 部署狀態 axstatus 資料庫檢查 apigee-service 狀態 apigee-monit**
管理伺服器
訊息處理器
Postgres
Qpid
路由器
更多資訊 更多資訊 更多資訊 更多資訊 更多資訊 更多資訊 更多資訊

* 您必須先啟用 JMX,才能使用這項功能。詳情請參閱「啟用 JMX」一節。

** apigee-monit 服務會檢查元件是否正常運作,如果沒有,則會嘗試重新啟動。詳情請參閱「使用 apigee-monit 自行修復」。

JMX 和 Management API 監控通訊埠

每個元件都支援不同通訊埠上的 JMX 和 Management API 監控呼叫。下表列出各類伺服器的 JMX 和 Management API 通訊埠:

元件 JMX 通訊埠 Management API 通訊埠
管理伺服器 1099 8080
路由器 1100 8081
訊息處理器 1101 8082
Qpid 1102 8083
Postgres 1103 8084

使用 JMX 監控

Management Server、訊息處理器、Qpid 和 Postgres 的監控程序都使用 JMX。不過,根據預設,JMX 僅適用於 Cassandra,且預設為停用所有其他 Edge 元件。因此,您必須先為每個元件個別啟用 JMX,才能監控這些元件。

JMX 驗證功能預設為停用。您可以為所有元件啟用 JMX 驗證。如果是 Cassandra,請按照「為 Cassandra 啟用 JMX 驗證」中的操作說明操作。

啟用 JMX

根據預設,系統只會為 Cassandra 啟用 JMX,並為所有其他 Edge 元件停用 JMX。本節說明如何為其他 Edge 元件啟用 JMX。

如何啟用 JMX:

  1. 編輯元件的設定檔。這個檔案位於 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。

  2. 在啟動元件的 exec 行中,新增下列 com.sun.management.jmxremote 選項:
    -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 和 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

    這個範例為 Management Server 指定通訊埠 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
  3. 儲存設定檔。
  4. 使用 restart 指令重新啟動元件。

    舉例來說,如要重新啟動 Management Server,請執行下列指令:

    /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 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 傳入,系統會提示您)

您可以使用指令列選項或設定檔,定義使用者名稱、密碼和啟用/停用狀態。請勿同時指定一組選項和設定檔。

以下範例使用指令列選項,為 Management Server 啟用 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 屬性 (MBean):

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

用量

使用 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

傳回服務相關資訊,包括:

  • 設定屬性
  • 開始時間和運作時間
  • 版本、RPM 和 UUID 資訊
  • 內部和外部主機名稱和 IP 位址
  • 區域和 Pod
  • <isUp> 屬性,指出服務是否正在執行

您必須使用 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 Server 的 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:password
curl 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。

這項呼叫需要您使用系統管理使用者名稱和密碼進行驗證。

伺服器應為所有呼叫傳回「已部署」狀態。如果上述方法無效,請按照下列步驟操作:

  1. 查看伺服器記錄,瞭解是否有任何錯誤。記錄檔位於:
    • 管理伺服器:opt/apigee/var/log/edge-management-server
    • 訊息處理器:opt/apigee/var/log/edge-message-processor
  2. 呼叫伺服器,檢查是否正常運作。
  3. 從 ELB 移除伺服器,然後重新啟動:
    /opt/apigee/apigee-service/bin/apigee-service service_name restart

    其中 service_name 為:

    • edge-management-server
    • edge-message-processor

使用 apigee-service 指令查看狀態

登入執行服務的伺服器後,您可以使用 apigee-service 指令排解 Edge 服務問題。

如要使用 apigee-service 檢查服務狀態,請按照下列步驟操作:

  1. 登入伺服器並執行下列指令:
    /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
  2. 如果服務未執行,請啟動服務:
    /opt/apigee/apigee-service/bin/apigee-service service_name start
  3. 重新啟動服務後,請使用先前用過的 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 Analytics 伺服器的狀態:

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。

執行指令碼前的注意事項:

  1. 您必須在每個 Postgres 節點上安裝 check_postgres.pl 指令碼。
  2. 確認您已安裝 perl-Time-HiRes.x86_64,這是一個 Perl 模組,可實作高解析度鬧鐘、睡眠、gettimeofday 和間隔計時器。舉例來說,您可以使用下列指令安裝:
    yum install perl-Time-HiRes.x86_64
  3. CentOS 7:在 CentOS 7 版上使用 check_postgres.pl 之前,請先安裝 perl-Data-Dumper.x86_64 RPM。

check_postgres.pl 輸出

使用 check_postgres.pl 的 API 呼叫預設輸出內容與 Nagios 相容。安裝指令碼後,請進行下列檢查:

  1. 檢查資料庫大小:
    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'
  2. 檢查資料庫的傳入連線數量,並與允許的連線數量上限進行比較:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action backends
  3. 檢查資料庫是否正在運作且可用:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action connection
  4. 檢查磁碟空間:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action disk_space --warning='80%' --critical='90%'
  5. 檢查 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 服務,請參閱下列資源:

Apache Cassandra

Cassandra 預設啟用 JMX,且不需密碼即可遠端存取 Cassandra。

啟用 Cassandra 的 JMX 驗證

您可以為 Cassandra 啟用 JMX 驗證。完成後,您必須將使用者名稱和密碼傳遞至對 nodetool 公用程式的所有呼叫。

如要為 Cassandra 啟用 JMX 驗證:

  1. 建立及編輯 cassandra.properties 檔案:
    1. 編輯 /opt/apigee/customer/application/cassandra.properties 檔案。如果檔案不存在,請建立檔案。
    2. 在檔案中新增下列內容:
      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
    3. 儲存 cassandra.properties 檔案。
    4. 將檔案擁有者變更為「apigee:apigee」,如以下範例所示:
      chown apigee:apigee /opt/apigee/customer/application/cassandra.properties

    如要進一步瞭解如何使用屬性檔案設定權杖,請參閱「如何設定 Edge」。

  2. 建立及編輯jmx_auth.sh:
    1. 如果下列位置沒有檔案,請建立檔案:
      /opt/apigee/customer/application/jmx_auth.sh
    2. 在檔案中新增下列屬性:
      export CASS_JMX_USERNAME=JMX_USERNAME
      export CASS_JMX_PASSWORD=JMX_PASSWORD
    3. 儲存 jmx_auth.sh 檔案。
    4. 提供檔案來源:
      source /opt/apigee/customer/application/jmx_auth.sh
  3. 複製並編輯 jmxremote.password 檔案:
    1. 將下列檔案從 $JAVA_HOME 目錄複製到 /opt/apigee/data/apigee-cassandra/:
      cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/data/apigee-cassandra/jmxremote.password
    2. 編輯 jmxremote.password 檔案,並使用下列語法新增 JMX 使用者名稱和密碼:
      JMX_USERNAME JMX_PASSWORD

      其中 JMX_USERNAME 和 JMX_PASSWORD 是您先前設定的 JMX 使用者名稱和密碼。

    3. 確認檔案擁有者為「apigee」,且檔案模式為 400:
      chown apigee:apigee /opt/apigee/data/apigee-cassandra/jmxremote.password
      chmod 400 /opt/apigee/data/apigee-cassandra/jmxremote.password
  4. 複製並編輯 jmxremote.access 檔案:
    1. 將下列檔案從 $JAVA_HOME 目錄複製到 /opt/apigee/data/apigee-cassandra/:
      cp ${JAVA_HOME}/lib/management/jmxremote.access $APIGEE_ROOT/data/apigee-cassandra/jmxremote.access
    2. 編輯 jmxremote.access 檔案,並新增下列角色:
      JMX_USERNAME readwrite
    3. 確認檔案擁有者為「apigee」,且檔案模式為 400:
      chown apigee:apigee /opt/apigee/data/apigee-cassandra/jmxremote.access
      chmod 400 /opt/apigee/data/apigee-cassandra/jmxremote.access
  5. 在 Cassandra 上執行 configure:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
  6. 重新啟動 Cassandra:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
  7. 在所有其他 Cassandra 節點上重複這項程序。

啟用 JMX 密碼加密

如要啟用 JMX 密碼加密功能,請按照下列步驟操作:

  1. 開啟 source/conf/casssandra-env.sh 檔案。
  2. 在檔案中取消註解下列幾行:
    • 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"
  3. 在指令列中輸入 echo -n 'Secret' | openssl dgst -sha1,產生所需密碼的 SHA1 雜湊
  4. 在 jmxremote.password 中設定使用者名稱的密碼。
  5. 更新後,請將檔案 cassandra-env.sh 改回唯讀。

停用 Cassandra 的 JMX 驗證

如要停用 Cassandra 的 JMX 驗證:

  1. 編輯 /opt/apigee/customer/application/cassandra.properties。
  2. 移除檔案中的下列程式碼行:
    conf_cassandra-env_com.sun.management.jmxremote.authenticate=true
  3. 在 Cassandra 上執行設定:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
  4. 重新啟動 Cassandra:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
  5. 在所有其他 Cassandra 節點上重複這項程序。

使用 JConsole:監控工作統計資料

使用 JConsole 和下列服務網址,監控透過 JMX 提供的 JMX 屬性 (MBean):

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 叢集節點上發出下列呼叫:

  1. 一般環狀資訊 (也適用於單一 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
  2. 節點一般資訊 (每個節點呼叫)
    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
  3. Thrift 伺服器狀態 (提供用戶端 API)
    nodetool [-u username -pw password] -h localhost statusthrift

    上述指令的輸出內容如下所示:

    running
  4. 資料串流作業狀態:觀察 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/operations/monitoring。

Apache ZooKeeper

檢查 ZooKeeper 狀態

  1. 確認 ZooKeeper 程序正在執行。ZooKeeper 會將 PID 檔案寫入 opt/apigee/var/run/apigee-zookeeper/apigee-zookeeper.pid。
  2. 測試 ZooKeeper 通訊埠,確保您能與每個 ZooKeeper 伺服器上的通訊埠 2181 和 3888 建立 TCP 連線。
  3. 確認您可以從 ZooKeeper 資料庫讀取值。使用 ZooKeeper 用戶端程式庫 (或 /opt/apigee/apigee-zookeeper/bin/zkCli.sh) 連線,並從資料庫讀取值。
  4. 查看狀態:
    /opt/apigee/apigee-service/bin/apigee-service apigee-zookeeper status

使用 ZooKeeper 四字母指令

您可以使用 netcat (nc) 或 telnet,將一小組指令 (四個字母的字詞) 傳送至通訊埠 2181,藉此監控 ZooKeeper。

如要進一步瞭解 ZooKeeper 指令,請參閱「Apache ZooKeeper 指令參考資料」。

例如:

  • srvr:列出伺服器的完整詳細資料。
  • stat:列出伺服器和已連線用戶端的簡短詳細資料。

您可以對 ZooKeeper 通訊埠發出下列指令:

  1. 執行四字母指令 ruok,測試伺服器是否在無錯誤狀態下運作。成功的回應會傳回「imok」。
    echo ruok | nc host 2181

    傳回值:

    imok
  2. 執行四字母指令 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
  3. 如果無法使用 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,確認特定要求是否正常處理。換句話說,請檢查特定搜尋是否傳回正確結果。

  1. 使用 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
  2. 使用下列指令,檢查管理伺服器是否仍連線至 LDAP:
    curl -u userEMail:password http://localhost:8080/v1/users/ADMIN

    傳回值:

    {
      "emailId" : ADMIN,
      "firstName" : "admin",
      "lastName" : "admin"
    }

您也可以監控 OpenLDAP 快取,這有助於減少磁碟存取次數,進而提升系統效能。監控並調整 OpenLDAP 伺服器中的快取大小,可能會大幅影響目錄伺服器的效能。您可以查看記錄檔 (opt/apigee/var/log),取得快取相關資訊。