123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta content="Apache Forrest" name="Generator">
- <meta name="Forrest-version" content="0.8">
- <meta name="Forrest-skin-name" content="pelt">
- <title>ZooKeeper Administrator's Guide</title>
- <link type="text/css" href="skin/basic.css" rel="stylesheet">
- <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
- <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
- <link type="text/css" href="skin/profile.css" rel="stylesheet">
- <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>
- <link rel="shortcut icon" href="images/favicon.ico">
- </head>
- <body onload="init()">
- <script type="text/javascript">ndeSetTextSize();</script>
- <div id="top">
- <!--+
- |breadtrail
- +-->
- <div class="breadtrail">
- <a href="http://www.apache.org/">Apache</a> > <a href="http://hadoop.apache.org/">Hadoop</a> > <a href="http://hadoop.apache.org/zookeeper/">ZooKeeper</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
- </div>
- <!--+
- |header
- +-->
- <div class="header">
- <!--+
- |start group logo
- +-->
- <div class="grouplogo">
- <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
- </div>
- <!--+
- |end group logo
- +-->
- <!--+
- |start Project Logo
- +-->
- <div class="projectlogo">
- <a href="http://hadoop.apache.org/zookeeper/"><img class="logoImage" alt="ZooKeeper" src="images/zookeeper_small.gif" title="The Hadoop database"></a>
- </div>
- <!--+
- |end Project Logo
- +-->
- <!--+
- |start Search
- +-->
- <div class="searchbox">
- <form action="http://www.google.com/search" method="get" class="roundtopsmall">
- <input value="hadoop.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">
- <input name="Search" value="Search" type="submit">
- </form>
- </div>
- <!--+
- |end search
- +-->
- <!--+
- |start Tabs
- +-->
- <ul id="tabs">
- <li>
- <a class="unselected" href="http://hadoop.apache.org/zookeeper/">Project</a>
- </li>
- <li>
- <a class="unselected" href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
- </li>
- <li class="current">
- <a class="selected" href="index.html">ZooKeeper Documentation</a>
- </li>
- </ul>
- <!--+
- |end Tabs
- +-->
- </div>
- </div>
- <div id="main">
- <div id="publishedStrip">
- <!--+
- |start Subtabs
- +-->
- <div id="level2tabs"></div>
- <!--+
- |end Endtabs
- +-->
- <script type="text/javascript"><!--
- document.write("Last Published: " + document.lastModified);
- // --></script>
- </div>
- <!--+
- |breadtrail
- +-->
- <div class="breadtrail">
-
- </div>
- <!--+
- |start Menu, mainarea
- +-->
- <!--+
- |start Menu
- +-->
- <div id="menu">
- <div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Overview</div>
- <div id="menu_1.1" class="menuitemgroup">
- <div class="menuitem">
- <a href="index.html">Welcome</a>
- </div>
- <div class="menuitem">
- <a href="zookeeperOver.html">Overview</a>
- </div>
- <div class="menuitem">
- <a href="zookeeperStarted.html">Getting Started</a>
- </div>
- </div>
- <div onclick="SwitchMenu('menu_1.2', 'skin/')" id="menu_1.2Title" class="menutitle">Developer</div>
- <div id="menu_1.2" class="menuitemgroup">
- <div class="menuitem">
- <a href="api/index.html">API Docs</a>
- </div>
- <div class="menuitem">
- <a href="zookeeperProgrammers.html">Programmer's Guide</a>
- </div>
- <div class="menuitem">
- <a href="javaExample.html">Java Example</a>
- </div>
- <div class="menuitem">
- <a href="zookeeperTutorial.html">Barrier and Queue Tutorial</a>
- </div>
- <div class="menuitem">
- <a href="recipes.html">Recipes</a>
- </div>
- </div>
- <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 & Ops</div>
- <div id="menu_selected_1.3" class="selectedmenuitemgroup" style="display: block;">
- <div class="menupage">
- <div class="menupagetitle">Administrator's Guide</div>
- </div>
- </div>
- <div onclick="SwitchMenu('menu_1.4', 'skin/')" id="menu_1.4Title" class="menutitle">Contributor</div>
- <div id="menu_1.4" class="menuitemgroup">
- <div class="menuitem">
- <a href="zookeeperInternals.html">ZooKeeper Internals</a>
- </div>
- </div>
- <div onclick="SwitchMenu('menu_1.5', 'skin/')" id="menu_1.5Title" class="menutitle">Informal Documentation</div>
- <div id="menu_1.5" class="menuitemgroup">
- <div class="menuitem">
- <a href="http://wiki.apache.org/hadoop/ZooKeeper">Wiki</a>
- </div>
- <div class="menuitem">
- <a href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ">FAQ</a>
- </div>
- <div class="menuitem">
- <a href="http://hadoop.apache.org/zookeeper/mailing_lists.html">Mailing Lists</a>
- </div>
- <div class="menuitem">
- <a href="zookeeperOtherInfo.html">Other Info</a>
- </div>
- </div>
- <div id="credit"></div>
- <div id="roundbottom">
- <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
- <!--+
- |alternative credits
- +-->
- <div id="credit2"></div>
- </div>
- <!--+
- |end Menu
- +-->
- <!--+
- |start content
- +-->
- <div id="content">
- <div title="Portable Document Format" class="pdflink">
- <a class="dida" href="zookeeperAdmin.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
- PDF</a>
- </div>
- <h1>ZooKeeper Administrator's Guide</h1>
- <h3>A Guide to Deployment and Administration</h3>
- <div id="minitoc-area">
- <ul class="minitoc">
- <li>
- <a href="#ch_deployment">Deployment</a>
- <ul class="minitoc">
- <li>
- <a href="#sc_systemReq">System Requirements</a>
- </li>
- <li>
- <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
- </li>
- <li>
- <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
- </li>
- </ul>
- </li>
- <li>
- <a href="#ch_administration">Administration</a>
- <ul class="minitoc">
- <li>
- <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
- </li>
- <li>
- <a href="#sc_provisioning">Provisioning</a>
- </li>
- <li>
- <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
- </li>
- <li>
- <a href="#sc_administering">Administering</a>
- </li>
- <li>
- <a href="#sc_monitoring">Monitoring</a>
- </li>
- <li>
- <a href="#sc_logging">Logging</a>
- </li>
- <li>
- <a href="#sc_troubleshooting">Troubleshooting</a>
- </li>
- <li>
- <a href="#sc_configuration">Configuration Parameters</a>
- <ul class="minitoc">
- <li>
- <a href="#sc_minimumConfiguration">Minimum Configuration</a>
- </li>
- <li>
- <a href="#sc_advancedConfiguration">Advanced Configuration</a>
- </li>
- <li>
- <a href="#sc_clusterOptions">Cluster Options</a>
- </li>
- <li>
- <a href="#Unsafe+Options">Unsafe Options</a>
- </li>
- </ul>
- </li>
- <li>
- <a href="#sc_zkCommands">ZooKeeper Commands: The Four Letter Words</a>
- </li>
- <li>
- <a href="#sc_dataFileManagement">Data File Management</a>
- <ul class="minitoc">
- <li>
- <a href="#The+Data+Directory">The Data Directory</a>
- </li>
- <li>
- <a href="#The+Log+Directory">The Log Directory</a>
- </li>
- <li>
- <a href="#File+Management">File Management</a>
- </li>
- </ul>
- </li>
- <li>
- <a href="#sc_commonProblems">Things to Avoid</a>
- </li>
- <li>
- <a href="#sc_bestPractices">Best Practices</a>
- </li>
- </ul>
- </li>
- </ul>
- </div>
-
-
-
-
- <a name="N1000B"></a><a name="ch_deployment"></a>
- <h2 class="h3">Deployment</h2>
- <div class="section">
- <p>This section contains information about deploying Zookeeper and
- covers these topics:</p>
- <ul>
-
- <li>
-
- <p>
- <a href="#sc_systemReq">System Requirements</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_zkMulitServerSetup">Clustered (Multi-Server) Setup</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_singleAndDevSetup">Single Server and Developer Setup</a>
- </p>
-
- </li>
-
- </ul>
- <p>The first two sections assume you are interested in installing
- ZooKeeper in a production environment such as a datacenter. The final
- section covers situations in which you are setting up ZooKeeper on a
- limited basis - for evaluation, testing, or development - but not in a
- production environment.</p>
- <a name="N10032"></a><a name="sc_systemReq"></a>
- <h3 class="h4">System Requirements</h3>
- <p>ZooKeeper runs in Java, release 1.5 or greater (JDK 5 or greater).
- It runs as group of hosts called a quorum. Three ZooKeeper hosts per
- quorum is the minimum recommended quorum size. At Yahoo!, ZooKeeper is
- usually deployed on dedicated RHEL boxes, with dual-core processors, 2GB
- of RAM, and 80GB IDE harddrives.</p>
- <a name="N1003C"></a><a name="sc_zkMulitServerSetup"></a>
- <h3 class="h4">Clustered (Multi-Server) Setup</h3>
- <p>For reliable ZooKeeper service, you should deploy ZooKeeper in a
- cluster known as a <em>quorum</em>. As long as a majority
- of the quorum are up, the service will be available. Because Zookeeper
- requires a majority, it is best to use an
- odd number of machines. For example, with four machines ZooKeeper can
- only handle the failure of a single machine; if two machines fail, the
- remaining two machines do not constitute a majority. However, with five
- machines ZooKeeper can handle the failure of two machines. </p>
- <p>Here are the steps to setting a server that will be part of a
- quorum. These steps should be performed on every host in the
- quorum:</p>
- <ol>
-
- <li>
-
- <p>Install the Java JDK. You can use the native packaging system
- for your system, or download the JDK from:</p>
-
- <p>
- <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a>
- </p>
-
- </li>
-
- <li>
-
- <p>Set the Java heap size. This is very important to avoid
- swapping, which will seriously degrade ZooKeeper performance. To
- determine the correct value, use load tests, and make sure you are
- well below the usage limit that would cause you to swap. Be
- conservative - use a maximum heap size of 3GB for a 4GB
- machine.</p>
-
- </li>
-
- <li>
-
- <p>Install the ZooKeeper Server Package. It can be downloaded
- from:
- </p>
-
- <p>
-
- <a href="http://hadoop.apache.org/zookeeper/releases.html">
- http://hadoop.apache.org/zookeeper/releases.html
- </a>
-
- </p>
-
- </li>
-
- <li>
-
- <p>Create a configuration file. This file can be called anything.
- Use the following settings as a starting point:</p>
-
- <p>
- <span class="codefrag computeroutput">
- tickTime=2000
- dataDir=/var/zookeeper/
- clientPort=2181
- initLimit=5
- syncLimit=2
- server.1=zoo1:2888
- server.2=zoo2:2888
- server.3=zoo3:2888</span>
- </p>
-
- <p>You can find the meanings of these and other configuration
- settings in the section <a href="#sc_configuration">Configuration Parameters</a>. A word
- though about a few here:</p>
-
- <p>Every machine that is part of the ZooKeeper quorum should know
- about every other machine in the quorum. You accomplish this with
- the series of lines of the form <strong>server.id=host:port</strong>. The integers <strong>host</strong> and <strong>port</strong> are straightforward. You attribute the
- server id to each machine by creating a file named
- <span class="codefrag filename">myid</span>, one for each server, which resides in
- that server's data directory, as specified by the configuration file
- parameter <strong>dataDir</strong>. The myid file
- consists of a single line containing only the text of that machine's
- id. So <span class="codefrag filename">myid</span> of server 1 would contain the text
- "1" and nothing else. The id must be unique within the
- quorum.</p>
-
- </li>
-
- <li>
-
- <p>If your configuration file is set up, you can start
- ZooKeeper:</p>
-
- <p>
- <span class="codefrag computeroutput">$ java -cp zookeeper-dev.jar:java/lib/log4j-1.2.15.jar:conf \
- org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg</span>
- </p>
-
- </li>
-
- <li>
-
- <p>Test your deployment by connecting to the hosts:</p>
-
- <ul>
-
- <li>
-
- <p>In Java, you can run the following command to execute
- simple operations:</p>
-
- <p>
- <span class="codefrag computeroutput">$ java -cp zookeeper.jar:java/lib/log4j-1.2.15.jar:conf \
- org.apache.zookeeper.ZooKeeperMain 127.0.0.1:2181</span>
- </p>
-
- </li>
-
- <li>
-
- <p>In C, you can compile either the single threaded client or
- the multithreaded client: or n the c subdirectory in the
- ZooKeeper sources. This compiles the single threaded
- client:</p>
-
- <p>
- <span class="codefrag computeroutput">$ _make cli_st_</span>
- </p>
-
- <p>And this compiles the mulithreaded client:</p>
-
- <p>
- <span class="codefrag computeroutput">$ _make cli_mt_</span>
- </p>
-
- </li>
-
- </ul>
-
- <p>Running either program gives you a shell in which to execute
- simple file-system-like operations. To connect to ZooKeeper with the
- multithreaded client, for example, you would run:</p>
-
- <p>
- <span class="codefrag computeroutput">$ cli_mt 127.0.0.1:2181</span>
- </p>
-
- </li>
-
- </ol>
- <a name="N100D0"></a><a name="sc_singleAndDevSetup"></a>
- <h3 class="h4">Single Server and Developer Setup</h3>
- <p>If you want to setup ZooKeeper for development purposes, you will
- probably want to setup a single server instance of ZooKeeper, and then
- install either the Java or C client-side libraries and bindings on your
- development machine.</p>
- <p>The steps to setting up a single server instance are the similar
- to the above, except the configuration file is simpler. You can find the
- complete instructions in the <a href="zookeeperStarted.html#sc_InstallingSingleMode">Installing and
- Running ZooKeeper in Single Server Mode</a> section of the <a href="zookeeperStarted.html">ZooKeeper Getting Started
- Guide</a>.</p>
- <p>For information on installing the client side libraries, refer to
- the <a href="zookeeperProgrammers.html#Bindings">Bindings</a>
- section of the <a href="zookeeperProgrammers.html">ZooKeeper
- Programmer's Guide</a>.</p>
- </div>
-
- <a name="N100F1"></a><a name="ch_administration"></a>
- <h2 class="h3">Administration</h2>
- <div class="section">
- <p>This section contains information about running and maintaining
- ZooKeeper and covers these topics: </p>
- <ul>
-
- <li>
-
- <p>
- <a href="#sc_designing">Designing a ZooKeeper Deployment</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_provisioning">Provisioning</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_strengthsAndLimitations">Things to Consider: ZooKeeper Strengths and Limitations</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_administering">Administering</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_monitoring">Monitoring</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_logging">Logging</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_troubleshooting">Troubleshooting</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_configuration">Configuration Parameters</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_zkCommands">ZooKeeper Commands: The Four Letter Words</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_dataFileManagement">Data File Management</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_commonProblems">Things to Avoid</a>
- </p>
-
- </li>
-
- <li>
-
- <p>
- <a href="#sc_bestPractices">Best Practices</a>
- </p>
-
- </li>
-
- </ul>
- <a name="N1015D"></a><a name="sc_designing"></a>
- <h3 class="h4">Designing a ZooKeeper Deployment</h3>
- <p></p>
- <a name="N10166"></a><a name="sc_provisioning"></a>
- <h3 class="h4">Provisioning</h3>
- <p></p>
- <a name="N1016F"></a><a name="sc_strengthsAndLimitations"></a>
- <h3 class="h4">Things to Consider: ZooKeeper Strengths and Limitations</h3>
- <p></p>
- <a name="N10178"></a><a name="sc_administering"></a>
- <h3 class="h4">Administering</h3>
- <p></p>
- <a name="N10181"></a><a name="sc_monitoring"></a>
- <h3 class="h4">Monitoring</h3>
- <p></p>
- <a name="N1018A"></a><a name="sc_logging"></a>
- <h3 class="h4">Logging</h3>
- <p>ZooKeeper uses <strong>log4j</strong> version 1.2 as
- its logging infrastructure. The ZooKeeper default <span class="codefrag filename">log4j.properties</span>
- file resides in the <span class="codefrag filename">conf</span> directory. Log4j requires that
- <span class="codefrag filename">log4j.properties</span> either be in the working directory
- (the directory from which ZooKeeper is run) or be accessible from the classpath.</p>
- <p>For more information, see
- <a href="http://logging.apache.org/log4j/1.2/manual.html#defaultInit">Log4j Default Initialization Procedure</a>
- of the log4j manual.</p>
- <a name="N101AA"></a><a name="sc_troubleshooting"></a>
- <h3 class="h4">Troubleshooting</h3>
- <p></p>
- <a name="N101B3"></a><a name="sc_configuration"></a>
- <h3 class="h4">Configuration Parameters</h3>
- <p>ZooKeeper's behavior is governed by the ZooKeeper configuration
- file. This file is designed so that the exact same file can be used by
- all the servers that make up a ZooKeeper server assuming the disk
- layouts are the same. If servers use different configuration files, care
- must be taken to ensure that the list of servers in all of the different
- configuration files match.</p>
- <a name="N101BC"></a><a name="sc_minimumConfiguration"></a>
- <h4>Minimum Configuration</h4>
- <p>Here are the minimum configuration keywords that must be defined
- in the configuration file:</p>
- <dl>
-
- <dt>
- <term>clientPort</term>
- </dt>
- <dd>
- <p>the port to listen for client connections; that is, the
- port that clients attempt to connect to.</p>
- </dd>
-
- <dt>
- <term>dataDir</term>
- </dt>
- <dd>
- <p>the location where ZooKeeper will store the in-memory
- database snapshots and, unless specified otherwise, the
- transaction log of updates to the database.</p>
- <div class="note">
- <div class="label">Note</div>
- <div class="content">
-
- <p>Be careful where you put the transaction log. A
- dedicated transaction log device is key to consistent good
- performance. Putting the log on a busy device will adversely
- effect performance.</p>
-
- </div>
- </div>
- </dd>
-
- <dt>
- <term>tickTime</term>
- </dt>
- <dd>
- <p>the length of a single tick, which is the basic time unit
- used by ZooKeeper, as measured in milliseconds. It is used to
- regulate heartbeats, and timeouts. For example, the minimum
- session timeout will be two ticks.</p>
- </dd>
-
- </dl>
- <a name="N101E3"></a><a name="sc_advancedConfiguration"></a>
- <h4>Advanced Configuration</h4>
- <p>The configuration settings in the section are optional. You can
- use them to further fine tune the behaviour of your ZooKeeper servers.
- Some can also be set using Java system properties, generally of the
- form <em>zookeeper.keyword</em>. The exact system
- property, when available, is noted below.</p>
- <dl>
-
- <dt>
- <term>dataLogDir</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>This option will direct the machine to write the
- transaction log to the <strong>dataLogDir</strong> rather than the <strong>dataDir</strong>. This allows a dedicated log
- device to be used, and helps avoid competition between logging
- and snaphots.</p>
- <div class="note">
- <div class="label">Note</div>
- <div class="content">
-
- <p>Having a dedicated log device has a large impact on
- throughput and stable latencies. It is highly recommened to
- dedicate a log device and set <strong>dataLogDir</strong> to point to a directory on
- that device, and then make sure to point <strong>dataDir</strong> to a directory
- <em>not</em> residing on that device.</p>
-
- </div>
- </div>
- </dd>
-
- <dt>
- <term>globalOutstandingLimit</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>zookeeper.globalOutstandingLimit.</strong>)</p>
- <p>Clients can submit requests faster than ZooKeeper can
- process them, especially if there are a lot of clients. To
- prevent ZooKeeper from running out of memory due to queued
- requests, ZooKeeper will throttle clients so that there is no
- more than globalOutstandingLimit outstanding requests in the
- system. The default limit is 1,000.</p>
- </dd>
-
- <dt>
- <term>preAllocSize</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>zookeeper.preAllocSize</strong>)</p>
- <p>To avoid seeks ZooKeeper allocates space in the
- transaction log file in blocks of preAllocSize kilobytes. The
- default block size is 64M. One reason for changing the size of
- the blocks is to reduce the block size if snapshots are taken
- more often. (Also, see <strong>snapCount</strong>).</p>
- </dd>
-
- <dt>
- <term>snapCount</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>zookeeper.snapCount</strong>)</p>
- <p>Clients can submit requests faster than ZooKeeper can
- process them, especially if there are a lot of clients. To
- prevent ZooKeeper from running out of memory due to queued
- requests, ZooKeeper will throttle clients so that there is no
- more than globalOutstandingLimit outstanding requests in the
- system. The default limit is 1,000.ZooKeeper logs transactions
- to a transaction log. After snapCount transactions are written
- to a log file a snapshot is started and a new transaction log
- file is started. The default snapCount is 10,000.</p>
- </dd>
-
- <dt>
- <term>traceFile</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>requestTraceFile</strong>)</p>
- <p>If this option is defined, requests will be will logged to
- a trace file named traceFile.year.month.day. Use of this option
- provides useful debugging information, but will impact
- performance. (Note: The system property has no zookeeper prefix,
- and the configuration variable name is different from the system
- property. Yes - it's not consistent, and it's annoying.)</p>
- </dd>
-
- </dl>
- <a name="N10243"></a><a name="sc_clusterOptions"></a>
- <h4>Cluster Options</h4>
- <p>The options in this section are designed for use in quorums --
- that is, when deploying clusters of servers.</p>
- <dl>
-
- <dt>
- <term>electionAlg</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>Election implementation to use. A value of "0" corresponds
- to the original UDP-based version, "1" corresponds to the
- non-authenticated UDP-based version of fast leader election, "2"
- corresponds to the authenticated UDP-based version of fast
- leader election, and "3" corresponds to TCP-based version of
- fast leader election</p>
- </dd>
-
- <dt>
- <term>electionPort</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>Port used for leader election. It is only used when the
- election algorithm is not "0". When the election algorithm is
- "0" a UDP port with the same port number as the port listed in
- the <strong>server.num</strong> option will be
- used.</p>
- </dd>
-
- <dt>
- <term>initLimit</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to
- connect and sync to a leader. Increased this value as needed, if
- the amount of data managed by ZooKeeper is large.</p>
- </dd>
-
- <dt>
- <term>leaderServes</term>
- </dt>
- <dd>
- <p>(Java system property: zookeeper.<strong>leaderServes</strong>)</p>
- <p>Leader accepts client connections. Default value is "yes".
- The leader machine coordinates updates. For higher update
- throughput at thes slight expense of read throughput the leader
- can be configured to not accept clients and focus on
- coordination. The default to this option is yes, which means
- that a leader will accept client connections.</p>
- <div class="note">
- <div class="label">Note</div>
- <div class="content">
-
- <p>Turning on leader selection is highly recommended when
- you have more than three ZooKeeper servers in a quorum.</p>
-
- </div>
- </div>
- </dd>
-
- <dt>
- <term>server.x=[hostname]:nnnn, etc</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>servers making up the ZooKeeper quorum. When the server
- starts up, it determines which server it is by looking for the
- file <span class="codefrag filename">myid</span> in the data directory. That file
- contains the server number, in ASCII, and it should match
- <strong>x</strong> in <strong>server.x</strong> in the left hand side of this
- setting.</p>
- <p>The list of servers that make up ZooKeeper servers that is
- used by the clients must match the list of ZooKeeper servers
- that each ZooKeeper server has.</p>
- <p>The port numbers <strong>nnnn</strong> in
- this setting are the <em>electionPort</em> numbers
- of the servers (as opposed to clientPorts). If you want to test
- multiple servers on a single machine, the individual choices of
- electionPort for each server can be defined in each server's
- config files using the line electionPort=xxxx to avoid
- clashes.</p>
- </dd>
-
- <dt>
- <term>syncLimit</term>
- </dt>
- <dd>
- <p>(No Java system property)</p>
- <p>Amount of time, in ticks (see <a href="#id_tickTime">tickTime</a>), to allow followers to sync
- with ZooKeeper. If followers fall too far behind a leader, they
- will be dropped.</p>
- </dd>
-
- </dl>
- <p></p>
- <a name="N102AF"></a><a name="Unsafe+Options"></a>
- <h4>Unsafe Options</h4>
- <p>The following options can be useful, but be careful when you use
- them. The risk of each is explained along with the explanation of what
- the variable does.</p>
- <dl>
-
- <dt>
- <term>forceSync</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>zookeeper.forceSync</strong>)</p>
- <p>Requires updates to be synced to media of the transaction
- log before finishing processing the update. If this option is
- set to no, ZooKeeper will not require updates to be synced to
- the media.</p>
- </dd>
-
- <dt>
- <term>jute.maxbuffer:</term>
- </dt>
- <dd>
- <p>(Java system property:<strong>
- jute.maxbuffer</strong>)</p>
- <p>This option can only be set as a Java system property.
- There is no zookeeper prefix on it. It specifies the maximum
- size of the data that can be stored in a znode. The default is
- 0xfffff, or just under 1M. If this option is changed, the system
- property must be set on all servers and clients otherwise
- problems will arise. This is really a sanity check. ZooKeeper is
- designed to store data on the order of kilobytes in size.</p>
- </dd>
-
- <dt>
- <term>skipACL</term>
- </dt>
- <dd>
- <p>(Java system property: <strong>zookeeper.skipACL</strong>)</p>
- <p>Skips ACL checks. This results in a boost in throughput,
- but opens up full access to the data tree to everyone.</p>
- </dd>
-
- </dl>
- <a name="N102E1"></a><a name="sc_zkCommands"></a>
- <h3 class="h4">ZooKeeper Commands: The Four Letter Words</h3>
- <p>ZooKeeper responds to a small set of commands. Each command is
- composed of four letters. You issue the commands to ZooKeeper via telnet
- or nc, at the client port.</p>
- <dl>
-
- <dt>
- <term>dump</term>
- </dt>
- <dd>
- <p>Lists the outstanding sessions and ephemeral nodes. This
- only works on the leader.</p>
- </dd>
-
- <dt>
- <term>kill</term>
- </dt>
- <dd>
- <p>Shuts down the server. This must be issued from the machine
- the ZooKeeper server is running on.</p>
- </dd>
-
- <dt>
- <term>ruok</term>
- </dt>
- <dd>
- <p>Tests if server is running in a non-error state. The server
- will respond with imok if it is running. Otherwise it will not
- respond at all.</p>
- </dd>
-
- <dt>
- <term>stat</term>
- </dt>
- <dd>
- <p>Lists statistics about performance and connected
- clients.</p>
- </dd>
-
- </dl>
- <p>Here's an example of the <strong>ruok</strong>
- command:</p>
- <pre class="code">$ echo ruok | nc 127.0.0.1 5111
- imok
- </pre>
- <a name="N10313"></a><a name="sc_dataFileManagement"></a>
- <h3 class="h4">Data File Management</h3>
- <p>ZooKeeper stores its data in a data directory and its transaction
- log in a transaction log directory. By default these two directories are
- the same. The server can (and should) be configured to store the
- transaction log files in a separate directory than the data files.
- Throughput increases and latency decreases when transaction logs reside
- on a dedicated log devices.</p>
- <a name="N1031C"></a><a name="The+Data+Directory"></a>
- <h4>The Data Directory</h4>
- <p>This directory has two files in it:</p>
- <ul>
-
- <li>
-
- <p>
- <span class="codefrag filename">myid</span> - contains a single integer in
- human readable ASCII text that represents the server id.</p>
-
- </li>
-
- <li>
-
- <p>
- <span class="codefrag filename">snapshot.<zxid></span> - holds the fuzzy
- snapshot of a data tree.</p>
-
- </li>
-
- </ul>
- <p>Each ZooKeeper server has a unique id. This id is used in two
- places: the <span class="codefrag filename">myid</span> file and the configuration file.
- The <span class="codefrag filename">myid</span> file identifies the server that
- corresponds to the given data directory. The configuration file lists
- the contact information for each server identified by its server id.
- When a ZooKeeper server instance starts, it reads its id from the
- <span class="codefrag filename">myid</span> file and then, using that id, reads from the
- configuration file, looking up the port on which it should
- listen.</p>
- <p>The <span class="codefrag filename">snapshot</span> files stored in the data
- directory are fuzzy snapshots in the sense that during the time the
- ZooKeeper server is taking the snapshot, updates are occurring to the
- data tree. The suffix of the <span class="codefrag filename">snapshot</span> file names
- is the <em>zxid</em>, the ZooKeeper transaction id, of the
- last committed transaction at the start of the snapshot. Thus, the
- snapshot includes a subset of the updates to the data tree that
- occurred while the snapshot was in process. The snapshot, then, may
- not correspond to any data tree that actually existed, and for this
- reason we refer to it as a fuzzy snapshot. Still, ZooKeeper can
- recover using this snapshot because it takes advantage of the
- idempotent nature of its updates. By replaying the transaction log
- against fuzzy snapshots ZooKeeper gets the state of the system at the
- end of the log.</p>
- <a name="N10358"></a><a name="The+Log+Directory"></a>
- <h4>The Log Directory</h4>
- <p>The Log Directory contains the ZooKeeper transaction logs.
- Before any update takes place, ZooKeeper ensures that the transaction
- that represents the update is written to non-volatile storage. A new
- log file is started each time a snapshot is begun. The log file's
- suffix is the first zxid written to that log.</p>
- <a name="N10362"></a><a name="File+Management"></a>
- <h4>File Management</h4>
- <p>The format of snapshot and log files does not change between
- standalone ZooKeeper servers and different configurations of
- replicated ZooKeeper servers. Therefore, you can pull these files from
- a running replicated ZooKeeper server to a development machine with a
- stand-alone ZooKeeper server for trouble shooting.</p>
- <p>Using older log and snapshot files, you can look at the previous
- state of ZooKeeper servers and even restore that state. The
- LogFormatter class allows an administrator to look at the transactions
- in a log.</p>
- <p>The ZooKeeper server creates snapshot and log files, but never
- deletes them. The retention policy of the data and log files is
- implemented outside of the ZooKeeper server. The server itself only
- needs the latest complete fuzzy snapshot and the log files from the
- start of that snapshot. The PurgeTxnLog utility implements a simple
- retention policy that administrators can use.</p>
- <a name="N10373"></a><a name="sc_commonProblems"></a>
- <h3 class="h4">Things to Avoid</h3>
- <p>Here are some common problems you can avoid by configuring
- ZooKeeper correctly:</p>
- <dl>
-
- <dt>
- <term>inconsistent lists of servers</term>
- </dt>
- <dd>
- <p>The list of ZooKeeper servers used by the clients must match
- the list of ZooKeeper servers that each ZooKeeper server has.
- Things work okay if the client list is a subset of the real list,
- but things will really act strange if clients have a list of
- ZooKeeper servers that are in different ZooKeeper clusters. Also,
- the server lists in each Zookeeper server configuration file
- should be consistent with one another.</p>
- </dd>
-
- <dt>
- <term>incorrect placement of transasction log</term>
- </dt>
- <dd>
- <p>The most performance critical part of ZooKeeper is the
- transaction log. ZooKeeper syncs transactions to media before it
- returns a response. A dedicated transaction log device is key to
- consistent good performance. Putting the log on a busy device will
- adversely effect performance. If you only have one storage device,
- put trace files on NFS and increase the snapshotCount; it doesn't
- eliminate the problem, but it should mitigate it.</p>
- </dd>
-
- <dt>
- <term>incorrect Java heap size</term>
- </dt>
- <dd>
- <p>You should take special care to set your Java max heap size
- correctly. In particular, you should not create a situation in
- which ZooKeeper swaps to disk. The disk is death to ZooKeeper.
- Everything is ordered, so if processing one request swaps the
- disk, all other queued requests will probably do the same. the
- disk. DON'T SWAP.</p>
- <p>Be conservative in your estimates: if you have 4G of RAM, do
- not set the Java max heap size to 6G or even 4G. For example, it
- is more likely you would use a 3G heap for a 4G machine, as the
- operating system and the cache also need memory. The best and only
- recommend practice for estimating the heap size your system needs
- is to run load tests, and then make sure you are well below the
- usage limit that would cause the system to swap.</p>
- </dd>
-
- </dl>
- <a name="N10397"></a><a name="sc_bestPractices"></a>
- <h3 class="h4">Best Practices</h3>
- <p>For best results, take note of the following list of good
- Zookeeper practices. <em>[tbd...]</em>
- </p>
- </div>
- <p align="right">
- <font size="-2"></font>
- </p>
- </div>
- <!--+
- |end content
- +-->
- <div class="clearboth"> </div>
- </div>
- <div id="footer">
- <!--+
- |start bottomstrip
- +-->
- <div class="lastmodified">
- <script type="text/javascript"><!--
- document.write("Last Published: " + document.lastModified);
- // --></script>
- </div>
- <div class="copyright">
- Copyright ©
- 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
- </div>
- <!--+
- |end bottomstrip
- +-->
- </div>
- </body>
- </html>
|