JMX 連接器¶
JMX 連接器提供從 Presto 叢集中所有節點查詢 JMX 資訊的功能。這對於監控或偵錯非常有用。Java 管理擴充功能 (JMX) 提供有關 Java 虛擬機器和其中執行之所有軟體的資訊。Presto 本身透過 JMX 進行大量檢測。
也可以設定此連接器,以便定期傾印所選的 JMX 資訊並儲存在記憶體中以供稍後存取。
組態¶
若要設定 JMX 連接器,請建立一個包含以下內容的目錄屬性檔案 etc/catalog/jmx.properties
connector.name=jmx
若要啟用定期傾印,請定義下列屬性
connector.name=jmx
jmx.dump-tables=java.lang:type=Runtime,com.facebook.presto.execution.scheduler:name=NodeScheduler
jmx.dump-period=10s
jmx.max-entries=86400
dump-tables
是以逗號分隔的 Managed Bean (MBean) 清單。它指定每個 dump-period
將會取樣並儲存在記憶體中的 MBean。歷史記錄的項目限制大小為 max-entries
。 dump-period
和 max-entries
的預設值分別為 10s
和 86400
。
MBean 名稱中的逗號應以以下方式逸出
connector.name=jmx
jmx.dump-tables=com.facebook.presto.memory:type=memorypool\\,name=general,\
com.facebook.presto.memory:type=memorypool\\,name=system,\
com.facebook.presto.memory:type=memorypool\\,name=reserved
查詢 JMX¶
JMX 連接器提供三個綱要:current
、history
和 information_schema
。
目前綱要¶
current
綱要包含 Presto 叢集中每個節點的每個 MBean。若要查看所有可用的 MBean,請執行 SHOW TABLES
SHOW TABLES FROM jmx.current;
MBean 名稱會對應到非標準的資料表名稱,並且在查詢中參考這些名稱時,必須用雙引號括住。例如,下列查詢會顯示每個節點的 JVM 版本
SELECT node, vmname, vmversion
FROM jmx.current."java.lang:type=runtime";
node | vmname | vmversion
--------------------------------------+-----------------------------------+-----------
ddc4df17-0b8e-4843-bb14-1b8af1a7451a | Java HotSpot(TM) 64-Bit Server VM | 24.60-b09
(1 row)
下列查詢會顯示每個節點開啟和最大檔案描述元計數
SELECT openfiledescriptorcount, maxfiledescriptorcount
FROM jmx.current."java.lang:type=operatingsystem";
openfiledescriptorcount | maxfiledescriptorcount
-------------------------+------------------------
329 | 10240
(1 row)
萬用字元 *
可用於 current
綱要中的資料表名稱。這允許在單一查詢中比對數個 MBean 物件。下列查詢會傳回每個節點上不同 Presto 記憶體集區的資訊
SELECT freebytes, node, object_name
FROM jmx.current."com.facebook.presto.memory:*type=memorypool*";
freebytes | node | object_name
------------+---------+----------------------------------------------------------
214748364 | example | com.facebook.presto.memory:type=MemoryPool,name=reserved
1073741825 | example | com.facebook.presto.memory:type=MemoryPool,name=general
858993459 | example | com.facebook.presto.memory:type=MemoryPool,name=system
(3 rows)
歷史綱要¶
history
綱要包含連接器屬性檔案中設定的資料表清單。這些資料表與 current 綱要中的資料表具有相同的欄,但多了一個時間戳記欄,其中儲存擷取快照的時間
SELECT "timestamp", "uptime" FROM jmx.history."java.lang:type=runtime";
timestamp | uptime
-------------------------+--------
2016-01-28 10:18:50.000 | 11420
2016-01-28 10:19:00.000 | 21422
2016-01-28 10:19:10.000 | 31412
(3 rows)
資訊綱要¶
information_schema
包含有關所有其他綱要的中繼資料。若要列出此綱要中所有可用的資料表,請執行下列命令
SHOW TABLES FROM jmx.information_schema;