zookeeperAdmin.html 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.9">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>ZooKeeper Administrator's Guide</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://zookeeper.apache.org/">ZooKeeper</a> &gt; <a href="http://zookeeper.apache.org/">ZooKeeper</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://zookeeper.apache.org/"><img class="logoImage" alt="ZooKeeper" src="images/zookeeper_small.gif" title="ZooKeeper: distributed coordination"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="zookeeper.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://zookeeper.apache.org/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="https://cwiki.apache.org/confluence/display/ZOOKEEPER/">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">ZooKeeper 3.6 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Overview</div>
  105. <div id="menu_1.1" class="menuitemgroup">
  106. <div class="menuitem">
  107. <a href="index.html">Welcome</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="zookeeperOver.html">Overview</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="zookeeperStarted.html">Getting Started</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="releasenotes.html">Release Notes</a>
  117. </div>
  118. </div>
  119. <div onclick="SwitchMenu('menu_1.2', 'skin/')" id="menu_1.2Title" class="menutitle">Developer</div>
  120. <div id="menu_1.2" class="menuitemgroup">
  121. <div class="menuitem">
  122. <a href="api/index.html">API Docs</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="zookeeperProgrammers.html">Programmer's Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="javaExample.html">Java Example</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="recipes.html">Recipes</a>
  135. </div>
  136. </div>
  137. <div onclick="SwitchMenu('menu_selected_1.3', 'skin/')" id="menu_selected_1.3Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Admin &amp; Ops</div>
  138. <div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
  139. <div class="menupage">
  140. <div class="menupagetitle">Administrator's Guide</div>
  141. </div>
  142. <div class="menuitem">
  143. <a href="zookeeperQuotas.html">Quota Guide</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="zookeeperJMX.html">JMX</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="zookeeperObservers.html">Observers Guide</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="zookeeperReconfig.html">Dynamic Reconfiguration</a>
  153. </div>
  154. </div>
  155. <div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle">Contributor</div>
  156. <div id="menu_1.4" class="menuitemgroup">
  157. <div class="menuitem">
  158. <a href="zookeeperInternals.html">ZooKeeper Internals</a>
  159. </div>
  160. </div>
  161. <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Miscellaneous</div>
  162. <div id="menu_1.5" class="menuitemgroup">
  163. <div class="menuitem">
  164. <a href="https://cwiki.apache.org/confluence/display/ZOOKEEPER">Wiki</a>
  165. </div>
  166. <div class="menuitem">
  167. <a href="https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ">FAQ</a>
  168. </div>
  169. <div class="menuitem">
  170. <a href="http://zookeeper.apache.org/mailing_lists.html">Mailing Lists</a>
  171. </div>
  172. </div>
  173. <div id="credit"></div>
  174. <div id="roundbottom">
  175. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  176. <!--+
  177. |alternative credits
  178. +-->
  179. <div id="credit2"></div>
  180. </div>
  181. <!--+
  182. |end Menu
  183. +-->
  184. <!--+
  185. |start content
  186. +-->
  187. <div id="content">
  188. <div title="Portable Document Format" class="pdflink">
  189. <a class="dida" href="zookeeperAdmin.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  190. PDF</a>
  191. </div>
  192. <h1>ZooKeeper Administrator's Guide</h1>
  193. <h3>A Guide to Deployment and Administration</h3>
  194. <div id="front-matter">
  195. <div id="minitoc-area">
  196. <ul class="minitoc">
  197. <li>
  198. <a href="#ch_deployment">Deployment</a>
  199. <ul class="minitoc">
  200. <li>
  201. <a href="#sc_systemReq">System Requirements</a>
  202. <ul class="minitoc">
  203. <li>
  204. <a href="#sc_supportedPlatforms">Supported Platforms</a>
  205. </li>
  206. <li>
  207. <a href="#sc_requiredSoftware">Required Software </a>
  208. </li>
  209. </ul>
  210. </li>
  211. <li>
  212. <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
  213. </li>
  214. <li>
  215. <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
  216. </li>
  217. </ul>
  218. </li>
  219. <li>
  220. <a href="#ch_administration">Administration</a>
  221. <ul class="minitoc">
  222. <li>
  223. <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
  224. <ul class="minitoc">
  225. <li>
  226. <a href="#sc_CrossMachineRequirements">Cross Machine Requirements</a>
  227. </li>
  228. <li>
  229. <a href="#Single+Machine+Requirements">Single Machine Requirements</a>
  230. </li>
  231. </ul>
  232. </li>
  233. <li>
  234. <a href="#sc_provisioning">Provisioning</a>
  235. </li>
  236. <li>
  237. <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
  238. </li>
  239. <li>
  240. <a href="#sc_administering">Administering</a>
  241. </li>
  242. <li>
  243. <a href="#sc_maintenance">Maintenance</a>
  244. <ul class="minitoc">
  245. <li>
  246. <a href="#Ongoing+Data+Directory+Cleanup">Ongoing Data Directory Cleanup</a>
  247. </li>
  248. <li>
  249. <a href="#Debug+Log+Cleanup+%28log4j%29">Debug Log Cleanup (log4j)</a>
  250. </li>
  251. </ul>
  252. </li>
  253. <li>
  254. <a href="#sc_supervision">Supervision</a>
  255. </li>
  256. <li>
  257. <a href="#sc_monitoring">Monitoring</a>
  258. </li>
  259. <li>
  260. <a href="#sc_logging">Logging</a>
  261. </li>
  262. <li>
  263. <a href="#sc_troubleshooting">Troubleshooting</a>
  264. </li>
  265. <li>
  266. <a href="#sc_configuration">Configuration Parameters</a>
  267. <ul class="minitoc">
  268. <li>
  269. <a href="#sc_minimumConfiguration">Minimum Configuration</a>
  270. </li>
  271. <li>
  272. <a href="#sc_advancedConfiguration">Advanced Configuration</a>
  273. </li>
  274. <li>
  275. <a href="#sc_clusterOptions">Cluster Options</a>
  276. </li>
  277. <li>
  278. <a href="#sc_authOptions">Encryption, Authentication, Authorization Options</a>
  279. </li>
  280. <li>
  281. <a href="#Experimental+Options%2FFeatures">Experimental Options/Features</a>
  282. </li>
  283. <li>
  284. <a href="#Unsafe+Options">Unsafe Options</a>
  285. </li>
  286. <li>
  287. <a href="#Disabling+data+directory+autocreation">Disabling data directory autocreation</a>
  288. </li>
  289. <li>
  290. <a href="#sc_db_existence_validation">Enabling db existence validation</a>
  291. </li>
  292. <li>
  293. <a href="#sc_performance_options">Performance Tuning Options</a>
  294. </li>
  295. <li>
  296. <a href="#Communication+using+the+Netty+framework">Communication using the Netty framework</a>
  297. </li>
  298. <li>
  299. <a href="#sc_adminserver_config">AdminServer configuration</a>
  300. </li>
  301. </ul>
  302. </li>
  303. <li>
  304. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  305. <ul class="minitoc">
  306. <li>
  307. <a href="#sc_4lw">The Four Letter Words</a>
  308. </li>
  309. <li>
  310. <a href="#sc_adminserver">The AdminServer</a>
  311. </li>
  312. </ul>
  313. </li>
  314. <li>
  315. <a href="#sc_dataFileManagement">Data File Management</a>
  316. <ul class="minitoc">
  317. <li>
  318. <a href="#The+Data+Directory">The Data Directory</a>
  319. </li>
  320. <li>
  321. <a href="#The+Log+Directory">The Log Directory</a>
  322. </li>
  323. <li>
  324. <a href="#sc_filemanagement">File Management</a>
  325. </li>
  326. </ul>
  327. </li>
  328. <li>
  329. <a href="#sc_commonProblems">Things to Avoid</a>
  330. </li>
  331. <li>
  332. <a href="#sc_bestPractices">Best Practices</a>
  333. </li>
  334. </ul>
  335. </li>
  336. </ul>
  337. </div>
  338. </div>
  339. <a name="ch_deployment"></a>
  340. <h2 class="h3">Deployment</h2>
  341. <div class="section">
  342. <p>This section contains information about deploying Zookeeper and
  343. covers these topics:</p>
  344. <ul>
  345. <li>
  346. <p>
  347. <a href="#sc_systemReq">System Requirements</a>
  348. </p>
  349. </li>
  350. <li>
  351. <p>
  352. <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
  353. </p>
  354. </li>
  355. <li>
  356. <p>
  357. <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
  358. </p>
  359. </li>
  360. </ul>
  361. <p>The first two sections assume you are interested in installing
  362. ZooKeeper in a production environment such as a datacenter. The final
  363. section covers situations in which you are setting up ZooKeeper on a
  364. limited basis - for evaluation, testing, or development - but not in a
  365. production environment.</p>
  366. <a name="sc_systemReq"></a>
  367. <h3 class="h4">System Requirements</h3>
  368. <a name="sc_supportedPlatforms"></a>
  369. <h4>Supported Platforms</h4>
  370. <p>ZooKeeper consists of multiple components. Some components are
  371. supported broadly, and other components are supported only on a smaller
  372. set of platforms.</p>
  373. <ul>
  374. <li>
  375. <p>
  376. <strong>Client</strong> is the Java client
  377. library, used by applications to connect to a ZooKeeper ensemble.
  378. </p>
  379. </li>
  380. <li>
  381. <p>
  382. <strong>Server</strong> is the Java server
  383. that runs on the ZooKeeper ensemble nodes.</p>
  384. </li>
  385. <li>
  386. <p>
  387. <strong>Native Client</strong> is a client
  388. implemented in C, similar to the Java client, used by applications
  389. to connect to a ZooKeeper ensemble.</p>
  390. </li>
  391. <li>
  392. <p>
  393. <strong>Contrib</strong> refers to multiple
  394. optional add-on components.</p>
  395. </li>
  396. </ul>
  397. <p>The following matrix describes the level of support committed for
  398. running each component on different operating system platforms.</p>
  399. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  400. <caption>Support Matrix</caption>
  401. <title>Support Matrix</title>
  402. <tr>
  403. <th>Operating System</th>
  404. <th>Client</th>
  405. <th>Server</th>
  406. <th>Native Client</th>
  407. <th>Contrib</th>
  408. </tr>
  409. <tr>
  410. <td>GNU/Linux</td>
  411. <td>Development and Production</td>
  412. <td>Development and Production</td>
  413. <td>Development and Production</td>
  414. <td>Development and Production</td>
  415. </tr>
  416. <tr>
  417. <td>Solaris</td>
  418. <td>Development and Production</td>
  419. <td>Development and Production</td>
  420. <td>Not Supported</td>
  421. <td>Not Supported</td>
  422. </tr>
  423. <tr>
  424. <td>FreeBSD</td>
  425. <td>Development and Production</td>
  426. <td>Development and Production</td>
  427. <td>Not Supported</td>
  428. <td>Not Supported</td>
  429. </tr>
  430. <tr>
  431. <td>Windows</td>
  432. <td>Development and Production</td>
  433. <td>Development and Production</td>
  434. <td>Not Supported</td>
  435. <td>Not Supported</td>
  436. </tr>
  437. <tr>
  438. <td>Mac OS X</td>
  439. <td>Development Only</td>
  440. <td>Development Only</td>
  441. <td>Not Supported</td>
  442. <td>Not Supported</td>
  443. </tr>
  444. </table>
  445. <p>For any operating system not explicitly mentioned as supported in
  446. the matrix, components may or may not work. The ZooKeeper community
  447. will fix obvious bugs that are reported for other platforms, but there
  448. is no full support.</p>
  449. <a name="sc_requiredSoftware"></a>
  450. <h4>Required Software </h4>
  451. <p>ZooKeeper runs in Java, release 1.7 or greater (JDK 7 or
  452. greater, FreeBSD support requires openjdk7). It runs as an
  453. <em>ensemble</em> of ZooKeeper servers. Three
  454. ZooKeeper servers is the minimum recommended size for an
  455. ensemble, and we also recommend that they run on separate
  456. machines. At Yahoo!, ZooKeeper is usually deployed on
  457. dedicated RHEL boxes, with dual-core processors, 2GB of RAM,
  458. and 80GB IDE hard drives.</p>
  459. <a name="sc_zkMulitServerSetup"></a>
  460. <h3 class="h4">Clustered (Multi-Server) Setup</h3>
  461. <p>For reliable ZooKeeper service, you should deploy ZooKeeper in a
  462. cluster known as an <em>ensemble</em>. As long as a majority
  463. of the ensemble are up, the service will be available. Because Zookeeper
  464. requires a majority, it is best to use an
  465. odd number of machines. For example, with four machines ZooKeeper can
  466. only handle the failure of a single machine; if two machines fail, the
  467. remaining two machines do not constitute a majority. However, with five
  468. machines ZooKeeper can handle the failure of two machines. </p>
  469. <div class="note">
  470. <div class="label">Note</div>
  471. <div class="content">
  472. <p>
  473. As mentioned in the
  474. <a href="zookeeperStarted.html">ZooKeeper Getting Started Guide</a>
  475. , a minimum of three servers are required for a fault tolerant
  476. clustered setup, and it is strongly recommended that you have an
  477. odd number of servers.
  478. </p>
  479. <p>Usually three servers is more than enough for a production
  480. install, but for maximum reliability during maintenance, you may
  481. wish to install five servers. With three servers, if you perform
  482. maintenance on one of them, you are vulnerable to a failure on one
  483. of the other two servers during that maintenance. If you have five
  484. of them running, you can take one down for maintenance, and know
  485. that you're still OK if one of the other four suddenly fails.
  486. </p>
  487. <p>Your redundancy considerations should include all aspects of
  488. your environment. If you have three ZooKeeper servers, but their
  489. network cables are all plugged into the same network switch, then
  490. the failure of that switch will take down your entire ensemble.
  491. </p>
  492. </div>
  493. </div>
  494. <p>Here are the steps to setting a server that will be part of an
  495. ensemble. These steps should be performed on every host in the
  496. ensemble:</p>
  497. <ol>
  498. <li>
  499. <p>Install the Java JDK. You can use the native packaging system
  500. for your system, or download the JDK from:</p>
  501. <p>
  502. <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a>
  503. </p>
  504. </li>
  505. <li>
  506. <p>Set the Java heap size. This is very important to avoid
  507. swapping, which will seriously degrade ZooKeeper performance. To
  508. determine the correct value, use load tests, and make sure you are
  509. well below the usage limit that would cause you to swap. Be
  510. conservative - use a maximum heap size of 3GB for a 4GB
  511. machine.</p>
  512. </li>
  513. <li>
  514. <p>Install the ZooKeeper Server Package. It can be downloaded
  515. from:
  516. </p>
  517. <p>
  518. <a href="http://zookeeper.apache.org/releases.html">
  519. http://zookeeper.apache.org/releases.html
  520. </a>
  521. </p>
  522. </li>
  523. <li>
  524. <p>Create a configuration file. This file can be called anything.
  525. Use the following settings as a starting point:</p>
  526. <pre class="code">
  527. tickTime=2000
  528. dataDir=/var/lib/zookeeper/
  529. clientPort=2181
  530. initLimit=5
  531. syncLimit=2
  532. server.1=zoo1:2888:3888
  533. server.2=zoo2:2888:3888
  534. server.3=zoo3:2888:3888</pre>
  535. <p>You can find the meanings of these and other configuration
  536. settings in the section <a href="#sc_configuration">Configuration Parameters</a>. A word
  537. though about a few here:</p>
  538. <p>Every machine that is part of the ZooKeeper ensemble should know
  539. about every other machine in the ensemble. You accomplish this with
  540. the series of lines of the form <strong>server.id=host:port:port</strong>. The parameters <strong>host</strong> and <strong>port</strong> are straightforward. You attribute the
  541. server id to each machine by creating a file named
  542. <span class="codefrag filename">myid</span>, one for each server, which resides in
  543. that server's data directory, as specified by the configuration file
  544. parameter <strong>dataDir</strong>.</p>
  545. </li>
  546. <li>
  547. <p>The myid file
  548. consists of a single line containing only the text of that machine's
  549. id. So <span class="codefrag filename">myid</span> of server 1 would contain the text
  550. "1" and nothing else. The id must be unique within the
  551. ensemble and should have a value between 1 and 255.</p>
  552. </li>
  553. <li>
  554. <p>Create an initialization marker file <span class="codefrag filename">initialize</span>
  555. in the same directory as <span class="codefrag filename">myid</span>. This file indicates
  556. that an empty data directory is expected. When present, an empty data base
  557. is created and the marker file deleted. When not present, an empty data
  558. directory will mean this peer will not have voting rights and it will not
  559. populate the data directory until it communicates with an active leader.
  560. Intended use is to only create this file when bringing up a new
  561. ensemble. </p>
  562. </li>
  563. <li>
  564. <p>If your configuration file is set up, you can start a
  565. ZooKeeper server:</p>
  566. <p>
  567. <span class="codefrag computeroutput">$ java -cp zookeeper.jar:lib/slf4j-api-1.7.5.jar:lib/slf4j-log4j12-1.7.5.jar:lib/log4j-1.2.17.jar:conf \
  568. org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg
  569. </span>
  570. </p>
  571. <p>QuorumPeerMain starts a ZooKeeper server,
  572. <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a>
  573. management beans are also registered which allows
  574. management through a JMX management console.
  575. The <a href="zookeeperJMX.html">ZooKeeper JMX
  576. document</a> contains details on managing ZooKeeper with JMX.
  577. </p>
  578. <p>See the script <em>bin/zkServer.sh</em>,
  579. which is included in the release, for an example
  580. of starting server instances.</p>
  581. </li>
  582. <li>
  583. <p>Test your deployment by connecting to the hosts:</p>
  584. <p>In Java, you can run the following command to execute
  585. simple operations:</p>
  586. <p>
  587. <span class="codefrag computeroutput">$ bin/zkCli.sh -server 127.0.0.1:2181</span>
  588. </p>
  589. </li>
  590. </ol>
  591. <a name="sc_singleAndDevSetup"></a>
  592. <h3 class="h4">Single Server and Developer Setup</h3>
  593. <p>If you want to setup ZooKeeper for development purposes, you will
  594. probably want to setup a single server instance of ZooKeeper, and then
  595. install either the Java or C client-side libraries and bindings on your
  596. development machine.</p>
  597. <p>The steps to setting up a single server instance are the similar
  598. to the above, except the configuration file is simpler. You can find the
  599. complete instructions in the <a href="zookeeperStarted.html#sc_InstallingSingleMode">Installing and
  600. Running ZooKeeper in Single Server Mode</a> section of the <a href="zookeeperStarted.html">ZooKeeper Getting Started
  601. Guide</a>.</p>
  602. <p>For information on installing the client side libraries, refer to
  603. the <a href="zookeeperProgrammers.html#Bindings">Bindings</a>
  604. section of the <a href="zookeeperProgrammers.html">ZooKeeper
  605. Programmer's Guide</a>.</p>
  606. </div>
  607. <a name="ch_administration"></a>
  608. <h2 class="h3">Administration</h2>
  609. <div class="section">
  610. <p>This section contains information about running and maintaining
  611. ZooKeeper and covers these topics: </p>
  612. <ul>
  613. <li>
  614. <p>
  615. <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
  616. </p>
  617. </li>
  618. <li>
  619. <p>
  620. <a href="#sc_provisioning">Provisioning</a>
  621. </p>
  622. </li>
  623. <li>
  624. <p>
  625. <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
  626. </p>
  627. </li>
  628. <li>
  629. <p>
  630. <a href="#sc_administering">Administering</a>
  631. </p>
  632. </li>
  633. <li>
  634. <p>
  635. <a href="#sc_maintenance">Maintenance</a>
  636. </p>
  637. </li>
  638. <li>
  639. <p>
  640. <a href="#sc_supervision">Supervision</a>
  641. </p>
  642. </li>
  643. <li>
  644. <p>
  645. <a href="#sc_monitoring">Monitoring</a>
  646. </p>
  647. </li>
  648. <li>
  649. <p>
  650. <a href="#sc_logging">Logging</a>
  651. </p>
  652. </li>
  653. <li>
  654. <p>
  655. <a href="#sc_troubleshooting">Troubleshooting</a>
  656. </p>
  657. </li>
  658. <li>
  659. <p>
  660. <a href="#sc_configuration">Configuration Parameters</a>
  661. </p>
  662. </li>
  663. <li>
  664. <p>
  665. <a href="#sc_zkCommands">ZooKeeper Commands</a>
  666. </p>
  667. </li>
  668. <li>
  669. <p>
  670. <a href="#sc_dataFileManagement">Data File Management</a>
  671. </p>
  672. </li>
  673. <li>
  674. <p>
  675. <a href="#sc_commonProblems">Things to Avoid</a>
  676. </p>
  677. </li>
  678. <li>
  679. <p>
  680. <a href="#sc_bestPractices">Best Practices</a>
  681. </p>
  682. </li>
  683. </ul>
  684. <a name="sc_designing"></a>
  685. <h3 class="h4">Designing a ZooKeeper Deployment</h3>
  686. <p>The reliability of ZooKeeper rests on two basic assumptions.</p>
  687. <ol>
  688. <li>
  689. <p> Only a minority of servers in a deployment
  690. will fail. <em>Failure</em> in this context
  691. means a machine crash, or some error in the network that
  692. partitions a server off from the majority.</p>
  693. </li>
  694. <li>
  695. <p> Deployed machines operate correctly. To
  696. operate correctly means to execute code correctly, to have
  697. clocks that work properly, and to have storage and network
  698. components that perform consistently.</p>
  699. </li>
  700. </ol>
  701. <p>The sections below contain considerations for ZooKeeper
  702. administrators to maximize the probability for these assumptions
  703. to hold true. Some of these are cross-machines considerations,
  704. and others are things you should consider for each and every
  705. machine in your deployment.</p>
  706. <a name="sc_CrossMachineRequirements"></a>
  707. <h4>Cross Machine Requirements</h4>
  708. <p>For the ZooKeeper service to be active, there must be a
  709. majority of non-failing machines that can communicate with
  710. each other. To create a deployment that can tolerate the
  711. failure of F machines, you should count on deploying 2xF+1
  712. machines. Thus, a deployment that consists of three machines
  713. can handle one failure, and a deployment of five machines can
  714. handle two failures. Note that a deployment of six machines
  715. can only handle two failures since three machines is not a
  716. majority. For this reason, ZooKeeper deployments are usually
  717. made up of an odd number of machines.</p>
  718. <p>To achieve the highest probability of tolerating a failure
  719. you should try to make machine failures independent. For
  720. example, if most of the machines share the same switch,
  721. failure of that switch could cause a correlated failure and
  722. bring down the service. The same holds true of shared power
  723. circuits, cooling systems, etc.</p>
  724. <a name="Single+Machine+Requirements"></a>
  725. <h4>Single Machine Requirements</h4>
  726. <p>If ZooKeeper has to contend with other applications for
  727. access to resources like storage media, CPU, network, or
  728. memory, its performance will suffer markedly. ZooKeeper has
  729. strong durability guarantees, which means it uses storage
  730. media to log changes before the operation responsible for the
  731. change is allowed to complete. You should be aware of this
  732. dependency then, and take great care if you want to ensure
  733. that ZooKeeper operations aren&rsquo;t held up by your media. Here
  734. are some things you can do to minimize that sort of
  735. degradation:
  736. </p>
  737. <ul>
  738. <li>
  739. <p>ZooKeeper's transaction log must be on a dedicated
  740. device. (A dedicated partition is not enough.) ZooKeeper
  741. writes the log sequentially, without seeking Sharing your
  742. log device with other processes can cause seeks and
  743. contention, which in turn can cause multi-second
  744. delays.</p>
  745. </li>
  746. <li>
  747. <p>Do not put ZooKeeper in a situation that can cause a
  748. swap. In order for ZooKeeper to function with any sort of
  749. timeliness, it simply cannot be allowed to swap.
  750. Therefore, make certain that the maximum heap size given
  751. to ZooKeeper is not bigger than the amount of real memory
  752. available to ZooKeeper. For more on this, see
  753. <a href="#sc_commonProblems">Things to Avoid</a>
  754. below. </p>
  755. </li>
  756. </ul>
  757. <a name="sc_provisioning"></a>
  758. <h3 class="h4">Provisioning</h3>
  759. <p></p>
  760. <a name="sc_strengthsAndLimitations"></a>
  761. <h3 class="h4">Things to Consider: ZooKeeper Strengths and Limitations</h3>
  762. <p></p>
  763. <a name="sc_administering"></a>
  764. <h3 class="h4">Administering</h3>
  765. <p></p>
  766. <a name="sc_maintenance"></a>
  767. <h3 class="h4">Maintenance</h3>
  768. <p>Little long term maintenance is required for a ZooKeeper
  769. cluster however you must be aware of the following:</p>
  770. <a name="Ongoing+Data+Directory+Cleanup"></a>
  771. <h4>Ongoing Data Directory Cleanup</h4>
  772. <p>The ZooKeeper <a href="#var_datadir">Data
  773. Directory</a> contains files which are a persistent copy
  774. of the znodes stored by a particular serving ensemble. These
  775. are the snapshot and transactional log files. As changes are
  776. made to the znodes these changes are appended to a
  777. transaction log, occasionally, when a log grows large, a
  778. snapshot of the current state of all znodes will be written
  779. to the filesystem. This snapshot supersedes all previous
  780. logs.
  781. </p>
  782. <p>A ZooKeeper server <strong>will not remove
  783. old snapshots and log files</strong> when using the default
  784. configuration (see autopurge below), this is the
  785. responsibility of the operator. Every serving environment is
  786. different and therefore the requirements of managing these
  787. files may differ from install to install (backup for example).
  788. </p>
  789. <p>The PurgeTxnLog utility implements a simple retention
  790. policy that administrators can use. The <a href="api/index.html">API docs</a> contains details on
  791. calling conventions (arguments, etc...).
  792. </p>
  793. <p>In the following example the last count snapshots and
  794. their corresponding logs are retained and the others are
  795. deleted. The value of &lt;count&gt; should typically be
  796. greater than 3 (although not required, this provides 3 backups
  797. in the unlikely event a recent log has become corrupted). This
  798. can be run as a cron job on the ZooKeeper server machines to
  799. clean up the logs daily.</p>
  800. <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>
  801. <p>Automatic purging of the snapshots and corresponding
  802. transaction logs was introduced in version 3.4.0 and can be
  803. enabled via the following configuration parameters <strong>autopurge.snapRetainCount</strong> and <strong>autopurge.purgeInterval</strong>. For more on
  804. this, see <a href="#sc_advancedConfiguration">Advanced Configuration</a>
  805. below.</p>
  806. <a name="Debug+Log+Cleanup+%28log4j%29"></a>
  807. <h4>Debug Log Cleanup (log4j)</h4>
  808. <p>See the section on <a href="#sc_logging">logging</a> in this document. It is
  809. expected that you will setup a rolling file appender using the
  810. in-built log4j feature. The sample configuration file in the
  811. release tar's conf/log4j.properties provides an example of
  812. this.
  813. </p>
  814. <a name="sc_supervision"></a>
  815. <h3 class="h4">Supervision</h3>
  816. <p>You will want to have a supervisory process that manages
  817. each of your ZooKeeper server processes (JVM). The ZK server is
  818. designed to be "fail fast" meaning that it will shutdown
  819. (process exit) if an error occurs that it cannot recover
  820. from. As a ZooKeeper serving cluster is highly reliable, this
  821. means that while the server may go down the cluster as a whole
  822. is still active and serving requests. Additionally, as the
  823. cluster is "self healing" the failed server once restarted will
  824. automatically rejoin the ensemble w/o any manual
  825. interaction.</p>
  826. <p>Having a supervisory process such as <a href="http://cr.yp.to/daemontools.html">daemontools</a> or
  827. <a href="http://en.wikipedia.org/wiki/Service_Management_Facility">SMF</a>
  828. (other options for supervisory process are also available, it's
  829. up to you which one you would like to use, these are just two
  830. examples) managing your ZooKeeper server ensures that if the
  831. process does exit abnormally it will automatically be restarted
  832. and will quickly rejoin the cluster.</p>
  833. <p>It is also recommended to configure the ZooKeeper server process to
  834. terminate and dump its heap if an
  835. <span class="codefrag computeroutput">OutOfMemoryError</span> occurs. This is achieved
  836. by launching the JVM with the following arguments on Linux and Windows
  837. respectively. The <span class="codefrag filename">zkServer.sh</span> and
  838. <span class="codefrag filename">zkServer.cmd</span> scripts that ship with ZooKeeper set
  839. these options.
  840. </p>
  841. <pre class="code">-XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError='kill -9 %p'</pre>
  842. <pre class="code">"-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f"</pre>
  843. <a name="sc_monitoring"></a>
  844. <h3 class="h4">Monitoring</h3>
  845. <p>The ZooKeeper service can be monitored in one of two
  846. 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
  847. your environment/requirements.</p>
  848. <a name="sc_logging"></a>
  849. <h3 class="h4">Logging</h3>
  850. <p>
  851. ZooKeeper uses <strong><a href="http://www.slf4j.org">SLF4J</a></strong>
  852. version 1.7.5 as its logging infrastructure. For backward compatibility it is bound to
  853. <strong>LOG4J</strong> but you can use
  854. <strong><a href="http://logback.qos.ch/">LOGBack</a></strong>
  855. or any other supported logging framework of your choice.
  856. </p>
  857. <p>
  858. The ZooKeeper default <span class="codefrag filename">log4j.properties</span>
  859. file resides in the <span class="codefrag filename">conf</span> directory. Log4j requires that
  860. <span class="codefrag filename">log4j.properties</span> either be in the working directory
  861. (the directory from which ZooKeeper is run) or be accessible from the classpath.
  862. </p>
  863. <p>For more information about SLF4J, see
  864. <a href="http://www.slf4j.org/manual.html">its manual</a>.</p>
  865. <p>For more information about LOG4J, see
  866. <a href="http://logging.apache.org/log4j/1.2/manual.html#defaultInit">Log4j Default Initialization Procedure</a>
  867. of the log4j manual.</p>
  868. <a name="sc_troubleshooting"></a>
  869. <h3 class="h4">Troubleshooting</h3>
  870. <dl>
  871. <dt>
  872. <term> Server not coming up because of file corruption</term>
  873. </dt>
  874. <dd>
  875. <p>A server might not be able to read its database and fail to come up because of
  876. some file corruption in the transaction logs of the ZooKeeper server. You will
  877. see some IOException on loading ZooKeeper database. In such a case,
  878. make sure all the other servers in your ensemble are up and working. Use "stat"
  879. command on the command port to see if they are in good health. After you have verified that
  880. all the other servers of the ensemble are up, you can go ahead and clean the database
  881. of the corrupt server. Delete all the files in datadir/version-2 and datalogdir/version-2/.
  882. Restart the server.
  883. </p>
  884. </dd>
  885. </dl>
  886. <a name="sc_configuration"></a>
  887. <h3 class="h4">Configuration Parameters</h3>
  888. <p>ZooKeeper's behavior is governed by the ZooKeeper configuration
  889. file. This file is designed so that the exact same file can be used by
  890. all the servers that make up a ZooKeeper server assuming the disk
  891. layouts are the same. If servers use different configuration files, care
  892. must be taken to ensure that the list of servers in all of the different
  893. configuration files match.</p>
  894. <div class="note">
  895. <div class="label">Note</div>
  896. <div class="content">
  897. <p>In 3.5.0 and later, some of these parameters should be placed in
  898. a dynamic configuration file. If they are placed in the static
  899. configuration file, ZooKeeper will automatically move them over to the
  900. dynamic configuration file. See <a href="zookeeperReconfig.html">
  901. Dynamic Reconfiguration</a> for more information.</p>
  902. </div>
  903. </div>
  904. <a name="sc_minimumConfiguration"></a>
  905. <h4>Minimum Configuration</h4>
  906. <p>Here are the minimum configuration keywords that must be defined
  907. in the configuration file:</p>
  908. <dl>
  909. <dt>
  910. <term>clientPort</term>
  911. </dt>
  912. <dd>
  913. <p>the port to listen for client connections; that is, the
  914. port that clients attempt to connect to.</p>
  915. </dd>
  916. <dt>
  917. <term>secureClientPort</term>
  918. </dt>
  919. <dd>
  920. <p>the port to listen on for secure client connections using SSL.
  921. <strong>clientPort</strong> specifies
  922. the port for plaintext connections while <strong>
  923. secureClientPort</strong> specifies the port for SSL
  924. connections. Specifying both enables mixed-mode while omitting
  925. either will disable that mode.</p>
  926. <p>Note that SSL feature will be enabled when user plugs-in
  927. zookeeper.serverCnxnFactory, zookeeper.clientCnxnSocket as Netty.</p>
  928. </dd>
  929. <dt>
  930. <term>dataDir</term>
  931. </dt>
  932. <dd>
  933. <p>the location where ZooKeeper will store the in-memory
  934. database snapshots and, unless specified otherwise, the
  935. transaction log of updates to the database.</p>
  936. <div class="note">
  937. <div class="label">Note</div>
  938. <div class="content">
  939. <p>Be careful where you put the transaction log. A
  940. dedicated transaction log device is key to consistent good
  941. performance. Putting the log on a busy device will adversely
  942. effect performance.</p>
  943. </div>
  944. </div>
  945. </dd>
  946. <dt>
  947. <term>tickTime</term>
  948. </dt>
  949. <dd>
  950. <p>the length of a single tick, which is the basic time unit
  951. used by ZooKeeper, as measured in milliseconds. It is used to
  952. regulate heartbeats, and timeouts. For example, the minimum
  953. session timeout will be two ticks.</p>
  954. </dd>
  955. </dl>
  956. <a name="sc_advancedConfiguration"></a>
  957. <h4>Advanced Configuration</h4>
  958. <p>The configuration settings in the section are optional. You can
  959. use them to further fine tune the behaviour of your ZooKeeper servers.
  960. Some can also be set using Java system properties, generally of the
  961. form <em>zookeeper.keyword</em>. The exact system
  962. property, when available, is noted below.</p>
  963. <dl>
  964. <dt>
  965. <term>dataLogDir</term>
  966. </dt>
  967. <dd>
  968. <p>(No Java system property)</p>
  969. <p>This option will direct the machine to write the
  970. transaction log to the <strong>dataLogDir</strong> rather than the <strong>dataDir</strong>. This allows a dedicated log
  971. device to be used, and helps avoid competition between logging
  972. and snapshots.</p>
  973. <div class="note">
  974. <div class="label">Note</div>
  975. <div class="content">
  976. <p>Having a dedicated log device has a large impact on
  977. throughput and stable latencies. It is highly recommended to
  978. dedicate a log device and set <strong>dataLogDir</strong> to point to a directory on
  979. that device, and then make sure to point <strong>dataDir</strong> to a directory
  980. <em>not</em> residing on that device.</p>
  981. </div>
  982. </div>
  983. </dd>
  984. <dt>
  985. <term>globalOutstandingLimit</term>
  986. </dt>
  987. <dd>
  988. <p>(Java system property: <strong>zookeeper.globalOutstandingLimit.</strong>)</p>
  989. <p>Clients can submit requests faster than ZooKeeper can
  990. process them, especially if there are a lot of clients. To
  991. prevent ZooKeeper from running out of memory due to queued
  992. requests, ZooKeeper will throttle clients so that there is no
  993. more than globalOutstandingLimit outstanding requests in the
  994. system. The default limit is 1,000.</p>
  995. </dd>
  996. <dt>
  997. <term>preAllocSize</term>
  998. </dt>
  999. <dd>
  1000. <p>(Java system property: <strong>zookeeper.preAllocSize</strong>)</p>
  1001. <p>To avoid seeks ZooKeeper allocates space in the
  1002. transaction log file in blocks of preAllocSize kilobytes. The
  1003. default block size is 64M. One reason for changing the size of
  1004. the blocks is to reduce the block size if snapshots are taken
  1005. more often. (Also, see <strong>snapCount</strong>).</p>
  1006. </dd>
  1007. <dt>
  1008. <term>snapCount</term>
  1009. </dt>
  1010. <dd>
  1011. <p>(Java system property: <strong>zookeeper.snapCount</strong>)</p>
  1012. <p>ZooKeeper records its transactions using snapshots and
  1013. a transaction log (think write-ahead log).The number of
  1014. transactions recorded in the transaction log before a snapshot
  1015. can be taken (and the transaction log rolled) is determined
  1016. by snapCount. In order to prevent all of the machines in the quorum
  1017. from taking a snapshot at the same time, each ZooKeeper server
  1018. will take a snapshot when the number of transactions in the transaction log
  1019. reaches a runtime generated random value in the [snapCount/2+1, snapCount]
  1020. range.The default snapCount is 100,000.</p>
  1021. </dd>
  1022. <dt>
  1023. <term>maxClientCnxns</term>
  1024. </dt>
  1025. <dd>
  1026. <p>(No Java system property)</p>
  1027. <p>Limits the number of concurrent connections (at the socket
  1028. level) that a single client, identified by IP address, may make
  1029. to a single member of the ZooKeeper ensemble. This is used to
  1030. prevent certain classes of DoS attacks, including file
  1031. descriptor exhaustion. The default is 60. Setting this to 0
  1032. entirely removes the limit on concurrent connections.</p>
  1033. </dd>
  1034. <dt>
  1035. <term>clientPortAddress</term>
  1036. </dt>
  1037. <dd>
  1038. <p>
  1039. <strong>New in 3.3.0:</strong> the
  1040. address (ipv4, ipv6 or hostname) to listen for client
  1041. connections; that is, the address that clients attempt
  1042. to connect to. This is optional, by default we bind in
  1043. such a way that any connection to the <strong>clientPort</strong> for any
  1044. address/interface/nic on the server will be
  1045. accepted.</p>
  1046. </dd>
  1047. <dt>
  1048. <term>minSessionTimeout</term>
  1049. </dt>
  1050. <dd>
  1051. <p>(No Java system property)</p>
  1052. <p>
  1053. <strong>New in 3.3.0:</strong> the
  1054. minimum session timeout in milliseconds that the server
  1055. will allow the client to negotiate. Defaults to 2 times
  1056. the <strong>tickTime</strong>.</p>
  1057. </dd>
  1058. <dt>
  1059. <term>maxSessionTimeout</term>
  1060. </dt>
  1061. <dd>
  1062. <p>(No Java system property)</p>
  1063. <p>
  1064. <strong>New in 3.3.0:</strong> the
  1065. maximum session timeout in milliseconds that the server
  1066. will allow the client to negotiate. Defaults to 20 times
  1067. the <strong>tickTime</strong>.</p>
  1068. </dd>
  1069. <dt>
  1070. <term>fsync.warningthresholdms</term>
  1071. </dt>
  1072. <dd>
  1073. <p>(Java system property: <strong>zookeeper.fsync.warningthresholdms</strong>)</p>
  1074. <p>
  1075. <strong>New in 3.3.4:</strong> A
  1076. warning message will be output to the log whenever an
  1077. fsync in the Transactional Log (WAL) takes longer than
  1078. this value. The values is specified in milliseconds and
  1079. defaults to 1000. This value can only be set as a
  1080. system property.</p>
  1081. </dd>
  1082. <dt>
  1083. <term>autopurge.snapRetainCount</term>
  1084. </dt>
  1085. <dd>
  1086. <p>(No Java system property)</p>
  1087. <p>
  1088. <strong>New in 3.4.0:</strong>
  1089. When enabled, ZooKeeper auto purge feature retains
  1090. the <strong>autopurge.snapRetainCount</strong> most
  1091. recent snapshots and the corresponding transaction logs in the
  1092. <strong>dataDir</strong> and <strong>dataLogDir</strong> respectively and deletes the rest.
  1093. Defaults to 3. Minimum value is 3.</p>
  1094. </dd>
  1095. <dt>
  1096. <term>autopurge.purgeInterval</term>
  1097. </dt>
  1098. <dd>
  1099. <p>(No Java system property)</p>
  1100. <p>
  1101. <strong>New in 3.4.0:</strong> The
  1102. time interval in hours for which the purge task has to
  1103. be triggered. Set to a positive integer (1 and above)
  1104. to enable the auto purging. Defaults to 0.</p>
  1105. </dd>
  1106. <dt>
  1107. <term>syncEnabled</term>
  1108. </dt>
  1109. <dd>
  1110. <p>(Java system property: <strong>zookeeper.observer.syncEnabled</strong>)</p>
  1111. <p>
  1112. <strong>New in 3.4.6, 3.5.0:</strong>
  1113. The observers now log transaction and write snapshot to disk
  1114. by default like the participants. This reduces the recovery time
  1115. of the observers on restart. Set to "false" to disable this
  1116. feature. Default is "true"</p>
  1117. </dd>
  1118. </dl>
  1119. <a name="sc_clusterOptions"></a>
  1120. <h4>Cluster Options</h4>
  1121. <p>The options in this section are designed for use with an ensemble
  1122. of servers -- that is, when deploying clusters of servers.</p>
  1123. <dl>
  1124. <dt>
  1125. <term>electionAlg</term>
  1126. </dt>
  1127. <dd>
  1128. <p>(No Java system property)</p>
  1129. <p>Election implementation to use. A value of "1" corresponds to the
  1130. non-authenticated UDP-based version of fast leader election, "2"
  1131. corresponds to the authenticated UDP-based version of fast
  1132. leader election, and "3" corresponds to TCP-based version of
  1133. fast leader election. Currently, algorithm 3 is the default.</p>
  1134. <div class="note">
  1135. <div class="label">Note</div>
  1136. <div class="content">
  1137. <p> The implementations of leader election 1, and 2 are now
  1138. <strong> deprecated </strong>. We have the intention
  1139. of removing them in the next release, at which point only the
  1140. FastLeaderElection will be available.
  1141. </p>
  1142. </div>
  1143. </div>
  1144. </dd>
  1145. <dt>
  1146. <term>initLimit</term>
  1147. </dt>
  1148. <dd>
  1149. <p>(No Java system property)</p>
  1150. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to
  1151. connect and sync to a leader. Increased this value as needed, if
  1152. the amount of data managed by ZooKeeper is large.</p>
  1153. </dd>
  1154. <dt>
  1155. <term>leaderServes</term>
  1156. </dt>
  1157. <dd>
  1158. <p>(Java system property: zookeeper.<strong>leaderServes</strong>)</p>
  1159. <p>Leader accepts client connections. Default value is "yes".
  1160. The leader machine coordinates updates. For higher update
  1161. throughput at the slight expense of read throughput the leader
  1162. can be configured to not accept clients and focus on
  1163. coordination. The default to this option is yes, which means
  1164. that a leader will accept client connections.</p>
  1165. <div class="note">
  1166. <div class="label">Note</div>
  1167. <div class="content">
  1168. <p>Turning on leader selection is highly recommended when
  1169. you have more than three ZooKeeper servers in an ensemble.</p>
  1170. </div>
  1171. </div>
  1172. </dd>
  1173. <dt>
  1174. <term>server.x=[hostname]:nnnnn[:nnnnn], etc</term>
  1175. </dt>
  1176. <dd>
  1177. <p>(No Java system property)</p>
  1178. <p>servers making up the ZooKeeper ensemble. When the server
  1179. starts up, it determines which server it is by looking for the
  1180. file <span class="codefrag filename">myid</span> in the data directory. That file
  1181. contains the server number, in ASCII, and it should match
  1182. <strong>x</strong> in <strong>server.x</strong> in the left hand side of this
  1183. setting.</p>
  1184. <p>The list of servers that make up ZooKeeper servers that is
  1185. used by the clients must match the list of ZooKeeper servers
  1186. that each ZooKeeper server has.</p>
  1187. <p>There are two port numbers <strong>nnnnn</strong>.
  1188. The first followers use to connect to the leader, and the second is for
  1189. leader election. If you want to test multiple servers on a single machine, then
  1190. different ports can be used for each server.</p>
  1191. </dd>
  1192. <dt>
  1193. <term>syncLimit</term>
  1194. </dt>
  1195. <dd>
  1196. <p>(No Java system property)</p>
  1197. <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to sync
  1198. with ZooKeeper. If followers fall too far behind a leader, they
  1199. will be dropped.</p>
  1200. </dd>
  1201. <dt>
  1202. <term>group.x=nnnnn[:nnnnn]</term>
  1203. </dt>
  1204. <dd>
  1205. <p>(No Java system property)</p>
  1206. <p>Enables a hierarchical quorum construction."x" is a group identifier
  1207. and the numbers following the "=" sign correspond to server identifiers.
  1208. The left-hand side of the assignment is a colon-separated list of server
  1209. identifiers. Note that groups must be disjoint and the union of all groups
  1210. must be the ZooKeeper ensemble. </p>
  1211. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1212. </p>
  1213. </dd>
  1214. <dt>
  1215. <term>weight.x=nnnnn</term>
  1216. </dt>
  1217. <dd>
  1218. <p>(No Java system property)</p>
  1219. <p>Used along with "group", it assigns a weight to a server when
  1220. forming quorums. Such a value corresponds to the weight of a server
  1221. when voting. There are a few parts of ZooKeeper that require voting
  1222. such as leader election and the atomic broadcast protocol. By default
  1223. the weight of server is 1. If the configuration defines groups, but not
  1224. weights, then a value of 1 will be assigned to all servers.
  1225. </p>
  1226. <p> You will find an example <a href="zookeeperHierarchicalQuorums.html">here</a>
  1227. </p>
  1228. </dd>
  1229. <dt>
  1230. <term>cnxTimeout</term>
  1231. </dt>
  1232. <dd>
  1233. <p>(Java system property: zookeeper.<strong>cnxTimeout</strong>)</p>
  1234. <p>Sets the timeout value for opening connections for leader election notifications.
  1235. Only applicable if you are using electionAlg 3.
  1236. </p>
  1237. <div class="note">
  1238. <div class="label">Note</div>
  1239. <div class="content">
  1240. <p>Default value is 5 seconds.</p>
  1241. </div>
  1242. </div>
  1243. </dd>
  1244. <dt>
  1245. <term>standaloneEnabled</term>
  1246. </dt>
  1247. <dd>
  1248. <p>(No Java system property)</p>
  1249. <p>
  1250. <strong>New in 3.5.0:</strong>
  1251. When set to false, a single server can be started in replicated
  1252. mode, a lone participant can run with observers, and a cluster
  1253. can reconfigure down to one node, and up from one node. The
  1254. default is true for backwards compatibility. It can be set
  1255. using QuorumPeerConfig's setStandaloneEnabled method or by
  1256. adding "standaloneEnabled=false" or "standaloneEnabled=true"
  1257. to a server's config file.
  1258. </p>
  1259. </dd>
  1260. <dt>
  1261. <term>reconfigEnabled</term>
  1262. </dt>
  1263. <dd>
  1264. <p>(No Java system property)</p>
  1265. <p>
  1266. <strong>New in 3.5.3:</strong>
  1267. This controls the enabling or disabling of
  1268. <a href="zookeeperReconfig.html">
  1269. Dynamic Reconfiguration</a> feature. When the feature
  1270. is enabled, users can perform reconfigure operations through
  1271. the ZooKeeper client API or through ZooKeeper command line tools
  1272. assuming users are authorized to perform such operations.
  1273. When the feature is disabled, no user, including the super user,
  1274. can perform a reconfiguration. Any attempt to reconfigure will return an error.
  1275. <strong>"reconfigEnabled"</strong> option can be set as
  1276. <strong>"reconfigEnabled=false"</strong> or
  1277. <strong>"reconfigEnabled=true"</strong>
  1278. to a server's config file, or using QuorumPeerConfig's
  1279. setReconfigEnabled method. The default value is false.
  1280. If present, the value should be consistent across every server in
  1281. the entire ensemble. Setting the value as true on some servers and false
  1282. on other servers will cause inconsistent behavior depending on which server
  1283. is elected as leader. If the leader has a setting of
  1284. <strong>"reconfigEnabled=true"</strong>, then the ensemble
  1285. will have reconfig feature enabled. If the leader has a setting of
  1286. <strong>"reconfigEnabled=false"</strong>, then the ensemble
  1287. will have reconfig feature disabled. It is thus recommended to have a consistent
  1288. value for <strong>"reconfigEnabled"</strong> across servers
  1289. in the ensemble.
  1290. </p>
  1291. </dd>
  1292. <dt>
  1293. <term>4lw.commands.whitelist</term>
  1294. </dt>
  1295. <dd>
  1296. <p>(Java system property: <strong>zookeeper.4lw.commands.whitelist</strong>)</p>
  1297. <p>
  1298. <strong>New in 3.5.3:</strong>
  1299. A list of comma separated <a href="#sc_4lw">Four Letter Words</a>
  1300. commands that user wants to use. A valid Four Letter Words
  1301. command must be put in this list else ZooKeeper server will
  1302. not enable the command.
  1303. By default the whitelist only contains "srvr" command
  1304. which zkServer.sh uses. The rest of four letter word commands are disabled
  1305. by default.
  1306. </p>
  1307. <p>Here's an example of the configuration that enables stat, ruok, conf, and isro
  1308. command while disabling the rest of Four Letter Words command:</p>
  1309. <pre class="code">
  1310. 4lw.commands.whitelist=stat, ruok, conf, isro
  1311. </pre>
  1312. <p>If you really need enable all four letter word commands by default, you can use
  1313. the asterisk option so you don't have to include every command one by one in the list.
  1314. As an example, this will enable all four letter word commands:
  1315. </p>
  1316. <pre class="code">
  1317. 4lw.commands.whitelist=*
  1318. </pre>
  1319. </dd>
  1320. <dt>
  1321. <term>tcpKeepAlive</term>
  1322. </dt>
  1323. <dd>
  1324. <p>(Java system property: <strong>zookeeper.tcpKeepAlive</strong>)</p>
  1325. <p>
  1326. <strong>New in 3.5.4:</strong>
  1327. Setting this to true sets the TCP keepAlive flag on the
  1328. sockets used by quorum members to perform elections.
  1329. This will allow for connections between quorum members to
  1330. remain up when there is network infrastructure that may
  1331. otherwise break them. Some NATs and firewalls may terminate
  1332. or lose state for long running or idle connections.</p>
  1333. <p> Enabling this option relies on OS level settings to work
  1334. properly, check your operating system's options regarding TCP
  1335. keepalive for more information. Defaults to
  1336. <strong>false</strong>.
  1337. </p>
  1338. </dd>
  1339. </dl>
  1340. <p></p>
  1341. <a name="sc_authOptions"></a>
  1342. <h4>Encryption, Authentication, Authorization Options</h4>
  1343. <p>The options in this section allow control over
  1344. encryption/authentication/authorization performed by the service.</p>
  1345. <dl>
  1346. <dt>
  1347. <term>DigestAuthenticationProvider.superDigest</term>
  1348. </dt>
  1349. <dd>
  1350. <p>(Java system property: <strong>zookeeper.DigestAuthenticationProvider.superDigest</strong>)</p>
  1351. <p>By default this feature is <strong>disabled</strong>
  1352. </p>
  1353. <p>
  1354. <strong>New in 3.2:</strong>
  1355. Enables a ZooKeeper ensemble administrator to access the
  1356. znode hierarchy as a "super" user. In particular no ACL
  1357. checking occurs for a user authenticated as
  1358. super.</p>
  1359. <p>org.apache.zookeeper.server.auth.DigestAuthenticationProvider
  1360. can be used to generate the superDigest, call it with
  1361. one parameter of "super:&lt;password&gt;". Provide the
  1362. generated "super:&lt;data&gt;" as the system property value
  1363. when starting each server of the ensemble.</p>
  1364. <p>When authenticating to a ZooKeeper server (from a
  1365. ZooKeeper client) pass a scheme of "digest" and authdata
  1366. of "super:&lt;password&gt;". Note that digest auth passes
  1367. the authdata in plaintext to the server, it would be
  1368. prudent to use this authentication method only on
  1369. localhost (not over the network) or over an encrypted
  1370. connection.</p>
  1371. </dd>
  1372. <dt>
  1373. <term>X509AuthenticationProvider.superUser</term>
  1374. </dt>
  1375. <dd>
  1376. <p>(Java system property: <strong>zookeeper.X509AuthenticationProvider.superUser</strong>)</p>
  1377. <p>The SSL-backed way to enable a ZooKeeper ensemble
  1378. administrator to access the znode hierarchy as a "super" user.
  1379. When this parameter is set to an X500 principal name, only an
  1380. authenticated client with that principal will be able to bypass
  1381. ACL checking and have full privileges to all znodes.</p>
  1382. </dd>
  1383. <dt>
  1384. <term>zookeeper.superUser</term>
  1385. </dt>
  1386. <dd>
  1387. <p>(Java system property: <strong>zookeeper.superUser</strong>)</p>
  1388. <p>Similar to <strong>zookeeper.X509AuthenticationProvider.superUser</strong>
  1389. but is generic for SASL based logins. It stores the name of
  1390. a user that can access the znode hierarchy as a "super" user.
  1391. </p>
  1392. </dd>
  1393. <dt>
  1394. <term>ssl.keyStore.location and ssl.keyStore.password</term>
  1395. </dt>
  1396. <dd>
  1397. <p>(Java system properties: <strong>
  1398. zookeeper.ssl.keyStore.location</strong> and <strong>zookeeper.ssl.keyStore.password</strong>)</p>
  1399. <p>Specifies the file path to a JKS containing the local
  1400. credentials to be used for SSL connections, and the
  1401. password to unlock the file.</p>
  1402. </dd>
  1403. <dt>
  1404. <term>ssl.trustStore.location and ssl.trustStore.password</term>
  1405. </dt>
  1406. <dd>
  1407. <p>(Java system properties: <strong>
  1408. zookeeper.ssl.trustStore.location</strong> and <strong>zookeeper.ssl.trustStore.password</strong>)</p>
  1409. <p>Specifies the file path to a JKS containing the remote
  1410. credentials to be used for SSL connections, and the
  1411. password to unlock the file.</p>
  1412. </dd>
  1413. <dt>
  1414. <term>ssl.authProvider</term>
  1415. </dt>
  1416. <dd>
  1417. <p>(Java system property: <strong>zookeeper.ssl.authProvider</strong>)</p>
  1418. <p>Specifies a subclass of <strong>
  1419. org.apache.zookeeper.auth.X509AuthenticationProvider</strong>
  1420. to use for secure client authentication. This is useful in
  1421. certificate key infrastructures that do not use JKS. It may be
  1422. necessary to extend <strong>javax.net.ssl.X509KeyManager
  1423. </strong> and <strong>javax.net.ssl.X509TrustManager</strong>
  1424. to get the desired behavior from the SSL stack. To configure the
  1425. ZooKeeper server to use the custom provider for authentication,
  1426. choose a scheme name for the custom AuthenticationProvider and
  1427. set the property <strong>zookeeper.authProvider.[scheme]
  1428. </strong> to the fully-qualified class name of the custom
  1429. implementation. This will load the provider into the ProviderRegistry.
  1430. Then set this property <strong>
  1431. zookeeper.ssl.authProvider=[scheme]</strong> and that provider
  1432. will be used for secure authentication.</p>
  1433. </dd>
  1434. </dl>
  1435. <a name="Experimental+Options%2FFeatures"></a>
  1436. <h4>Experimental Options/Features</h4>
  1437. <p>New features that are currently considered experimental.</p>
  1438. <dl>
  1439. <dt>
  1440. <term>Read Only Mode Server</term>
  1441. </dt>
  1442. <dd>
  1443. <p>(Java system property: <strong>readonlymode.enabled</strong>)</p>
  1444. <p>
  1445. <strong>New in 3.4.0:</strong>
  1446. Setting this value to true enables Read Only Mode server
  1447. support (disabled by default). ROM allows clients
  1448. sessions which requested ROM support to connect to the
  1449. server even when the server might be partitioned from
  1450. the quorum. In this mode ROM clients can still read
  1451. values from the ZK service, but will be unable to write
  1452. values and see changes from other clients. See
  1453. ZOOKEEPER-784 for more details.
  1454. </p>
  1455. </dd>
  1456. </dl>
  1457. <a name="Unsafe+Options"></a>
  1458. <h4>Unsafe Options</h4>
  1459. <p>The following options can be useful, but be careful when you use
  1460. them. The risk of each is explained along with the explanation of what
  1461. the variable does.</p>
  1462. <dl>
  1463. <dt>
  1464. <term>forceSync</term>
  1465. </dt>
  1466. <dd>
  1467. <p>(Java system property: <strong>zookeeper.forceSync</strong>)</p>
  1468. <p>Requires updates to be synced to media of the transaction
  1469. log before finishing processing the update. If this option is
  1470. set to no, ZooKeeper will not require updates to be synced to
  1471. the media.</p>
  1472. </dd>
  1473. <dt>
  1474. <term>jute.maxbuffer:</term>
  1475. </dt>
  1476. <dd>
  1477. <p>(Java system property:<strong>
  1478. jute.maxbuffer</strong>)</p>
  1479. <p>This option can only be set as a Java system property.
  1480. There is no zookeeper prefix on it. It specifies the maximum
  1481. size of the data that can be stored in a znode. The default is
  1482. 0xfffff, or just under 1M. If this option is changed, the system
  1483. property must be set on all servers and clients otherwise
  1484. problems will arise. This is really a sanity check. ZooKeeper is
  1485. designed to store data on the order of kilobytes in size.</p>
  1486. </dd>
  1487. <dt>
  1488. <term>skipACL</term>
  1489. </dt>
  1490. <dd>
  1491. <p>(Java system property: <strong>zookeeper.skipACL</strong>)</p>
  1492. <p>Skips ACL checks. This results in a boost in throughput,
  1493. but opens up full access to the data tree to everyone.</p>
  1494. </dd>
  1495. <dt>
  1496. <term>quorumListenOnAllIPs</term>
  1497. </dt>
  1498. <dd>
  1499. <p>When set to true the ZooKeeper server will listen
  1500. for connections from its peers on all available IP addresses,
  1501. and not only the address configured in the server list of the
  1502. configuration file. It affects the connections handling the
  1503. ZAB protocol and the Fast Leader Election protocol. Default
  1504. value is <strong>false</strong>.</p>
  1505. </dd>
  1506. </dl>
  1507. <a name="Disabling+data+directory+autocreation"></a>
  1508. <h4>Disabling data directory autocreation</h4>
  1509. <p>
  1510. <strong>New in 3.5:</strong> The default
  1511. behavior of a ZooKeeper server is to automatically create the
  1512. data directory (specified in the configuration file) when
  1513. started if that directory does not already exist. This can be
  1514. inconvenient and even dangerous in some cases. Take the case
  1515. where a configuration change is made to a running server,
  1516. wherein the <strong>dataDir</strong> parameter
  1517. is accidentally changed. When the ZooKeeper server is
  1518. restarted it will create this non-existent directory and begin
  1519. serving - with an empty znode namespace. This scenario can
  1520. result in an effective "split brain" situation (i.e. data in
  1521. both the new invalid directory and the original valid data
  1522. store). As such is would be good to have an option to turn off
  1523. this autocreate behavior. In general for production
  1524. environments this should be done, unfortunately however the
  1525. default legacy behavior cannot be changed at this point and
  1526. therefore this must be done on a case by case basis. This is
  1527. left to users and to packagers of ZooKeeper distributions.
  1528. </p>
  1529. <p>When running <strong>zkServer.sh</strong> autocreate can be disabled
  1530. by setting the environment variable <strong>ZOO_DATADIR_AUTOCREATE_DISABLE</strong> to 1.
  1531. When running ZooKeeper servers directly from class files this
  1532. can be accomplished by setting <strong>zookeeper.datadir.autocreate=false</strong> on
  1533. the java command line, i.e. <strong>-Dzookeeper.datadir.autocreate=false</strong>
  1534. </p>
  1535. <p>When this feature is disabled, and the ZooKeeper server
  1536. determines that the required directories do not exist it will
  1537. generate an error and refuse to start.
  1538. </p>
  1539. <p>A new script <strong>zkServer-initialize.sh</strong> is provided to
  1540. support this new feature. If autocreate is disabled it is
  1541. necessary for the user to first install ZooKeeper, then create
  1542. the data directory (and potentially txnlog directory), and
  1543. then start the server. Otherwise as mentioned in the previous
  1544. paragraph the server will not start. Running <strong>zkServer-initialize.sh</strong> will create the
  1545. required directories, and optionally setup the myid file
  1546. (optional command line parameter). This script can be used
  1547. even if the autocreate feature itself is not used, and will
  1548. likely be of use to users as this (setup, including creation
  1549. of the myid file) has been an issue for users in the past.
  1550. Note that this script ensures the data directories exist only,
  1551. it does not create a config file, but rather requires a config
  1552. file to be available in order to execute.
  1553. </p>
  1554. <a name="sc_db_existence_validation"></a>
  1555. <h4>Enabling db existence validation</h4>
  1556. <p>
  1557. <strong>New in 3.6.0:</strong> The default
  1558. behavior of a ZooKeeper server on startup when no data tree
  1559. is found is to set zxid to zero and join the quorum as a
  1560. voting member. This can be dangerous if some event (e.g. a
  1561. rogue 'rm -rf') has removed the data directory while the
  1562. server was down since this server may help elect a leader
  1563. that is missing transactions. Enabling db existence validation
  1564. will change the behavior on startup when no data tree is
  1565. found: the server joins the ensemble as a non-voting participant
  1566. until it is able to sync with the leader and acquire an up-to-date
  1567. version of the ensemble data. To indicate an empty data tree is
  1568. expected (ensemble creation), the user should place a file
  1569. 'initialize' in the same directory as 'myid'. This file will
  1570. be detected and deleted by the server on startup.
  1571. </p>
  1572. <p> Initialization validation can be enabled when running
  1573. ZooKeeper servers directly from class files by setting
  1574. <strong>zookeeper.db.autocreate=false</strong>
  1575. on the java command line, i.e.
  1576. <strong>-Dzookeeper.db.autocreate=false</strong>.
  1577. Running <strong>zkServer-initialize.sh</strong>
  1578. will create the required initialization file.
  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.6.0:</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.6.0:</strong> The
  1651. maximum number of container and ttl 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 or three 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">initialize</span> - presence indicates lack of
  2045. data tree is expected. Cleaned up once data tree is created.</p>
  2046. </li>
  2047. <li>
  2048. <p>
  2049. <span class="codefrag filename">snapshot.&lt;zxid&gt;</span> - holds the fuzzy
  2050. snapshot of a data tree.</p>
  2051. </li>
  2052. </ul>
  2053. <p>Each ZooKeeper server has a unique id. This id is used in two
  2054. places: the <span class="codefrag filename">myid</span> file and the configuration file.
  2055. The <span class="codefrag filename">myid</span> file identifies the server that
  2056. corresponds to the given data directory. The configuration file lists
  2057. the contact information for each server identified by its server id.
  2058. When a ZooKeeper server instance starts, it reads its id from the
  2059. <span class="codefrag filename">myid</span> file and then, using that id, reads from the
  2060. configuration file, looking up the port on which it should
  2061. listen.</p>
  2062. <p>The <span class="codefrag filename">snapshot</span> files stored in the data
  2063. directory are fuzzy snapshots in the sense that during the time the
  2064. ZooKeeper server is taking the snapshot, updates are occurring to the
  2065. data tree. The suffix of the <span class="codefrag filename">snapshot</span> file names
  2066. is the <em>zxid</em>, the ZooKeeper transaction id, of the
  2067. last committed transaction at the start of the snapshot. Thus, the
  2068. snapshot includes a subset of the updates to the data tree that
  2069. occurred while the snapshot was in process. The snapshot, then, may
  2070. not correspond to any data tree that actually existed, and for this
  2071. reason we refer to it as a fuzzy snapshot. Still, ZooKeeper can
  2072. recover using this snapshot because it takes advantage of the
  2073. idempotent nature of its updates. By replaying the transaction log
  2074. against fuzzy snapshots ZooKeeper gets the state of the system at the
  2075. end of the log.</p>
  2076. <a name="The+Log+Directory"></a>
  2077. <h4>The Log Directory</h4>
  2078. <p>The Log Directory contains the ZooKeeper transaction logs.
  2079. Before any update takes place, ZooKeeper ensures that the transaction
  2080. that represents the update is written to non-volatile storage. A new
  2081. log file is started each time a snapshot is begun. The log file's
  2082. suffix is the first zxid written to that log.</p>
  2083. <a name="sc_filemanagement"></a>
  2084. <h4>File Management</h4>
  2085. <p>The format of snapshot and log files does not change between
  2086. standalone ZooKeeper servers and different configurations of
  2087. replicated ZooKeeper servers. Therefore, you can pull these files from
  2088. a running replicated ZooKeeper server to a development machine with a
  2089. stand-alone ZooKeeper server for trouble shooting.</p>
  2090. <p>Using older log and snapshot files, you can look at the previous
  2091. state of ZooKeeper servers and even restore that state. The
  2092. LogFormatter class allows an administrator to look at the transactions
  2093. in a log.</p>
  2094. <p>The ZooKeeper server creates snapshot and log files, but
  2095. never deletes them. The retention policy of the data and log
  2096. files is implemented outside of the ZooKeeper server. The
  2097. server itself only needs the latest complete fuzzy snapshot
  2098. and the log files from the start of that snapshot. See the
  2099. <a href="#sc_maintenance">maintenance</a> section in
  2100. this document for more details on setting a retention policy
  2101. and maintenance of ZooKeeper storage.
  2102. </p>
  2103. <div class="note">
  2104. <div class="label">Note</div>
  2105. <div class="content">
  2106. <p>The data stored in these files is not encrypted. In the case of
  2107. storing sensitive data in ZooKeeper, necessary measures need to be
  2108. taken to prevent unauthorized access. Such measures are external to
  2109. ZooKeeper (e.g., control access to the files) and depend on the
  2110. individual settings in which it is being deployed. </p>
  2111. </div>
  2112. </div>
  2113. <a name="sc_commonProblems"></a>
  2114. <h3 class="h4">Things to Avoid</h3>
  2115. <p>Here are some common problems you can avoid by configuring
  2116. ZooKeeper correctly:</p>
  2117. <dl>
  2118. <dt>
  2119. <term>inconsistent lists of servers</term>
  2120. </dt>
  2121. <dd>
  2122. <p>The list of ZooKeeper servers used by the clients must match
  2123. the list of ZooKeeper servers that each ZooKeeper server has.
  2124. Things work okay if the client list is a subset of the real list,
  2125. but things will really act strange if clients have a list of
  2126. ZooKeeper servers that are in different ZooKeeper clusters. Also,
  2127. the server lists in each Zookeeper server configuration file
  2128. should be consistent with one another.</p>
  2129. </dd>
  2130. <dt>
  2131. <term>incorrect placement of transaction log</term>
  2132. </dt>
  2133. <dd>
  2134. <p>The most performance critical part of ZooKeeper is the
  2135. transaction log. ZooKeeper syncs transactions to media before it
  2136. returns a response. A dedicated transaction log device is key to
  2137. consistent good performance. Putting the log on a busy device will
  2138. adversely effect performance. If you only have one storage device,
  2139. put trace files on NFS and increase the snapshotCount; it doesn't
  2140. eliminate the problem, but it should mitigate it.</p>
  2141. </dd>
  2142. <dt>
  2143. <term>incorrect Java heap size</term>
  2144. </dt>
  2145. <dd>
  2146. <p>You should take special care to set your Java max heap size
  2147. correctly. In particular, you should not create a situation in
  2148. which ZooKeeper swaps to disk. The disk is death to ZooKeeper.
  2149. Everything is ordered, so if processing one request swaps the
  2150. disk, all other queued requests will probably do the same. the
  2151. disk. DON'T SWAP.</p>
  2152. <p>Be conservative in your estimates: if you have 4G of RAM, do
  2153. not set the Java max heap size to 6G or even 4G. For example, it
  2154. is more likely you would use a 3G heap for a 4G machine, as the
  2155. operating system and the cache also need memory. The best and only
  2156. recommend practice for estimating the heap size your system needs
  2157. is to run load tests, and then make sure you are well below the
  2158. usage limit that would cause the system to swap.</p>
  2159. </dd>
  2160. <dt>
  2161. <term>Publicly accessible deployment</term>
  2162. </dt>
  2163. <dd>
  2164. <p>
  2165. A ZooKeeper ensemble is expected to operate in a trusted computing environment.
  2166. It is thus recommended to deploy ZooKeeper behind a firewall.
  2167. </p>
  2168. </dd>
  2169. </dl>
  2170. <a name="sc_bestPractices"></a>
  2171. <h3 class="h4">Best Practices</h3>
  2172. <p>For best results, take note of the following list of good
  2173. Zookeeper practices:</p>
  2174. <p>For multi-tenant installations see the <a href="zookeeperProgrammers.html#ch_zkSessions">section</a>
  2175. detailing ZooKeeper "chroot" support, this can be very useful
  2176. when deploying many applications/services interfacing to a
  2177. single ZooKeeper cluster.</p>
  2178. </div>
  2179. <p align="right">
  2180. <font size="-2"></font>
  2181. </p>
  2182. </div>
  2183. <!--+
  2184. |end content
  2185. +-->
  2186. <div class="clearboth">&nbsp;</div>
  2187. </div>
  2188. <div id="footer">
  2189. <!--+
  2190. |start bottomstrip
  2191. +-->
  2192. <div class="lastmodified">
  2193. <script type="text/javascript"><!--
  2194. document.write("Last Published: " + document.lastModified);
  2195. // --></script>
  2196. </div>
  2197. <div class="copyright">
  2198. Copyright &copy;
  2199. <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  2200. </div>
  2201. <!--+
  2202. |end bottomstrip
  2203. +-->
  2204. </div>
  2205. </body>
  2206. </html>