zookeeperAdmin.html 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618
  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.6 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">Encryption, Authentication, 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_db_existence_validation">Enabling db existence validation</a>
  291. </li>
  292. <li>
  293. <a href="#sc_performance_options">Performance Tuning Options</a>
  294. </li>
  295. <li>
  296. <a href="#Communication+using+the+Netty+framework">Communication using the Netty framework</a>
  297. </li>
  298. <li>
  299. <a href="#sc_adminserver_config">AdminServer configuration</a>
  300. </li>
  301. </ul>
  302. </li>
  303. <li>
  304. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  305. <ul class="minitoc">
  306. <li>
  307. <a href="#sc_4lw">The Four Letter Words</a>
  308. </li>
  309. <li>
  310. <a href="#sc_adminserver">The AdminServer</a>
  311. </li>
  312. </ul>
  313. </li>
  314. <li>
  315. <a href="#sc_dataFileManagement">Data File Management</a>
  316. <ul class="minitoc">
  317. <li>
  318. <a href="#The+Data+Directory">The Data Directory</a>
  319. </li>
  320. <li>
  321. <a href="#The+Log+Directory">The Log Directory</a>
  322. </li>
  323. <li>
  324. <a href="#sc_filemanagement">File Management</a>
  325. </li>
  326. </ul>
  327. </li>
  328. <li>
  329. <a href="#sc_commonProblems">Things to Avoid</a>
  330. </li>
  331. <li>
  332. <a href="#sc_bestPractices">Best Practices</a>
  333. </li>
  334. </ul>
  335. </li>
  336. </ul>
  337. </div>
  338. </div>
  339. <a name="ch_deployment"></a>
  340. <h2 class="h3">Deployment</h2>
  341. <div class="section">
  342. <p>This section contains information about deploying Zookeeper and
  343. covers these topics:</p>
  344. <ul>
  345. <li>
  346. <p>
  347. <a href="#sc_systemReq">System Requirements</a>
  348. </p>
  349. </li>
  350. <li>
  351. <p>
  352. <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
  353. </p>
  354. </li>
  355. <li>
  356. <p>
  357. <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
  358. </p>
  359. </li>
  360. </ul>
  361. <p>The first two sections assume you are interested in installing
  362. ZooKeeper in a production environment such as a datacenter. The final
  363. section covers situations in which you are setting up ZooKeeper on a
  364. limited basis - for evaluation, testing, or development - but not in a
  365. production environment.</p>
  366. <a name="sc_systemReq"></a>
  367. <h3 class="h4">System Requirements</h3>
  368. <a name="sc_supportedPlatforms"></a>
  369. <h4>Supported Platforms</h4>
  370. <p>ZooKeeper consists of multiple components. Some components are
  371. supported broadly, and other components are supported only on a smaller
  372. set of platforms.</p>
  373. <ul>
  374. <li>
  375. <p>
  376. <strong>Client</strong> is the Java client
  377. library, used by applications to connect to a ZooKeeper ensemble.
  378. </p>
  379. </li>
  380. <li>
  381. <p>
  382. <strong>Server</strong> is the Java server
  383. that runs on the ZooKeeper ensemble nodes.</p>
  384. </li>
  385. <li>
  386. <p>
  387. <strong>Native Client</strong> is a client
  388. implemented in C, similar to the Java client, used by applications
  389. to connect to a ZooKeeper ensemble.</p>
  390. </li>
  391. <li>
  392. <p>
  393. <strong>Contrib</strong> refers to multiple
  394. optional add-on components.</p>
  395. </li>
  396. </ul>
  397. <p>The following matrix describes the level of support committed for
  398. running each component on different operating system platforms.</p>
  399. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  400. <caption>Support Matrix</caption>
  401. <title>Support Matrix</title>
  402. <tr>
  403. <th>Operating System</th>
  404. <th>Client</th>
  405. <th>Server</th>
  406. <th>Native Client</th>
  407. <th>Contrib</th>
  408. </tr>
  409. <tr>
  410. <td>GNU/Linux</td>
  411. <td>Development and Production</td>
  412. <td>Development and Production</td>
  413. <td>Development and Production</td>
  414. <td>Development and Production</td>
  415. </tr>
  416. <tr>
  417. <td>Solaris</td>
  418. <td>Development and Production</td>
  419. <td>Development and Production</td>
  420. <td>Not Supported</td>
  421. <td>Not Supported</td>
  422. </tr>
  423. <tr>
  424. <td>FreeBSD</td>
  425. <td>Development and Production</td>
  426. <td>Development and Production</td>
  427. <td>Not Supported</td>
  428. <td>Not Supported</td>
  429. </tr>
  430. <tr>
  431. <td>Windows</td>
  432. <td>Development and Production</td>
  433. <td>Development and Production</td>
  434. <td>Not Supported</td>
  435. <td>Not Supported</td>
  436. </tr>
  437. <tr>
  438. <td>Mac OS X</td>
  439. <td>Development Only</td>
  440. <td>Development Only</td>
  441. <td>Not Supported</td>
  442. <td>Not Supported</td>
  443. </tr>
  444. </table>
  445. <p>For any operating system not explicitly mentioned as supported in
  446. the matrix, components may or may not work. The ZooKeeper community
  447. will fix obvious bugs that are reported for other platforms, but there
  448. is no full support.</p>
  449. <a name="sc_requiredSoftware"></a>
  450. <h4>Required Software </h4>
  451. <p>ZooKeeper runs in Java, release 1.7 or greater (JDK 7 or
  452. greater, FreeBSD support requires openjdk7). It runs as an
  453. <em>ensemble</em> of ZooKeeper servers. Three
  454. ZooKeeper servers is the minimum recommended size for an
  455. ensemble, and we also recommend that they run on separate
  456. machines. At Yahoo!, ZooKeeper is usually deployed on
  457. dedicated RHEL boxes, with dual-core processors, 2GB of RAM,
  458. and 80GB IDE hard drives.</p>
  459. <a name="sc_zkMulitServerSetup"></a>
  460. <h3 class="h4">Clustered (Multi-Server) Setup</h3>
  461. <p>For reliable ZooKeeper service, you should deploy ZooKeeper in a
  462. cluster known as an <em>ensemble</em>. As long as a majority
  463. of the ensemble are up, the service will be available. Because Zookeeper
  464. requires a majority, it is best to use an
  465. odd number of machines. For example, with four machines ZooKeeper can
  466. only handle the failure of a single machine; if two machines fail, the
  467. remaining two machines do not constitute a majority. However, with five
  468. machines ZooKeeper can handle the failure of two machines. </p>
  469. <div class="note">
  470. <div class="label">Note</div>
  471. <div class="content">
  472. <p>
  473. As mentioned in the
  474. <a href="zookeeperStarted.html">ZooKeeper Getting Started Guide</a>
  475. , a minimum of three servers are required for a fault tolerant
  476. clustered setup, and it is strongly recommended that you have an
  477. odd number of servers.
  478. </p>
  479. <p>Usually three servers is more than enough for a production
  480. install, but for maximum reliability during maintenance, you may
  481. wish to install five servers. With three servers, if you perform
  482. maintenance on one of them, you are vulnerable to a failure on one
  483. of the other two servers during that maintenance. If you have five
  484. of them running, you can take one down for maintenance, and know
  485. that you're still OK if one of the other four suddenly fails.
  486. </p>
  487. <p>Your redundancy considerations should include all aspects of
  488. your environment. If you have three ZooKeeper servers, but their
  489. network cables are all plugged into the same network switch, then
  490. the failure of that switch will take down your entire ensemble.
  491. </p>
  492. </div>
  493. </div>
  494. <p>Here are the steps to setting a server that will be part of an
  495. ensemble. These steps should be performed on every host in the
  496. ensemble:</p>
  497. <ol>
  498. <li>
  499. <p>Install the Java JDK. You can use the native packaging system
  500. for your system, or download the JDK from:</p>
  501. <p>
  502. <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a>
  503. </p>
  504. </li>
  505. <li>
  506. <p>Set the Java heap size. This is very important to avoid
  507. swapping, which will seriously degrade ZooKeeper performance. To
  508. determine the correct value, use load tests, and make sure you are
  509. well below the usage limit that would cause you to swap. Be
  510. conservative - use a maximum heap size of 3GB for a 4GB
  511. machine.</p>
  512. </li>
  513. <li>
  514. <p>Install the ZooKeeper Server Package. It can be downloaded
  515. from:
  516. </p>
  517. <p>
  518. <a href="http://zookeeper.apache.org/releases.html">
  519. http://zookeeper.apache.org/releases.html
  520. </a>
  521. </p>
  522. </li>
  523. <li>
  524. <p>Create a configuration file. This file can be called anything.
  525. Use the following settings as a starting point:</p>
  526. <pre class="code">
  527. tickTime=2000
  528. dataDir=/var/lib/zookeeper/
  529. clientPort=2181
  530. initLimit=5
  531. syncLimit=2
  532. server.1=zoo1:2888:3888
  533. server.2=zoo2:2888:3888
  534. server.3=zoo3:2888:3888</pre>
  535. <p>You can find the meanings of these and other configuration
  536. settings in the section <a href="#sc_configuration">Configuration Parameters</a>. A word
  537. though about a few here:</p>
  538. <p>Every machine that is part of the ZooKeeper ensemble should know
  539. about every other machine in the ensemble. You accomplish this with
  540. 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
  541. server id to each machine by creating a file named
  542. <span class="codefrag filename">myid</span>, one for each server, which resides in
  543. that server's data directory, as specified by the configuration file
  544. parameter <strong>dataDir</strong>.</p>
  545. </li>
  546. <li>
  547. <p>The myid file
  548. consists of a single line containing only the text of that machine's
  549. id. So <span class="codefrag filename">myid</span> of server 1 would contain the text
  550. "1" and nothing else. The id must be unique within the
  551. ensemble and should have a value between 1 and 255.</p>
  552. </li>
  553. <li>
  554. <p>Create an initialization marker file <span class="codefrag filename">initialize</span>
  555. in the same directory as <span class="codefrag filename">myid</span>. This file indicates
  556. that an empty data directory is expected. When present, an empty data base
  557. is created and the marker file deleted. When not present, an empty data
  558. directory will mean this peer will not have voting rights and it will not
  559. populate the data directory until it communicates with an active leader.
  560. Intended use is to only create this file when bringing up a new
  561. ensemble. </p>
  562. </li>
  563. <li>
  564. <p>If your configuration file is set up, you can start a
  565. ZooKeeper server:</p>
  566. <p>
  567. <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.17.jar:conf \
  568. org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg
  569. </span>
  570. </p>
  571. <p>QuorumPeerMain starts a ZooKeeper server,
  572. <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a>
  573. management beans are also registered which allows
  574. management through a JMX management console.
  575. The <a href="zookeeperJMX.html">ZooKeeper JMX
  576. document</a> contains details on managing ZooKeeper with JMX.
  577. </p>
  578. <p>See the script <em>bin/zkServer.sh</em>,
  579. which is included in the release, for an example
  580. of starting server instances.</p>
  581. </li>
  582. <li>
  583. <p>Test your deployment by connecting to the hosts:</p>
  584. <p>In Java, you can run the following command to execute
  585. simple operations:</p>
  586. <p>
  587. <span class="codefrag computeroutput">$ bin/zkCli.sh -server 127.0.0.1:2181</span>
  588. </p>
  589. </li>
  590. </ol>
  591. <a name="sc_singleAndDevSetup"></a>
  592. <h3 class="h4">Single Server and Developer Setup</h3>
  593. <p>If you want to setup ZooKeeper for development purposes, you will
  594. probably want to setup a single server instance of ZooKeeper, and then
  595. install either the Java or C client-side libraries and bindings on your
  596. development machine.</p>
  597. <p>The steps to setting up a single server instance are the similar
  598. to the above, except the configuration file is simpler. You can find the
  599. complete instructions in the <a href="zookeeperStarted.html#sc_InstallingSingleMode">Installing and
  600. Running ZooKeeper in Single Server Mode</a> section of the <a href="zookeeperStarted.html">ZooKeeper Getting Started
  601. Guide</a>.</p>
  602. <p>For information on installing the client side libraries, refer to
  603. the <a href="zookeeperProgrammers.html#Bindings">Bindings</a>
  604. section of the <a href="zookeeperProgrammers.html">ZooKeeper
  605. Programmer's Guide</a>.</p>
  606. </div>
  607. <a name="ch_administration"></a>
  608. <h2 class="h3">Administration</h2>
  609. <div class="section">
  610. <p>This section contains information about running and maintaining
  611. ZooKeeper and covers these topics: </p>
  612. <ul>
  613. <li>
  614. <p>
  615. <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
  616. </p>
  617. </li>
  618. <li>
  619. <p>
  620. <a href="#sc_provisioning">Provisioning</a>
  621. </p>
  622. </li>
  623. <li>
  624. <p>
  625. <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
  626. </p>
  627. </li>
  628. <li>
  629. <p>
  630. <a href="#sc_administering">Administering</a>
  631. </p>
  632. </li>
  633. <li>
  634. <p>
  635. <a href="#sc_maintenance">Maintenance</a>
  636. </p>
  637. </li>
  638. <li>
  639. <p>
  640. <a href="#sc_supervision">Supervision</a>
  641. </p>
  642. </li>
  643. <li>
  644. <p>
  645. <a href="#sc_monitoring">Monitoring</a>
  646. </p>
  647. </li>
  648. <li>
  649. <p>
  650. <a href="#sc_logging">Logging</a>
  651. </p>
  652. </li>
  653. <li>
  654. <p>
  655. <a href="#sc_troubleshooting">Troubleshooting</a>
  656. </p>
  657. </li>
  658. <li>
  659. <p>
  660. <a href="#sc_configuration">Configuration Parameters</a>
  661. </p>
  662. </li>
  663. <li>
  664. <p>
  665. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  666. </p>
  667. </li>
  668. <li>
  669. <p>
  670. <a href="#sc_dataFileManagement">Data File Management</a>
  671. </p>
  672. </li>
  673. <li>
  674. <p>
  675. <a href="#sc_commonProblems">Things to Avoid</a>
  676. </p>
  677. </li>
  678. <li>
  679. <p>
  680. <a href="#sc_bestPractices">Best Practices</a>
  681. </p>
  682. </li>
  683. </ul>
  684. <a name="sc_designing"></a>
  685. <h3 class="h4">Designing a ZooKeeper Deployment</h3>
  686. <p>The reliability of ZooKeeper rests on two basic assumptions.</p>
  687. <ol>
  688. <li>
  689. <p> Only a minority of servers in a deployment
  690. will fail. <em>Failure</em> in this context
  691. means a machine crash, or some error in the network that
  692. partitions a server off from the majority.</p>
  693. </li>
  694. <li>
  695. <p> Deployed machines operate correctly. To
  696. operate correctly means to execute code correctly, to have
  697. clocks that work properly, and to have storage and network
  698. components that perform consistently.</p>
  699. </li>
  700. </ol>
  701. <p>The sections below contain considerations for ZooKeeper
  702. administrators to maximize the probability for these assumptions
  703. to hold true. Some of these are cross-machines considerations,
  704. and others are things you should consider for each and every
  705. machine in your deployment.</p>
  706. <a name="sc_CrossMachineRequirements"></a>
  707. <h4>Cross Machine Requirements</h4>
  708. <p>For the ZooKeeper service to be active, there must be a
  709. majority of non-failing machines that can communicate with
  710. each other. To create a deployment that can tolerate the
  711. failure of F machines, you should count on deploying 2xF+1
  712. machines. Thus, a deployment that consists of three machines
  713. can handle one failure, and a deployment of five machines can
  714. handle two failures. Note that a deployment of six machines
  715. can only handle two failures since three machines is not a
  716. majority. For this reason, ZooKeeper deployments are usually
  717. made up of an odd number of machines.</p>
  718. <p>To achieve the highest probability of tolerating a failure
  719. you should try to make machine failures independent. For
  720. example, if most of the machines share the same switch,
  721. failure of that switch could cause a correlated failure and
  722. bring down the service. The same holds true of shared power
  723. circuits, cooling systems, etc.</p>
  724. <a name="Single+Machine+Requirements"></a>
  725. <h4>Single Machine Requirements</h4>
  726. <p>If ZooKeeper has to contend with other applications for
  727. access to resources like storage media, CPU, network, or
  728. memory, its performance will suffer markedly. ZooKeeper has
  729. strong durability guarantees, which means it uses storage
  730. media to log changes before the operation responsible for the
  731. change is allowed to complete. You should be aware of this
  732. dependency then, and take great care if you want to ensure
  733. that ZooKeeper operations aren&rsquo;t held up by your media. Here
  734. are some things you can do to minimize that sort of
  735. degradation:
  736. </p>
  737. <ul>
  738. <li>
  739. <p>ZooKeeper's transaction log must be on a dedicated
  740. device. (A dedicated partition is not enough.) ZooKeeper
  741. writes the log sequentially, without seeking Sharing your
  742. log device with other processes can cause seeks and
  743. contention, which in turn can cause multi-second
  744. delays.</p>
  745. </li>
  746. <li>
  747. <p>Do not put ZooKeeper in a situation that can cause a
  748. swap. In order for ZooKeeper to function with any sort of
  749. timeliness, it simply cannot be allowed to swap.
  750. Therefore, make certain that the maximum heap size given
  751. to ZooKeeper is not bigger than the amount of real memory
  752. available to ZooKeeper. For more on this, see
  753. <a href="#sc_commonProblems">Things to Avoid</a>
  754. below. </p>
  755. </li>
  756. </ul>
  757. <a name="sc_provisioning"></a>
  758. <h3 class="h4">Provisioning</h3>
  759. <p></p>
  760. <a name="sc_strengthsAndLimitations"></a>
  761. <h3 class="h4">Things to Consider: ZooKeeper Strengths and Limitations</h3>
  762. <p></p>
  763. <a name="sc_administering"></a>
  764. <h3 class="h4">Administering</h3>
  765. <p></p>
  766. <a name="sc_maintenance"></a>
  767. <h3 class="h4">Maintenance</h3>
  768. <p>Little long term maintenance is required for a ZooKeeper
  769. cluster however you must be aware of the following:</p>
  770. <a name="Ongoing+Data+Directory+Cleanup"></a>
  771. <h4>Ongoing Data Directory Cleanup</h4>
  772. <p>The ZooKeeper <a href="#var_datadir">Data
  773. Directory</a> contains files which are a persistent copy
  774. of the znodes stored by a particular serving ensemble. These
  775. are the snapshot and transactional log files. As changes are
  776. made to the znodes these changes are appended to a
  777. transaction log. Occasionally, when a log grows large, a
  778. snapshot of the current state of all znodes will be written
  779. to the filesystem and a new transaction log file is created
  780. for future transactions. During snapshotting, ZooKeeper may
  781. continue appending incoming transactions to the old log file.
  782. Therefore, some transactions which are newer than a snapshot
  783. may be found in the last transaction log preceding the
  784. snapshot.
  785. </p>
  786. <p>A ZooKeeper server <strong>will not remove
  787. old snapshots and log files</strong> when using the default
  788. configuration (see autopurge below), this is the
  789. responsibility of the operator. Every serving environment is
  790. different and therefore the requirements of managing these
  791. files may differ from install to install (backup for example).
  792. </p>
  793. <p>The PurgeTxnLog utility implements a simple retention
  794. policy that administrators can use. The <a href="api/index.html">API docs</a> contains details on
  795. calling conventions (arguments, etc...).
  796. </p>
  797. <p>In the following example the last count snapshots and
  798. their corresponding logs are retained and the others are
  799. deleted. The value of &lt;count&gt; should typically be
  800. greater than 3 (although not required, this provides 3 backups
  801. in the unlikely event a recent log has become corrupted). This
  802. can be run as a cron job on the ZooKeeper server machines to
  803. clean up the logs daily.</p>
  804. <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.17.jar:conf org.apache.zookeeper.server.PurgeTxnLog &lt;dataDir&gt; &lt;snapDir&gt; -n &lt;count&gt;</pre>
  805. <p>Automatic purging of the snapshots and corresponding
  806. transaction logs was introduced in version 3.4.0 and can be
  807. enabled via the following configuration parameters <strong>autopurge.snapRetainCount</strong> and <strong>autopurge.purgeInterval</strong>. For more on
  808. this, see <a href="#sc_advancedConfiguration">Advanced Configuration</a>
  809. below.</p>
  810. <a name="Debug+Log+Cleanup+%28log4j%29"></a>
  811. <h4>Debug Log Cleanup (log4j)</h4>
  812. <p>See the section on <a href="#sc_logging">logging</a> in this document. It is
  813. expected that you will setup a rolling file appender using the
  814. in-built log4j feature. The sample configuration file in the
  815. release tar's conf/log4j.properties provides an example of
  816. this.
  817. </p>
  818. <a name="sc_supervision"></a>
  819. <h3 class="h4">Supervision</h3>
  820. <p>You will want to have a supervisory process that manages
  821. each of your ZooKeeper server processes (JVM). The ZK server is
  822. designed to be "fail fast" meaning that it will shutdown
  823. (process exit) if an error occurs that it cannot recover
  824. from. As a ZooKeeper serving cluster is highly reliable, this
  825. means that while the server may go down the cluster as a whole
  826. is still active and serving requests. Additionally, as the
  827. cluster is "self healing" the failed server once restarted will
  828. automatically rejoin the ensemble w/o any manual
  829. interaction.</p>
  830. <p>Having a supervisory process such as <a href="http://cr.yp.to/daemontools.html">daemontools</a> or
  831. <a href="http://en.wikipedia.org/wiki/Service_Management_Facility">SMF</a>
  832. (other options for supervisory process are also available, it's
  833. up to you which one you would like to use, these are just two
  834. examples) managing your ZooKeeper server ensures that if the
  835. process does exit abnormally it will automatically be restarted
  836. and will quickly rejoin the cluster.</p>
  837. <p>It is also recommended to configure the ZooKeeper server process to
  838. terminate and dump its heap if an
  839. <span class="codefrag computeroutput">OutOfMemoryError</span> occurs. This is achieved
  840. by launching the JVM with the following arguments on Linux and Windows
  841. respectively. The <span class="codefrag filename">zkServer.sh</span> and
  842. <span class="codefrag filename">zkServer.cmd</span> scripts that ship with ZooKeeper set
  843. these options.
  844. </p>
  845. <pre class="code">-XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError='kill -9 %p'</pre>
  846. <pre class="code">"-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f"</pre>
  847. <a name="sc_monitoring"></a>
  848. <h3 class="h4">Monitoring</h3>
  849. <p>The ZooKeeper service can be monitored in one of two
  850. 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
  851. your environment/requirements.</p>
  852. <a name="sc_logging"></a>
  853. <h3 class="h4">Logging</h3>
  854. <p>
  855. ZooKeeper uses <strong><a href="http://www.slf4j.org">SLF4J</a></strong>
  856. version 1.7.5 as its logging infrastructure. For backward compatibility it is bound to
  857. <strong>LOG4J</strong> but you can use
  858. <strong><a href="http://logback.qos.ch/">LOGBack</a></strong>
  859. or any other supported logging framework of your choice.
  860. </p>
  861. <p>
  862. The ZooKeeper default <span class="codefrag filename">log4j.properties</span>
  863. file resides in the <span class="codefrag filename">conf</span> directory. Log4j requires that
  864. <span class="codefrag filename">log4j.properties</span> either be in the working directory
  865. (the directory from which ZooKeeper is run) or be accessible from the classpath.
  866. </p>
  867. <p>For more information about SLF4J, see
  868. <a href="http://www.slf4j.org/manual.html">its manual</a>.</p>
  869. <p>For more information about LOG4J, see
  870. <a href="http://logging.apache.org/log4j/1.2/manual.html#defaultInit">Log4j Default Initialization Procedure</a>
  871. of the log4j manual.</p>
  872. <a name="sc_troubleshooting"></a>
  873. <h3 class="h4">Troubleshooting</h3>
  874. <dl>
  875. <dt>
  876. <term> Server not coming up because of file corruption</term>
  877. </dt>
  878. <dd>
  879. <p>A server might not be able to read its database and fail to come up because of
  880. some file corruption in the transaction logs of the ZooKeeper server. You will
  881. see some IOException on loading ZooKeeper database. In such a case,
  882. make sure all the other servers in your ensemble are up and working. Use "stat"
  883. command on the command port to see if they are in good health. After you have verified that
  884. all the other servers of the ensemble are up, you can go ahead and clean the database
  885. of the corrupt server. Delete all the files in datadir/version-2 and datalogdir/version-2/.
  886. Restart the server.
  887. </p>
  888. </dd>
  889. </dl>
  890. <a name="sc_configuration"></a>
  891. <h3 class="h4">Configuration Parameters</h3>
  892. <p>ZooKeeper's behavior is governed by the ZooKeeper configuration
  893. file. This file is designed so that the exact same file can be used by
  894. all the servers that make up a ZooKeeper server assuming the disk
  895. layouts are the same. If servers use different configuration files, care
  896. must be taken to ensure that the list of servers in all of the different
  897. configuration files match.</p>
  898. <div class="note">
  899. <div class="label">Note</div>
  900. <div class="content">
  901. <p>In 3.5.0 and later, some of these parameters should be placed in
  902. a dynamic configuration file. If they are placed in the static
  903. configuration file, ZooKeeper will automatically move them over to the
  904. dynamic configuration file. See <a href="zookeeperReconfig.html">
  905. Dynamic Reconfiguration</a> for more information.</p>
  906. </div>
  907. </div>
  908. <a name="sc_minimumConfiguration"></a>
  909. <h4>Minimum Configuration</h4>
  910. <p>Here are the minimum configuration keywords that must be defined
  911. in the configuration file:</p>
  912. <dl>
  913. <dt>
  914. <term>clientPort</term>
  915. </dt>
  916. <dd>
  917. <p>the port to listen for client connections; that is, the
  918. port that clients attempt to connect to.</p>
  919. </dd>
  920. <dt>
  921. <term>secureClientPort</term>
  922. </dt>
  923. <dd>
  924. <p>the port to listen on for secure client connections using SSL.
  925. <strong>clientPort</strong> specifies
  926. the port for plaintext connections while <strong>
  927. secureClientPort</strong> specifies the port for SSL
  928. connections. Specifying both enables mixed-mode while omitting
  929. either will disable that mode.</p>
  930. <p>Note that SSL feature will be enabled when user plugs-in
  931. zookeeper.serverCnxnFactory, zookeeper.clientCnxnSocket as Netty.</p>
  932. </dd>
  933. <dt>
  934. <term>dataDir</term>
  935. </dt>
  936. <dd>
  937. <p>the location where ZooKeeper will store the in-memory
  938. database snapshots and, unless specified otherwise, the
  939. transaction log of updates to the database.</p>
  940. <div class="note">
  941. <div class="label">Note</div>
  942. <div class="content">
  943. <p>Be careful where you put the transaction log. A
  944. dedicated transaction log device is key to consistent good
  945. performance. Putting the log on a busy device will adversely
  946. effect performance.</p>
  947. </div>
  948. </div>
  949. </dd>
  950. <dt>
  951. <term>tickTime</term>
  952. </dt>
  953. <dd>
  954. <p>the length of a single tick, which is the basic time unit
  955. used by ZooKeeper, as measured in milliseconds. It is used to
  956. regulate heartbeats, and timeouts. For example, the minimum
  957. session timeout will be two ticks.</p>
  958. </dd>
  959. </dl>
  960. <a name="sc_advancedConfiguration"></a>
  961. <h4>Advanced Configuration</h4>
  962. <p>The configuration settings in the section are optional. You can
  963. use them to further fine tune the behaviour of your ZooKeeper servers.
  964. Some can also be set using Java system properties, generally of the
  965. form <em>zookeeper.keyword</em>. The exact system
  966. property, when available, is noted below.</p>
  967. <dl>
  968. <dt>
  969. <term>dataLogDir</term>
  970. </dt>
  971. <dd>
  972. <p>(No Java system property)</p>
  973. <p>This option will direct the machine to write the
  974. transaction log to the <strong>dataLogDir</strong> rather than the <strong>dataDir</strong>. This allows a dedicated log
  975. device to be used, and helps avoid competition between logging
  976. and snapshots.</p>
  977. <div class="note">
  978. <div class="label">Note</div>
  979. <div class="content">
  980. <p>Having a dedicated log device has a large impact on
  981. throughput and stable latencies. It is highly recommended to
  982. dedicate a log device and set <strong>dataLogDir</strong> to point to a directory on
  983. that device, and then make sure to point <strong>dataDir</strong> to a directory
  984. <em>not</em> residing on that device.</p>
  985. </div>
  986. </div>
  987. </dd>
  988. <dt>
  989. <term>globalOutstandingLimit</term>
  990. </dt>
  991. <dd>
  992. <p>(Java system property: <strong>zookeeper.globalOutstandingLimit.</strong>)</p>
  993. <p>Clients can submit requests faster than ZooKeeper can
  994. process them, especially if there are a lot of clients. To
  995. prevent ZooKeeper from running out of memory due to queued
  996. requests, ZooKeeper will throttle clients so that there is no
  997. more than globalOutstandingLimit outstanding requests in the
  998. system. The default limit is 1,000.</p>
  999. </dd>
  1000. <dt>
  1001. <term>preAllocSize</term>
  1002. </dt>
  1003. <dd>
  1004. <p>(Java system property: <strong>zookeeper.preAllocSize</strong>)</p>
  1005. <p>To avoid seeks ZooKeeper allocates space in the
  1006. transaction log file in blocks of preAllocSize kilobytes. The
  1007. default block size is 64M. One reason for changing the size of
  1008. the blocks is to reduce the block size if snapshots are taken
  1009. more often. (Also, see <strong>snapCount</strong>).</p>
  1010. </dd>
  1011. <dt>
  1012. <term>snapCount</term>
  1013. </dt>
  1014. <dd>
  1015. <p>(Java system property: <strong>zookeeper.snapCount</strong>)</p>
  1016. <p>ZooKeeper records its transactions using snapshots and
  1017. a transaction log (think write-ahead log).The number of
  1018. transactions recorded in the transaction log before a snapshot
  1019. can be taken (and the transaction log rolled) is determined
  1020. by snapCount. In order to prevent all of the machines in the quorum
  1021. from taking a snapshot at the same time, each ZooKeeper server
  1022. will take a snapshot when the number of transactions in the transaction log
  1023. reaches a runtime generated random value in the [snapCount/2+1, snapCount]
  1024. range.The default snapCount is 100,000.</p>
  1025. </dd>
  1026. <dt>
  1027. <term>maxClientCnxns</term>
  1028. </dt>
  1029. <dd>
  1030. <p>(No Java system property)</p>
  1031. <p>Limits the number of concurrent connections (at the socket
  1032. level) that a single client, identified by IP address, may make
  1033. to a single member of the ZooKeeper ensemble. This is used to
  1034. prevent certain classes of DoS attacks, including file
  1035. descriptor exhaustion. The default is 60. Setting this to 0
  1036. entirely removes the limit on concurrent connections.</p>
  1037. </dd>
  1038. <dt>
  1039. <term>clientPortAddress</term>
  1040. </dt>
  1041. <dd>
  1042. <p>
  1043. <strong>New in 3.3.0:</strong> the
  1044. address (ipv4, ipv6 or hostname) to listen for client
  1045. connections; that is, the address that clients attempt
  1046. to connect to. This is optional, by default we bind in
  1047. such a way that any connection to the <strong>clientPort</strong> for any
  1048. address/interface/nic on the server will be
  1049. accepted.</p>
  1050. </dd>
  1051. <dt>
  1052. <term>minSessionTimeout</term>
  1053. </dt>
  1054. <dd>
  1055. <p>(No Java system property)</p>
  1056. <p>
  1057. <strong>New in 3.3.0:</strong> the
  1058. minimum session timeout in milliseconds that the server
  1059. will allow the client to negotiate. Defaults to 2 times
  1060. the <strong>tickTime</strong>.</p>
  1061. </dd>
  1062. <dt>
  1063. <term>maxSessionTimeout</term>
  1064. </dt>
  1065. <dd>
  1066. <p>(No Java system property)</p>
  1067. <p>
  1068. <strong>New in 3.3.0:</strong> the
  1069. maximum session timeout in milliseconds that the server
  1070. will allow the client to negotiate. Defaults to 20 times
  1071. the <strong>tickTime</strong>.</p>
  1072. </dd>
  1073. <dt>
  1074. <term>fsync.warningthresholdms</term>
  1075. </dt>
  1076. <dd>
  1077. <p>(Java system property: <strong>zookeeper.fsync.warningthresholdms</strong>)</p>
  1078. <p>
  1079. <strong>New in 3.3.4:</strong> A
  1080. warning message will be output to the log whenever an
  1081. fsync in the Transactional Log (WAL) takes longer than
  1082. this value. The values is specified in milliseconds and
  1083. defaults to 1000. This value can only be set as a
  1084. system property.</p>
  1085. </dd>
  1086. <dt>
  1087. <term>autopurge.snapRetainCount</term>
  1088. </dt>
  1089. <dd>
  1090. <p>(No Java system property)</p>
  1091. <p>
  1092. <strong>New in 3.4.0:</strong>
  1093. When enabled, ZooKeeper auto purge feature retains
  1094. the <strong>autopurge.snapRetainCount</strong> most
  1095. recent snapshots and the corresponding transaction logs in the
  1096. <strong>dataDir</strong> and <strong>dataLogDir</strong> respectively and deletes the rest.
  1097. Defaults to 3. Minimum value is 3.</p>
  1098. </dd>
  1099. <dt>
  1100. <term>autopurge.purgeInterval</term>
  1101. </dt>
  1102. <dd>
  1103. <p>(No Java system property)</p>
  1104. <p>
  1105. <strong>New in 3.4.0:</strong> The
  1106. time interval in hours for which the purge task has to
  1107. be triggered. Set to a positive integer (1 and above)
  1108. to enable the auto purging. Defaults to 0.</p>
  1109. </dd>
  1110. <dt>
  1111. <term>syncEnabled</term>
  1112. </dt>
  1113. <dd>
  1114. <p>(Java system property: <strong>zookeeper.observer.syncEnabled</strong>)</p>
  1115. <p>
  1116. <strong>New in 3.4.6, 3.5.0:</strong>
  1117. The observers now log transaction and write snapshot to disk
  1118. by default like the participants. This reduces the recovery time
  1119. of the observers on restart. Set to "false" to disable this
  1120. feature. Default is "true"</p>
  1121. </dd>
  1122. </dl>
  1123. <a name="sc_clusterOptions"></a>
  1124. <h4>Cluster Options</h4>
  1125. <p>The options in this section are designed for use with an ensemble
  1126. of servers -- that is, when deploying clusters of servers.</p>
  1127. <dl>
  1128. <dt>
  1129. <term>electionAlg</term>
  1130. </dt>
  1131. <dd>
  1132. <p>(No Java system property)</p>
  1133. <p>Election implementation to use. A value of "1" corresponds to the
  1134. non-authenticated UDP-based version of fast leader election, "2"
  1135. corresponds to the authenticated UDP-based version of fast
  1136. leader election, and "3" corresponds to TCP-based version of
  1137. fast leader election. Currently, algorithm 3 is the default.</p>
  1138. <div class="note">
  1139. <div class="label">Note</div>
  1140. <div class="content">
  1141. <p> The implementations of leader election 1, and 2 are now
  1142. <strong> deprecated </strong>. We have the intention
  1143. of removing them in the next release, at which point only the
  1144. FastLeaderElection will be available.
  1145. </p>
  1146. </div>
  1147. </div>
  1148. </dd>
  1149. <dt>
  1150. <term>initLimit</term>
  1151. </dt>
  1152. <dd>
  1153. <p>(No Java system property)</p>
  1154. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to
  1155. connect and sync to a leader. Increased this value as needed, if
  1156. the amount of data managed by ZooKeeper is large.</p>
  1157. </dd>
  1158. <dt>
  1159. <term>leaderServes</term>
  1160. </dt>
  1161. <dd>
  1162. <p>(Java system property: zookeeper.<strong>leaderServes</strong>)</p>
  1163. <p>Leader accepts client connections. Default value is "yes".
  1164. The leader machine coordinates updates. For higher update
  1165. throughput at the slight expense of read throughput the leader
  1166. can be configured to not accept clients and focus on
  1167. coordination. The default to this option is yes, which means
  1168. that a leader will accept client connections.</p>
  1169. <div class="note">
  1170. <div class="label">Note</div>
  1171. <div class="content">
  1172. <p>Turning on leader selection is highly recommended when
  1173. you have more than three ZooKeeper servers in an ensemble.</p>
  1174. </div>
  1175. </div>
  1176. </dd>
  1177. <dt>
  1178. <term>server.x=[hostname]:nnnnn[:nnnnn], etc</term>
  1179. </dt>
  1180. <dd>
  1181. <p>(No Java system property)</p>
  1182. <p>servers making up the ZooKeeper ensemble. When the server
  1183. starts up, it determines which server it is by looking for the
  1184. file <span class="codefrag filename">myid</span> in the data directory. That file
  1185. contains the server number, in ASCII, and it should match
  1186. <strong>x</strong> in <strong>server.x</strong> in the left hand side of this
  1187. setting.</p>
  1188. <p>The list of servers that make up ZooKeeper servers that is
  1189. used by the clients must match the list of ZooKeeper servers
  1190. that each ZooKeeper server has.</p>
  1191. <p>There are two port numbers <strong>nnnnn</strong>.
  1192. The first followers use to connect to the leader, and the second is for
  1193. leader election. If you want to test multiple servers on a single machine, then
  1194. different ports can be used for each server.</p>
  1195. </dd>
  1196. <dt>
  1197. <term>syncLimit</term>
  1198. </dt>
  1199. <dd>
  1200. <p>(No Java system property)</p>
  1201. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to sync
  1202. with ZooKeeper. If followers fall too far behind a leader, they
  1203. will be dropped.</p>
  1204. </dd>
  1205. <dt>
  1206. <term>group.x=nnnnn[:nnnnn]</term>
  1207. </dt>
  1208. <dd>
  1209. <p>(No Java system property)</p>
  1210. <p>Enables a hierarchical quorum construction."x" is a group identifier
  1211. and the numbers following the "=" sign correspond to server identifiers.
  1212. The left-hand side of the assignment is a colon-separated list of server
  1213. identifiers. Note that groups must be disjoint and the union of all groups
  1214. must be the ZooKeeper ensemble. </p>
  1215. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1216. </p>
  1217. </dd>
  1218. <dt>
  1219. <term>weight.x=nnnnn</term>
  1220. </dt>
  1221. <dd>
  1222. <p>(No Java system property)</p>
  1223. <p>Used along with "group", it assigns a weight to a server when
  1224. forming quorums. Such a value corresponds to the weight of a server
  1225. when voting. There are a few parts of ZooKeeper that require voting
  1226. such as leader election and the atomic broadcast protocol. By default
  1227. the weight of server is 1. If the configuration defines groups, but not
  1228. weights, then a value of 1 will be assigned to all servers.
  1229. </p>
  1230. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1231. </p>
  1232. </dd>
  1233. <dt>
  1234. <term>cnxTimeout</term>
  1235. </dt>
  1236. <dd>
  1237. <p>(Java system property: zookeeper.<strong>cnxTimeout</strong>)</p>
  1238. <p>Sets the timeout value for opening connections for leader election notifications.
  1239. Only applicable if you are using electionAlg 3.
  1240. </p>
  1241. <div class="note">
  1242. <div class="label">Note</div>
  1243. <div class="content">
  1244. <p>Default value is 5 seconds.</p>
  1245. </div>
  1246. </div>
  1247. </dd>
  1248. <dt>
  1249. <term>standaloneEnabled</term>
  1250. </dt>
  1251. <dd>
  1252. <p>(No Java system property)</p>
  1253. <p>
  1254. <strong>New in 3.5.0:</strong>
  1255. When set to false, a single server can be started in replicated
  1256. mode, a lone participant can run with observers, and a cluster
  1257. can reconfigure down to one node, and up from one node. The
  1258. default is true for backwards compatibility. It can be set
  1259. using QuorumPeerConfig's setStandaloneEnabled method or by
  1260. adding "standaloneEnabled=false" or "standaloneEnabled=true"
  1261. to a server's config file.
  1262. </p>
  1263. </dd>
  1264. <dt>
  1265. <term>reconfigEnabled</term>
  1266. </dt>
  1267. <dd>
  1268. <p>(No Java system property)</p>
  1269. <p>
  1270. <strong>New in 3.5.3:</strong>
  1271. This controls the enabling or disabling of
  1272. <a href="zookeeperReconfig.html">
  1273. Dynamic Reconfiguration</a> feature. When the feature
  1274. is enabled, users can perform reconfigure operations through
  1275. the ZooKeeper client API or through ZooKeeper command line tools
  1276. assuming users are authorized to perform such operations.
  1277. When the feature is disabled, no user, including the super user,
  1278. can perform a reconfiguration. Any attempt to reconfigure will return an error.
  1279. <strong>"reconfigEnabled"</strong> option can be set as
  1280. <strong>"reconfigEnabled=false"</strong> or
  1281. <strong>"reconfigEnabled=true"</strong>
  1282. to a server's config file, or using QuorumPeerConfig's
  1283. setReconfigEnabled method. The default value is false.
  1284. If present, the value should be consistent across every server in
  1285. the entire ensemble. Setting the value as true on some servers and false
  1286. on other servers will cause inconsistent behavior depending on which server
  1287. is elected as leader. If the leader has a setting of
  1288. <strong>"reconfigEnabled=true"</strong>, then the ensemble
  1289. will have reconfig feature enabled. If the leader has a setting of
  1290. <strong>"reconfigEnabled=false"</strong>, then the ensemble
  1291. will have reconfig feature disabled. It is thus recommended to have a consistent
  1292. value for <strong>"reconfigEnabled"</strong> across servers
  1293. in the ensemble.
  1294. </p>
  1295. </dd>
  1296. <dt>
  1297. <term>4lw.commands.whitelist</term>
  1298. </dt>
  1299. <dd>
  1300. <p>(Java system property: <strong>zookeeper.4lw.commands.whitelist</strong>)</p>
  1301. <p>
  1302. <strong>New in 3.5.3:</strong>
  1303. A list of comma separated <a href="#sc_4lw">Four Letter Words</a>
  1304. commands that user wants to use. A valid Four Letter Words
  1305. command must be put in this list else ZooKeeper server will
  1306. not enable the command.
  1307. By default the whitelist only contains "srvr" command
  1308. which zkServer.sh uses. The rest of four letter word commands are disabled
  1309. by default.
  1310. </p>
  1311. <p>Here's an example of the configuration that enables stat, ruok, conf, and isro
  1312. command while disabling the rest of Four Letter Words command:</p>
  1313. <pre class="code">
  1314. 4lw.commands.whitelist=stat, ruok, conf, isro
  1315. </pre>
  1316. <p>If you really need enable all four letter word commands by default, you can use
  1317. the asterisk option so you don't have to include every command one by one in the list.
  1318. As an example, this will enable all four letter word commands:
  1319. </p>
  1320. <pre class="code">
  1321. 4lw.commands.whitelist=*
  1322. </pre>
  1323. </dd>
  1324. <dt>
  1325. <term>tcpKeepAlive</term>
  1326. </dt>
  1327. <dd>
  1328. <p>(Java system property: <strong>zookeeper.tcpKeepAlive</strong>)</p>
  1329. <p>
  1330. <strong>New in 3.5.4:</strong>
  1331. Setting this to true sets the TCP keepAlive flag on the
  1332. sockets used by quorum members to perform elections.
  1333. This will allow for connections between quorum members to
  1334. remain up when there is network infrastructure that may
  1335. otherwise break them. Some NATs and firewalls may terminate
  1336. or lose state for long running or idle connections.</p>
  1337. <p> Enabling this option relies on OS level settings to work
  1338. properly, check your operating system's options regarding TCP
  1339. keepalive for more information. Defaults to
  1340. <strong>false</strong>.
  1341. </p>
  1342. </dd>
  1343. </dl>
  1344. <p></p>
  1345. <a name="sc_authOptions"></a>
  1346. <h4>Encryption, Authentication, Authorization Options</h4>
  1347. <p>The options in this section allow control over
  1348. encryption/authentication/authorization performed by the service.</p>
  1349. <dl>
  1350. <dt>
  1351. <term>DigestAuthenticationProvider.superDigest</term>
  1352. </dt>
  1353. <dd>
  1354. <p>(Java system property: <strong>zookeeper.DigestAuthenticationProvider.superDigest</strong>)</p>
  1355. <p>By default this feature is <strong>disabled</strong>
  1356. </p>
  1357. <p>
  1358. <strong>New in 3.2:</strong>
  1359. Enables a ZooKeeper ensemble administrator to access the
  1360. znode hierarchy as a "super" user. In particular no ACL
  1361. checking occurs for a user authenticated as
  1362. super.</p>
  1363. <p>org.apache.zookeeper.server.auth.DigestAuthenticationProvider
  1364. can be used to generate the superDigest, call it with
  1365. one parameter of "super:&lt;password&gt;". Provide the
  1366. generated "super:&lt;data&gt;" as the system property value
  1367. when starting each server of the ensemble.</p>
  1368. <p>When authenticating to a ZooKeeper server (from a
  1369. ZooKeeper client) pass a scheme of "digest" and authdata
  1370. of "super:&lt;password&gt;". Note that digest auth passes
  1371. the authdata in plaintext to the server, it would be
  1372. prudent to use this authentication method only on
  1373. localhost (not over the network) or over an encrypted
  1374. connection.</p>
  1375. </dd>
  1376. <dt>
  1377. <term>X509AuthenticationProvider.superUser</term>
  1378. </dt>
  1379. <dd>
  1380. <p>(Java system property: <strong>zookeeper.X509AuthenticationProvider.superUser</strong>)</p>
  1381. <p>The SSL-backed way to enable a ZooKeeper ensemble
  1382. administrator to access the znode hierarchy as a "super" user.
  1383. When this parameter is set to an X500 principal name, only an
  1384. authenticated client with that principal will be able to bypass
  1385. ACL checking and have full privileges to all znodes.</p>
  1386. </dd>
  1387. <dt>
  1388. <term>zookeeper.superUser</term>
  1389. </dt>
  1390. <dd>
  1391. <p>(Java system property: <strong>zookeeper.superUser</strong>)</p>
  1392. <p>Similar to <strong>zookeeper.X509AuthenticationProvider.superUser</strong>
  1393. but is generic for SASL based logins. It stores the name of
  1394. a user that can access the znode hierarchy as a "super" user.
  1395. </p>
  1396. </dd>
  1397. <dt>
  1398. <term>ssl.keyStore.location and ssl.keyStore.password</term>
  1399. </dt>
  1400. <dd>
  1401. <p>(Java system properties: <strong>
  1402. zookeeper.ssl.keyStore.location</strong> and <strong>zookeeper.ssl.keyStore.password</strong>)</p>
  1403. <p>Specifies the file path to a JKS containing the local
  1404. credentials to be used for SSL connections, and the
  1405. password to unlock the file.</p>
  1406. </dd>
  1407. <dt>
  1408. <term>ssl.trustStore.location and ssl.trustStore.password</term>
  1409. </dt>
  1410. <dd>
  1411. <p>(Java system properties: <strong>
  1412. zookeeper.ssl.trustStore.location</strong> and <strong>zookeeper.ssl.trustStore.password</strong>)</p>
  1413. <p>Specifies the file path to a JKS containing the remote
  1414. credentials to be used for SSL connections, and the
  1415. password to unlock the file.</p>
  1416. </dd>
  1417. <dt>
  1418. <term>ssl.authProvider</term>
  1419. </dt>
  1420. <dd>
  1421. <p>(Java system property: <strong>zookeeper.ssl.authProvider</strong>)</p>
  1422. <p>Specifies a subclass of <strong>
  1423. org.apache.zookeeper.auth.X509AuthenticationProvider</strong>
  1424. to use for secure client authentication. This is useful in
  1425. certificate key infrastructures that do not use JKS. It may be
  1426. necessary to extend <strong>javax.net.ssl.X509KeyManager
  1427. </strong> and <strong>javax.net.ssl.X509TrustManager</strong>
  1428. to get the desired behavior from the SSL stack. To configure the
  1429. ZooKeeper server to use the custom provider for authentication,
  1430. choose a scheme name for the custom AuthenticationProvider and
  1431. set the property <strong>zookeeper.authProvider.[scheme]
  1432. </strong> to the fully-qualified class name of the custom
  1433. implementation. This will load the provider into the ProviderRegistry.
  1434. Then set this property <strong>
  1435. zookeeper.ssl.authProvider=[scheme]</strong> and that provider
  1436. will be used for secure authentication.</p>
  1437. </dd>
  1438. </dl>
  1439. <a name="Experimental+Options%2FFeatures"></a>
  1440. <h4>Experimental Options/Features</h4>
  1441. <p>New features that are currently considered experimental.</p>
  1442. <dl>
  1443. <dt>
  1444. <term>Read Only Mode Server</term>
  1445. </dt>
  1446. <dd>
  1447. <p>(Java system property: <strong>readonlymode.enabled</strong>)</p>
  1448. <p>
  1449. <strong>New in 3.4.0:</strong>
  1450. Setting this value to true enables Read Only Mode server
  1451. support (disabled by default). ROM allows clients
  1452. sessions which requested ROM support to connect to the
  1453. server even when the server might be partitioned from
  1454. the quorum. In this mode ROM clients can still read
  1455. values from the ZK service, but will be unable to write
  1456. values and see changes from other clients. See
  1457. ZOOKEEPER-784 for more details.
  1458. </p>
  1459. </dd>
  1460. </dl>
  1461. <a name="Unsafe+Options"></a>
  1462. <h4>Unsafe Options</h4>
  1463. <p>The following options can be useful, but be careful when you use
  1464. them. The risk of each is explained along with the explanation of what
  1465. the variable does.</p>
  1466. <dl>
  1467. <dt>
  1468. <term>forceSync</term>
  1469. </dt>
  1470. <dd>
  1471. <p>(Java system property: <strong>zookeeper.forceSync</strong>)</p>
  1472. <p>Requires updates to be synced to media of the transaction
  1473. log before finishing processing the update. If this option is
  1474. set to no, ZooKeeper will not require updates to be synced to
  1475. the media.</p>
  1476. </dd>
  1477. <dt>
  1478. <term>jute.maxbuffer:</term>
  1479. </dt>
  1480. <dd>
  1481. <p>(Java system property:<strong>
  1482. jute.maxbuffer</strong>)</p>
  1483. <p>This option can only be set as a Java system property.
  1484. There is no zookeeper prefix on it. It specifies the maximum
  1485. size of the data that can be stored in a znode. The default is
  1486. 0xfffff, or just under 1M. If this option is changed, the system
  1487. property must be set on all servers and clients otherwise
  1488. problems will arise. This is really a sanity check. ZooKeeper is
  1489. designed to store data on the order of kilobytes in size.</p>
  1490. </dd>
  1491. <dt>
  1492. <term>skipACL</term>
  1493. </dt>
  1494. <dd>
  1495. <p>(Java system property: <strong>zookeeper.skipACL</strong>)</p>
  1496. <p>Skips ACL checks. This results in a boost in throughput,
  1497. but opens up full access to the data tree to everyone.</p>
  1498. </dd>
  1499. <dt>
  1500. <term>quorumListenOnAllIPs</term>
  1501. </dt>
  1502. <dd>
  1503. <p>When set to true the ZooKeeper server will listen
  1504. for connections from its peers on all available IP addresses,
  1505. and not only the address configured in the server list of the
  1506. configuration file. It affects the connections handling the
  1507. ZAB protocol and the Fast Leader Election protocol. Default
  1508. value is <strong>false</strong>.</p>
  1509. </dd>
  1510. </dl>
  1511. <a name="Disabling+data+directory+autocreation"></a>
  1512. <h4>Disabling data directory autocreation</h4>
  1513. <p>
  1514. <strong>New in 3.5:</strong> The default
  1515. behavior of a ZooKeeper server is to automatically create the
  1516. data directory (specified in the configuration file) when
  1517. started if that directory does not already exist. This can be
  1518. inconvenient and even dangerous in some cases. Take the case
  1519. where a configuration change is made to a running server,
  1520. wherein the <strong>dataDir</strong> parameter
  1521. is accidentally changed. When the ZooKeeper server is
  1522. restarted it will create this non-existent directory and begin
  1523. serving - with an empty znode namespace. This scenario can
  1524. result in an effective "split brain" situation (i.e. data in
  1525. both the new invalid directory and the original valid data
  1526. store). As such is would be good to have an option to turn off
  1527. this autocreate behavior. In general for production
  1528. environments this should be done, unfortunately however the
  1529. default legacy behavior cannot be changed at this point and
  1530. therefore this must be done on a case by case basis. This is
  1531. left to users and to packagers of ZooKeeper distributions.
  1532. </p>
  1533. <p>When running <strong>zkServer.sh</strong> autocreate can be disabled
  1534. by setting the environment variable <strong>ZOO_DATADIR_AUTOCREATE_DISABLE</strong> to 1.
  1535. When running ZooKeeper servers directly from class files this
  1536. can be accomplished by setting <strong>zookeeper.datadir.autocreate=false</strong> on
  1537. the java command line, i.e. <strong>-Dzookeeper.datadir.autocreate=false</strong>
  1538. </p>
  1539. <p>When this feature is disabled, and the ZooKeeper server
  1540. determines that the required directories do not exist it will
  1541. generate an error and refuse to start.
  1542. </p>
  1543. <p>A new script <strong>zkServer-initialize.sh</strong> is provided to
  1544. support this new feature. If autocreate is disabled it is
  1545. necessary for the user to first install ZooKeeper, then create
  1546. the data directory (and potentially txnlog directory), and
  1547. then start the server. Otherwise as mentioned in the previous
  1548. paragraph the server will not start. Running <strong>zkServer-initialize.sh</strong> will create the
  1549. required directories, and optionally setup the myid file
  1550. (optional command line parameter). This script can be used
  1551. even if the autocreate feature itself is not used, and will
  1552. likely be of use to users as this (setup, including creation
  1553. of the myid file) has been an issue for users in the past.
  1554. Note that this script ensures the data directories exist only,
  1555. it does not create a config file, but rather requires a config
  1556. file to be available in order to execute.
  1557. </p>
  1558. <a name="sc_db_existence_validation"></a>
  1559. <h4>Enabling db existence validation</h4>
  1560. <p>
  1561. <strong>New in 3.6.0:</strong> The default
  1562. behavior of a ZooKeeper server on startup when no data tree
  1563. is found is to set zxid to zero and join the quorum as a
  1564. voting member. This can be dangerous if some event (e.g. a
  1565. rogue 'rm -rf') has removed the data directory while the
  1566. server was down since this server may help elect a leader
  1567. that is missing transactions. Enabling db existence validation
  1568. will change the behavior on startup when no data tree is
  1569. found: the server joins the ensemble as a non-voting participant
  1570. until it is able to sync with the leader and acquire an up-to-date
  1571. version of the ensemble data. To indicate an empty data tree is
  1572. expected (ensemble creation), the user should place a file
  1573. 'initialize' in the same directory as 'myid'. This file will
  1574. be detected and deleted by the server on startup.
  1575. </p>
  1576. <p> Initialization validation can be enabled when running
  1577. ZooKeeper servers directly from class files by setting
  1578. <strong>zookeeper.db.autocreate=false</strong>
  1579. on the java command line, i.e.
  1580. <strong>-Dzookeeper.db.autocreate=false</strong>.
  1581. Running <strong>zkServer-initialize.sh</strong>
  1582. will create the required initialization file.
  1583. </p>
  1584. <a name="sc_performance_options"></a>
  1585. <h4>Performance Tuning Options</h4>
  1586. <p>
  1587. <strong>New in 3.5.0:</strong> Several subsystems have been reworked
  1588. to improve read throughput. This includes multi-threading of the NIO communication subsystem and
  1589. request processing pipeline (Commit Processor). NIO is the default client/server communication
  1590. subsystem. Its threading model comprises 1 acceptor thread, 1-N selector threads and 0-M
  1591. socket I/O worker threads. In the request processing pipeline the system can be configured
  1592. to process multiple read request at once while maintaining the same consistency guarantee
  1593. (same-session read-after-write). The Commit Processor threading model comprises 1 main
  1594. thread and 0-N worker threads.
  1595. </p>
  1596. <p>
  1597. The default values are aimed at maximizing read throughput on a dedicated ZooKeeper machine.
  1598. Both subsystems need to have sufficient amount of threads to achieve peak read throughput.
  1599. </p>
  1600. <dl>
  1601. <dt>
  1602. <term>zookeeper.nio.numSelectorThreads</term>
  1603. </dt>
  1604. <dd>
  1605. <p>(Java system property only: <strong>zookeeper.nio.numSelectorThreads</strong>)
  1606. </p>
  1607. <p>
  1608. <strong>New in 3.5.0:</strong>
  1609. Number of NIO selector threads. At least 1 selector thread required.
  1610. It is recommended to use more than one selector for large numbers
  1611. of client connections. The default value is sqrt( number of cpu cores / 2 ).
  1612. </p>
  1613. </dd>
  1614. <dt>
  1615. <term>zookeeper.nio.numWorkerThreads</term>
  1616. </dt>
  1617. <dd>
  1618. <p>(Java system property only: <strong>zookeeper.nio.numWorkerThreads</strong>)
  1619. </p>
  1620. <p>
  1621. <strong>New in 3.5.0:</strong>
  1622. Number of NIO worker threads. If configured with 0 worker threads, the selector threads
  1623. do the socket I/O directly. The default value is 2 times the number of cpu cores.
  1624. </p>
  1625. </dd>
  1626. <dt>
  1627. <term>zookeeper.commitProcessor.numWorkerThreads</term>
  1628. </dt>
  1629. <dd>
  1630. <p>(Java system property only: <strong>zookeeper.commitProcessor.numWorkerThreads</strong>)
  1631. </p>
  1632. <p>
  1633. <strong>New in 3.5.0:</strong>
  1634. Number of Commit Processor worker threads. If configured with 0 worker threads, the main thread
  1635. will process the request directly. The default value is the number of cpu cores.
  1636. </p>
  1637. </dd>
  1638. <dt>
  1639. <term>znode.container.checkIntervalMs</term>
  1640. </dt>
  1641. <dd>
  1642. <p>(Java system property only)</p>
  1643. <p>
  1644. <strong>New in 3.6.0:</strong> The
  1645. time interval in milliseconds for each check of candidate container
  1646. and ttl nodes. Default is "60000".</p>
  1647. </dd>
  1648. <dt>
  1649. <term>znode.container.maxPerMinute</term>
  1650. </dt>
  1651. <dd>
  1652. <p>(Java system property only)</p>
  1653. <p>
  1654. <strong>New in 3.6.0:</strong> The
  1655. maximum number of container and ttl nodes that can be deleted per
  1656. minute. This prevents herding during container deletion.
  1657. Default is "10000".</p>
  1658. </dd>
  1659. </dl>
  1660. <a name="Communication+using+the+Netty+framework"></a>
  1661. <h4>Communication using the Netty framework</h4>
  1662. <p>
  1663. <a href="http://netty.io">Netty</a>
  1664. is an NIO based client/server communication framework, it
  1665. simplifies (over NIO being used directly) many of the
  1666. complexities of network level communication for java
  1667. applications. Additionally the Netty framework has built
  1668. in support for encryption (SSL) and authentication
  1669. (certificates). These are optional features and can be
  1670. turned on or off individually.
  1671. </p>
  1672. <p>In versions 3.5+, a ZooKeeper server can use Netty
  1673. instead of NIO (default option) by setting the environment
  1674. variable <strong>zookeeper.serverCnxnFactory</strong>
  1675. to <strong>org.apache.zookeeper.server.NettyServerCnxnFactory</strong>;
  1676. for the client, set <strong>zookeeper.clientCnxnSocket</strong>
  1677. to <strong>org.apache.zookeeper.ClientCnxnSocketNetty</strong>.
  1678. </p>
  1679. <p>
  1680. 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.
  1681. </p>
  1682. <p>
  1683. TBD - how to manage encryption
  1684. </p>
  1685. <p>
  1686. TBD - how to manage certificates
  1687. </p>
  1688. <a name="sc_adminserver_config"></a>
  1689. <h4>AdminServer configuration</h4>
  1690. <p>
  1691. <strong>New in 3.5.0:</strong> The following
  1692. options are used to configure the <a href="#sc_adminserver">AdminServer</a>.</p>
  1693. <dl>
  1694. <dt>
  1695. <term>admin.enableServer</term>
  1696. </dt>
  1697. <dd>
  1698. <p>(Java system property: <strong>zookeeper.admin.enableServer</strong>)</p>
  1699. <p>Set to "false" to disable the AdminServer. By default the
  1700. AdminServer is enabled.</p>
  1701. </dd>
  1702. <dt>
  1703. <term>admin.serverAddress</term>
  1704. </dt>
  1705. <dd>
  1706. <p>(Java system property: <strong>zookeeper.admin.serverAddress</strong>)</p>
  1707. <p>The address the embedded Jetty server listens on. Defaults to 0.0.0.0.</p>
  1708. </dd>
  1709. <dt>
  1710. <term>admin.serverPort</term>
  1711. </dt>
  1712. <dd>
  1713. <p>(Java system property: <strong>zookeeper.admin.serverPort</strong>)</p>
  1714. <p>The port the embedded Jetty server listens on. Defaults to 8080.</p>
  1715. </dd>
  1716. <dt>
  1717. <term>admin.idleTimeout</term>
  1718. </dt>
  1719. <dd>
  1720. <p>(Java system property: <strong>zookeeper.admin.idleTimeout</strong>)</p>
  1721. <p>Set the maximum idle time in milliseconds that a connection can wait
  1722. before sending or receiving data. Defaults to 30000 ms.</p>
  1723. </dd>
  1724. <dt>
  1725. <term>admin.commandURL</term>
  1726. </dt>
  1727. <dd>
  1728. <p>(Java system property: <strong>zookeeper.admin.commandURL</strong>)</p>
  1729. <p>The URL for listing and issuing commands relative to the
  1730. root URL. Defaults to "/commands".</p>
  1731. </dd>
  1732. </dl>
  1733. <a name="sc_zkCommands"></a>
  1734. <h3 class="h4">ZooKeeper Commands</h3>
  1735. <a name="sc_4lw"></a>
  1736. <h4>The Four Letter Words</h4>
  1737. <p>ZooKeeper responds to a small set of commands. Each command is
  1738. composed of four letters. You issue the commands to ZooKeeper via telnet
  1739. or nc, at the client port.</p>
  1740. <p>Three of the more interesting commands: "stat" gives some
  1741. general information about the server and connected clients,
  1742. while "srvr" and "cons" give extended details on server and
  1743. connections respectively.</p>
  1744. <p>
  1745. <strong>New in 3.5.3:</strong>
  1746. Four Letter Words need to be explicitly white listed before using.
  1747. Please refer <strong>4lw.commands.whitelist</strong>
  1748. described in <a href="#sc_clusterOptions">
  1749. cluster configuration section</a> for details.
  1750. Moving forward, Four Letter Words will be deprecated, please use
  1751. <a href="#sc_adminserver">AdminServer</a> instead.
  1752. </p>
  1753. <dl>
  1754. <dt>
  1755. <term>conf</term>
  1756. </dt>
  1757. <dd>
  1758. <p>
  1759. <strong>New in 3.3.0:</strong> Print
  1760. details about serving configuration.</p>
  1761. </dd>
  1762. <dt>
  1763. <term>cons</term>
  1764. </dt>
  1765. <dd>
  1766. <p>
  1767. <strong>New in 3.3.0:</strong> List
  1768. full connection/session details for all clients connected
  1769. to this server. Includes information on numbers of packets
  1770. received/sent, session id, operation latencies, last
  1771. operation performed, etc...</p>
  1772. </dd>
  1773. <dt>
  1774. <term>crst</term>
  1775. </dt>
  1776. <dd>
  1777. <p>
  1778. <strong>New in 3.3.0:</strong> Reset
  1779. connection/session statistics for all connections.</p>
  1780. </dd>
  1781. <dt>
  1782. <term>dump</term>
  1783. </dt>
  1784. <dd>
  1785. <p>Lists the outstanding sessions and ephemeral nodes. This
  1786. only works on the leader.</p>
  1787. </dd>
  1788. <dt>
  1789. <term>envi</term>
  1790. </dt>
  1791. <dd>
  1792. <p>Print details about serving environment</p>
  1793. </dd>
  1794. <dt>
  1795. <term>ruok</term>
  1796. </dt>
  1797. <dd>
  1798. <p>Tests if server is running in a non-error state. The server
  1799. will respond with imok if it is running. Otherwise it will not
  1800. respond at all.</p>
  1801. <p>A response of "imok" does not necessarily indicate that the
  1802. server has joined the quorum, just that the server process is active
  1803. and bound to the specified client port. Use "stat" for details on
  1804. state wrt quorum and client connection information.</p>
  1805. </dd>
  1806. <dt>
  1807. <term>srst</term>
  1808. </dt>
  1809. <dd>
  1810. <p>Reset server statistics.</p>
  1811. </dd>
  1812. <dt>
  1813. <term>srvr</term>
  1814. </dt>
  1815. <dd>
  1816. <p>
  1817. <strong>New in 3.3.0:</strong> Lists
  1818. full details for the server.</p>
  1819. </dd>
  1820. <dt>
  1821. <term>stat</term>
  1822. </dt>
  1823. <dd>
  1824. <p>Lists brief details for the server and connected
  1825. clients.</p>
  1826. </dd>
  1827. <dt>
  1828. <term>wchs</term>
  1829. </dt>
  1830. <dd>
  1831. <p>
  1832. <strong>New in 3.3.0:</strong> Lists
  1833. brief information on watches for the server.</p>
  1834. </dd>
  1835. <dt>
  1836. <term>wchc</term>
  1837. </dt>
  1838. <dd>
  1839. <p>
  1840. <strong>New in 3.3.0:</strong> Lists
  1841. detailed information on watches for the server, by
  1842. session. This outputs a list of sessions(connections)
  1843. with associated watches (paths). Note, depending on the
  1844. number of watches this operation may be expensive (ie
  1845. impact server performance), use it carefully.</p>
  1846. </dd>
  1847. <dt>
  1848. <term>dirs</term>
  1849. </dt>
  1850. <dd>
  1851. <p>
  1852. <strong>New in 3.5.1:</strong>
  1853. Shows the total size of snapshot and log files in bytes
  1854. </p>
  1855. </dd>
  1856. <dt>
  1857. <term>wchp</term>
  1858. </dt>
  1859. <dd>
  1860. <p>
  1861. <strong>New in 3.3.0:</strong> Lists
  1862. detailed information on watches for the server, by path.
  1863. This outputs a list of paths (znodes) with associated
  1864. sessions. Note, depending on the number of watches this
  1865. operation may be expensive (ie impact server performance),
  1866. use it carefully.</p>
  1867. </dd>
  1868. <dt>
  1869. <term>mntr</term>
  1870. </dt>
  1871. <dd>
  1872. <p>
  1873. <strong>New in 3.4.0:</strong> Outputs a list
  1874. of variables that could be used for monitoring the health of the cluster.</p>
  1875. <pre class="code">$ echo mntr | nc localhost 2185
  1876. zk_version 3.4.0
  1877. zk_avg_latency 0
  1878. zk_max_latency 0
  1879. zk_min_latency 0
  1880. zk_packets_received 70
  1881. zk_packets_sent 69
  1882. zk_outstanding_requests 0
  1883. zk_server_state leader
  1884. zk_znode_count 4
  1885. zk_watch_count 0
  1886. zk_ephemerals_count 0
  1887. zk_approximate_data_size 27
  1888. zk_followers 4 - only exposed by the Leader
  1889. zk_synced_followers 4 - only exposed by the Leader
  1890. zk_pending_syncs 0 - only exposed by the Leader
  1891. zk_open_file_descriptor_count 23 - only available on Unix platforms
  1892. zk_max_file_descriptor_count 1024 - only available on Unix platforms
  1893. </pre>
  1894. <p>The output is compatible with java properties format and the content
  1895. may change over time (new keys added). Your scripts should expect changes.</p>
  1896. <p>ATTENTION: Some of the keys are platform specific and some of the keys are only exported by the Leader. </p>
  1897. <p>The output contains multiple lines with the following format:</p>
  1898. <pre class="code">key \t value</pre>
  1899. </dd>
  1900. <dt>
  1901. <term>isro</term>
  1902. </dt>
  1903. <dd>
  1904. <p>
  1905. <strong>New in 3.4.0:</strong> Tests if
  1906. server is running in read-only mode. The server will respond with
  1907. "ro" if in read-only mode or "rw" if not in read-only mode.</p>
  1908. </dd>
  1909. <dt>
  1910. <term>gtmk</term>
  1911. </dt>
  1912. <dd>
  1913. <p>Gets the current trace mask as a 64-bit signed long value in
  1914. decimal format. See <span class="codefrag command">stmk</span> for an explanation of
  1915. the possible values.</p>
  1916. </dd>
  1917. <dt>
  1918. <term>stmk</term>
  1919. </dt>
  1920. <dd>
  1921. <p>Sets the current trace mask. The trace mask is 64 bits,
  1922. where each bit enables or disables a specific category of trace
  1923. logging on the server. Log4J must be configured to enable
  1924. <span class="codefrag command">TRACE</span> level first in order to see trace logging
  1925. messages. The bits of the trace mask correspond to the following
  1926. trace logging categories.</p>
  1927. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  1928. <caption>Trace Mask Bit Values</caption>
  1929. <title>Trace Mask Bit Values</title>
  1930. <tr>
  1931. <td>0b0000000000</td>
  1932. <td>Unused, reserved for future use.</td>
  1933. </tr>
  1934. <tr>
  1935. <td>0b0000000010</td>
  1936. <td>Logs client requests, excluding ping
  1937. requests.</td>
  1938. </tr>
  1939. <tr>
  1940. <td>0b0000000100</td>
  1941. <td>Unused, reserved for future use.</td>
  1942. </tr>
  1943. <tr>
  1944. <td>0b0000001000</td>
  1945. <td>Logs client ping requests.</td>
  1946. </tr>
  1947. <tr>
  1948. <td>0b0000010000</td>
  1949. <td>Logs packets received from the quorum peer that is
  1950. the current leader, excluding ping requests.</td>
  1951. </tr>
  1952. <tr>
  1953. <td>0b0000100000</td>
  1954. <td>Logs addition, removal and validation of client
  1955. sessions.</td>
  1956. </tr>
  1957. <tr>
  1958. <td>0b0001000000</td>
  1959. <td>Logs delivery of watch events to client
  1960. sessions.</td>
  1961. </tr>
  1962. <tr>
  1963. <td>0b0010000000</td>
  1964. <td>Logs ping packets received from the quorum peer
  1965. that is the current leader.</td>
  1966. </tr>
  1967. <tr>
  1968. <td>0b0100000000</td>
  1969. <td>Unused, reserved for future use.</td>
  1970. </tr>
  1971. <tr>
  1972. <td>0b1000000000</td>
  1973. <td>Unused, reserved for future use.</td>
  1974. </tr>
  1975. </table>
  1976. <p>All remaining bits in the 64-bit value are unused and
  1977. reserved for future use. Multiple trace logging categories are
  1978. specified by calculating the bitwise OR of the documented values.
  1979. The default trace mask is 0b0100110010. Thus, by default, trace
  1980. logging includes client requests, packets received from the
  1981. leader and sessions.</p>
  1982. <p>To set a different trace mask, send a request containing the
  1983. <span class="codefrag command">stmk</span> four-letter word followed by the trace
  1984. mask represented as a 64-bit signed long value. This example uses
  1985. the Perl <span class="codefrag command">pack</span> function to construct a trace
  1986. mask that enables all trace logging categories described above and
  1987. convert it to a 64-bit signed long value with big-endian byte
  1988. order. The result is appended to <span class="codefrag command">stmk</span> and sent
  1989. to the server using netcat. The server responds with the new
  1990. trace mask in decimal format.</p>
  1991. <pre class="code">$ perl -e "print 'stmk', pack('q&gt;', 0b0011111010)" | nc localhost 2181
  1992. 250
  1993. </pre>
  1994. </dd>
  1995. </dl>
  1996. <p>Here's an example of the <strong>ruok</strong>
  1997. command:</p>
  1998. <pre class="code">$ echo ruok | nc 127.0.0.1 5111
  1999. imok
  2000. </pre>
  2001. <a name="sc_adminserver"></a>
  2002. <h4>The AdminServer</h4>
  2003. <p>
  2004. <strong>New in 3.5.0: </strong>The AdminServer is
  2005. an embedded Jetty server that provides an HTTP interface to the four
  2006. letter word commands. By default, the server is started on port 8080,
  2007. and commands are issued by going to the URL "/commands/[command name]",
  2008. e.g., http://localhost:8080/commands/stat. The command response is
  2009. returned as JSON. Unlike the original protocol, commands are not
  2010. restricted to four-letter names, and commands can have multiple names;
  2011. for instance, "stmk" can also be referred to as "set_trace_mask". To
  2012. view a list of all available commands, point a browser to the URL
  2013. /commands (e.g., http://localhost:8080/commands). See the <a href="#sc_adminserver_config">AdminServer configuration options</a>
  2014. for how to change the port and URLs.</p>
  2015. <p>The AdminServer is enabled by default, but can be disabled by either:</p>
  2016. <ul>
  2017. <li>
  2018. <p>Setting the zookeeper.admin.enableServer system
  2019. property to false.</p>
  2020. </li>
  2021. <li>
  2022. <p>Removing Jetty from the classpath. (This option is
  2023. useful if you would like to override ZooKeeper's jetty
  2024. dependency.)</p>
  2025. </li>
  2026. </ul>
  2027. <p>Note that the TCP four letter word interface is still available if
  2028. the AdminServer is disabled.</p>
  2029. <a name="sc_dataFileManagement"></a>
  2030. <h3 class="h4">Data File Management</h3>
  2031. <p>ZooKeeper stores its data in a data directory and its transaction
  2032. log in a transaction log directory. By default these two directories are
  2033. the same. The server can (and should) be configured to store the
  2034. transaction log files in a separate directory than the data files.
  2035. Throughput increases and latency decreases when transaction logs reside
  2036. on a dedicated log devices.</p>
  2037. <a name="The+Data+Directory"></a>
  2038. <h4>The Data Directory</h4>
  2039. <p>This directory has two or three files in it:</p>
  2040. <ul>
  2041. <li>
  2042. <p>
  2043. <span class="codefrag filename">myid</span> - contains a single integer in
  2044. human readable ASCII text that represents the server id.</p>
  2045. </li>
  2046. <li>
  2047. <p>
  2048. <span class="codefrag filename">initialize</span> - presence indicates lack of
  2049. data tree is expected. Cleaned up once data tree is created.</p>
  2050. </li>
  2051. <li>
  2052. <p>
  2053. <span class="codefrag filename">snapshot.&lt;zxid&gt;</span> - holds the fuzzy
  2054. snapshot of a data tree.</p>
  2055. </li>
  2056. </ul>
  2057. <p>Each ZooKeeper server has a unique id. This id is used in two
  2058. places: the <span class="codefrag filename">myid</span> file and the configuration file.
  2059. The <span class="codefrag filename">myid</span> file identifies the server that
  2060. corresponds to the given data directory. The configuration file lists
  2061. the contact information for each server identified by its server id.
  2062. When a ZooKeeper server instance starts, it reads its id from the
  2063. <span class="codefrag filename">myid</span> file and then, using that id, reads from the
  2064. configuration file, looking up the port on which it should
  2065. listen.</p>
  2066. <p>The <span class="codefrag filename">snapshot</span> files stored in the data
  2067. directory are fuzzy snapshots in the sense that during the time the
  2068. ZooKeeper server is taking the snapshot, updates are occurring to the
  2069. data tree. The suffix of the <span class="codefrag filename">snapshot</span> file names
  2070. is the <em>zxid</em>, the ZooKeeper transaction id, of the
  2071. last committed transaction at the start of the snapshot. Thus, the
  2072. snapshot includes a subset of the updates to the data tree that
  2073. occurred while the snapshot was in process. The snapshot, then, may
  2074. not correspond to any data tree that actually existed, and for this
  2075. reason we refer to it as a fuzzy snapshot. Still, ZooKeeper can
  2076. recover using this snapshot because it takes advantage of the
  2077. idempotent nature of its updates. By replaying the transaction log
  2078. against fuzzy snapshots ZooKeeper gets the state of the system at the
  2079. end of the log.</p>
  2080. <a name="The+Log+Directory"></a>
  2081. <h4>The Log Directory</h4>
  2082. <p>The Log Directory contains the ZooKeeper transaction logs.
  2083. Before any update takes place, ZooKeeper ensures that the transaction
  2084. that represents the update is written to non-volatile storage. A new
  2085. log file is started when the number of transactions written to the
  2086. current log file reaches a (variable) threshold. The threshold is
  2087. computed using the same parameter which influences the frequency of
  2088. snapshotting (see snapCount above). The log file's suffix is the first
  2089. zxid written to that log.</p>
  2090. <a name="sc_filemanagement"></a>
  2091. <h4>File Management</h4>
  2092. <p>The format of snapshot and log files does not change between
  2093. standalone ZooKeeper servers and different configurations of
  2094. replicated ZooKeeper servers. Therefore, you can pull these files from
  2095. a running replicated ZooKeeper server to a development machine with a
  2096. stand-alone ZooKeeper server for trouble shooting.</p>
  2097. <p>Using older log and snapshot files, you can look at the previous
  2098. state of ZooKeeper servers and even restore that state. The
  2099. LogFormatter class allows an administrator to look at the transactions
  2100. in a log.</p>
  2101. <p>The ZooKeeper server creates snapshot and log files, but
  2102. never deletes them. The retention policy of the data and log
  2103. files is implemented outside of the ZooKeeper server. The
  2104. server itself only needs the latest complete fuzzy snapshot, all log
  2105. files following it, and the last log file preceding it. The latter
  2106. requirement is necessary to include updates which happened after this
  2107. snapshot was started but went into the existing log file at that time.
  2108. This is possible because snapshotting and rolling over of logs
  2109. proceed somewhat independently in ZooKeeper. See the
  2110. <a href="#sc_maintenance">maintenance</a> section in
  2111. this document for more details on setting a retention policy
  2112. and maintenance of ZooKeeper storage.
  2113. </p>
  2114. <div class="note">
  2115. <div class="label">Note</div>
  2116. <div class="content">
  2117. <p>The data stored in these files is not encrypted. In the case of
  2118. storing sensitive data in ZooKeeper, necessary measures need to be
  2119. taken to prevent unauthorized access. Such measures are external to
  2120. ZooKeeper (e.g., control access to the files) and depend on the
  2121. individual settings in which it is being deployed. </p>
  2122. </div>
  2123. </div>
  2124. <a name="sc_commonProblems"></a>
  2125. <h3 class="h4">Things to Avoid</h3>
  2126. <p>Here are some common problems you can avoid by configuring
  2127. ZooKeeper correctly:</p>
  2128. <dl>
  2129. <dt>
  2130. <term>inconsistent lists of servers</term>
  2131. </dt>
  2132. <dd>
  2133. <p>The list of ZooKeeper servers used by the clients must match
  2134. the list of ZooKeeper servers that each ZooKeeper server has.
  2135. Things work okay if the client list is a subset of the real list,
  2136. but things will really act strange if clients have a list of
  2137. ZooKeeper servers that are in different ZooKeeper clusters. Also,
  2138. the server lists in each Zookeeper server configuration file
  2139. should be consistent with one another.</p>
  2140. </dd>
  2141. <dt>
  2142. <term>incorrect placement of transaction log</term>
  2143. </dt>
  2144. <dd>
  2145. <p>The most performance critical part of ZooKeeper is the
  2146. transaction log. ZooKeeper syncs transactions to media before it
  2147. returns a response. A dedicated transaction log device is key to
  2148. consistent good performance. Putting the log on a busy device will
  2149. adversely effect performance. If you only have one storage device,
  2150. put trace files on NFS and increase the snapshotCount; it doesn't
  2151. eliminate the problem, but it should mitigate it.</p>
  2152. </dd>
  2153. <dt>
  2154. <term>incorrect Java heap size</term>
  2155. </dt>
  2156. <dd>
  2157. <p>You should take special care to set your Java max heap size
  2158. correctly. In particular, you should not create a situation in
  2159. which ZooKeeper swaps to disk. The disk is death to ZooKeeper.
  2160. Everything is ordered, so if processing one request swaps the
  2161. disk, all other queued requests will probably do the same. the
  2162. disk. DON'T SWAP.</p>
  2163. <p>Be conservative in your estimates: if you have 4G of RAM, do
  2164. not set the Java max heap size to 6G or even 4G. For example, it
  2165. is more likely you would use a 3G heap for a 4G machine, as the
  2166. operating system and the cache also need memory. The best and only
  2167. recommend practice for estimating the heap size your system needs
  2168. is to run load tests, and then make sure you are well below the
  2169. usage limit that would cause the system to swap.</p>
  2170. </dd>
  2171. <dt>
  2172. <term>Publicly accessible deployment</term>
  2173. </dt>
  2174. <dd>
  2175. <p>
  2176. A ZooKeeper ensemble is expected to operate in a trusted computing environment.
  2177. It is thus recommended to deploy ZooKeeper behind a firewall.
  2178. </p>
  2179. </dd>
  2180. </dl>
  2181. <a name="sc_bestPractices"></a>
  2182. <h3 class="h4">Best Practices</h3>
  2183. <p>For best results, take note of the following list of good
  2184. Zookeeper practices:</p>
  2185. <p>For multi-tenant installations see the <a href="zookeeperProgrammers.html#ch_zkSessions">section</a>
  2186. detailing ZooKeeper "chroot" support, this can be very useful
  2187. when deploying many applications/services interfacing to a
  2188. single ZooKeeper cluster.</p>
  2189. </div>
  2190. <p align="right">
  2191. <font size="-2"></font>
  2192. </p>
  2193. </div>
  2194. <!--+
  2195. |end content
  2196. +-->
  2197. <div class="clearboth">&nbsp;</div>
  2198. </div>
  2199. <div id="footer">
  2200. <!--+
  2201. |start bottomstrip
  2202. +-->
  2203. <div class="lastmodified">
  2204. <script type="text/javascript"><!--
  2205. document.write("Last Published: " + document.lastModified);
  2206. // --></script>
  2207. </div>
  2208. <div class="copyright">
  2209. Copyright &copy;
  2210. <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  2211. </div>
  2212. <!--+
  2213. |end bottomstrip
  2214. +-->
  2215. </div>
  2216. </body>
  2217. </html>