zookeeperAdmin.html 81 KB

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