zookeeperAdmin.html 65 KB

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