zookeeperJMX.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.8">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>ZooKeeper JMX</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://hadoop.apache.org/">Hadoop</a> &gt; <a href="http://hadoop.apache.org/zookeeper/">ZooKeeper</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://hadoop.apache.org/zookeeper/"><img class="logoImage" alt="ZooKeeper" src="images/zookeeper_small.gif" title="ZooKeeper: distributed coordination"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="hadoop.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://hadoop.apache.org/zookeeper/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">ZooKeeper 3.2 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Overview</div>
  105. <div id="menu_1.1" class="menuitemgroup">
  106. <div class="menuitem">
  107. <a href="index.html">Welcome</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="zookeeperOver.html">Overview</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="zookeeperStarted.html">Getting Started</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="releasenotes.html">Release Notes</a>
  117. </div>
  118. </div>
  119. <div onclick="SwitchMenu('menu_1.2', 'skin/')" id="menu_1.2Title" class="menutitle">Developer</div>
  120. <div id="menu_1.2" class="menuitemgroup">
  121. <div class="menuitem">
  122. <a href="api/index.html">API Docs</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="zookeeperProgrammers.html">Programmer's Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="javaExample.html">Java Example</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="recipes.html">Recipes</a>
  135. </div>
  136. </div>
  137. <div onclick="SwitchMenu('menu_1.3', 'skin/')" id="menu_1.3Title" class="menutitle">BookKeeper</div>
  138. <div id="menu_1.3" class="menuitemgroup">
  139. <div class="menuitem">
  140. <a href="bookkeeperStarted.html">Getting started</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="bookkeeperOverview.html">Overview</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="bookkeeperConfig.html">Setup guide</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="bookkeeperProgrammer.html">Programmer's guide</a>
  150. </div>
  151. </div>
  152. <div onclick="SwitchMenu('menu_selected_1.4', 'skin/')" id="menu_selected_1.4Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Admin &amp; Ops</div>
  153. <div id="menu_selected_1.4" class="selectedmenuitemgroup" style="display: block;">
  154. <div class="menuitem">
  155. <a href="zookeeperAdmin.html">Administrator's Guide</a>
  156. </div>
  157. <div class="menuitem">
  158. <a href="zookeeperQuotas.html">Quota Guide</a>
  159. </div>
  160. <div class="menupage">
  161. <div class="menupagetitle">JMX</div>
  162. </div>
  163. </div>
  164. <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Contributor</div>
  165. <div id="menu_1.5" class="menuitemgroup">
  166. <div class="menuitem">
  167. <a href="zookeeperInternals.html">ZooKeeper Internals</a>
  168. </div>
  169. </div>
  170. <div onclick="SwitchMenu('menu_1.6', 'skin/')" id="menu_1.6Title" class="menutitle">Miscellaneous</div>
  171. <div id="menu_1.6" class="menuitemgroup">
  172. <div class="menuitem">
  173. <a href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
  174. </div>
  175. <div class="menuitem">
  176. <a href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ">FAQ</a>
  177. </div>
  178. <div class="menuitem">
  179. <a href="http://hadoop.apache.org/zookeeper/mailing_lists.html">Mailing Lists</a>
  180. </div>
  181. </div>
  182. <div id="credit"></div>
  183. <div id="roundbottom">
  184. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  185. <!--+
  186. |alternative credits
  187. +-->
  188. <div id="credit2"></div>
  189. </div>
  190. <!--+
  191. |end Menu
  192. +-->
  193. <!--+
  194. |start content
  195. +-->
  196. <div id="content">
  197. <div title="Portable Document Format" class="pdflink">
  198. <a class="dida" href="zookeeperJMX.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  199. PDF</a>
  200. </div>
  201. <h1>ZooKeeper JMX</h1>
  202. <div id="minitoc-area">
  203. <ul class="minitoc">
  204. <li>
  205. <a href="#ch_jmx">JMX</a>
  206. </li>
  207. <li>
  208. <a href="#ch_starting">Starting ZooKeeper with JMX enabled</a>
  209. </li>
  210. <li>
  211. <a href="#ch_console">Run a JMX console</a>
  212. </li>
  213. <li>
  214. <a href="#ch_reference">ZooKeeper MBean Reference</a>
  215. </li>
  216. </ul>
  217. </div>
  218. <a name="N10009"></a><a name="ch_jmx"></a>
  219. <h2 class="h3">JMX</h2>
  220. <div class="section">
  221. <p>Apache ZooKeeper has extensive support for JMX, allowing you
  222. to view and manage a ZooKeeper serving ensemble.</p>
  223. <p>This document assumes that you have basic knowledge of
  224. JMX. See <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">
  225. Sun JMX Technology</a> page to get started with JMX.
  226. </p>
  227. <p>See the <a href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html">
  228. JMX Management Guide</a> for details on setting up local and
  229. remote management of VM instances. By default the included
  230. <em>zkServer.sh</em> supports only local management -
  231. review the linked document to enable support for remote management
  232. (beyond the scope of this document).
  233. </p>
  234. </div>
  235. <a name="N10024"></a><a name="ch_starting"></a>
  236. <h2 class="h3">Starting ZooKeeper with JMX enabled</h2>
  237. <div class="section">
  238. <p>The class
  239. <em>org.apache.zookeeper.server.quorum.QuorumPeerMain</em>
  240. will start a JMX manageable ZooKeeper server. This class
  241. registers the proper MBeans during initalization to support JMX
  242. monitoring and management of the
  243. instance. See <em>bin/zkServer.sh</em> for one
  244. example of starting ZooKeeper using QuorumPeerMain.</p>
  245. </div>
  246. <a name="N10034"></a><a name="ch_console"></a>
  247. <h2 class="h3">Run a JMX console</h2>
  248. <div class="section">
  249. <p>There are a number of JMX consoles available which can connect
  250. to the running server. For this example we will use Sun's
  251. <em>jconsole</em>.</p>
  252. <p>The Java JDK ships with a simple JMX console
  253. named <a href="http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html">jconsole</a>
  254. which can be used to connect to ZooKeeper and inspect a running
  255. server. Once you've started ZooKeeper using QuorumPeerMain
  256. start <em>jconsole</em>, which typically resides in
  257. <em>JDK_HOME/bin/jconsole</em>
  258. </p>
  259. <p>When the "new connection" window is displayed either connect
  260. to local process (if jconsole started on same host as Server) or
  261. use the remote process connection.</p>
  262. <p>By default the "overview" tab for the VM is displayed (this
  263. is a great way to get insight into the VM btw). Select
  264. the "MBeans" tab.</p>
  265. <p>You should now see <em>org.apache.ZooKeeperService</em>
  266. on the left hand side. Expand this item and depending on how you've
  267. started the server you will be able to monitor and manage various
  268. service related features.</p>
  269. <p>Also note that ZooKeeper will register log4j MBeans as
  270. well. In the same section along the left hand side you will see
  271. "log4j". Expand that to manage log4j through JMX. Of particular
  272. interest is the ability to dynamically change the logging levels
  273. used by editing the appender and root thresholds. Log4j MBean
  274. registration can be disabled by passing
  275. <em>-Dzookeeper.jmx.log4j.disable=true</em> to the JVM
  276. when starting ZooKeeper.
  277. </p>
  278. </div>
  279. <a name="N1005F"></a><a name="ch_reference"></a>
  280. <h2 class="h3">ZooKeeper MBean Reference</h2>
  281. <div class="section">
  282. <p>This table details JMX for a server participating in a
  283. replicated ZooKeeper ensemble (ie not standalone). This is the
  284. typical case for a production environment.</p>
  285. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  286. <caption>MBeans, their names and description</caption>
  287. <title>MBeans, their names and description</title>
  288. <tr>
  289. <th>MBean</th>
  290. <th>MBean Object Name</th>
  291. <th>Description</th>
  292. </tr>
  293. <tr>
  294. <td>Quorum</td>
  295. <td>ReplicatedServer_id&lt;#&gt;</td>
  296. <td>Represents the Quorum, or Ensemble - parent of all
  297. cluster members. Note that the object name includes the
  298. "myid" of the server (name suffix) that your JMX agent has
  299. connected to.</td>
  300. </tr>
  301. <tr>
  302. <td>LocalPeer|RemotePeer</td>
  303. <td>replica.&lt;#&gt;</td>
  304. <td>Represents a local or remote peer (ie server
  305. participating in the ensemble). Note that the object name
  306. includes the "myid" of the server (name suffix).</td>
  307. </tr>
  308. <tr>
  309. <td>LeaderElection</td>
  310. <td>LeaderElection</td>
  311. <td>Represents a ZooKeeper cluster leader election which is
  312. in progress. Provides information about the election, such as
  313. when it started.</td>
  314. </tr>
  315. <tr>
  316. <td>Leader</td>
  317. <td>Leader</td>
  318. <td>Indicates that the parent replica is the leader and
  319. provides attributes/operations for that server. Note that
  320. Leader is a subclass of ZooKeeperServer, so it provides
  321. all of the information normally associated with a
  322. ZooKeeperServer node.</td>
  323. </tr>
  324. <tr>
  325. <td>Follower</td>
  326. <td>Follower</td>
  327. <td>Indicates that the parent replica is a follower and
  328. provides attributes/operations for that server. Note that
  329. Follower is a subclass of ZooKeeperServer, so it provides
  330. all of the information normally associated with a
  331. ZooKeeperServer node.</td>
  332. </tr>
  333. <tr>
  334. <td>DataTree</td>
  335. <td>InMemoryDataTree</td>
  336. <td>Statistics on the in memory znode database, also
  337. operations to access finer (and more computationally
  338. intensive) statistics on the data (such as ephemeral
  339. count). InMemoryDataTrees are children of ZooKeeperServer
  340. nodes.</td>
  341. </tr>
  342. <tr>
  343. <td>ServerCnxn</td>
  344. <td>&lt;session_id&gt;</td>
  345. <td>Statistics on each client connection, also
  346. operations on those connections (such as
  347. termination). Note the object name is the session id of
  348. the connection in hex form.</td>
  349. </tr>
  350. </table>
  351. <p>This table details JMX for a standalone server. Typically
  352. standalone is only used in development situations.</p>
  353. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  354. <caption>MBeans, their names and description</caption>
  355. <title>MBeans, their names and description</title>
  356. <tr>
  357. <th>MBean</th>
  358. <th>MBean Object Name</th>
  359. <th>Description</th>
  360. </tr>
  361. <tr>
  362. <td>ZooKeeperServer</td>
  363. <td>StandaloneServer_port&lt;#&gt;</td>
  364. <td>Statistics on the running server, also operations
  365. to reset these attributes. Note that the object name
  366. includes the client port of the server (name
  367. suffix).</td>
  368. </tr>
  369. <tr>
  370. <td>DataTree</td>
  371. <td>InMemoryDataTree</td>
  372. <td>Statistics on the in memory znode database, also
  373. operations to access finer (and more computationally
  374. intensive) statistics on the data (such as ephemeral
  375. count).</td>
  376. </tr>
  377. <tr>
  378. <td>ServerCnxn</td>
  379. <td>&lt;session_id&gt;</td>
  380. <td>Statistics on each client connection, also
  381. operations on those connections (such as
  382. termination). Note the object name is the session id of
  383. the connection in hex form.</td>
  384. </tr>
  385. </table>
  386. </div>
  387. <p align="right">
  388. <font size="-2"></font>
  389. </p>
  390. </div>
  391. <!--+
  392. |end content
  393. +-->
  394. <div class="clearboth">&nbsp;</div>
  395. </div>
  396. <div id="footer">
  397. <!--+
  398. |start bottomstrip
  399. +-->
  400. <div class="lastmodified">
  401. <script type="text/javascript"><!--
  402. document.write("Last Published: " + document.lastModified);
  403. // --></script>
  404. </div>
  405. <div class="copyright">
  406. Copyright &copy;
  407. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  408. </div>
  409. <!--+
  410. |end bottomstrip
  411. +-->
  412. </div>
  413. </body>
  414. </html>