zookeeperAdmin.html 82 KB

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