Apache ZooKeeperにおいて、4文字コマンド`mntr`で取得できる項目の中から”Leader“のZooKeeperサーバだけが返す項目があるようである。
■ 環境
- Apache ZooKeeper 3.4.6
- Amazon Linux
■ mntr
先日のエントリでは、接続した先がStandaloneであったので気がつかなかった。アンサンブルが構築されたZooKeeperでLeaderに接続した時にのみ出力される項目があるようであるので確認する。
Standalone:
$ echo mntr | nc localhost 2181
zk_version 3.4.6-1569965, built on 02/20/2014 09:09 GMT
zk_avg_latency 0
zk_max_latency 41
zk_min_latency 0
zk_packets_received 13484768
zk_packets_sent 13485026
zk_num_alive_connections 6
zk_outstanding_requests 0
zk_server_state standalone
zk_znode_count 60
zk_watch_count 4
zk_ephemerals_count 2
zk_approximate_data_size 13453
zk_open_file_descriptor_count 37
zk_max_file_descriptor_count 4096
$
Follower:
$ echo mntr | nc localhost 2181
zk_version 3.4.6-1569965, built on 02/20/2014 09:09 GMT
zk_avg_latency 0
zk_max_latency 6843
zk_min_latency 0
zk_packets_received 5556397
zk_packets_sent 5535538
zk_num_alive_connections 16
zk_outstanding_requests 0
zk_server_state follower
zk_znode_count 142
zk_watch_count 6
zk_ephemerals_count 26
zk_approximate_data_size 249939
zk_open_file_descriptor_count 43
zk_max_file_descriptor_count 32768
$
Leader:
$ echo mntr | nc localhost 2181
zk_version 3.4.6-1569965, built on 02/20/2014 09:09 GMT
zk_avg_latency 0
zk_max_latency 899
zk_min_latency 0
zk_packets_received 18389509
zk_packets_sent 18368737
zk_num_alive_connections 25
zk_outstanding_requests 0
zk_server_state leader
zk_znode_count 142
zk_watch_count 31
zk_ephemerals_count 26
zk_approximate_data_size 250020
zk_open_file_descriptor_count 54
zk_max_file_descriptor_count 32768
zk_followers 2
zk_synced_followers 2
zk_pending_syncs 0
$
なるほど。確かに下記3つの項目がLeaderにのみ出力されている。
- zk_followers
- zk_synced_followers
- zk_pending_syncs
今回接続した先は、3台でアンサンブルを構築しているので、正常に同期が取れているFollowerが2台ある、ということである。
また、下記2項目についてはUnix系のOSでしか取得できないとのことだ。
- zk_open_file_descriptor_count
- zk_max_file_descriptor_count
手元にWindows系で動かしているZooKeeperが無いので確認はできないが。
以上。