zookeeperAdmin.html 93 KB

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