1. 程式人生 > >zookeeper四字命令

zookeeper四字命令

ZooKeeper3.4.6支援某些特定的四字命令字母與其的互動。它們大多是查詢命令,用來獲取 ZooKeeper 服務的當前狀態及相關資訊。使用者在客戶端可以通過 telnet 或 nc 向 ZooKeeper 提交相應的命令。 其中stat、srvr、cons三個命令比較類似:"stat"提供伺服器統計和客戶端連線的一般資訊;"srvr"只有服務的統計資訊,"cons"提供客戶端連線的更加詳細的資訊。 

 使用方式,在shell終端輸入:echo mntr | nc localhost 2181 

 在64位CentOS6下,預設使用不了netcat,請參考上篇 :64位CentOS6系統下安裝netcat

命令    示例    描述 conf    echo conf | nc localhost 2181    (New in 3.3.0)輸出相關服務配置的詳細資訊。比如埠、zk資料及日誌配置路徑、最大連線數,session超時時間、serverId等 cons    echo cons | nc localhost 2181    (New in 3.3.0)列出所有連線到這臺伺服器的客戶端連線/會話的詳細資訊。包括“接受/傳送”的包數量、session id 、操作延遲、最後的操作執行等資訊。 crst    echo crst | nc localhost 2181    (New in 3.3.0)重置當前這臺伺服器所有連線/會話的統計資訊 dump    echo dump | nc localhost 2181    列出未經處理的會話和臨時節點(只在leader上有效)。 envi    echo envi | nc localhost 2181    輸出關於伺服器的環境詳細資訊(不同於conf命令),比如host.name、java.version、java.home、user.dir=/data/zookeeper-3.4.6/bin之類資訊 ruok    echo ruok | nc localhost 2181    測試服務是否處於正確執行狀態。如果正常返回"imok",否則返回空。 srst    echo srst | nc localhost 2181    重置伺服器的統計資訊 srvr    echo srvr | nc localhost 2181    (New in 3.3.0)輸出伺服器的詳細資訊。zk版本、接收/傳送包數量、連線數、模式(leader/follower)、節點總數。 stat    echo stat | nc localhost 2181    輸出伺服器的詳細資訊:接收/傳送包數量、連線數、模式(leader/follower)、節點總數、延遲。 所有客戶端的列表。 wchs    echo wchs | nc localhost 2181    (New in 3.3.0)列出伺服器watches的簡潔資訊:連線總數、watching節點總數和watches總數 wchc    echo wchc | nc localhost 2181    (New in 3.3.0)通過session分組,列出watch的所有節點,它的輸出是一個與 watch 相關的會話的節點列表。如果watches數量很大的話,將會產生很大的開銷,會影響效能,小心使用。 wchp    echo wchp | nc localhost 2181    (New in 3.3.0)通過路徑分組,列出所有的 watch 的session id資訊。它輸出一個與 session 相關的路徑。如果watches數量很大的話,將會產生很大的開銷,會影響效能,小心使用。 mntr    echo mntr | nc localhost 2181    (New in 3.4.0)列出叢集的健康狀態。包括“接受/傳送”的包數量、操作延遲、當前服務模式(leader/follower)、節點總數、watch總數、臨時節點總數。

監控指標(參照hackerwin7的部落格 http://blog.csdn.net/hackerwin7/article/details/43985049):

conf: clientPort:客戶端埠號  dataDir:資料檔案目錄 dataLogDir:日誌檔案目錄   tickTime:間隔單位時間 maxClientCnxns:最大連線數   minSessionTimeout:最小session超時 maxSessionTimeout:最大session超時   serverId:id   initLimit:初始化時間   syncLimit:心跳時間間隔   electionAlg:選舉演算法 預設3   electionPort:選舉埠   quorumPort:法人埠   peerType:未確認   cons: ip=ip port=埠 queued=所在佇列 received=收包數 sent=發包數 sid=session id lop=最後操作 est=連線時間戳 to=超時時間 lcxid=最後id(未確認具體id) lzxid=最後id(狀態變更id) lresp=最後響應時間戳 llat=最後/最新 延時 minlat=最小延時 maxlat=最大延時 avglat=平均延時     crst: 重置所有連線     dump: session id : znode path  (1對多   ,  處於佇列中排隊的session和臨時節點)     envi: zookeeper.version=版本 host.name=host資訊 java.version=java版本 java.vendor=供應商 java.home=jdk目錄 java.class.path=classpath java.library.path=lib path java.io.tmpdir=temp目錄 java.compiler=<NA> os.name=Linux os.arch=amd64 os.version=2.6.32-358.el6.x86_64 user.name=hhz user.home=/home/hhz user.dir=/export/servers/zookeeper-3.4.6     ruok: 檢視server是否正常 imok=正常     srst: 重置server狀態     srvr: Zookeeper version:版本 Latency min/avg/max: 延時 Received: 收包 Sent: 發包 Connections: 連線數 Outstanding: 堆積數 Zxid: 操作id Mode: leader/follower Node count: 節點數   stat: Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT Clients:  /192.168.147.102:56168[1](queued=0,recved=41,sent=41)  /192.168.144.102:34378[1](queued=0,recved=54,sent=54)  /192.168.162.16:43108[1](queued=0,recved=40,sent=40)  /192.168.144.107:39948[1](queued=0,recved=1421,sent=1421)  /192.168.162.16:43112[1](queued=0,recved=54,sent=54)  /192.168.162.16:43107[1](queued=0,recved=54,sent=54)  /192.168.162.16:43110[1](queued=0,recved=53,sent=53)  /192.168.144.98:34702[1](queued=0,recved=41,sent=41)  /192.168.144.98:34135[1](queued=0,recved=61,sent=65)  /192.168.162.16:43109[1](queued=0,recved=54,sent=54)  /192.168.147.102:56038[1](queued=0,recved=165313,sent=165314)  /192.168.147.102:56039[1](queued=0,recved=165526,sent=165527)  /192.168.147.101:44124[1](queued=0,recved=162811,sent=162812)  /192.168.147.102:39271[1](queued=0,recved=41,sent=41)  /192.168.144.107:45476[1](queued=0,recved=166422,sent=166423)  /192.168.144.103:45100[1](queued=0,recved=54,sent=54)  /192.168.162.16:43133[0](queued=0,recved=1,sent=0)  /192.168.144.107:39945[1](queued=0,recved=1825,sent=1825)  /192.168.144.107:39919[1](queued=0,recved=325,sent=325)  /192.168.144.106:47163[1](queued=0,recved=17891,sent=17891)  /192.168.144.107:45488[1](queued=0,recved=166554,sent=166555)  /172.17.36.11:32728[1](queued=0,recved=54,sent=54)  /192.168.162.16:43115[1](queued=0,recved=54,sent=54)   Latency min/avg/max: 0/0/599 Received: 224869 Sent: 224817 Connections: 23 Outstanding: 0 Zxid: 0x68000af707 Mode: follower Node count: 101081   (同上面的命令整合的資訊)     wchs: connectsions=連線數 watch-paths=watch節點數 watchers=watcher數量     wchc: session id 對應 path   wchp: path 對應 session id   mntr: zk_version=版本 zk_avg_latency=平均延時 zk_max_latency=最大延時 zk_min_latency=最小延時 zk_packets_received=收包數   zk_packets_sent=發包數 zk_num_alive_connections=連線數 zk_outstanding_requests=堆積請求數 zk_server_state=leader/follower 狀態 zk_znode_count=znode數量 zk_watch_count=watch數量 zk_ephemerals_count=臨時節點(znode) zk_approximate_data_size=資料大小 zk_open_file_descriptor_count=開啟的檔案描述符數量 zk_max_file_descriptor_count=最大檔案描述符數量 zk_followers=follower數量 zk_synced_followers=同步的follower數量 zk_pending_syncs=準備同步數 ---------------------  轉載 原文:https://blog.csdn.net/u013673976/article/details/47279707