zookeeperAdmin.html 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132
  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.9">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>ZooKeeper Administrator's Guide</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://zookeeper.apache.org/">ZooKeeper</a> &gt; <a href="http://zookeeper.apache.org/">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://zookeeper.apache.org/"><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="zookeeper.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://zookeeper.apache.org/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="https://cwiki.apache.org/confluence/display/ZOOKEEPER/">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">ZooKeeper 3.4 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_selected_1.3', 'skin/')" id="menu_selected_1.3Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Admin &amp; Ops</div>
  138. <div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
  139. <div class="menupage">
  140. <div class="menupagetitle">Administrator's Guide</div>
  141. </div>
  142. <div class="menuitem">
  143. <a href="zookeeperQuotas.html">Quota Guide</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="zookeeperJMX.html">JMX</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="zookeeperObservers.html">Observers Guide</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="zookeeperReconfig.html">Dynamic Reconfiguration</a>
  153. </div>
  154. </div>
  155. <div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle">Contributor</div>
  156. <div id="menu_1.4" class="menuitemgroup">
  157. <div class="menuitem">
  158. <a href="zookeeperInternals.html">ZooKeeper Internals</a>
  159. </div>
  160. </div>
  161. <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Miscellaneous</div>
  162. <div id="menu_1.5" class="menuitemgroup">
  163. <div class="menuitem">
  164. <a href="https://cwiki.apache.org/confluence/display/ZOOKEEPER">Wiki</a>
  165. </div>
  166. <div class="menuitem">
  167. <a href="https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ">FAQ</a>
  168. </div>
  169. <div class="menuitem">
  170. <a href="http://zookeeper.apache.org/mailing_lists.html">Mailing Lists</a>
  171. </div>
  172. </div>
  173. <div id="credit"></div>
  174. <div id="roundbottom">
  175. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  176. <!--+
  177. |alternative credits
  178. +-->
  179. <div id="credit2"></div>
  180. </div>
  181. <!--+
  182. |end Menu
  183. +-->
  184. <!--+
  185. |start content
  186. +-->
  187. <div id="content">
  188. <div title="Portable Document Format" class="pdflink">
  189. <a class="dida" href="zookeeperAdmin.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  190. PDF</a>
  191. </div>
  192. <h1>ZooKeeper Administrator's Guide</h1>
  193. <h3>A Guide to Deployment and Administration</h3>
  194. <div id="front-matter">
  195. <div id="minitoc-area">
  196. <ul class="minitoc">
  197. <li>
  198. <a href="#ch_deployment">Deployment</a>
  199. <ul class="minitoc">
  200. <li>
  201. <a href="#sc_systemReq">System Requirements</a>
  202. <ul class="minitoc">
  203. <li>
  204. <a href="#sc_supportedPlatforms">Supported Platforms</a>
  205. </li>
  206. <li>
  207. <a href="#sc_requiredSoftware">Required Software </a>
  208. </li>
  209. </ul>
  210. </li>
  211. <li>
  212. <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
  213. </li>
  214. <li>
  215. <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
  216. </li>
  217. </ul>
  218. </li>
  219. <li>
  220. <a href="#ch_administration">Administration</a>
  221. <ul class="minitoc">
  222. <li>
  223. <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
  224. <ul class="minitoc">
  225. <li>
  226. <a href="#sc_CrossMachineRequirements">Cross Machine Requirements</a>
  227. </li>
  228. <li>
  229. <a href="#Single+Machine+Requirements">Single Machine Requirements</a>
  230. </li>
  231. </ul>
  232. </li>
  233. <li>
  234. <a href="#sc_provisioning">Provisioning</a>
  235. </li>
  236. <li>
  237. <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
  238. </li>
  239. <li>
  240. <a href="#sc_administering">Administering</a>
  241. </li>
  242. <li>
  243. <a href="#sc_maintenance">Maintenance</a>
  244. <ul class="minitoc">
  245. <li>
  246. <a href="#Ongoing+Data+Directory+Cleanup">Ongoing Data Directory Cleanup</a>
  247. </li>
  248. <li>
  249. <a href="#Debug+Log+Cleanup+%28log4j%29">Debug Log Cleanup (log4j)</a>
  250. </li>
  251. </ul>
  252. </li>
  253. <li>
  254. <a href="#sc_supervision">Supervision</a>
  255. </li>
  256. <li>
  257. <a href="#sc_monitoring">Monitoring</a>
  258. </li>
  259. <li>
  260. <a href="#sc_logging">Logging</a>
  261. </li>
  262. <li>
  263. <a href="#sc_troubleshooting">Troubleshooting</a>
  264. </li>
  265. <li>
  266. <a href="#sc_configuration">Configuration Parameters</a>
  267. <ul class="minitoc">
  268. <li>
  269. <a href="#sc_minimumConfiguration">Minimum Configuration</a>
  270. </li>
  271. <li>
  272. <a href="#sc_advancedConfiguration">Advanced Configuration</a>
  273. </li>
  274. <li>
  275. <a href="#sc_clusterOptions">Cluster Options</a>
  276. </li>
  277. <li>
  278. <a href="#sc_authOptions">Authentication &amp; Authorization Options</a>
  279. </li>
  280. <li>
  281. <a href="#Experimental+Options%2FFeatures">Experimental Options/Features</a>
  282. </li>
  283. <li>
  284. <a href="#Unsafe+Options">Unsafe Options</a>
  285. </li>
  286. <li>
  287. <a href="#Disabling+data+directory+autocreation">Disabling data directory autocreation</a>
  288. </li>
  289. <li>
  290. <a href="#sc_performance_options">Performance Tuning Options</a>
  291. </li>
  292. <li>
  293. <a href="#Communication+using+the+Netty+framework">Communication using the Netty framework</a>
  294. </li>
  295. <li>
  296. <a href="#sc_adminserver_config">AdminServer configuration</a>
  297. </li>
  298. </ul>
  299. </li>
  300. <li>
  301. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  302. <ul class="minitoc">
  303. <li>
  304. <a href="#The+Four+Letter+Words">The Four Letter Words</a>
  305. </li>
  306. <li>
  307. <a href="#sc_adminserver">The AdminServer</a>
  308. </li>
  309. </ul>
  310. </li>
  311. <li>
  312. <a href="#sc_dataFileManagement">Data File Management</a>
  313. <ul class="minitoc">
  314. <li>
  315. <a href="#The+Data+Directory">The Data Directory</a>
  316. </li>
  317. <li>
  318. <a href="#The+Log+Directory">The Log Directory</a>
  319. </li>
  320. <li>
  321. <a href="#sc_filemanagement">File Management</a>
  322. </li>
  323. </ul>
  324. </li>
  325. <li>
  326. <a href="#sc_commonProblems">Things to Avoid</a>
  327. </li>
  328. <li>
  329. <a href="#sc_bestPractices">Best Practices</a>
  330. </li>
  331. </ul>
  332. </li>
  333. </ul>
  334. </div>
  335. </div>
  336. <a name="ch_deployment"></a>
  337. <h2 class="h3">Deployment</h2>
  338. <div class="section">
  339. <p>This section contains information about deploying Zookeeper and
  340. covers these topics:</p>
  341. <ul>
  342. <li>
  343. <p>
  344. <a href="#sc_systemReq">System Requirements</a>
  345. </p>
  346. </li>
  347. <li>
  348. <p>
  349. <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
  350. </p>
  351. </li>
  352. <li>
  353. <p>
  354. <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
  355. </p>
  356. </li>
  357. </ul>
  358. <p>The first two sections assume you are interested in installing
  359. ZooKeeper in a production environment such as a datacenter. The final
  360. section covers situations in which you are setting up ZooKeeper on a
  361. limited basis - for evaluation, testing, or development - but not in a
  362. production environment.</p>
  363. <a name="sc_systemReq"></a>
  364. <h3 class="h4">System Requirements</h3>
  365. <a name="sc_supportedPlatforms"></a>
  366. <h4>Supported Platforms</h4>
  367. <ul>
  368. <li>
  369. <p>GNU/Linux is supported as a development and production
  370. platform for both server and client.</p>
  371. </li>
  372. <li>
  373. <p>Sun Solaris is supported as a development and production
  374. platform for both server and client.</p>
  375. </li>
  376. <li>
  377. <p>FreeBSD is supported as a development and production
  378. platform for both server and client.</p>
  379. </li>
  380. <li>
  381. <p>Win32 is supported as a <em>development
  382. platform</em> only for both server and client.</p>
  383. </li>
  384. <li>
  385. <p>Win64 is supported as a <em>development
  386. platform</em> only for both server and client.</p>
  387. </li>
  388. <li>
  389. <p>MacOSX is supported as a <em>development
  390. platform</em> only for both server and client.</p>
  391. </li>
  392. </ul>
  393. <a name="sc_requiredSoftware"></a>
  394. <h4>Required Software </h4>
  395. <p>ZooKeeper runs in Java, release 1.6 or greater (JDK 6 or
  396. greater, FreeBSD support requires openjdk7). It runs as an
  397. <em>ensemble</em> of ZooKeeper servers. Three
  398. ZooKeeper servers is the minimum recommended size for an
  399. ensemble, and we also recommend that they run on separate
  400. machines. At Yahoo!, ZooKeeper is usually deployed on
  401. dedicated RHEL boxes, with dual-core processors, 2GB of RAM,
  402. and 80GB IDE hard drives.</p>
  403. <a name="sc_zkMulitServerSetup"></a>
  404. <h3 class="h4">Clustered (Multi-Server) Setup</h3>
  405. <p>For reliable ZooKeeper service, you should deploy ZooKeeper in a
  406. cluster known as an <em>ensemble</em>. As long as a majority
  407. of the ensemble are up, the service will be available. Because Zookeeper
  408. requires a majority, it is best to use an
  409. odd number of machines. For example, with four machines ZooKeeper can
  410. only handle the failure of a single machine; if two machines fail, the
  411. remaining two machines do not constitute a majority. However, with five
  412. machines ZooKeeper can handle the failure of two machines. </p>
  413. <div class="note">
  414. <div class="label">Note</div>
  415. <div class="content">
  416. <p>As mentioned in the Getting Started guide, a minimum of three servers are
  417. required for a fault tolerant clustered setup, and it is strongly
  418. recommended that you have an odd number of servers.</p>
  419. <p>Usually three servers is more than enough for a production install, but
  420. for maximum reliability during maintenance, you may wish to install
  421. five servers. With three servers, if you perform maintenance on
  422. one of them, you are vulnerable to a failure on one of the other
  423. two servers during that maintenance. If you have five of them
  424. running, you can take one down for maintenance, and know that
  425. you're still OK if one of the other four suddenly fails.</p>
  426. <p>Your redundancy considerations should include all aspects of your
  427. environment. If you have three zookeeper servers, but their
  428. network cables are all plugged into the same network switch, then
  429. the failure of that switch will take down your entire ensemble.</p>
  430. </div>
  431. </div>
  432. <p>Here are the steps to setting a server that will be part of an
  433. ensemble. These steps should be performed on every host in the
  434. ensemble:</p>
  435. <ol>
  436. <li>
  437. <p>Install the Java JDK. You can use the native packaging system
  438. for your system, or download the JDK from:</p>
  439. <p>
  440. <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a>
  441. </p>
  442. </li>
  443. <li>
  444. <p>Set the Java heap size. This is very important to avoid
  445. swapping, which will seriously degrade ZooKeeper performance. To
  446. determine the correct value, use load tests, and make sure you are
  447. well below the usage limit that would cause you to swap. Be
  448. conservative - use a maximum heap size of 3GB for a 4GB
  449. machine.</p>
  450. </li>
  451. <li>
  452. <p>Install the ZooKeeper Server Package. It can be downloaded
  453. from:
  454. </p>
  455. <p>
  456. <a href="http://zookeeper.apache.org/releases.html">
  457. http://zookeeper.apache.org/releases.html
  458. </a>
  459. </p>
  460. </li>
  461. <li>
  462. <p>Create a configuration file. This file can be called anything.
  463. Use the following settings as a starting point:</p>
  464. <pre class="code">
  465. tickTime=2000
  466. dataDir=/var/lib/zookeeper/
  467. clientPort=2181
  468. initLimit=5
  469. syncLimit=2
  470. server.1=zoo1:2888:3888
  471. server.2=zoo2:2888:3888
  472. server.3=zoo3:2888:3888</pre>
  473. <p>You can find the meanings of these and other configuration
  474. settings in the section <a href="#sc_configuration">Configuration Parameters</a>. A word
  475. though about a few here:</p>
  476. <p>Every machine that is part of the ZooKeeper ensemble should know
  477. about every other machine in the ensemble. You accomplish this with
  478. the series of lines of the form <strong>server.id=host:port:port</strong>. The parameters <strong>host</strong> and <strong>port</strong> are straightforward. You attribute the
  479. server id to each machine by creating a file named
  480. <span class="codefrag filename">myid</span>, one for each server, which resides in
  481. that server's data directory, as specified by the configuration file
  482. parameter <strong>dataDir</strong>.</p>
  483. </li>
  484. <li>
  485. <p>The myid file
  486. consists of a single line containing only the text of that machine's
  487. id. So <span class="codefrag filename">myid</span> of server 1 would contain the text
  488. "1" and nothing else. The id must be unique within the
  489. ensemble and should have a value between 1 and 255.</p>
  490. </li>
  491. <li>
  492. <p>If your configuration file is set up, you can start a
  493. ZooKeeper server:</p>
  494. <p>
  495. <span class="codefrag computeroutput">$ java -cp zookeeper.jar:lib/slf4j-api-1.7.5.jar:lib/slf4j-log4j12-1.7.5.jar:lib/log4j-1.2.16.jar:conf \
  496. org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg
  497. </span>
  498. </p>
  499. <p>QuorumPeerMain starts a ZooKeeper server,
  500. <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a>
  501. management beans are also registered which allows
  502. management through a JMX management console.
  503. The <a href="zookeeperJMX.html">ZooKeeper JMX
  504. document</a> contains details on managing ZooKeeper with JMX.
  505. </p>
  506. <p>See the script <em>bin/zkServer.sh</em>,
  507. which is included in the release, for an example
  508. of starting server instances.</p>
  509. </li>
  510. <li>
  511. <p>Test your deployment by connecting to the hosts:</p>
  512. <ul>
  513. <li>
  514. <p>In Java, you can run the following command to execute
  515. simple operations:</p>
  516. <p>
  517. <span class="codefrag computeroutput">$ java -cp zookeeper.jar:lib/slf4j-api-1.7.5.jar:lib/slf4j-log4j12-1.7.5.jar:lib/log4j-1.2.16.jar:conf:src/java/lib/jline-2.11.jar \
  518. org.apache.zookeeper.ZooKeeperMain -server 127.0.0.1:2181</span>
  519. </p>
  520. </li>
  521. <li>
  522. <p>In C, you can compile either the single threaded client or
  523. the multithreaded client: or n the c subdirectory in the
  524. ZooKeeper sources. This compiles the single threaded
  525. client:</p>
  526. <p>
  527. <span class="codefrag computeroutput">$ make cli_st</span>
  528. </p>
  529. <p>And this compiles the mulithreaded client:</p>
  530. <p>
  531. <span class="codefrag computeroutput">$ make cli_mt</span>
  532. </p>
  533. </li>
  534. </ul>
  535. <p>Running either program gives you a shell in which to execute
  536. simple file-system-like operations. To connect to ZooKeeper with the
  537. multithreaded client, for example, you would run:</p>
  538. <p>
  539. <span class="codefrag computeroutput">$ cli_mt 127.0.0.1:2181</span>
  540. </p>
  541. </li>
  542. </ol>
  543. <a name="sc_singleAndDevSetup"></a>
  544. <h3 class="h4">Single Server and Developer Setup</h3>
  545. <p>If you want to setup ZooKeeper for development purposes, you will
  546. probably want to setup a single server instance of ZooKeeper, and then
  547. install either the Java or C client-side libraries and bindings on your
  548. development machine.</p>
  549. <p>The steps to setting up a single server instance are the similar
  550. to the above, except the configuration file is simpler. You can find the
  551. complete instructions in the <a href="zookeeperStarted.html#sc_InstallingSingleMode">Installing and
  552. Running ZooKeeper in Single Server Mode</a> section of the <a href="zookeeperStarted.html">ZooKeeper Getting Started
  553. Guide</a>.</p>
  554. <p>For information on installing the client side libraries, refer to
  555. the <a href="zookeeperProgrammers.html#Bindings">Bindings</a>
  556. section of the <a href="zookeeperProgrammers.html">ZooKeeper
  557. Programmer's Guide</a>.</p>
  558. </div>
  559. <a name="ch_administration"></a>
  560. <h2 class="h3">Administration</h2>
  561. <div class="section">
  562. <p>This section contains information about running and maintaining
  563. ZooKeeper and covers these topics: </p>
  564. <ul>
  565. <li>
  566. <p>
  567. <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
  568. </p>
  569. </li>
  570. <li>
  571. <p>
  572. <a href="#sc_provisioning">Provisioning</a>
  573. </p>
  574. </li>
  575. <li>
  576. <p>
  577. <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
  578. </p>
  579. </li>
  580. <li>
  581. <p>
  582. <a href="#sc_administering">Administering</a>
  583. </p>
  584. </li>
  585. <li>
  586. <p>
  587. <a href="#sc_maintenance">Maintenance</a>
  588. </p>
  589. </li>
  590. <li>
  591. <p>
  592. <a href="#sc_supervision">Supervision</a>
  593. </p>
  594. </li>
  595. <li>
  596. <p>
  597. <a href="#sc_monitoring">Monitoring</a>
  598. </p>
  599. </li>
  600. <li>
  601. <p>
  602. <a href="#sc_logging">Logging</a>
  603. </p>
  604. </li>
  605. <li>
  606. <p>
  607. <a href="#sc_troubleshooting">Troubleshooting</a>
  608. </p>
  609. </li>
  610. <li>
  611. <p>
  612. <a href="#sc_configuration">Configuration Parameters</a>
  613. </p>
  614. </li>
  615. <li>
  616. <p>
  617. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  618. </p>
  619. </li>
  620. <li>
  621. <p>
  622. <a href="#sc_dataFileManagement">Data File Management</a>
  623. </p>
  624. </li>
  625. <li>
  626. <p>
  627. <a href="#sc_commonProblems">Things to Avoid</a>
  628. </p>
  629. </li>
  630. <li>
  631. <p>
  632. <a href="#sc_bestPractices">Best Practices</a>
  633. </p>
  634. </li>
  635. </ul>
  636. <a name="sc_designing"></a>
  637. <h3 class="h4">Designing a ZooKeeper Deployment</h3>
  638. <p>The reliablity of ZooKeeper rests on two basic assumptions.</p>
  639. <ol>
  640. <li>
  641. <p> Only a minority of servers in a deployment
  642. will fail. <em>Failure</em> in this context
  643. means a machine crash, or some error in the network that
  644. partitions a server off from the majority.</p>
  645. </li>
  646. <li>
  647. <p> Deployed machines operate correctly. To
  648. operate correctly means to execute code correctly, to have
  649. clocks that work properly, and to have storage and network
  650. components that perform consistently.</p>
  651. </li>
  652. </ol>
  653. <p>The sections below contain considerations for ZooKeeper
  654. administrators to maximize the probability for these assumptions
  655. to hold true. Some of these are cross-machines considerations,
  656. and others are things you should consider for each and every
  657. machine in your deployment.</p>
  658. <a name="sc_CrossMachineRequirements"></a>
  659. <h4>Cross Machine Requirements</h4>
  660. <p>For the ZooKeeper service to be active, there must be a
  661. majority of non-failing machines that can communicate with
  662. each other. To create a deployment that can tolerate the
  663. failure of F machines, you should count on deploying 2xF+1
  664. machines. Thus, a deployment that consists of three machines
  665. can handle one failure, and a deployment of five machines can
  666. handle two failures. Note that a deployment of six machines
  667. can only handle two failures since three machines is not a
  668. majority. For this reason, ZooKeeper deployments are usually
  669. made up of an odd number of machines.</p>
  670. <p>To achieve the highest probability of tolerating a failure
  671. you should try to make machine failures independent. For
  672. example, if most of the machines share the same switch,
  673. failure of that switch could cause a correlated failure and
  674. bring down the service. The same holds true of shared power
  675. circuits, cooling systems, etc.</p>
  676. <a name="Single+Machine+Requirements"></a>
  677. <h4>Single Machine Requirements</h4>
  678. <p>If ZooKeeper has to contend with other applications for
  679. access to resourses like storage media, CPU, network, or
  680. memory, its performance will suffer markedly. ZooKeeper has
  681. strong durability guarantees, which means it uses storage
  682. media to log changes before the operation responsible for the
  683. change is allowed to complete. You should be aware of this
  684. dependency then, and take great care if you want to ensure
  685. that ZooKeeper operations aren&rsquo;t held up by your media. Here
  686. are some things you can do to minimize that sort of
  687. degradation:
  688. </p>
  689. <ul>
  690. <li>
  691. <p>ZooKeeper's transaction log must be on a dedicated
  692. device. (A dedicated partition is not enough.) ZooKeeper
  693. writes the log sequentially, without seeking Sharing your
  694. log device with other processes can cause seeks and
  695. contention, which in turn can cause multi-second
  696. delays.</p>
  697. </li>
  698. <li>
  699. <p>Do not put ZooKeeper in a situation that can cause a
  700. swap. In order for ZooKeeper to function with any sort of
  701. timeliness, it simply cannot be allowed to swap.
  702. Therefore, make certain that the maximum heap size given
  703. to ZooKeeper is not bigger than the amount of real memory
  704. available to ZooKeeper. For more on this, see
  705. <a href="#sc_commonProblems">Things to Avoid</a>
  706. below. </p>
  707. </li>
  708. </ul>
  709. <a name="sc_provisioning"></a>
  710. <h3 class="h4">Provisioning</h3>
  711. <p></p>
  712. <a name="sc_strengthsAndLimitations"></a>
  713. <h3 class="h4">Things to Consider: ZooKeeper Strengths and Limitations</h3>
  714. <p></p>
  715. <a name="sc_administering"></a>
  716. <h3 class="h4">Administering</h3>
  717. <p></p>
  718. <a name="sc_maintenance"></a>
  719. <h3 class="h4">Maintenance</h3>
  720. <p>Little long term maintenance is required for a ZooKeeper
  721. cluster however you must be aware of the following:</p>
  722. <a name="Ongoing+Data+Directory+Cleanup"></a>
  723. <h4>Ongoing Data Directory Cleanup</h4>
  724. <p>The ZooKeeper <a href="#var_datadir">Data
  725. Directory</a> contains files which are a persistent copy
  726. of the znodes stored by a particular serving ensemble. These
  727. are the snapshot and transactional log files. As changes are
  728. made to the znodes these changes are appended to a
  729. transaction log, occasionally, when a log grows large, a
  730. snapshot of the current state of all znodes will be written
  731. to the filesystem. This snapshot supercedes all previous
  732. logs.
  733. </p>
  734. <p>A ZooKeeper server <strong>will not remove
  735. old snapshots and log files</strong> when using the default
  736. configuration (see autopurge below), this is the
  737. responsibility of the operator. Every serving environment is
  738. different and therefore the requirements of managing these
  739. files may differ from install to install (backup for example).
  740. </p>
  741. <p>The PurgeTxnLog utility implements a simple retention
  742. policy that administrators can use. The <a href="api/index.html">API docs</a> contains details on
  743. calling conventions (arguments, etc...).
  744. </p>
  745. <p>In the following example the last count snapshots and
  746. their corresponding logs are retained and the others are
  747. deleted. The value of &lt;count&gt; should typically be
  748. greater than 3 (although not required, this provides 3 backups
  749. in the unlikely event a recent log has become corrupted). This
  750. can be run as a cron job on the ZooKeeper server machines to
  751. clean up the logs daily.</p>
  752. <pre class="code"> java -cp zookeeper.jar:lib/slf4j-api-1.7.5.jar:lib/slf4j-log4j12-1.7.5.jar:lib/log4j-1.2.16.jar:conf org.apache.zookeeper.server.PurgeTxnLog &lt;dataDir&gt; &lt;snapDir&gt; -n &lt;count&gt;</pre>
  753. <p>Automatic purging of the snapshots and corresponding
  754. transaction logs was introduced in version 3.4.0 and can be
  755. enabled via the following configuration parameters <strong>autopurge.snapRetainCount</strong> and <strong>autopurge.purgeInterval</strong>. For more on
  756. this, see <a href="#sc_advancedConfiguration">Advanced Configuration</a>
  757. below.</p>
  758. <a name="Debug+Log+Cleanup+%28log4j%29"></a>
  759. <h4>Debug Log Cleanup (log4j)</h4>
  760. <p>See the section on <a href="#sc_logging">logging</a> in this document. It is
  761. expected that you will setup a rolling file appender using the
  762. in-built log4j feature. The sample configuration file in the
  763. release tar's conf/log4j.properties provides an example of
  764. this.
  765. </p>
  766. <a name="sc_supervision"></a>
  767. <h3 class="h4">Supervision</h3>
  768. <p>You will want to have a supervisory process that manages
  769. each of your ZooKeeper server processes (JVM). The ZK server is
  770. designed to be "fail fast" meaning that it will shutdown
  771. (process exit) if an error occurs that it cannot recover
  772. from. As a ZooKeeper serving cluster is highly reliable, this
  773. means that while the server may go down the cluster as a whole
  774. is still active and serving requests. Additionally, as the
  775. cluster is "self healing" the failed server once restarted will
  776. automatically rejoin the ensemble w/o any manual
  777. interaction.</p>
  778. <p>Having a supervisory process such as <a href="http://cr.yp.to/daemontools.html">daemontools</a> or
  779. <a href="http://en.wikipedia.org/wiki/Service_Management_Facility">SMF</a>
  780. (other options for supervisory process are also available, it's
  781. up to you which one you would like to use, these are just two
  782. examples) managing your ZooKeeper server ensures that if the
  783. process does exit abnormally it will automatically be restarted
  784. and will quickly rejoin the cluster.</p>
  785. <a name="sc_monitoring"></a>
  786. <h3 class="h4">Monitoring</h3>
  787. <p>The ZooKeeper service can be monitored in one of two
  788. primary ways; 1) the command port through the use of <a href="#sc_zkCommands">4 letter words</a> and 2) <a href="zookeeperJMX.html">JMX</a>. See the appropriate section for
  789. your environment/requirements.</p>
  790. <a name="sc_logging"></a>
  791. <h3 class="h4">Logging</h3>
  792. <p>ZooKeeper uses <strong>log4j</strong> version 1.2 as
  793. its logging infrastructure. The ZooKeeper default <span class="codefrag filename">log4j.properties</span>
  794. file resides in the <span class="codefrag filename">conf</span> directory. Log4j requires that
  795. <span class="codefrag filename">log4j.properties</span> either be in the working directory
  796. (the directory from which ZooKeeper is run) or be accessible from the classpath.</p>
  797. <p>For more information, see
  798. <a href="http://logging.apache.org/log4j/1.2/manual.html#defaultInit">Log4j Default Initialization Procedure</a>
  799. of the log4j manual.</p>
  800. <a name="sc_troubleshooting"></a>
  801. <h3 class="h4">Troubleshooting</h3>
  802. <dl>
  803. <dt>
  804. <term> Server not coming up because of file corruption</term>
  805. </dt>
  806. <dd>
  807. <p>A server might not be able to read its database and fail to come up because of
  808. some file corruption in the transaction logs of the ZooKeeper server. You will
  809. see some IOException on loading ZooKeeper database. In such a case,
  810. make sure all the other servers in your ensemble are up and working. Use "stat"
  811. command on the command port to see if they are in good health. After you have verified that
  812. all the other servers of the ensemble are up, you can go ahead and clean the database
  813. of the corrupt server. Delete all the files in datadir/version-2 and datalogdir/version-2/.
  814. Restart the server.
  815. </p>
  816. </dd>
  817. </dl>
  818. <a name="sc_configuration"></a>
  819. <h3 class="h4">Configuration Parameters</h3>
  820. <p>ZooKeeper's behavior is governed by the ZooKeeper configuration
  821. file. This file is designed so that the exact same file can be used by
  822. all the servers that make up a ZooKeeper server assuming the disk
  823. layouts are the same. If servers use different configuration files, care
  824. must be taken to ensure that the list of servers in all of the different
  825. configuration files match.</p>
  826. <div class="note">
  827. <div class="label">Note</div>
  828. <div class="content">
  829. <p>In 3.5.0 and later, some of these parameters should be placed in
  830. a dynamic configuration file. If they are placed in the static
  831. configuration file, ZooKeeper will automatically move them over to the
  832. dynamic configuration file. See <a href="zookeeperReconfig.html">
  833. Dynamic Reconfiguration</a> for more information.</p>
  834. </div>
  835. </div>
  836. <a name="sc_minimumConfiguration"></a>
  837. <h4>Minimum Configuration</h4>
  838. <p>Here are the minimum configuration keywords that must be defined
  839. in the configuration file:</p>
  840. <dl>
  841. <dt>
  842. <term>clientPort</term>
  843. </dt>
  844. <dd>
  845. <p>the port to listen for client connections; that is, the
  846. port that clients attempt to connect to.</p>
  847. </dd>
  848. <dt>
  849. <term>dataDir</term>
  850. </dt>
  851. <dd>
  852. <p>the location where ZooKeeper will store the in-memory
  853. database snapshots and, unless specified otherwise, the
  854. transaction log of updates to the database.</p>
  855. <div class="note">
  856. <div class="label">Note</div>
  857. <div class="content">
  858. <p>Be careful where you put the transaction log. A
  859. dedicated transaction log device is key to consistent good
  860. performance. Putting the log on a busy device will adversely
  861. effect performance.</p>
  862. </div>
  863. </div>
  864. </dd>
  865. <dt>
  866. <term>tickTime</term>
  867. </dt>
  868. <dd>
  869. <p>the length of a single tick, which is the basic time unit
  870. used by ZooKeeper, as measured in milliseconds. It is used to
  871. regulate heartbeats, and timeouts. For example, the minimum
  872. session timeout will be two ticks.</p>
  873. </dd>
  874. </dl>
  875. <a name="sc_advancedConfiguration"></a>
  876. <h4>Advanced Configuration</h4>
  877. <p>The configuration settings in the section are optional. You can
  878. use them to further fine tune the behaviour of your ZooKeeper servers.
  879. Some can also be set using Java system properties, generally of the
  880. form <em>zookeeper.keyword</em>. The exact system
  881. property, when available, is noted below.</p>
  882. <dl>
  883. <dt>
  884. <term>dataLogDir</term>
  885. </dt>
  886. <dd>
  887. <p>(No Java system property)</p>
  888. <p>This option will direct the machine to write the
  889. transaction log to the <strong>dataLogDir</strong> rather than the <strong>dataDir</strong>. This allows a dedicated log
  890. device to be used, and helps avoid competition between logging
  891. and snaphots.</p>
  892. <div class="note">
  893. <div class="label">Note</div>
  894. <div class="content">
  895. <p>Having a dedicated log device has a large impact on
  896. throughput and stable latencies. It is highly recommened to
  897. dedicate a log device and set <strong>dataLogDir</strong> to point to a directory on
  898. that device, and then make sure to point <strong>dataDir</strong> to a directory
  899. <em>not</em> residing on that device.</p>
  900. </div>
  901. </div>
  902. </dd>
  903. <dt>
  904. <term>globalOutstandingLimit</term>
  905. </dt>
  906. <dd>
  907. <p>(Java system property: <strong>zookeeper.globalOutstandingLimit.</strong>)</p>
  908. <p>Clients can submit requests faster than ZooKeeper can
  909. process them, especially if there are a lot of clients. To
  910. prevent ZooKeeper from running out of memory due to queued
  911. requests, ZooKeeper will throttle clients so that there is no
  912. more than globalOutstandingLimit outstanding requests in the
  913. system. The default limit is 1,000.</p>
  914. </dd>
  915. <dt>
  916. <term>preAllocSize</term>
  917. </dt>
  918. <dd>
  919. <p>(Java system property: <strong>zookeeper.preAllocSize</strong>)</p>
  920. <p>To avoid seeks ZooKeeper allocates space in the
  921. transaction log file in blocks of preAllocSize kilobytes. The
  922. default block size is 64M. One reason for changing the size of
  923. the blocks is to reduce the block size if snapshots are taken
  924. more often. (Also, see <strong>snapCount</strong>).</p>
  925. </dd>
  926. <dt>
  927. <term>snapCount</term>
  928. </dt>
  929. <dd>
  930. <p>(Java system property: <strong>zookeeper.snapCount</strong>)</p>
  931. <p>ZooKeeper logs transactions to a transaction
  932. log. After snapCount transactions are written to a log
  933. file a snapshot is started and a new transaction log
  934. file is created. The default snapCount is
  935. 100,000.</p>
  936. </dd>
  937. <dt>
  938. <term>traceFile</term>
  939. </dt>
  940. <dd>
  941. <p>(Java system property: <strong>requestTraceFile</strong>)</p>
  942. <p>If this option is defined, requests will be will logged to
  943. a trace file named traceFile.year.month.day. Use of this option
  944. provides useful debugging information, but will impact
  945. performance. (Note: The system property has no zookeeper prefix,
  946. and the configuration variable name is different from the system
  947. property. Yes - it's not consistent, and it's annoying.)</p>
  948. </dd>
  949. <dt>
  950. <term>maxClientCnxns</term>
  951. </dt>
  952. <dd>
  953. <p>(No Java system property)</p>
  954. <p>Limits the number of concurrent connections (at the socket
  955. level) that a single client, identified by IP address, may make
  956. to a single member of the ZooKeeper ensemble. This is used to
  957. prevent certain classes of DoS attacks, including file
  958. descriptor exhaustion. The default is 60. Setting this to 0
  959. entirely removes the limit on concurrent connections.</p>
  960. </dd>
  961. <dt>
  962. <term>clientPortAddress</term>
  963. </dt>
  964. <dd>
  965. <p>
  966. <strong>New in 3.3.0:</strong> the
  967. address (ipv4, ipv6 or hostname) to listen for client
  968. connections; that is, the address that clients attempt
  969. to connect to. This is optional, by default we bind in
  970. such a way that any connection to the <strong>clientPort</strong> for any
  971. address/interface/nic on the server will be
  972. accepted.</p>
  973. </dd>
  974. <dt>
  975. <term>minSessionTimeout</term>
  976. </dt>
  977. <dd>
  978. <p>(No Java system property)</p>
  979. <p>
  980. <strong>New in 3.3.0:</strong> the
  981. minimum session timeout in milliseconds that the server
  982. will allow the client to negotiate. Defaults to 2 times
  983. the <strong>tickTime</strong>.</p>
  984. </dd>
  985. <dt>
  986. <term>maxSessionTimeout</term>
  987. </dt>
  988. <dd>
  989. <p>(No Java system property)</p>
  990. <p>
  991. <strong>New in 3.3.0:</strong> the
  992. maximum session timeout in milliseconds that the server
  993. will allow the client to negotiate. Defaults to 20 times
  994. the <strong>tickTime</strong>.</p>
  995. </dd>
  996. <dt>
  997. <term>fsync.warningthresholdms</term>
  998. </dt>
  999. <dd>
  1000. <p>(Java system property: <strong>fsync.warningthresholdms</strong>)</p>
  1001. <p>
  1002. <strong>New in 3.3.4:</strong> A
  1003. warning message will be output to the log whenever an
  1004. fsync in the Transactional Log (WAL) takes longer than
  1005. this value. The values is specified in milliseconds and
  1006. defaults to 1000. This value can only be set as a
  1007. system property.</p>
  1008. </dd>
  1009. <dt>
  1010. <term>autopurge.snapRetainCount</term>
  1011. </dt>
  1012. <dd>
  1013. <p>(No Java system property)</p>
  1014. <p>
  1015. <strong>New in 3.4.0:</strong>
  1016. When enabled, ZooKeeper auto purge feature retains
  1017. the <strong>autopurge.snapRetainCount</strong> most
  1018. recent snapshots and the corresponding transaction logs in the
  1019. <strong>dataDir</strong> and <strong>dataLogDir</strong> respectively and deletes the rest.
  1020. Defaults to 3. Minimum value is 3.</p>
  1021. </dd>
  1022. <dt>
  1023. <term>autopurge.purgeInterval</term>
  1024. </dt>
  1025. <dd>
  1026. <p>(No Java system property)</p>
  1027. <p>
  1028. <strong>New in 3.4.0:</strong> The
  1029. time interval in hours for which the purge task has to
  1030. be triggered. Set to a positive integer (1 and above)
  1031. to enable the auto purging. Defaults to 0.</p>
  1032. </dd>
  1033. <dt>
  1034. <term>syncEnabled</term>
  1035. </dt>
  1036. <dd>
  1037. <p>(Java system property: <strong>zookeeper.observer.syncEnabled</strong>)</p>
  1038. <p>
  1039. <strong>New in 3.4.6, 3.5.0:</strong>
  1040. The observers now log transaction and write snapshot to disk
  1041. by default like the participants. This reduces the recovery time
  1042. of the observers on restart. Set to "false" to disable this
  1043. feature. Default is "true"</p>
  1044. </dd>
  1045. </dl>
  1046. <a name="sc_clusterOptions"></a>
  1047. <h4>Cluster Options</h4>
  1048. <p>The options in this section are designed for use with an ensemble
  1049. of servers -- that is, when deploying clusters of servers.</p>
  1050. <dl>
  1051. <dt>
  1052. <term>electionAlg</term>
  1053. </dt>
  1054. <dd>
  1055. <p>(No Java system property)</p>
  1056. <p>Election implementation to use. A value of "0" corresponds
  1057. to the original UDP-based version, "1" corresponds to the
  1058. non-authenticated UDP-based version of fast leader election, "2"
  1059. corresponds to the authenticated UDP-based version of fast
  1060. leader election, and "3" corresponds to TCP-based version of
  1061. fast leader election. Currently, algorithm 3 is the default</p>
  1062. <div class="note">
  1063. <div class="label">Note</div>
  1064. <div class="content">
  1065. <p> The implementations of leader election 0, 1, and 2 are now
  1066. <strong> deprecated </strong>. We have the intention
  1067. of removing them in the next release, at which point only the
  1068. FastLeaderElection will be available.
  1069. </p>
  1070. </div>
  1071. </div>
  1072. </dd>
  1073. <dt>
  1074. <term>initLimit</term>
  1075. </dt>
  1076. <dd>
  1077. <p>(No Java system property)</p>
  1078. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to
  1079. connect and sync to a leader. Increased this value as needed, if
  1080. the amount of data managed by ZooKeeper is large.</p>
  1081. </dd>
  1082. <dt>
  1083. <term>leaderServes</term>
  1084. </dt>
  1085. <dd>
  1086. <p>(Java system property: zookeeper.<strong>leaderServes</strong>)</p>
  1087. <p>Leader accepts client connections. Default value is "yes".
  1088. The leader machine coordinates updates. For higher update
  1089. throughput at thes slight expense of read throughput the leader
  1090. can be configured to not accept clients and focus on
  1091. coordination. The default to this option is yes, which means
  1092. that a leader will accept client connections.</p>
  1093. <div class="note">
  1094. <div class="label">Note</div>
  1095. <div class="content">
  1096. <p>Turning on leader selection is highly recommended when
  1097. you have more than three ZooKeeper servers in an ensemble.</p>
  1098. </div>
  1099. </div>
  1100. </dd>
  1101. <dt>
  1102. <term>server.x=[hostname]:nnnnn[:nnnnn], etc</term>
  1103. </dt>
  1104. <dd>
  1105. <p>(No Java system property)</p>
  1106. <p>servers making up the ZooKeeper ensemble. When the server
  1107. starts up, it determines which server it is by looking for the
  1108. file <span class="codefrag filename">myid</span> in the data directory. That file
  1109. contains the server number, in ASCII, and it should match
  1110. <strong>x</strong> in <strong>server.x</strong> in the left hand side of this
  1111. setting.</p>
  1112. <p>The list of servers that make up ZooKeeper servers that is
  1113. used by the clients must match the list of ZooKeeper servers
  1114. that each ZooKeeper server has.</p>
  1115. <p>There are two port numbers <strong>nnnnn</strong>.
  1116. The first followers use to connect to the leader, and the second is for
  1117. leader election. The leader election port is only necessary if electionAlg
  1118. is 1, 2, or 3 (default). If electionAlg is 0, then the second port is not
  1119. necessary. If you want to test multiple servers on a single machine, then
  1120. different ports can be used for each server.</p>
  1121. </dd>
  1122. <dt>
  1123. <term>syncLimit</term>
  1124. </dt>
  1125. <dd>
  1126. <p>(No Java system property)</p>
  1127. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to sync
  1128. with ZooKeeper. If followers fall too far behind a leader, they
  1129. will be dropped.</p>
  1130. </dd>
  1131. <dt>
  1132. <term>group.x=nnnnn[:nnnnn]</term>
  1133. </dt>
  1134. <dd>
  1135. <p>(No Java system property)</p>
  1136. <p>Enables a hierarchical quorum construction."x" is a group identifier
  1137. and the numbers following the "=" sign correspond to server identifiers.
  1138. The left-hand side of the assignment is a colon-separated list of server
  1139. identifiers. Note that groups must be disjoint and the union of all groups
  1140. must be the ZooKeeper ensemble. </p>
  1141. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1142. </p>
  1143. </dd>
  1144. <dt>
  1145. <term>weight.x=nnnnn</term>
  1146. </dt>
  1147. <dd>
  1148. <p>(No Java system property)</p>
  1149. <p>Used along with "group", it assigns a weight to a server when
  1150. forming quorums. Such a value corresponds to the weight of a server
  1151. when voting. There are a few parts of ZooKeeper that require voting
  1152. such as leader election and the atomic broadcast protocol. By default
  1153. the weight of server is 1. If the configuration defines groups, but not
  1154. weights, then a value of 1 will be assigned to all servers.
  1155. </p>
  1156. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1157. </p>
  1158. </dd>
  1159. <dt>
  1160. <term>cnxTimeout</term>
  1161. </dt>
  1162. <dd>
  1163. <p>(Java system property: zookeeper.<strong>cnxTimeout</strong>)</p>
  1164. <p>Sets the timeout value for opening connections for leader election notifications.
  1165. Only applicable if you are using electionAlg 3.
  1166. </p>
  1167. <div class="note">
  1168. <div class="label">Note</div>
  1169. <div class="content">
  1170. <p>Default value is 5 seconds.</p>
  1171. </div>
  1172. </div>
  1173. </dd>
  1174. <dt>
  1175. <term>standaloneEnabled</term>
  1176. </dt>
  1177. <dd>
  1178. <p>(No Java system property)</p>
  1179. <p>
  1180. <strong>New in 3.5.0:</strong>
  1181. When set to false, a single server can be started in replicated
  1182. mode, a lone participant can run with observers, and a cluster
  1183. can reconfigure down to one node, and up from one node. The
  1184. default is true for backwards compatibility. It can be set
  1185. using QuorumPeerConfig's setStandaloneEnabled method or by
  1186. adding "standaloneEnabled=false" or "standaloneEnabled=true"
  1187. to a server's config file.
  1188. </p>
  1189. </dd>
  1190. </dl>
  1191. <p></p>
  1192. <a name="sc_authOptions"></a>
  1193. <h4>Authentication &amp; Authorization Options</h4>
  1194. <p>The options in this section allow control over
  1195. authentication/authorization performed by the service.</p>
  1196. <dl>
  1197. <dt>
  1198. <term>zookeeper.DigestAuthenticationProvider.superDigest</term>
  1199. </dt>
  1200. <dd>
  1201. <p>(Java system property only: <strong>zookeeper.DigestAuthenticationProvider.superDigest</strong>)</p>
  1202. <p>By default this feature is <strong>disabled</strong>
  1203. </p>
  1204. <p>
  1205. <strong>New in 3.2:</strong>
  1206. Enables a ZooKeeper ensemble administrator to access the
  1207. znode hierarchy as a "super" user. In particular no ACL
  1208. checking occurs for a user authenticated as
  1209. super.</p>
  1210. <p>org.apache.zookeeper.server.auth.DigestAuthenticationProvider
  1211. can be used to generate the superDigest, call it with
  1212. one parameter of "super:&lt;password&gt;". Provide the
  1213. generated "super:&lt;data&gt;" as the system property value
  1214. when starting each server of the ensemble.</p>
  1215. <p>When authenticating to a ZooKeeper server (from a
  1216. ZooKeeper client) pass a scheme of "digest" and authdata
  1217. of "super:&lt;password&gt;". Note that digest auth passes
  1218. the authdata in plaintext to the server, it would be
  1219. prudent to use this authentication method only on
  1220. localhost (not over the network) or over an encrypted
  1221. connection.</p>
  1222. </dd>
  1223. </dl>
  1224. <a name="Experimental+Options%2FFeatures"></a>
  1225. <h4>Experimental Options/Features</h4>
  1226. <p>New features that are currently considered experimental.</p>
  1227. <dl>
  1228. <dt>
  1229. <term>Read Only Mode Server</term>
  1230. </dt>
  1231. <dd>
  1232. <p>(Java system property: <strong>readonlymode.enabled</strong>)</p>
  1233. <p>
  1234. <strong>New in 3.4.0:</strong>
  1235. Setting this value to true enables Read Only Mode server
  1236. support (disabled by default). ROM allows clients
  1237. sessions which requested ROM support to connect to the
  1238. server even when the server might be partitioned from
  1239. the quorum. In this mode ROM clients can still read
  1240. values from the ZK service, but will be unable to write
  1241. values and see changes from other clients. See
  1242. ZOOKEEPER-784 for more details.
  1243. </p>
  1244. </dd>
  1245. </dl>
  1246. <a name="Unsafe+Options"></a>
  1247. <h4>Unsafe Options</h4>
  1248. <p>The following options can be useful, but be careful when you use
  1249. them. The risk of each is explained along with the explanation of what
  1250. the variable does.</p>
  1251. <dl>
  1252. <dt>
  1253. <term>forceSync</term>
  1254. </dt>
  1255. <dd>
  1256. <p>(Java system property: <strong>zookeeper.forceSync</strong>)</p>
  1257. <p>Requires updates to be synced to media of the transaction
  1258. log before finishing processing the update. If this option is
  1259. set to no, ZooKeeper will not require updates to be synced to
  1260. the media.</p>
  1261. </dd>
  1262. <dt>
  1263. <term>jute.maxbuffer:</term>
  1264. </dt>
  1265. <dd>
  1266. <p>(Java system property:<strong>
  1267. jute.maxbuffer</strong>)</p>
  1268. <p>This option can only be set as a Java system property.
  1269. There is no zookeeper prefix on it. It specifies the maximum
  1270. size of the data that can be stored in a znode. The default is
  1271. 0xfffff, or just under 1M. If this option is changed, the system
  1272. property must be set on all servers and clients otherwise
  1273. problems will arise. This is really a sanity check. ZooKeeper is
  1274. designed to store data on the order of kilobytes in size.</p>
  1275. </dd>
  1276. <dt>
  1277. <term>skipACL</term>
  1278. </dt>
  1279. <dd>
  1280. <p>(Java system property: <strong>zookeeper.skipACL</strong>)</p>
  1281. <p>Skips ACL checks. This results in a boost in throughput,
  1282. but opens up full access to the data tree to everyone.</p>
  1283. </dd>
  1284. <dt>
  1285. <term>quorumListenOnAllIPs</term>
  1286. </dt>
  1287. <dd>
  1288. <p>When set to true the ZooKeeper server will listen
  1289. for connections from its peers on all available IP addresses,
  1290. and not only the address configured in the server list of the
  1291. configuration file. It affects the connections handling the
  1292. ZAB protocol and the Fast Leader Election protocol. Default
  1293. value is <strong>false</strong>.</p>
  1294. </dd>
  1295. </dl>
  1296. <a name="Disabling+data+directory+autocreation"></a>
  1297. <h4>Disabling data directory autocreation</h4>
  1298. <p>
  1299. <strong>New in 3.5:</strong> The default
  1300. behavior of a ZooKeeper server is to automatically create the
  1301. data directory (specified in the configuration file) when
  1302. started if that directory does not already exist. This can be
  1303. inconvenient and even dangerous in some cases. Take the case
  1304. where a configuration change is made to a running server,
  1305. wherein the <strong>dataDir</strong> parameter
  1306. is accidentally changed. When the ZooKeeper server is
  1307. restarted it will create this non-existent directory and begin
  1308. serving - with an empty znode namespace. This scenario can
  1309. result in an effective "split brain" situation (i.e. data in
  1310. both the new invalid directory and the original valid data
  1311. store). As such is would be good to have an option to turn off
  1312. this autocreate behavior. In general for production
  1313. environments this should be done, unfortunately however the
  1314. default legacy behavior cannot be changed at this point and
  1315. therefore this must be done on a case by case basis. This is
  1316. left to users and to packagers of ZooKeeper distributions.
  1317. </p>
  1318. <p>When running <strong>zkServer.sh</strong> autocreate can be disabled
  1319. by setting the environment variable <strong>ZOO_DATADIR_AUTOCREATE_DISABLE</strong> to 1.
  1320. When running ZooKeeper servers directly from class files this
  1321. can be accomplished by setting <strong>zookeeper.datadir.autocreate=false</strong> on
  1322. the java command line, i.e. <strong>-Dzookeeper.datadir.autocreate=false</strong>
  1323. </p>
  1324. <p>When this feature is disabled, and the ZooKeeper server
  1325. determines that the required directories do not exist it will
  1326. generate an error and refuse to start.
  1327. </p>
  1328. <p>A new script <strong>zkServer-initialize.sh</strong> is provided to
  1329. support this new feature. If autocreate is disabled it is
  1330. necessary for the user to first install ZooKeeper, then create
  1331. the data directory (and potentially txnlog directory), and
  1332. then start the server. Otherwise as mentioned in the previous
  1333. paragraph the server will not start. Running <strong>zkServer-initialize.sh</strong> will create the
  1334. required directories, and optionally setup the myid file
  1335. (optional command line parameter). This script can be used
  1336. even if the autocreate feature itself is not used, and will
  1337. likely be of use to users as this (setup, including creation
  1338. of the myid file) has been an issue for users in the past.
  1339. Note that this script ensures the data directories exist only,
  1340. it does not create a config file, but rather requires a config
  1341. file to be available in order to execute.
  1342. </p>
  1343. <a name="sc_performance_options"></a>
  1344. <h4>Performance Tuning Options</h4>
  1345. <p>
  1346. <strong>New in 3.5.0:</strong> Several subsystems have been reworked
  1347. to improve read throughput. This includes multi-threading of the NIO communication subsystem and
  1348. request processing pipeline (Commit Processor). NIO is the default client/server communication
  1349. subsystem. Its threading model comprises 1 acceptor thread, 1-N selector threads and 0-M
  1350. socket I/O worker threads. In the request processing pipeline the system can be configured
  1351. to process multiple read request at once while maintaining the same consistency guarantee
  1352. (same-session read-after-write). The Commit Processor threading model comprises 1 main
  1353. thread and 0-N worker threads.
  1354. </p>
  1355. <p>
  1356. The default values are aimed at maximizing read throughput on a dedicated ZooKeeper machine.
  1357. Both subsystems need to have sufficient amount of threads to achieve peak read throughput.
  1358. </p>
  1359. <dl>
  1360. <dt>
  1361. <term>zookeeper.nio.numSelectorThreads</term>
  1362. </dt>
  1363. <dd>
  1364. <p>(Java system property only: <strong>zookeeper.nio.numSelectorThreads</strong>)
  1365. </p>
  1366. <p>
  1367. <strong>New in 3.5.0:</strong>
  1368. Number of NIO selector threads. At least 1 selector thread required.
  1369. It is recommended to use more than one selector for large numbers
  1370. of client connections. The default value is sqrt( number of cpu cores / 2 ).
  1371. </p>
  1372. </dd>
  1373. <dt>
  1374. <term>zookeeper.nio.numWorkerThreads</term>
  1375. </dt>
  1376. <dd>
  1377. <p>(Java system property only: <strong>zookeeper.nio.numWorkerThreads</strong>)
  1378. </p>
  1379. <p>
  1380. <strong>New in 3.5.0:</strong>
  1381. Number of NIO worker threads. If configured with 0 worker threads, the selector threads
  1382. do the socket I/O directly. The default value is 2 times the number of cpu cores.
  1383. </p>
  1384. </dd>
  1385. <dt>
  1386. <term>zookeeper.commitProcessor.numWorkerThreads</term>
  1387. </dt>
  1388. <dd>
  1389. <p>(Java system property only: <strong>zookeeper.commitProcessor.numWorkerThreads</strong>)
  1390. </p>
  1391. <p>
  1392. <strong>New in 3.5.0:</strong>
  1393. Number of Commit Processor worker threads. If configured with 0 worker threads, the main thread
  1394. will process the request directly. The default value is the number of cpu cores.
  1395. </p>
  1396. </dd>
  1397. </dl>
  1398. <a name="Communication+using+the+Netty+framework"></a>
  1399. <h4>Communication using the Netty framework</h4>
  1400. <p>
  1401. <strong>New in
  1402. 3.4:</strong> <a href="http://jboss.org/netty">Netty</a>
  1403. is an NIO based client/server communication framework, it
  1404. simplifies (over NIO being used directly) many of the
  1405. complexities of network level communication for java
  1406. applications. Additionally the Netty framework has built
  1407. in support for encryption (SSL) and authentication
  1408. (certificates). These are optional features and can be
  1409. turned on or off individually.
  1410. </p>
  1411. <p>Prior to version 3.4 ZooKeeper has always used NIO
  1412. directly, however in versions 3.4 and later Netty is
  1413. supported as an option to NIO (replaces). NIO continues to
  1414. be the default, however Netty based communication can be
  1415. used in place of NIO by setting the environment variable
  1416. "zookeeper.serverCnxnFactory" to
  1417. "org.apache.zookeeper.server.NettyServerCnxnFactory". You
  1418. have the option of setting this on either the client(s) or
  1419. server(s), typically you would want to set this on both,
  1420. however that is at your discretion.
  1421. </p>
  1422. <p>
  1423. TBD - tuning options for netty - currently there are none that are netty specific but we should add some. Esp around max bound on the number of reader worker threads netty creates.
  1424. </p>
  1425. <p>
  1426. TBD - how to manage encryption
  1427. </p>
  1428. <p>
  1429. TBD - how to manage certificates
  1430. </p>
  1431. <a name="sc_adminserver_config"></a>
  1432. <h4>AdminServer configuration</h4>
  1433. <p>
  1434. <strong>New in 3.5.0:</strong> The following
  1435. options are used to configure the <a href="#sc_adminserver">AdminServer</a>.</p>
  1436. <dl>
  1437. <dt>
  1438. <term>admin.enableServer</term>
  1439. </dt>
  1440. <dd>
  1441. <p>(Java system property: <strong>zookeeper.admin.enableServer</strong>)</p>
  1442. <p>Set to "false" to disable the AdminServer. By default the
  1443. AdminServer is enabled.</p>
  1444. </dd>
  1445. <dt>
  1446. <term>admin.serverPort</term>
  1447. </dt>
  1448. <dd>
  1449. <p>(Java system property: <strong>zookeeper.admin.serverPort</strong>)</p>
  1450. <p>The port the embedded Jetty server listens on. Defaults to 8080.</p>
  1451. </dd>
  1452. <dt>
  1453. <term>admin.commandURL</term>
  1454. </dt>
  1455. <dd>
  1456. <p>(Java system property: <strong>zookeeper.admin.commandURL</strong>)</p>
  1457. <p>The URL for listing and issuing commands relative to the
  1458. root URL. Defaults to "/commands".</p>
  1459. </dd>
  1460. </dl>
  1461. <a name="sc_zkCommands"></a>
  1462. <h3 class="h4">ZooKeeper Commands</h3>
  1463. <a name="The+Four+Letter+Words"></a>
  1464. <h4>The Four Letter Words</h4>
  1465. <p>ZooKeeper responds to a small set of commands. Each command is
  1466. composed of four letters. You issue the commands to ZooKeeper via telnet
  1467. or nc, at the client port.</p>
  1468. <p>Three of the more interesting commands: "stat" gives some
  1469. general information about the server and connected clients,
  1470. while "srvr" and "cons" give extended details on server and
  1471. connections respectively.</p>
  1472. <dl>
  1473. <dt>
  1474. <term>conf</term>
  1475. </dt>
  1476. <dd>
  1477. <p>
  1478. <strong>New in 3.3.0:</strong> Print
  1479. details about serving configuration.</p>
  1480. </dd>
  1481. <dt>
  1482. <term>cons</term>
  1483. </dt>
  1484. <dd>
  1485. <p>
  1486. <strong>New in 3.3.0:</strong> List
  1487. full connection/session details for all clients connected
  1488. to this server. Includes information on numbers of packets
  1489. received/sent, session id, operation latencies, last
  1490. operation performed, etc...</p>
  1491. </dd>
  1492. <dt>
  1493. <term>crst</term>
  1494. </dt>
  1495. <dd>
  1496. <p>
  1497. <strong>New in 3.3.0:</strong> Reset
  1498. connection/session statistics for all connections.</p>
  1499. </dd>
  1500. <dt>
  1501. <term>dump</term>
  1502. </dt>
  1503. <dd>
  1504. <p>Lists the outstanding sessions and ephemeral nodes. This
  1505. only works on the leader.</p>
  1506. </dd>
  1507. <dt>
  1508. <term>envi</term>
  1509. </dt>
  1510. <dd>
  1511. <p>Print details about serving environment</p>
  1512. </dd>
  1513. <dt>
  1514. <term>ruok</term>
  1515. </dt>
  1516. <dd>
  1517. <p>Tests if server is running in a non-error state. The server
  1518. will respond with imok if it is running. Otherwise it will not
  1519. respond at all.</p>
  1520. <p>A response of "imok" does not necessarily indicate that the
  1521. server has joined the quorum, just that the server process is active
  1522. and bound to the specified client port. Use "stat" for details on
  1523. state wrt quorum and client connection information.</p>
  1524. </dd>
  1525. <dt>
  1526. <term>srst</term>
  1527. </dt>
  1528. <dd>
  1529. <p>Reset server statistics.</p>
  1530. </dd>
  1531. <dt>
  1532. <term>srvr</term>
  1533. </dt>
  1534. <dd>
  1535. <p>
  1536. <strong>New in 3.3.0:</strong> Lists
  1537. full details for the server.</p>
  1538. </dd>
  1539. <dt>
  1540. <term>stat</term>
  1541. </dt>
  1542. <dd>
  1543. <p>Lists brief details for the server and connected
  1544. clients.</p>
  1545. </dd>
  1546. <dt>
  1547. <term>wchs</term>
  1548. </dt>
  1549. <dd>
  1550. <p>
  1551. <strong>New in 3.3.0:</strong> Lists
  1552. brief information on watches for the server.</p>
  1553. </dd>
  1554. <dt>
  1555. <term>wchc</term>
  1556. </dt>
  1557. <dd>
  1558. <p>
  1559. <strong>New in 3.3.0:</strong> Lists
  1560. detailed information on watches for the server, by
  1561. session. This outputs a list of sessions(connections)
  1562. with associated watches (paths). Note, depending on the
  1563. number of watches this operation may be expensive (ie
  1564. impact server performance), use it carefully.</p>
  1565. </dd>
  1566. <dt>
  1567. <term>wchp</term>
  1568. </dt>
  1569. <dd>
  1570. <p>
  1571. <strong>New in 3.3.0:</strong> Lists
  1572. detailed information on watches for the server, by path.
  1573. This outputs a list of paths (znodes) with associated
  1574. sessions. Note, depending on the number of watches this
  1575. operation may be expensive (ie impact server performance),
  1576. use it carefully.</p>
  1577. </dd>
  1578. <dt>
  1579. <term>mntr</term>
  1580. </dt>
  1581. <dd>
  1582. <p>
  1583. <strong>New in 3.4.0:</strong> Outputs a list
  1584. of variables that could be used for monitoring the health of the cluster.</p>
  1585. <pre class="code">$ echo mntr | nc localhost 2185
  1586. zk_version 3.4.0
  1587. zk_avg_latency 0
  1588. zk_max_latency 0
  1589. zk_min_latency 0
  1590. zk_packets_received 70
  1591. zk_packets_sent 69
  1592. zk_outstanding_requests 0
  1593. zk_server_state leader
  1594. zk_znode_count 4
  1595. zk_watch_count 0
  1596. zk_ephemerals_count 0
  1597. zk_approximate_data_size 27
  1598. zk_followers 4 - only exposed by the Leader
  1599. zk_synced_followers 4 - only exposed by the Leader
  1600. zk_pending_syncs 0 - only exposed by the Leader
  1601. zk_open_file_descriptor_count 23 - only available on Unix platforms
  1602. zk_max_file_descriptor_count 1024 - only available on Unix platforms
  1603. </pre>
  1604. <p>The output is compatible with java properties format and the content
  1605. may change over time (new keys added). Your scripts should expect changes.</p>
  1606. <p>ATTENTION: Some of the keys are platform specific and some of the keys are only exported by the Leader. </p>
  1607. <p>The output contains multiple lines with the following format:</p>
  1608. <pre class="code">key \t value</pre>
  1609. </dd>
  1610. </dl>
  1611. <p>Here's an example of the <strong>ruok</strong>
  1612. command:</p>
  1613. <pre class="code">$ echo ruok | nc 127.0.0.1 5111
  1614. imok
  1615. </pre>
  1616. <a name="sc_adminserver"></a>
  1617. <h4>The AdminServer</h4>
  1618. <p>
  1619. <strong>New in 3.5.0: </strong>The AdminServer is
  1620. an embedded Jetty server that provides an HTTP interface to the four
  1621. letter word commands. By default, the server is started on port 8080,
  1622. and commands are issued by going to the URL "/commands/[command name]",
  1623. e.g., http://localhost:8080/commands/stat. The command response is
  1624. returned as JSON. Unlike the original protocol, commands are not
  1625. restricted to four-letter names, and commands can have multiple names;
  1626. for instance, "stmk" can also be referred to as "set_trace_mask". To
  1627. view a list of all available commands, point a browser to the URL
  1628. /commands (e.g., http://localhost:8080/commands). See the <a href="#sc_adminserver_config">AdminServer configuration options</a>
  1629. for how to change the port and URLs.</p>
  1630. <p>The AdminServer is enabled by default, but can be disabled by either:</p>
  1631. <ul>
  1632. <li>
  1633. <p>Setting the zookeeper.admin.enableServer system
  1634. property to false.</p>
  1635. </li>
  1636. <li>
  1637. <p>Removing Jetty from the classpath. (This option is
  1638. useful if you would like to override ZooKeeper's jetty
  1639. dependency.)</p>
  1640. </li>
  1641. </ul>
  1642. <p>Note that the TCP four letter word interface is still available if
  1643. the AdminServer is disabled.</p>
  1644. <a name="sc_dataFileManagement"></a>
  1645. <h3 class="h4">Data File Management</h3>
  1646. <p>ZooKeeper stores its data in a data directory and its transaction
  1647. log in a transaction log directory. By default these two directories are
  1648. the same. The server can (and should) be configured to store the
  1649. transaction log files in a separate directory than the data files.
  1650. Throughput increases and latency decreases when transaction logs reside
  1651. on a dedicated log devices.</p>
  1652. <a name="The+Data+Directory"></a>
  1653. <h4>The Data Directory</h4>
  1654. <p>This directory has two files in it:</p>
  1655. <ul>
  1656. <li>
  1657. <p>
  1658. <span class="codefrag filename">myid</span> - contains a single integer in
  1659. human readable ASCII text that represents the server id.</p>
  1660. </li>
  1661. <li>
  1662. <p>
  1663. <span class="codefrag filename">snapshot.&lt;zxid&gt;</span> - holds the fuzzy
  1664. snapshot of a data tree.</p>
  1665. </li>
  1666. </ul>
  1667. <p>Each ZooKeeper server has a unique id. This id is used in two
  1668. places: the <span class="codefrag filename">myid</span> file and the configuration file.
  1669. The <span class="codefrag filename">myid</span> file identifies the server that
  1670. corresponds to the given data directory. The configuration file lists
  1671. the contact information for each server identified by its server id.
  1672. When a ZooKeeper server instance starts, it reads its id from the
  1673. <span class="codefrag filename">myid</span> file and then, using that id, reads from the
  1674. configuration file, looking up the port on which it should
  1675. listen.</p>
  1676. <p>The <span class="codefrag filename">snapshot</span> files stored in the data
  1677. directory are fuzzy snapshots in the sense that during the time the
  1678. ZooKeeper server is taking the snapshot, updates are occurring to the
  1679. data tree. The suffix of the <span class="codefrag filename">snapshot</span> file names
  1680. is the <em>zxid</em>, the ZooKeeper transaction id, of the
  1681. last committed transaction at the start of the snapshot. Thus, the
  1682. snapshot includes a subset of the updates to the data tree that
  1683. occurred while the snapshot was in process. The snapshot, then, may
  1684. not correspond to any data tree that actually existed, and for this
  1685. reason we refer to it as a fuzzy snapshot. Still, ZooKeeper can
  1686. recover using this snapshot because it takes advantage of the
  1687. idempotent nature of its updates. By replaying the transaction log
  1688. against fuzzy snapshots ZooKeeper gets the state of the system at the
  1689. end of the log.</p>
  1690. <a name="The+Log+Directory"></a>
  1691. <h4>The Log Directory</h4>
  1692. <p>The Log Directory contains the ZooKeeper transaction logs.
  1693. Before any update takes place, ZooKeeper ensures that the transaction
  1694. that represents the update is written to non-volatile storage. A new
  1695. log file is started each time a snapshot is begun. The log file's
  1696. suffix is the first zxid written to that log.</p>
  1697. <a name="sc_filemanagement"></a>
  1698. <h4>File Management</h4>
  1699. <p>The format of snapshot and log files does not change between
  1700. standalone ZooKeeper servers and different configurations of
  1701. replicated ZooKeeper servers. Therefore, you can pull these files from
  1702. a running replicated ZooKeeper server to a development machine with a
  1703. stand-alone ZooKeeper server for trouble shooting.</p>
  1704. <p>Using older log and snapshot files, you can look at the previous
  1705. state of ZooKeeper servers and even restore that state. The
  1706. LogFormatter class allows an administrator to look at the transactions
  1707. in a log.</p>
  1708. <p>The ZooKeeper server creates snapshot and log files, but
  1709. never deletes them. The retention policy of the data and log
  1710. files is implemented outside of the ZooKeeper server. The
  1711. server itself only needs the latest complete fuzzy snapshot
  1712. and the log files from the start of that snapshot. See the
  1713. <a href="#sc_maintenance">maintenance</a> section in
  1714. this document for more details on setting a retention policy
  1715. and maintenance of ZooKeeper storage.
  1716. </p>
  1717. <div class="note">
  1718. <div class="label">Note</div>
  1719. <div class="content">
  1720. <p>The data stored in these files is not encrypted. In the case of
  1721. storing sensitive data in ZooKeeper, necessary measures need to be
  1722. taken to prevent unauthorized access. Such measures are external to
  1723. ZooKeeper (e.g., control access to the files) and depend on the
  1724. individual settings in which it is being deployed. </p>
  1725. </div>
  1726. </div>
  1727. <a name="sc_commonProblems"></a>
  1728. <h3 class="h4">Things to Avoid</h3>
  1729. <p>Here are some common problems you can avoid by configuring
  1730. ZooKeeper correctly:</p>
  1731. <dl>
  1732. <dt>
  1733. <term>inconsistent lists of servers</term>
  1734. </dt>
  1735. <dd>
  1736. <p>The list of ZooKeeper servers used by the clients must match
  1737. the list of ZooKeeper servers that each ZooKeeper server has.
  1738. Things work okay if the client list is a subset of the real list,
  1739. but things will really act strange if clients have a list of
  1740. ZooKeeper servers that are in different ZooKeeper clusters. Also,
  1741. the server lists in each Zookeeper server configuration file
  1742. should be consistent with one another.</p>
  1743. </dd>
  1744. <dt>
  1745. <term>incorrect placement of transasction log</term>
  1746. </dt>
  1747. <dd>
  1748. <p>The most performance critical part of ZooKeeper is the
  1749. transaction log. ZooKeeper syncs transactions to media before it
  1750. returns a response. A dedicated transaction log device is key to
  1751. consistent good performance. Putting the log on a busy device will
  1752. adversely effect performance. If you only have one storage device,
  1753. put trace files on NFS and increase the snapshotCount; it doesn't
  1754. eliminate the problem, but it should mitigate it.</p>
  1755. </dd>
  1756. <dt>
  1757. <term>incorrect Java heap size</term>
  1758. </dt>
  1759. <dd>
  1760. <p>You should take special care to set your Java max heap size
  1761. correctly. In particular, you should not create a situation in
  1762. which ZooKeeper swaps to disk. The disk is death to ZooKeeper.
  1763. Everything is ordered, so if processing one request swaps the
  1764. disk, all other queued requests will probably do the same. the
  1765. disk. DON'T SWAP.</p>
  1766. <p>Be conservative in your estimates: if you have 4G of RAM, do
  1767. not set the Java max heap size to 6G or even 4G. For example, it
  1768. is more likely you would use a 3G heap for a 4G machine, as the
  1769. operating system and the cache also need memory. The best and only
  1770. recommend practice for estimating the heap size your system needs
  1771. is to run load tests, and then make sure you are well below the
  1772. usage limit that would cause the system to swap.</p>
  1773. </dd>
  1774. </dl>
  1775. <a name="sc_bestPractices"></a>
  1776. <h3 class="h4">Best Practices</h3>
  1777. <p>For best results, take note of the following list of good
  1778. Zookeeper practices:</p>
  1779. <p>For multi-tennant installations see the <a href="zookeeperProgrammers.html#ch_zkSessions">section</a>
  1780. detailing ZooKeeper "chroot" support, this can be very useful
  1781. when deploying many applications/services interfacing to a
  1782. single ZooKeeper cluster.</p>
  1783. </div>
  1784. <p align="right">
  1785. <font size="-2"></font>
  1786. </p>
  1787. </div>
  1788. <!--+
  1789. |end content
  1790. +-->
  1791. <div class="clearboth">&nbsp;</div>
  1792. </div>
  1793. <div id="footer">
  1794. <!--+
  1795. |start bottomstrip
  1796. +-->
  1797. <div class="lastmodified">
  1798. <script type="text/javascript"><!--
  1799. document.write("Last Published: " + document.lastModified);
  1800. // --></script>
  1801. </div>
  1802. <div class="copyright">
  1803. Copyright &copy;
  1804. 2008-2013 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  1805. </div>
  1806. <!--+
  1807. |end bottomstrip
  1808. +-->
  1809. </div>
  1810. </body>
  1811. </html>