Edge for Private Cloud 4.17.05 版
本文說明 Apigee Edge 地端部署支援的元件監控技術。
啟用 JMX
根據預設,Cassandra 會啟用 JMX,所有其他 Edge 元件則會停用 JMX。因此,您必須為每個元件個別啟用 JMX。
每個元件都支援不同通訊埠上的 JMX。下表列出 JMX 連接埠,以及您要修改以在該連接埠上啟用 JMX 的檔案:
| 元件 | JMX 通訊埠 | 檔案 |
|---|---|---|
| 管理伺服器 | 1099 | /opt/apigee/edge-management-server/bin/start |
| 訊息處理器 | 1101 | /opt/apigee/edge-mesage-processor/bin/start |
| Qpid | 1102 | /opt/apigee/edge-qpid-server/bin/start |
| Postgres | 1103 | /opt/apigee/edge-postgres-server/bin/start |
舉例來說,如要在管理伺服器上啟用 JMX,請在編輯器中開啟 /opt/apigee/edge-management-server/bin/start。您應該會看到下列用於啟動管理伺服器的指令行:
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 $* $debug_options com.apigee.kernel.MicroKernel
編輯這行程式碼,加入以下內容:
-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
請注意,這行會將 Management Server 的 JMX 通訊埠編號指定為 1099。請按照上表定義,為每個元件設定通訊埠號碼。例如:
exec $JAVA -classpath "$classpath" -Xms$min_mem -Xmx$max_mem $xx_opts -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 -Djava.security.auth.login.config=$conf_path/jaas.config -Dinstallation.dir=$install_dir $sys_props -Dconf.dir=$conf_path -Ddata.dir=$data_dir $* $debug_options com.apigee.kernel.MicroKernel
儲存檔案,然後重新啟動元件。例如,如要重新啟動管理伺服器:
> /opt/apigee/apigee-service/bin/ apigee-service edge-management-server restart
啟用 JMX 驗證及設定 JMX 密碼
Management Server、訊息處理器、Qpid 和 Postgres 的監控程序都使用 JMX。根據預設,遠端 JMX 存取權不需要密碼。
如要啟用 JMX 驗證,每個元件都有 change_jmx_auth 動作,可用來啟用/停用驗證及設定 JMX 憑證。
如要啟用 JMX 驗證,請使用下列指令:
> /<inst_root>/apigee/apigee-service/bin/apigee-service comp change_jmx_auth optionsOrConfigFile
其中:
- comp 是 edge-management-server、edge-message-processor、edge-qpid-server 或 edge-postgres-server。
- 選項包括:
- -u:使用者名稱
- -p:密碼
- -e:y (啟用) 或 n (停用)
- 設定檔包含:
- JMX_USERNAME=username
- JMX_ENABLED=y/n
- JMX_PASSWORD=password (如果未設定或未透過 -p 傳入,系統會提示您)
舉例來說,如要在指令列使用選項,請輸入:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -u foo -p bar -e y
如果您有設定檔:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -f configFile
如果您在多個節點上執行 Edge,請在所有節點上執行這個指令,並指定相同的使用者名稱和密碼。
如要停用 JMX 驗證,請使用下列指令:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -e n
管理伺服器
使用 JConsole 監控系統健康狀態檢查和程序資訊
使用 JConsole (符合 JMX 規範的工具) 管理及監控健康狀態檢查和程序統計資料。您可以使用 JConsole 擷取管理伺服器 (或任何伺服器) 公開的 JMX 統計資料,並以圖形介面顯示。如要進一步瞭解 JConsole 的使用方式,請參閱 http://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html。
使用 JConsole 和下列服務網址,監控透過 JMX 提供的 JMX 屬性 (MBean)。
service:jmx:rmi:///jndi/rmi://<ip address>:<port>/jmxrmi
其中 <ip address> 是管理伺服器 (或個別伺服器) 的 IP 位址。Management Server 的預設通訊埠為 1099。
下表列出一般 JMX 統計資料:
|
JMX MBean |
JMX 屬性 |
|---|---|
|
記憶體 |
HeapMemoryUsage |
|
NonHeapMemoryUsage |
|
|
用量 |
|
|
注意:屬性值會顯示為四個值:committed、init、max 和 used。 |
|
使用 Edge Application API 檢查
您可以叫用下列 CURL 指令,在管理伺服器 (或任何伺服器) 上執行 API 檢查:
curl http://<host>:8080/v1/servers/self/up
其中 <host> 是管理伺服器的 IP 位址。
這項呼叫會傳回「true」和「false」。如果為 true,表示節點已啟動,且 Java 服務正在執行。
如果未收到 HTTP 200 (OK) 回應,表示 Edge 無法回應通訊埠 8080 要求。
疑難排解
- 登入伺服器並執行下列指令:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server status - 如果服務未執行,請啟動服務:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server start
使用 Edge 應用程式:使用者、組織和部署作業檢查
在每個地端部署安裝中,管理伺服器扮演著重要角色,可將所有其他套件整合在一起。您可以發出下列指令,在管理伺服器上檢查使用者、組織和部署作業狀態:
curl -u userEmail:password http://localhost:8080/v1/users curl -u userEmail:password http://localhost:8080/v1/organizations curl -u userEmail:password http://localhost:8080/v1/organizations/orgname/deployments
系統應會為所有呼叫顯示「已部署」狀態。如果上述方法都無效,請按照下列步驟操作:
- 查看管理伺服器記錄 (位於 <inst_root>/apigee/var/log/edge-management-server),瞭解是否有任何錯誤。
- 呼叫管理伺服器,檢查是否正常運作。
- 從 ELB 移除伺服器,然後重新啟動管理伺服器。
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server restart
路由器
您可以叫用下列 CURL 指令,在路由器 (或任何伺服器) 上執行 API 檢查:
curl http://<host>:8081/v1/servers/self/up
其中,host 是路由器的 IP 位址。
這項呼叫會傳回「true」和「false」。如果為 true,代表節點已啟動,且路由器服務正在執行。
如果未收到 HTTP 200 (OK) 回應,表示 Edge 無法回應通訊埠 8081 要求。
疑難排解
- 登入伺服器並執行下列指令:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-router status - 如果服務未執行,請啟動服務
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-router start - 重新啟動後,請確認其運作正常
curl -v http://localhost:port/v1/servers/self/up
其中 port 是路由器為 8081,訊息處理器為 8082。
訊息處理器
使用 JConsole 監控系統健康狀態檢查和程序資訊
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 1101。
使用 Edge Application API 檢查
按照上述步驟操作。
注意:請務必使用通訊埠 8082。
使用 JMX 訊息流程檢查
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 1101。
Qpid 伺服器
使用 JConsole 監控系統健康狀態檢查和程序資訊
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 1102。
使用 Edge Application API 檢查
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 8083。Qpid 伺服器也支援下列 CURL 指令:
curl http://<qpid_IP>:8083/v1/servers/self
Postgres 伺服器
使用 JConsole 監控系統健康狀態檢查和程序資訊
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 1103。
使用 Edge Application API 檢查
請按照上述管理伺服器的步驟操作。
注意:請務必使用通訊埠 8084。Postgres 伺服器也支援下列 CURL 指令:
curl http://<postgres_IP>:8084/v1/servers/self
使用 Edge Application 機構和環境檢查
您可以發出下列 CURL 指令,檢查 Postgres 伺服器上已上線的組織和環境名稱:
curl http:// <postgres_IP>:8084/v1/servers/self/organizations
注意:請務必使用通訊埠 8084。
系統應會顯示組織和環境名稱。
使用 Edge Application axstatus 檢查
您可以發出下列 CURL 指令,驗證數據分析伺服器的狀態。
curl -u userEmail:password http://<host>:<port>/v1/organizations/<orgname>/environments/<envname>/provisioning/axstatus
系統應會為所有數據分析伺服器顯示「成功」狀態。上述 CURL 指令的輸出內容如下所示:
{
"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 資料庫
使用 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
使用 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
注意:如需使用上述指令的相關協助,請參閱 http://bucardo.org/check_postgres/check_postgres.pl.html。
資料庫檢查
您可以確認 PostgreSQL 資料庫中是否已建立適當的資料表。使用下列指令登入 PostgreSQL 資料庫:
psql -h /opt/apigee/var/run/apigee-postgresql/ -U apigee -d apigee
然後執行:
\d analytics."<org>.<env>.fact"
檢查 postgres 程序健康狀態
您可以叫用下列 CURL 指令,在 postgres 機器上執行 API 檢查:
http://<postgres_IP>:8084/v1/servers/self/health/
注意:請務必使用通訊埠 8084。
如果 postgres 程序處於啟用狀態,則會傳回「ACTIVE」狀態。如果 postgres 程序未啟動並執行,則會傳回「INACTIVE」狀態。
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
使用 JConsole:監控工作統計資料
使用 JConsole 和下列服務網址,監控透過 JMX 提供的 JMX 屬性 (MBean)。
service:jmx:rmi:///jndi/rmi://<ip address>:7199/jmxrmi
其中 <ip address> 是 Cassandra 伺服器的 IP 位址。
Cassandra 預設會啟用 JMX,且不需密碼即可遠端存取 Cassandra。
如要啟用 JMX 驗證並新增密碼,請按照下列步驟操作:
- 編輯 /<inst_root>/apigee/customer/application/cassandra.properties。 如果檔案不存在,請建立檔案。
- 在檔案中新增下列內容:
conf_cassandra-env_com.sun.management.jmxremote.authenticate=true - 儲存檔案。
- 將下列檔案從 $JAVA_HOME 目錄複製到 /<inst_root>/apigee/data/apigee-cassandra/:
cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/data/apigee-cassandra/jmxremote.password
cp ${JAVA_HOME}/lib/management/jmxremote.access $APIGEE_ROOT/data/apigee-cassandra/jmxremote.access - 編輯 jmxremote.password,並在檔案中新增使用者名稱和密碼:
cassandra password
其中 password 是 JMX 密碼。 - 編輯 jmxremote.access 並新增下列角色:
cassandra readwrite - 確認檔案擁有者為「apigee」,且檔案模式為 400:
> chown apigee:apigee /<inst_root>/apigee/data/apigee-cassandra/jmxremote.*
> chmod 400 /<inst_root>/apigee/data/apigee-cassandra/jmxremote.* - 在 Cassandra 上執行 configure:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure - 重新啟動 Cassandra:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
如要停用驗證功能,請按照下列步驟操作:
- 編輯 /<inst_root>/apigee/customer/application/cassandra.properties。
- 移除檔案中的下列程式碼行:
conf_cassandra-env_com.sun.management.jmxremote.authenticate=true - 在 Cassandra 上執行設定:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure - 重新啟動 Cassandra:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
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 的指令列介面,用於管理叢集節點。這個公用程式位於 <inst_root>/apigee/apigee-cassandra/bin。
如要進一步瞭解 nodetool 公用程式,請參閱 http://www.datastax.com/docs/1.0/references/nodetool。
您可以在所有 Cassandra 叢集節點上發出下列呼叫:
- 一般環狀資訊 (也適用於單一 Cassandra 節點):尋找所有節點的「Up」和「Normal」。
[host]# nodetool -h localhost ring
上述指令的輸出內容如下所示:
Address DC Rack Status State Load Owns Token
192.168.124.201 dc1 ra1 Up Normal 1.67 MB 33,33% 0
192.168.124.202 dc1 ra1 Up Normal 1.68 MB 33,33% 56713727820156410577229101238628035242
192.168.124.203 dc1 ra1 Up Normal 1.67 MB 33,33% 113427455640312821154458202477256070484 - 節點的一般資訊 (每個節點呼叫)
nodetool -h localhost info
上述指令的輸出內容如下所示:
Token : 0
Gossip active : true
Load : 1.67 MB
Generation No : 1361968765
Uptime (seconds) : 78108
Heap Memory (MB) : 46,80 / 772,00
Data Center : dc1
Rack : ra1
Exceptions : 0 - Thrift 伺服器 (提供用戶端 API) 的狀態
host]# nodetool -h localhost statusthrift
上述指令的輸出內容會顯示「running」狀態。 - 資料串流作業的狀態:觀察 Cassandra 節點的流量
nodetool -h localhost netstats 192.168.124.203
上述指令的輸出內容如下所示:
Mode: NORMAL
Nothing streaming to /192.168.124.203
Nothing streaming from /192.168.124.203
Pool Name Active Pending Completed
Commands n/a 0 1688
Responses n/a 0 292277
Cassandra 監控 (使用者介面)
請參閱 datastax opscenter 網址:http://www.datastax.com/products/opscenter。
Cassandra 資源
請參閱下列網址:http://www.datastax.com/docs/1.0/operations/monitoring。
Apache ZooKeeper
檢查 ZooKeeper 狀態
- 確認 ZooKeeper 程序正在執行。ZooKeeper 會將 PID 檔案寫入 <inst_root>/apigee/var/run/apigee-zookeeper/apigee-zookeeper.pid。
- 測試 ZooKeeper 通訊埠,確保您能與每個 ZooKeeper 伺服器上的通訊埠 2181 和 3888 建立 TCP 連線。
- 確認您可以從 ZooKeeper 資料庫讀取值。使用 ZooKeeper 用戶端程式庫 (或 /<inst_root>/apigee/apigee-zookeeper/bin/zkCli.sh) 連線,並從資料庫讀取值。
- 檢查狀態:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-zookeeper status
使用 ZooKeeper 四字母指令
您可以使用 netcat (nc) 或 telnet,將一小組指令 (四個字母的字詞) 傳送至通訊埠 2181,藉此監控 ZooKeeper。
如要進一步瞭解 ZooKeeper 指令,請參閱 http://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands。
例如:
- srvr:列出伺服器的完整詳細資料。
- stat:列出伺服器和已連線用戶端的簡短詳細資料。
您可以對 ZooKeeper 通訊埠發出下列指令:
- 執行四字母指令 ruok,測試伺服器是否在無錯誤狀態下運作。成功的回應會傳回「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
注意:有時必須查看 ZooKeeper 的模式是 leader、follower 還是 observer。 - 如果無法使用 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
OpenLDAP
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 伺服器中的快取大小,可能會大幅影響目錄伺服器的效能。您可以查看記錄檔 (<inst_root>/apigee/var/log),取得快取相關資訊。