zookeeperAdmin.html 81 KB

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