zookeeperAdmin.html 96 KB

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