如何監控

本文件說明 Apigee Edge for Private Cloud 內部部署系統支援的元件監控技術。

總覽

Edge 支援多種取得服務詳細資料及查看狀態的方法。下表列出您可以對各項合格服務執行的檢查類型:

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

* 您必須先按照啟用 JMX 一文所述的方式啟用 JMX。

** apigee-monit 服務會檢查元件是否設定完成,如果不是,則會嘗試重新啟動。詳情請參閱使用 apigee-monit 自行修復

監控通訊埠和設定檔

每個元件支援不同通訊埠的 Java Management Extensions (JMX) 和 Management 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

如要在不啟用驗證或 SSL 式通訊的情況下啟用 JMX,請執行下列步驟。 注意:在實際運作系統中,基於安全考量,您應同時啟用加密驗證和 SSL。

  1. 編輯適當的設定檔 (請參閱 設定檔參考資料)。如果設定檔不存在,請建立設定檔。
    conf_system_jmxremote_enable=true
  2. 儲存設定檔,並確認該檔案的擁有者為 apigee:apigee
  3. 重新啟動適當的 Edge 元件
    apigee-service edge-management-server restart

如要停用 JMX,請移除屬性 conf_system_jmxremote_enable 或將其值變更為 false。然後重新啟動適當的 Edge 元件。

JMX 驗證

Edge for Private Cloud 支援使用儲存在檔案中的詳細資料以密碼進行驗證。您可以將密碼儲存為雜湊,進一步提升安全性。

  1. 如要在 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 所擁有。
  2. 為密碼建立 SHA256 雜湊:
    echo -n '' | openssl dgst -sha256
  3. 使用 JMX 使用者憑證建立 jmxremote.password 檔案:
    1. 將下列檔案從 $JAVA_HOME 目錄複製到 /opt/apigee/customer/application/<component>/ 目錄:
      cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/customer/application/management-server/jmxremote.password
    2. 請編輯檔案,並使用以下語法新增 JMX 使用者名稱和密碼:
      USERNAME <HASH-PASSWORD>
    3. 確認檔案的擁有者為 apigee,且檔案模式為 400:
      chown apigee:apigee $APIGEE_ROOT/customer/application/management-server/jmxremote.password
      chmod 400 $APIGEE_ROOT/customer/application/management-server/jmxremote.password
  4. 建立具有 JMX 使用者權限的 jmxremote.access 檔案:
    1. 將下列檔案從 $JAVA_HOME 目錄中複製到 /opt/apigee/customer/application/<component>/
      
      cp ${JAVA_HOME}/lib/management/jmxremote.access$APIGEE_ROOT/customer/application/management-server/jmxremote.password/jmxremote.access
    2. 編輯檔案,新增 JMX 使用者名稱,並在後方加上權限 (READONLY/READWRITE)
      USERNAME READONLY
    3. 確認檔案的擁有者為 apigee,且檔案模式為 400:
      chown apigee:apigee $APIGEE_ROOT/customer/application/management-server/jmxremote.password
      
      chmod 400 $APIGEE_ROOT/customer/application/management-server/jmxremote.access
  5. 重新啟動適當的 Edge 元件:
    apigee-service edge-management-server restart

如要停用 JMX 驗證,請移除屬性 conf_system_jmxremote_authenticate 或將值變更為 false,並重新啟動適當的 Edge 元件。

JMX 中的 SSL

如何在 Edge-* 元件中啟用 SSL 型 JMX:

  1. 編輯適當的設定檔 (請參閱 設定檔參考資料)。建立設定檔 (如果不存在):
    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 所擁有。
  2. 準備含有伺服器金鑰的 KeyStore,然後將其放在上方 conf_system_javax_net_ssl_keystore 設定中提供的路徑。請確認 apigee:apigee 可讀取 KeyStore 檔案。
  3. 重新啟動適當的 Edge 元件:
    apigee-service edge-management-server restart

如要停用 SSL 型 JMX,請移除 conf_system_jmxremote_ssl 屬性,或是將值改為 false。重新啟動適當的 Edge 元件。

透過 Jconsole 監控

透過 jconsole 監控的操作說明與 https://docs.apigee.com/private-cloud/v4.52.01/how-monitor#jconsole 。

可加入一行文字,說明「如果 JMX 已啟用 SSL,則必須啟動 jconsole 和 Truststore 密碼。」參考資料:https://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html

使用 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 and Management API 監控通訊埠

下表列出一般 JMX 統計資料:

JMX MBeans JMX 屬性

記憶體

HeapMemoryUsage

NonHeapMemoryUsage

用量

設定檔參考資料

以下各節說明針對 JMX 相關設定,您可能需要對 Edge 元件設定檔進行的變更。詳情請參閱「監控通訊埠和設定檔」一文。

將 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
  • 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

檢查服務是否正在執行。但不需要驗證。

如果服務正在執行,此端點會傳回下列回應:

<ServerField>
  <Up>true</Up>
</ServerField>

如果服務並未執行,您會收到類似下列的回應 (視服務類型和勾選方式而定):

curl: Failed connect to localhost:port_number; Connection refused
/servers/self

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

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

這個 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 Server 的 Management API 通訊埠為 8080。如需要使用的 Management API 通訊埠編號清單,請參閱 JMX and 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 分析伺服器的狀態:

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 v7 上使用 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 程序的健康狀態

您可以叫用下列 curl 指令,在 Postgres 機器上執行 API 檢查:

curl -v http://postgres_IP:8084/v1/servers/self/health

這個指令會在 postgres 程序執行時傳回 ACTIVE 狀態。如果 Postgres 程序未啟動及執行,會傳回 INACTIVE 狀態。

Postgres 資源

如要進一步瞭解如何監控 Postgres 服務,請參閱以下資訊:

Apache Cassandra

根據預設,Cassandra 會啟用 JMX,遠端 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}/customer/application/apigee-cassandra/jmxremote.password
      conf_cassandra_env_com.sun.management.jmxremote.access.file=${APIGEE_ROOT}/customer/application/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/customer/application/apigee-cassandra/
      cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.password
    2. 編輯 jmxremote.password 檔案,並使用以下語法新增 JMX 使用者名稱和密碼:
      JMX_USERNAME JMX_PASSWORD

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

    3. 請確定檔案的擁有者為「apigee」,且檔案模式為 400:
      chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/jmxremote.password
      chmod 400 /opt/apigee/customer/application/apigee-cassandra/jmxremote.password
  4. 複製並編輯 jmxremote.access 檔案:
    1. 將下列檔案從 $JAVA_HOME 目錄複製到 /opt/apigee/customer/application/apigee-cassandra/
      cp ${JAVA_HOME}/lib/management/jmxremote.access
      $APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.access
    2. 編輯 jmxremote.access 檔案並新增下列角色:
      JMX_USERNAME readwrite
    3. 請確定檔案的擁有者為「apigee」,且檔案模式為 400:
      chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/jmxremote.access
      chmod 400 /opt/apigee/customer/application/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. 建立及編輯 cassandra.properties 檔案:
    1. 編輯 /opt/apigee/customer/application/cassandra.properties 檔案。如果檔案不存在,請建立該檔案。
    2. 將下列指令新增至檔案:
      conf_cassandra_env_com.sun.management.jmxremote.encrypted.authenticate=true
    3. 儲存 cassandra.properties 檔案。
    4. 將檔案擁有者變更為 apigee:apigee,如以下範例所示:
      chown apigee:apigee /opt/apigee/customer/application/cassandra.properties
  3. 在指令列中輸入 echo -n 'Secret' | openssl dgst -sha1,產生所需密碼的 SHA1 雜湊
  4. 根據 $APIGEE_ROOT/customer/application/apigee-cassandra/jmxremote.password 中的使用者名稱 (在上一節建立) 設定密碼。
  5. 在 Cassandra 上執行設定:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
  6. 重新啟動 Cassandra:
    /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
  7. 對所有其他 Cassandra 節點重複這項程序。

為 Cassandra 啟用具備 SSL 的 JMX

啟用具有 SSL 的 JMX 可為與 Cassandra 進行的 JMX 通訊提供額外的安全與加密機制。如要透過 SSL 啟用 JMX,您必須為 Cassandra 提供金鑰和憑證,以便接受 SSL 型 JMX 連線。對於 SSL,您也需要設定 nodetool (以及透過 JMX 與 Cassandra 通訊的任何其他工具)。

啟用 SSL 的 JMX 支援明文和加密的 JMX 密碼。

如要為 Cassandra 啟用具備 SSL 的 JMX,請按照下列步驟操作:

  1. 啟用 JMX。 請視需要啟用密碼加密功能。
  2. 為 Cassandra 啟用 JMX 驗證。 。確保 nodetool 使用已設定的使用者名稱和密碼。
    /opt/apigee/apigee-cassandra/bin/nodetool -u <JMX_USER> -pw <JMX_PASS> ring
  3. 準備 KeyStore 和信任存放區。

    • KeyStore 應包含金鑰和憑證,可用於設定 Cassandra 伺服器。如果 KeyStore 包含多個金鑰組,Cassandra 就會使用第一個金鑰組啟用 SSL。

      請注意,KeyStore 和金鑰的密碼必須相同 (使用 keytool 產生金鑰時的預設值)。

    • Truststore 只能包含憑證,並可讓用戶端 (Apigee-service-based 指令或 nodetool) 透過 JMX 連線。

    確認上述規定後:

    1. 將 KeyStore 檔案放入 /opt/apigee/customer/application/apigee-cassandra/ 中。
    2. 輸入
      chown apigee:apigee /opt/apigee/customer/application/apigee-cassandra/keystore.node1
      chmod 400 /opt/apigee/customer/application/apigee-cassandra/keystore.node1
      ,確保 Apigee 使用者才能讀取 KeyStore 檔案
  4. 請按照下列步驟為具有 SSL 的 JMX 設定 Cassandra:
    1. 輸入
      apigee-service apigee-cassandra stop
      來停止 Cassandra 節點
    2. 開啟檔案 /opt/apigee/customer/application/cassandra.properties 並新增下列幾行內容,即可在 Cassandra 中啟用安全資料傳輸層 (SSL):
      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
    3. 將檔案擁有者變更為 apigee:apigee,如以下範例所示:
      chown apigee:apigee /opt/apigee/customer/application/cassandra.properties
    4. 在 Cassandra 上執行設定:
      /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
    5. 重新啟動 Cassandra:
      /opt/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
    6. 對所有其他 Cassandra 節點重複這項程序。
    7. 輸入
      apigee-service apigee-cassandra start
      來啟動 Cassandra 節點
  5. 設定 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 引數)

    設定下列環境變數:

    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
  6. 設定 nodetool。必須將 JMX 參數傳遞至 Nodetool。您可以透過下列兩種方式設定 Nodetool,在執行已啟用 SSL 的 JMX 時執行,如以下設定選項所述:

    選項與 SSL 相關設定傳送至 nodetool 的方式不同。在這兩種情況下,執行 nodetool 的使用者都應擁有信任儲存庫檔案的 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 設定,請按照下列步驟操作:

  1. 進入「
    apigee-service apigee-cassandra stop
    」即可停止apigee-cassandra
  2. 從檔案 /opt/apigee/customer/application/cassandra.properties 中移除 conf_cassandra-env_com.sun.management.jmxremote.ssl=true 行。
  3. /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”
    中的下列幾行註解排除
  4. 從入場apigee-cassandra開始
  5. apigee-service apigee-cassandra start
  6. 如果已設定環境變數 CASS_JMX_SSL,請移除該變數。

    unset CASS_JMX_SSL
  7. 檢查 ringstopbackup 等指令的 apigee-service 是否運作正常。
  8. 停止搭配使用 --ssl 切換器和 nodetool

停用 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 屬性 (MBeans):

service:jmx:rmi:///jndi/rmi://IP_address:7199/jmxrmi

其中 IP_address 是 Cassandra 伺服器的 IP。

Cassandra JMX 統計資料

JMX MBeans JMX 屬性

ColumnFamilies/apprepo/環境

ColumnFamilies/apprepo/機構

ColumnFamilies/apprepo/apiproxy_revisions

ColumnFamilies/apprepo/apiproxies

資料欄系列/稽核/稽核

ColumnFamily/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 節點):尋找所有節點的「向上」和「一般」。
    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. 等待伺服器的狀態 (提供用戶端 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 Qpid Broker-J

您可以透過 Qpid 管理控制台監控 Qpid Broker-J。本節說明如何存取主控台,以及如何使用主控台執行基本監控功能。如要進一步瞭解如何使用管理主控台,請參閱 Apache Qpid 說明文件中的 網路管理主控台

存取管理控制台

預設的管理主控台通訊埠為 8090。如要存取這個預設通訊埠的控制台,請將網路瀏覽器指向下列位置:

http://QPID_NODE_IP:8090

如要登入控制台,請使用 Apigee 或 Edge 設定檔中設定的預設憑證。詳情請參閱 Edge 設定檔參考資料

監控佇列和訊息

在左側導覽面板中,前往「Java-Broker」>「virtualhosts」>「Queues」。選取佇列即可在 UI 的主要部分查看其詳細資料。詳細資料檢視畫面中會顯示「佇列屬性」和「統計資料」,包括已傳送訊息、已排入佇列、訊息率等資訊。

查看及下載記錄檔

在左側導覽面板中,依序前往「Java-Broker」>「brokerloggers」>「logfile」。在主要 UI 詳細資料檢視畫面中,您可以查看記錄檔詳細資料及下載記錄檔。

使用 Qpid Management API

您可以使用 Apache Qpid Broker-J REST API 自動管理工作及監控代理程式。 詳情請參閱 Apache Qpid 代理程式 REST API 說明文件

您也可以使用指令列工具來監控代理程式。例如:

curl "QPID_NODE_IP":"8090"/api/latest/broker -u "USERNAME":"PASSWORD"

啟用透過 SSL 進行 Qpid 監控的功能

如要提高監控與管理的安全性,請在 Qpid 的管理入口網站和 Qpid 的 Management API 上啟用 SSL。請按照以下指南提供金鑰和憑證。

Qpid 提供適用於 Apigee 的 File KeyStore 選項。這個類型接受 Java 和 Java 工具 (例如 keytool) 瞭解的標準 JKS KeyStore 格式。

KeyStore 準備

除了使用 keytool 以外,您還需要直接提供憑證檔案以供 Qpidd 用戶端使用。

如要產生 KeyStore,請參閱 Java Keytool 說明文件

確認需求條件後

  1. 將 KeyStore 和憑證檔案放入 /opt/apigee/customer/application/apigee-qpidd 中。
  2. 確保只有 Apigee 使用者能夠讀取 KeyStore 檔案:
    chown apigee:apigee /opt/apigee/customer/application/apigee-qpidd/qpidd.keystore
      chmod 400 /opt/apigee/customer/application/apigee-qpidd/qpidd.keystore
        
      chown apigee:apigee /opt/apigee/customer/application/apigee-qpidd/qpidd-cert.pem
      chmod 400 /opt/apigee/customer/application/apigee-qpidd/qpidd-cert.pem

在 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
  conf_qpidd_qpid.keystore.certificate=/opt/apigee/customer/application/apigee-qpidd/qpidd-cert.pem
  1. 將檔案擁有者變更為 Apigee:apigee:
    chown apigee:apigee /opt/apigee/customer/application/qpidd.properties
  2. 設定 Qpidd:
    apigee-service apigee-qpidd configure
  3. 重新啟動 Qpidd:
    apigee-service apigee-qpidd restart
  4. 使用 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
  1. 設定 Qpidd:
    apigee-service apigee-qpidd configure
  2. 重新啟動 Qpidd:
    apigee-service apigee-qpidd restart
  3. 使用 wait_for_ready 查看狀態:
    apigee-service apigee-qpidd wait_for_ready

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 字母字詞

系統可以透過一組小型指令 (四字母字) 監控 ZooKeeper,這些指令會使用 netcat (nc) 或 telnet 傳送至通訊埠 2181。

如要進一步瞭解 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. 使用下列指令,檢查 Management Server 是否仍與 LDAP 連線:
    curl -u userEMail:password http://localhost:8080/v1/users/ADMIN

    退貨:

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

您也可以監控 OpenLDAP 快取,藉此減少磁碟存取次數,進而改善系統效能。如果監控又調整 OpenLDAP 伺服器中的快取大小,就會嚴重影響目錄伺服器的效能。您可以查看記錄檔 (opt/apigee/var/log) 來取得快取的相關資訊。