{"id":131,"date":"2019-03-10T14:48:13","date_gmt":"2019-03-10T13:48:13","guid":{"rendered":"http:\/\/deleforterie.com\/wordpress\/?p=131"},"modified":"2023-01-18T08:53:12","modified_gmt":"2023-01-18T07:53:12","slug":"zookeeper-4-letters-words-admin-commands","status":"publish","type":"post","link":"https:\/\/deleforterie.com\/wordpress\/index.php\/2019\/03\/10\/zookeeper-4-letters-words-admin-commands\/","title":{"rendered":"Zookeeper 4 letters words admin commands"},"content":{"rendered":"\n<p>In this article we will discover Zookeeper 4 letters commands to help us to monitor Zookeper<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">How to send 4 letters words commands to Zookeeper<\/h2>\n\n\n\n<p>You will find all the ZK 4 letters words commands in the <a href=\"https:\/\/zookeeper.apache.org\/doc\/current\/zookeeperAdmin.html#sc_zkCommands\">Administrator documentation<\/a> <\/p>\n\n\n\n<p>The more interesting in my point of view are <strong>mntr<\/strong>, <strong>stat<\/strong> and <strong>wchc<\/strong>.<\/p>\n\n\n\n<p>For sending the command you have to know your Zookeeper servers hostnames and port (usually 2181) and use the <strong>nc<\/strong>  command to access to the Zookeeper server.<\/p>\n\n\n\n<p>As you can see there is no security about authentification on the ZK server when using those 4lw commands, we will see below how to manage that.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[zookeeper@sandbox-hdp ~]$ echo mntr | nc zk_hostname 2181\nzk_version\t3.4.6-292--1, built on 05\/11\/2018 07:15 GMT\nzk_avg_latency\t3\nzk_max_latency\t4073\nzk_min_latency\t0\nzk_packets_received\t58670\nzk_packets_sent\t58714\nzk_num_alive_connections\t19\nzk_outstanding_requests\t0\nzk_server_state\tstandalone\nzk_znode_count\t318\nzk_watch_count\t71\nzk_ephemerals_count\t12\nzk_approximate_data_size\t102703\nzk_open_file_descriptor_count\t73\nzk_max_file_descriptor_count\t65536\n\n[zookeeper@sandbox-hdp ~]$ echo stat|nc localhost 2181\nZookeeper version: 3.4.6-292--1, built on 05\/11\/2018 07:15 GMT\nClients:\n \/172.18.0.2:34318[1](queued=0,recved=6769,sent=6769)\n \/172.18.0.3:34308[0](queued=0,recved=1,sent=0)\n \/172.18.0.2:33512[1](queued=0,recved=585,sent=585)\n \/172.18.0.2:54036[1](queued=0,recved=1535,sent=1542)\n \/172.18.0.2:59180[1](queued=0,recved=1332,sent=1334)\n \/172.18.0.2:58414[1](queued=0,recved=602,sent=602)\n \/172.18.0.2:59492[1](queued=0,recved=1020,sent=1020)\n \/172.18.0.2:58322[1](queued=0,recved=515,sent=515)\n \/172.18.0.2:59486[1](queued=0,recved=9523,sent=9523)\n \/172.18.0.2:59490[1](queued=0,recved=1006,sent=1006)\n \/172.18.0.2:59494[1](queued=0,recved=24283,sent=24283)\n \/172.18.0.2:60686[1](queued=0,recved=502,sent=502)\n \/172.18.0.2:33978[1](queued=0,recved=495,sent=495)\n \/172.18.0.2:55896[1](queued=0,recved=1064,sent=1065)\n \/172.18.0.2:58374[1](queued=0,recved=512,sent=512)\n \/172.18.0.2:54034[1](queued=0,recved=1652,sent=1657)\n \/172.18.0.2:58280[1](queued=0,recved=2321,sent=2347)\n \/172.18.0.2:54030[1](queued=0,recved=1166,sent=1166)\n \/172.18.0.2:33514[1](queued=0,recved=498,sent=498)\n\nLatency min\/avg\/max: 0\/3\/4073\nReceived: 58753\nSent: 58797\nConnections: 19\nOutstanding: 0\nZxid: 0xe25\nMode: standalone\nNode count: 318\n\n[zookeeper@sandbox-hdp ~]$ echo wchc|nc localhost 2181\n0x169670ccd570006\n\t\/ambari-metrics-cluster\/INSTANCES\/sandbox-hdp.hortonworks.com_12001\/MESSAGES\n0x169670ccd570009\n\t\/hbase-unsecure\/master\n\t\/hbase-unsecure\/namespace\/default\n\t\/hbase-unsecure\/namespace\/hbase\n\t\/hbase-unsecure\/normalizer\n\t\/hbase-unsecure\/switch\/merge\n\t\/hbase-unsecure\/rs\/sandbox-hdp.hortonworks.com,16020,1552214703261\n\t\/hbase-unsecure\/namespace\n\t\/hbase-unsecure\/running\n\t\/hbase-unsecure\/balancer\n\t\/hbase-unsecure\/switch\/split\n0x169670ccd57000e\n\t\/controller\n\t\/isr_change_notification\n\t\/admin\/preferred_replica_election\n\t\/admin\/reassign_partitions\n\t\/log_dir_event_notification\n\t\/brokers\/ids\n\t\/admin\/delete_topics\n\t\/config\/changes\n\t\/brokers\/topics\/ATLAS_ENTITIES\n\t\/brokers\/topics\/__consumer_offsets\n\t\/brokers\/topics\n0x169670ccd570008\n\t\/druid\/listeners\/lookups\/__default\/sandbox-hdp.hortonworks.com:8082\n0x169670ccd570017\n\t\/hiveserver2\/serverUri=sandbox-hdp.hortonworks.com:10000;version=1.2.1000.2.6.5.0-292;sequence=0000000005\n0x169670ccd570007\n\t\/ambari-metrics-cluster\/IDEALSTATES\n\t\/ambari-metrics-cluster\/CONFIGS\/PARTICIPANT\n\t\/ambari-metrics-cluster\/LIVEINSTANCES\/sandbox-hdp.hortonworks.com_12001\n\t\/ambari-metrics-cluster\/CONTROLLER\n\t\/ambari-metrics-cluster\/LIVEINSTANCES\n\t\/ambari-metrics-cluster\/CONTROLLER\/MESSAGES\n\t\/ambari-metrics-cluster\/IDEALSTATES\/METRIC_AGGREGATORS\n\t\/ambari-metrics-cluster\/CONFIGS\/PARTICIPANT\/sandbox-hdp.hortonworks.com_12001\n\t\/ambari-metrics-cluster\/INSTANCES\/sandbox-hdp.hortonworks.com_12001\/CURRENTSTATES\/169670ccd570006\n\t\/ambari-metrics-cluster\/INSTANCES\/sandbox-hdp.hortonworks.com_12001\/CURRENTSTATES\/169670ccd570006\/METRIC_AGGREGATORS\n\t\/ambari-metrics-cluster\/INSTANCES\/sandbox-hdp.hortonworks.com_12001\/MESSAGES\n0x169670ccd570015\n\t\/hbase-unsecure\/master\n\t\/hbase-unsecure\/rs\/sandbox-hdp.hortonworks.com,16020,1552214703261\n\t\/hbase-unsecure\/running\n\t\/hbase-unsecure\/meta-region-server\n<\/pre>\n\n\n\n<p>If you got an error when using 4lw commands like this :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[zookeeper@sandbox-hdp ~]$ echo wchc|nc localhost 2181\nwchc is not executed because it is not in the whitelist.\n<\/pre>\n\n\n\n<p>The reason is that in the last version for avoid security leaks and ddos attack on Zookeeper by using those 4lw you have to set a whitelist of the 4lw commands that could be used.<\/p>\n\n\n\n<p>You could add in <strong>zoo.cfg<\/strong> the whitelist a comma list of 4lw commands or an * if you authorize all :<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"ini\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">4lw.commands.whitelist=stat, ruok, conf, isro, wchc\nor\n4lw.commands.whitelist=*<\/pre>\n\n\n\n<p>Another security recommandation si to not expose the ZK servers ports at the outside of your cluster trusted network.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article we will discover Zookeeper 4 letters commands to help us to monitor Zookeper<\/p>\n","protected":false},"author":2,"featured_media":150,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[4,24],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata","category-zookeeper"],"_links":{"self":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":2,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/131\/revisions\/133"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media\/150"}],"wp:attachment":[{"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deleforterie.com\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}