HBASE-12858 - remove extraneous Docbook files

This commit is contained in:
Misty Stanley-Jones 2015-01-14 20:11:33 -08:00
parent 4b0efe5515
commit e80b3092a6
41 changed files with 0 additions and 26881 deletions

View File

@ -1,662 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix version="5.0" xml:id="appendix_acl_matrix"
xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Access Control Matrix</title>
<para>The following matrix shows the minimum permission set required to perform operations in
HBase. Before using the table, read through the information about how to interpret it.</para>
<variablelist>
<title>Interpreting the ACL Matrix Table</title>
<para>The following conventions are used in the ACL Matrix table:</para>
<varlistentry>
<term>Scopes</term>
<listitem>
<para>Permissions are evaluated starting at the widest scope and working to the
narrowest scope. A scope corresponds to a level of the data model. From broadest to
narrowest, the scopes are as follows::</para>
<itemizedlist>
<listitem><para>Global</para></listitem>
<listitem><para>Namespace (NS)</para></listitem>
<listitem><para>Table</para></listitem>
<listitem><para>Column Family (CF)</para></listitem>
<listitem><para>Column Qualifier (CQ)</para></listitem>
<listitem><para>Cell</para></listitem>
</itemizedlist>
<para>For instance, a permission granted at table level dominates any grants done at
the Column Family, Column Qualifier, or cell level. The user can do what that
grant implies at any location in the table. A permission granted at global scope
dominates all: the user is always allowed to take that action everywhere.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Permissions</term>
<listitem>
<para>Possible permissions include the following:</para>
<itemizedlist>
<listitem><para>Superuser - a special user that belongs to group "supergroup" and has
unlimited access</para></listitem>
<listitem><para>Admin (A)</para></listitem>
<listitem><para>Create (C)</para></listitem>
<listitem><para>Write (W)</para></listitem>
<listitem><para>Read (R)</para></listitem>
<listitem><para>Execute (X)</para></listitem>
</itemizedlist>
</listitem>
</varlistentry>
</variablelist>
<para>For the most part, permissions work in an expected way, with the following caveats:</para>
<itemizedlist>
<listitem>
<para>Having Write permission does not imply Read permission. It is possible and sometimes
desirable for a user to be able to write data that same user cannot read. One such example
is a log-writing process.</para>
</listitem>
<listitem>
<para>The <systemitem>hbase:meta</systemitem> table is readable by every user, regardless
of the user's other grants or restrictions. This is a requirement for HBase to
function correctly.</para>
</listitem>
<listitem>
<para><code>CheckAndPut</code> and <code>CheckAndDelete</code> operations will fail if
the user does not have both Write and Read permission.</para>
</listitem>
<listitem>
<para><code>Increment</code> and <code>Append</code> operations do not require Read
access.</para>
</listitem>
</itemizedlist>
<para>The following table is sorted by the interface that provides each operation. In case the
table goes out of date, the unit tests which check for accuracy of permissions can be found
in
<filename>hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java</filename>,
and the access controls themselves can be examined in
<filename>hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java</filename>.</para>
<table frame="all">
<title>ACL Matrix</title>
<tgroup cols="4">
<thead>
<row>
<entry>Interface</entry>
<entry>Operation</entry>
<entry>Minimum Scope</entry>
<entry>Minimum Permission</entry>
</row>
</thead>
<tbody>
<row>
<entry morerows="27">
<!-- incrememt this if you add another "master" operation -->
<para>Master</para>
</entry>
<entry>
<para>createTable</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>C</para>
</entry>
</row>
<row>
<entry>
<para>modifyTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>deleteTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>truncateTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>addColumn</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>modifyColumn</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>deleteColumn</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>disableTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>disableAclTable</para>
</entry>
<entry>
<para>None</para>
</entry>
<entry>
<para>Not allowed</para>
</entry>
</row>
<row>
<entry>
<para>enableTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>move</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>assign</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>unassign</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>regionOffline</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>balance</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>balanceSwitch</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>shutdown</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>stopMaster</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>snapshot</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>clone</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>restore</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>deleteSnapshot</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>createNamespace</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>deleteNamespace</para>
</entry>
<entry>
<para>Namespace</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>modifyNamespace</para>
</entry>
<entry>
<para>Namespace</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>flushTable</para>
</entry>
<entry>
<para>Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>getTableDescriptors</para>
</entry>
<entry>
<para>Global|Table</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>mergeRegions</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry morerows="24">Region</entry>
<!-- Incrememt this if you add any more Region
operations -->
<entry>open</entry>
<entry>Global</entry>
<entry>A</entry>
</row>
<row>
<entry>
<para>openRegion</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>close</entry>
<entry>Global</entry>
<entry>A</entry>
</row>
<row>
<entry>
<para>closeRegion</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>stopRegionServer</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>rollHLog</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>mergeRegions</para>
</entry>
<entry>
<para>Global</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>append</entry>
<entry>Table|CF|CQ</entry>
<entry>W</entry>
</row>
<row>
<entry>delete</entry>
<entry>Table|CF|CQ|Cell (if the user has write permission for all cells)</entry>
<entry>W</entry>
</row>
<row>
<entry>exists</entry>
<entry>Table|CF|CQ</entry>
<entry>R</entry>
</row>
<row>
<entry>get</entry>
<entry>Table|CF|CQ</entry>
<entry>R</entry>
</row>
<row>
<entry>getClosestRowBefore</entry>
<entry>Table|CF|CQ</entry>
<entry>R</entry>
</row>
<row>
<entry>increment</entry>
<entry>Table|CF|CQ</entry>
<entry>W</entry>
</row>
<row>
<entry>put</entry>
<entry>Table|CF|CQ</entry>
<entry>W</entry>
</row>
<row>
<entry>
<para>flush</para>
</entry>
<entry>
<para>Global|Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>
<para>split</para>
</entry>
<entry>
<para>Global|Table</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>compact</para>
</entry>
<entry>
<para>Global|Table</para>
</entry>
<entry>
<para>A|C</para>
</entry>
</row>
<row>
<entry>bulkLoadHFile</entry>
<entry>Table</entry>
<entry>W</entry>
</row>
<row>
<entry>prepareBulkLoad</entry>
<entry>Table</entry>
<entry>C</entry>
</row>
<row>
<entry>cleanupBulkLoad</entry>
<entry>Table</entry>
<entry>W</entry>
</row>
<row>
<entry>checkAndDelete</entry>
<entry>Table|CF|CQ</entry>
<entry>RW</entry>
</row>
<row>
<entry>checkAndPut</entry>
<entry>Table|CF|CQ</entry>
<entry>RW</entry>
</row>
<row>
<entry>incrementColumnValue</entry>
<entry>Table|CF|CQ</entry>
<entry>RW</entry>
</row>
<row>
<entry>scannerClose</entry>
<entry>Table</entry>
<entry>R</entry>
</row>
<row>
<entry>scannerNext</entry>
<entry>Table</entry>
<entry>R</entry>
</row>
<row>
<entry>scannerOpen</entry>
<entry>Table|CQ|CF</entry>
<entry>R</entry>
</row>
<row>
<entry>
<para>Endpoint</para>
</entry>
<entry>
<para>invoke</para>
</entry>
<entry>Endpoint</entry>
<entry>
<para>X</para>
</entry>
</row>
<row>
<entry morerows="3">
<para>AccessController</para>
</entry>
<entry>
<para>grant</para>
</entry>
<entry>Global|Table|NS</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>revoke</para>
</entry>
<entry>Global|Table|NS</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>getUserPermissions</para>
</entry>
<entry>
<para>Global|Table|NS</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
<row>
<entry>
<para>checkPermissions</para>
</entry>
<entry>
<para>Global|Table|NS</para>
</entry>
<entry>
<para>A</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</appendix>

View File

@ -1,426 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix version="5.0" xml:id="appendix_contributing_to_documentation"
xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Contributing to Documentation</title>
<para>The Apache HBase project welcomes contributions to all aspects of the project, including
the documentation. In HBase, documentation includes the following areas, and probably some
others:</para>
<itemizedlist>
<listitem>
<para>The <link xlink:href="http://hbase.apache.org/book.html">HBase Reference
Guide</link> (this book)</para>
</listitem>
<listitem>
<para>The <link xlink:href="http://hbase.apache.org/">HBase website</link>e</para>
</listitem>
<listitem>
<para>The <link xlink:href="http://wiki.apache.org/hadoop/Hbase">HBase
Wiki</link></para>
</listitem>
<listitem>
<para>API documentation</para>
</listitem>
<listitem>
<para>Command-line utility output and help text</para>
</listitem>
<listitem>
<para>Web UI strings, explicit help text, context-sensitive strings, and others</para>
</listitem>
<listitem>
<para>Log messages</para>
</listitem>
<listitem>
<para>Comments in source files, configuration files, and others</para>
</listitem>
<listitem>
<para>Localization of any of the above into target languages other than English</para>
</listitem>
</itemizedlist>
<para>No matter which area you want to help out with, the first step is almost always to
download (typically by cloning the Git repository) and familiarize yourself with the HBase
source code. The only exception in the list above is the HBase Wiki, which is edited online.
For information on downloading and building the source, see <xref linkend="developer"
/>.</para>
<section>
<title>Getting Access to the Wiki</title>
<para>The HBase Wiki is not well-maintained and much of its content has been moved into the
HBase Reference Guide (this guide). However, some pages on the Wiki are well maintained,
and it would be great to have some volunteers willing to help out with the Wiki. To
request access to the Wiki, register a new account at <link
xlink:href="https://wiki.apache.org/hadoop/Hbase?action=newaccount"
>https://wiki.apache.org/hadoop/Hbase?action=newaccount</link>. Contact one of the
HBase committers, who can either give you access or refer you to someone who can.</para>
</section>
<section>
<title>Contributing to Documentation or Other Strings</title>
<para> If you spot an error in a string in a UI, utility, script, log message, or elsewhere,
or you think something could be made more clear, or you think text needs to be added
where it doesn't currently exist, the first step is to file a JIRA. Be sure to set the
component to <literal>Documentation</literal> in addition any other involved components.
Most components have one or more default owners, who monitor new issues which come into
those queues. Regardless of whether you feel able to fix the bug, you should still file
bugs where you see them.</para>
<para>If you want to try your hand at fixing your newly-filed bug, assign it to yourself.
You will need to clone the HBase Git repository to your local system and work on the
issue there. When you have developed a potential fix, submit it for review. If it
addresses the issue and is seen as an improvement, one of the HBase committers will
commit it to one or more branches, as appropriate.</para>
<procedure xml:id="submit_doc_patch_procedure">
<title>Suggested Work flow for Submitting Patches</title>
<para>This procedure goes into more detail than Git pros will need, but is included in
this appendix so that people unfamiliar with Git can feel confident contributing to
HBase while they learn.</para>
<step>
<para>If you have not already done so, clone the Git repository locally. You only
need to do this once.</para>
</step>
<step>
<para>Fairly often, pull remote changes into your local repository by using the
<code>git pull</code> command, while your master branch is checked
out.</para>
</step>
<step>
<para>For each issue you work on, create a new branch. One convention that works
well for naming the branches is to name a given branch the same as the JIRA it
relates to:</para>
<screen language="bourne">$ git checkout -b HBASE-123456</screen>
</step>
<step>
<para>Make your suggested changes on your branch, committing your changes to your
local repository often. If you need to switch to working on a different issue,
remember to check out the appropriate branch.</para>
</step>
<step>
<para>When you are ready to submit your patch, first be sure that HBase builds
cleanly and behaves as expected in your modified branch. If you have made
documentation changes, be sure the documentation and website builds.</para>
<note>
<para>Before you use the <literal>site</literal> target the very first time, be
sure you have built HBase at least once, in order to fetch all the Maven
dependencies you need.</para>
</note>
<screen language="bourne">$ mvn clean install -DskipTests # Builds HBase</screen>
<screen language="bourne">$ mvn clean site -DskipTests # Builds the website and documentation</screen>
<para>If any errors occur, address them.</para>
</step>
<step>
<para>If it takes you several days or weeks to implement your fix, or you know that
the area of the code you are working in has had a lot of changes lately, make
sure you rebase your branch against the remote master and take care of any
conflicts before submitting your patch.</para>
<screen language="bourne">
$ git checkout HBASE-123456
$ git rebase origin/master
</screen>
</step>
<step>
<para>Generate your patch against the remote master. Run the following command from
the top level of your git repository (usually called
<literal>hbase</literal>):</para>
<screen language="bourne">$ git diff --no-prefix origin/master > HBASE-123456.patch</screen>
<para>The name of the patch should contain the JIRA ID. Look over the patch file to
be sure that you did not change any additional files by accident and that there
are no other surprises. When you are satisfied, attach the patch to the JIRA and
click the <guibutton>Patch Available</guibutton> button. A reviewer
will review your patch. If you need to submit a new version of the patch, leave
the old one on the JIRA and add a version number to the name of the new
patch.</para>
</step>
<step>
<para>After a change has been committed, there is no need to keep your local branch
around. Instead you should run <command>git pull</command> to get the new change
into your master branch.</para>
</step>
</procedure>
</section>
<section>
<title>Editing the HBase Website</title>
<para>The source for the HBase website is in the HBase source, in the
<filename>src/main/site/</filename> directory. Within this directory, source for the
individual pages is in the <filename>xdocs/</filename> directory, and images referenced
in those pages are in the <filename>images/</filename> directory. This directory also
stores images used in the HBase Reference Guide.</para>
<para>The website's pages are written in an HTML-like XML dialect called xdoc, which has a
reference guide at <link
xlink:href="http://maven.apache.org/archives/maven-1.x/plugins/xdoc/reference/xdocs.html"
>http://maven.apache.org/archives/maven-1.x/plugins/xdoc/reference/xdocs.html</link>.
You can edit these files in a plain-text editor, an IDE, or an XML editor such as
XML Mind XML Editor (XXE) or Oxygen XML Author. </para>
<para>To preview your changes, build the website using the <command>mvn clean site
-DskipTests</command> command. The HTML output resides in the
<filename>target/site/</filename> directory. When you are satisfied with your
changes, follow the procedure in <xref linkend="submit_doc_patch_procedure"/> to submit
your patch.</para>
</section>
<section>
<title>Editing the HBase Reference Guide</title>
<para>The source for the HBase Reference Guide is in the HBase source, in the
<filename>src/main/docbkx/</filename> directory. It is written in <link
xlink:href="http://www.docbook.org/">Docbook</link> XML. Docbook can be
intimidating, but you can typically follow the formatting of the surrounding file to get
an idea of the mark-up. You can edit Docbook XML files using a plain-text editor, an
XML-aware IDE, or a specialized XML editor.</para>
<para>Docbook's syntax can be picky. Before submitting a patch, be sure to build the output
locally using the <command>mvn site</command> command. If you do not get any build
errors, that means that the XML is well-formed, which means that each opening tag is
balanced by a closing tag. Well-formedness is not exactly the same as validity. Check
the output in <filename>target/docbkx/</filename> for any surprises before submitting a
patch.</para>
</section>
<section>
<title>Auto-Generated Content</title>
<para>Some parts of the HBase Reference Guide, most notably <xref linkend="config.files"/>,
are generated automatically, so that this area of the documentation stays in sync with
the code. This is done by means of an XSLT transform, which you can examine in the
source at <filename>src/main/xslt/configuration_to_docbook_section.xsl</filename>. This
transforms the <filename>hbase-common/src/main/resources/hbase-default.xml</filename>
file into a Docbook output which can be included in the Reference Guide. Sometimes, it
is necessary to add configuration parameters or modify their descriptions. Make the
modifications to the source file, and they will be included in the Reference Guide when
it is rebuilt.</para>
<para>It is possible that other types of content can and will be automatically generated
from HBase source files in the future.</para>
</section>
<section>
<title>Multi-Page and Single-Page Output</title>
<para>You can examine the <literal>site</literal> target in the Maven
<filename>pom.xml</filename> file included at the top level of the HBase source for
details on the process of building the website and documentation. The Reference Guide is
built twice, once as a single-page output and once with one HTML file per chapter. The
single-page output is located in <filename>target/docbkx/book.html</filename>, while the
multi-page output's index page is at <filename>target/docbkx/book/book.html</filename>.
Each of these outputs has its own <filename>images/</filename> and
<filename>css/</filename> directories, which are created at build time.</para>
</section>
<section>
<title>Images in the HBase Reference Guide</title>
<para>You can include images in the HBase Reference Guide. For accessibility reasons, it is
recommended that you use a &lt;figure&gt; Docbook element for an image. This allows
screen readers to navigate to the image and also provides alternative text for the
image. The following is an example of a &lt;figure&gt; element.</para>
<programlisting language="xml"><![CDATA[<figure>
<title>HFile Version 1</title>
<mediaobject>
<imageobject>
<imagedata fileref="timeline_consistency.png" />
</imageobject>
<textobject>
<phrase>HFile Version 1</phrase>
</textobject>
</mediaobject>
</figure>]]>
</programlisting>
<para>The &lt;textobject&gt; can contain a few sentences describing the image, rather than
simply reiterating the title. You can optionally specify alignment and size options in
the &lt;imagedata&gt; element.</para>
<para>When doing a local build, save the image to the
<filename>src/main/site/resources/images/</filename> directory. In the
&lt;imagedata&gt; element, refer to the image as above, with no directory component. The
image will be copied to the appropriate target location during the build of the
output.</para>
<para>When you submit a patch which includes adding an image to the HBase Reference Guide,
attach the image to the JIRA. If the committer asks where the image should be committed,
it should go into the above directory.</para>
</section>
<section>
<title>Adding a New Chapter to the HBase Reference Guide</title>
<para>If you want to add a new chapter to the HBase Reference Guide, the easiest way is to
copy an existing chapter file, rename it, and change the ID and title elements near the
top of the file. Delete the existing content and create the new content. Then open the
<filename>book.xml</filename> file, which is the main file for the HBase Reference
Guide, and use an &lt;xi:include&gt; element to include your new chapter in the
appropriate location. Be sure to add your new file to your Git repository before
creating your patch. Note that the <filename>book.xml</filename> file currently contains
many chapters. You can only include a chapter at the same nesting levels as the other
chapters in the file. When in doubt, check to see how other files have been
included.</para>
</section>
<section>
<title>Docbook Common Issues</title>
<para>The following Docbook issues come up often. Some of these are preferences, but others
can create mysterious build errors or other problems.</para>
<qandaset>
<qandaentry>
<question>
<para>What can go where?</para>
</question>
<answer>
<para>There is often confusion about which child elements are valid in a given
context. When in doubt, <link
xlink:href="http://docbook.org/tdg/en/html/docbook.html">Docbook: The
Definitive Guide</link> is the best resource. It has an appendix which
is indexed by element and contains all valid child and parent elements of
any given element. If you edit Docbook often, a schema-aware XML editor
makes things easier.</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Paragraphs and Admonitions</para>
</question>
<answer>
<para>It is a common pattern, and it is technically valid, to put an admonition
such as a &lt;note&gt; inside a &lt;para&gt; element. Because admonitions
render as block-level elements (they take the whole width of the page), it
is better to mark them up as siblings to the paragraphs around them, like
this:</para>
<programlisting language="xml"><![CDATA[<para>This is the paragraph.</para>
<note>
<para>This is an admonition which occurs after the paragraph.</para>
</note>]]></programlisting>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Wrap textual &lt;listitem&gt; and &lt;entry&gt; contents in &lt;para&gt;
elements.</para>
</question>
<answer>
<para>Because the contents of a &lt;listitem&gt; (an element in an itemized,
ordered, or variable list) or an &lt;entry&gt; (a cell in a table) can
consist of things other than plain text, they need to be wrapped in some
element. If they are plain text, they need to be inclosed in &lt;para&gt;
tags. This is tedious but necessary for validity.</para>
<programlisting language="xml"><![CDATA[<itemizedlist>
<listitem>
<para>This is a paragraph.</para>
</listitem>
<listitem>
<screen>This is screen output.</screen>
</listitem>
</itemizedlist>]]></programlisting>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>When to use &lt;command&gt;, &lt;code&gt;, &lt;programlisting&gt;,
&lt;screen&gt;</para>
</question>
<answer>
<para>The first two are in-line tags, which can occur within the flow of
paragraphs or titles. The second two are block elements.</para>
<para>Use &lt;command&gt; to mention a command such as <command>hbase
shell</command> in the flow of a sentence. Use &lt;code&gt; for other
inline text referring to code. Incidentally, use &lt;literal&gt; to specify
literal strings that should be typed or entered exactly as shown. Within a
&lt;screen&gt; listing, it can be helpful to use the &lt;userinput&gt; and
&lt;computeroutput&gt; elements to mark up the text further.</para>
<para>Use &lt;screen&gt; to display input and output as the user would
<emphasis>see</emphasis> it on the screen, in a log file, etc. Use
&lt;programlisting&gt; only for blocks of code that occur within a file,
such as Java or XML code, or a Bash shell script.</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>How to escape XML elements so that they show up as XML</para>
</question>
<answer>
<para>For one-off instances or short in-line mentions, use the &amp;lt; and
&amp;gt; encoded characters. For longer mentions, or blocks of code, enclose
it with <![CDATA[&lt;![CDATA[]]&gt;]]>, which is much easier to maintain and
parse in the source files..</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Tips and tricks for making screen output look good</para>
</question>
<answer>
<para>Text within &lt;screen&gt; and &lt;programlisting&gt; elements is shown
exactly as it appears in the source, including indentation, tabs, and line
wrap.</para>
<itemizedlist>
<listitem>
<para>Indent the starting and closing XML elements, but do not indent
the content. Also, to avoid having an extra blank line at the
beginning of the programlisting output, do not put the CDATA
element on its own line. For example:</para>
<programlisting language="bourne"><![CDATA[ <programlisting>
case $1 in
--cleanZk|--cleanHdfs|--cleanAll)
matches="yes" ;;
*) ;;
esac
</programlisting>]]></programlisting>
</listitem>
<listitem>
<para>After pasting code into a programlisting, fix the indentation
manually, using two <emphasis>spaces</emphasis> per desired
indentation. For screen output, be sure to include line breaks so
that the text is no longer than 100 characters.</para>
</listitem>
</itemizedlist>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Isolate Changes for Easy Diff Review.</para>
</question>
<answer>
<para>Be careful with pretty-printing or re-formatting an entire XML file, even
if the formatting has degraded over time. If you need to reformat a file, do
that in a separate JIRA where you do not change any content. Be careful
because some XML editors do a bulk-reformat when you open a new file,
especially if you use GUI mode in the editor.</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Syntax Highlighting</para>
</question>
<answer>
<para>The HBase Reference Guide uses the <link
xlink:href="http://sourceforge.net/projects/xslthl/files/xslthl/2.1.0/"
>XSLT Syntax Highlighting</link> Maven module for syntax highlighting.
To enable syntax highlighting for a given &lt;programlisting&gt; or
&lt;screen&gt; (or possibly other elements), add the attribute
<literal>language=<replaceable>LANGUAGE_OF_CHOICE</replaceable></literal>
to the element, as in the following example:</para>
<programlisting language="xml"><![CDATA[
<programlisting language="xml">
<foo>bar</foo>
<bar>foo</bar>
</programlisting>]]></programlisting>
<para>Several syntax types are supported. The most interesting ones for the
HBase Reference Guide are <literal>java</literal>, <literal>xml</literal>,
<literal>sql</literal>, and <literal>bourne</literal> (for BASH shell
output or Linux command-line examples).</para>
</answer>
</qandaentry>
</qandaset>
</section>
</appendix>

View File

@ -1,657 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix version="5.0" xml:id="hfile_format"
xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>HFile format</title>
<para>This appendix describes the evolution of the HFile format.</para>
<section xml:id="hfilev1">
<title>HBase File Format (version 1)</title>
<para>As we will be discussing changes to the HFile format, it is useful to give a short overview of the original (HFile version 1) format.</para>
<section xml:id="hfilev1.overview">
<title>Overview of Version 1</title>
<para>An HFile in version 1 format is structured as follows:</para>
<figure>
<title>HFile V1 Format</title>
<mediaobject>
<imageobject>
<imagedata align="center" valign="middle" fileref="hfile.png"/>
</imageobject>
<textobject>
<phrase>HFile Version 1</phrase>
</textobject>
<caption><para>Image courtesy of Lars George, <link
xlink:href="http://www.larsgeorge.com/2009/10/hbase-architecture-101-storage.html"
>hbase-architecture-101-storage.html</link>.</para></caption>
</mediaobject>
</figure>
</section>
<section><title> Block index format in version 1 </title>
<para>The block index in version 1 is very straightforward. For each entry, it contains: </para>
<orderedlist>
<listitem>
<para>Offset (long)</para>
</listitem>
<listitem>
<para>Uncompressed size (int)</para>
</listitem>
<listitem>
<para>Key (a serialized byte array written using Bytes.writeByteArray) </para>
<orderedlist>
<listitem>
<para>Key length as a variable-length integer (VInt)
</para>
</listitem>
<listitem>
<para>
Key bytes
</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
<para>The number of entries in the block index is stored in the fixed file trailer, and has to be passed in to the method that reads the block index. One of the limitations of the block index in version 1 is that it does not provide the compressed size of a block, which turns out to be necessary for decompression. Therefore, the HFile reader has to infer this compressed size from the offset difference between blocks. We fix this limitation in version 2, where we store on-disk block size instead of uncompressed size, and get uncompressed size from the block header.</para>
</section>
</section>
<section xml:id="hfilev2"><title>
HBase file format with inline blocks (version 2)
</title>
<para>Note: this feature was introduced in HBase 0.92</para>
<section><title>Motivation </title>
<para>We found it necessary to revise the HFile format after encountering high memory usage and slow startup times caused by large Bloom filters and block indexes in the region server. Bloom filters can get as large as 100 MB per HFile, which adds up to 2 GB when aggregated over 20 regions. Block indexes can grow as large as 6 GB in aggregate size over the same set of regions. A region is not considered opened until all of its block index data is loaded. Large Bloom filters produce a different performance problem: the first get request that requires a Bloom filter lookup will incur the latency of loading the entire Bloom filter bit array.</para>
<para>To speed up region server startup we break Bloom filters and block indexes into multiple blocks and write those blocks out as they fill up, which also reduces the HFile writers memory footprint. In the Bloom filter case, “filling up a block” means accumulating enough keys to efficiently utilize a fixed-size bit array, and in the block index case we accumulate an “index block” of the desired size. Bloom filter blocks and index blocks (we call these “inline blocks”) become interspersed with data blocks, and as a side effect we can no longer rely on the difference between block offsets to determine data block length, as it was done in version 1.</para>
<para>HFile is a low-level file format by design, and it should not deal with application-specific details such as Bloom filters, which are handled at StoreFile level. Therefore, we call Bloom filter blocks in an HFile "inline" blocks. We also supply HFile with an interface to write those inline blocks. </para>
<para>Another format modification aimed at reducing the region server startup time is to use a contiguous “load-on-open” section that has to be loaded in memory at the time an HFile is being opened. Currently, as an HFile opens, there are separate seek operations to read the trailer, data/meta indexes, and file info. To read the Bloom filter, there are two more seek operations for its “data” and “meta” portions. In version 2, we seek once to read the trailer and seek again to read everything else we need to open the file from a contiguous block.</para></section>
<section xml:id="hfilev2.overview">
<title>Overview of Version 2</title>
<para>The version of HBase introducing the above features reads both version 1 and 2 HFiles, but only writes version 2 HFiles. A version 2 HFile is structured as follows:
<inlinemediaobject>
<imageobject>
<imagedata align="center" valign="middle" fileref="hfilev2.png" />
</imageobject>
<textobject>
<phrase>HFile Version 2</phrase>
</textobject>
</inlinemediaobject>
</para>
</section>
<section><title>Unified version 2 block format</title>
<para>In the version 2 every block in the data section contains the following fields: </para>
<orderedlist>
<listitem>
<para>8 bytes: Block type, a sequence of bytes equivalent to version 1's "magic records". Supported block types are: </para>
<orderedlist>
<listitem>
<para>DATA data blocks
</para>
</listitem>
<listitem>
<para>
LEAF_INDEX leaf-level index blocks in a multi-level-block-index
</para>
</listitem>
<listitem>
<para>
BLOOM_CHUNK Bloom filter chunks
</para>
</listitem>
<listitem>
<para>
META meta blocks (not used for Bloom filters in version 2 anymore)
</para>
</listitem>
<listitem>
<para>
INTERMEDIATE_INDEX intermediate-level index blocks in a multi-level blockindex
</para>
</listitem>
<listitem>
<para>
ROOT_INDEX root>level index blocks in a multi>level block index
</para>
</listitem>
<listitem>
<para>
FILE_INFO the “file info” block, a small key>value map of metadata
</para>
</listitem>
<listitem>
<para>
BLOOM_META a Bloom filter metadata block in the load>on>open section
</para>
</listitem>
<listitem>
<para>
TRAILER a fixed>size file trailer. As opposed to the above, this is not an
HFile v2 block but a fixed>size (for each HFile version) data structure
</para>
</listitem>
<listitem>
<para>
INDEX_V1 this block type is only used for legacy HFile v1 block
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>Compressed size of the block's data, not including the header (int).
</para>
<para>
Can be used for skipping the current data block when scanning HFile data.
</para>
</listitem>
<listitem>
<para>Uncompressed size of the block's data, not including the header (int)</para>
<para>
This is equal to the compressed size if the compression algorithm is NONE
</para>
</listitem>
<listitem>
<para>File offset of the previous block of the same type (long)</para>
<para>
Can be used for seeking to the previous data/index block
</para>
</listitem>
<listitem>
<para>Compressed data (or uncompressed data if the compression algorithm is NONE).</para>
</listitem>
</orderedlist>
<para>The above format of blocks is used in the following HFile sections:</para>
<orderedlist>
<listitem>
<para>Scanned block section. The section is named so because it contains all data blocks that need to be read when an HFile is scanned sequentially.  Also contains leaf block index and Bloom chunk blocks. </para>
</listitem>
<listitem>
<para>Non-scanned block section. This section still contains unified-format v2 blocks but it does not have to be read when doing a sequential scan. This section contains “meta” blocks and intermediate-level index blocks.
</para>
</listitem>
</orderedlist>
<para>We are supporting “meta” blocks in version 2 the same way they were supported in version 1, even though we do not store Bloom filter data in these blocks anymore. </para></section>
<section><title> Block index in version 2</title>
<para>There are three types of block indexes in HFile version 2, stored in two different formats (root and non-root): </para>
<orderedlist>
<listitem>
<para>Data index — version 2 multi-level block index, consisting of:</para>
<orderedlist>
<listitem>
<para>
Version 2 root index, stored in the data block index section of the file
</para>
</listitem>
<listitem>
<para>
Optionally, version 2 intermediate levels, stored in the non%root format in the data index section of the file. Intermediate levels can only be present if leaf level blocks are present
</para>
</listitem>
<listitem>
<para>
Optionally, version 2 leaf levels, stored in the non%root format inline with data blocks
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>Meta index — version 2 root index format only, stored in the meta index section of the file</para>
</listitem>
<listitem>
<para>Bloom index — version 2 root index format only, stored in the “load-on-open” section as part of Bloom filter metadata.</para>
</listitem>
</orderedlist></section>
<section><title>
Root block index format in version 2</title>
<para>This format applies to:</para>
<orderedlist>
<listitem>
<para>Root level of the version 2 data index</para>
</listitem>
<listitem>
<para>Entire meta and Bloom indexes in version 2, which are always single-level. </para>
</listitem>
</orderedlist>
<para>A version 2 root index block is a sequence of entries of the following format, similar to entries of a version 1 block index, but storing on-disk size instead of uncompressed size. </para>
<orderedlist>
<listitem>
<para>Offset (long) </para>
<para>
This offset may point to a data block or to a deeper>level index block.
</para>
</listitem>
<listitem>
<para>On-disk size (int) </para>
</listitem>
<listitem>
<para>Key (a serialized byte array stored using Bytes.writeByteArray) </para>
<orderedlist>
<listitem>
<para>Key (VInt)
</para>
</listitem>
<listitem>
<para>Key bytes
</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
<para>A single-level version 2 block index consists of just a single root index block. To read a root index block of version 2, one needs to know the number of entries. For the data index and the meta index the number of entries is stored in the trailer, and for the Bloom index it is stored in the compound Bloom filter metadata.</para>
<para>For a multi-level block index we also store the following fields in the root index block in the load-on-open section of the HFile, in addition to the data structure described above:</para>
<orderedlist>
<listitem>
<para>Middle leaf index block offset</para>
</listitem>
<listitem>
<para>Middle leaf block on-disk size (meaning the leaf index block containing the reference to the “middle” data block of the file) </para>
</listitem>
<listitem>
<para>The index of the mid-key (defined below) in the middle leaf-level block.</para>
</listitem>
</orderedlist>
<para/>
<para>These additional fields are used to efficiently retrieve the mid-key of the HFile used in HFile splits, which we define as the first key of the block with a zero-based index of (n 1) / 2, if the total number of blocks in the HFile is n. This definition is consistent with how the mid-key was determined in HFile version 1, and is reasonable in general, because blocks are likely to be the same size on average, but we dont have any estimates on individual key/value pair sizes. </para>
<para/>
<para>When writing a version 2 HFile, the total number of data blocks pointed to by every leaf-level index block is kept track of. When we finish writing and the total number of leaf-level blocks is determined, it is clear which leaf-level block contains the mid-key, and the fields listed above are computed.  When reading the HFile and the mid-key is requested, we retrieve the middle leaf index block (potentially from the block cache) and get the mid-key value from the appropriate position inside that leaf block.</para></section>
<section><title>
Non-root block index format in version 2</title>
<para>This format applies to intermediate-level and leaf index blocks of a version 2 multi-level data block index. Every non-root index block is structured as follows. </para>
<orderedlist>
<listitem>
<para>numEntries: the number of entries (int). </para>
</listitem>
<listitem>
<para>entryOffsets: the “secondary index” of offsets of entries in the block, to facilitate a quick binary search on the key (numEntries + 1 int values). The last value is the total length of all entries in this index block. For example, in a non-root index block with entry sizes 60, 80, 50 the “secondary index” will contain the following int array: {0, 60, 140, 190}.</para>
</listitem>
<listitem>
<para>Entries. Each entry contains: </para>
<orderedlist>
<listitem>
<para>
Offset of the block referenced by this entry in the file (long)
</para>
</listitem>
<listitem>
<para>
On>disk size of the referenced block (int)
</para>
</listitem>
<listitem>
<para>
Key. The length can be calculated from entryOffsets.
</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist></section><section><title>
Bloom filters in version 2</title>
<para>In contrast with version 1, in a version 2 HFile Bloom filter metadata is stored in the load-on-open section of the HFile for quick startup. </para>
<orderedlist>
<listitem>
<para>A compound Bloom filter. </para>
<orderedlist>
<listitem>
<para>
Bloom filter version = 3 (int). There used to be a DynamicByteBloomFilter class that had the Bloom filter version number 2
</para>
</listitem>
<listitem>
<para>
The total byte size of all compound Bloom filter chunks (long)
</para>
</listitem>
<listitem>
<para>
Number of hash functions (int
</para>
</listitem>
<listitem>
<para>
Type of hash functions (int)
</para>
</listitem>
<listitem>
<para>
The total key count inserted into the Bloom filter (long)
</para>
</listitem>
<listitem>
<para>
The maximum total number of keys in the Bloom filter (long)
</para>
</listitem>
<listitem>
<para>
The number of chunks (int)
</para>
</listitem>
<listitem>
<para>
Comparator class used for Bloom filter keys, a UTF>8 encoded string stored using Bytes.writeByteArray
</para>
</listitem>
<listitem>
<para>
Bloom block index in the version 2 root block index format
</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist></section><section><title>File Info format in versions 1 and 2</title>
<para>The file info block is a serialized <link xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/io/HbaseMapWritable.html">HbaseMapWritable</link> (essentially a map from byte arrays to byte arrays) with the following keys, among others. StoreFile-level logic adds more keys to this.</para>
<informaltable frame="all">
<tgroup cols="2"><tbody><row>
<entry>
<para>hfile.LASTKEY </para>
</entry>
<entry>
<para>The last key of the file (byte array) </para>
</entry>
</row>
<row>
<entry>
<para>hfile.AVG_KEY_LEN </para>
</entry>
<entry>
<para>The average key length in the file (int) </para>
</entry>
</row>
<row>
<entry>
<para>hfile.AVG_VALUE_LEN </para>
</entry>
<entry>
<para>The average value length in the file (int) </para>
</entry>
</row></tbody></tgroup>
</informaltable>
<para>File info format did not change in version 2. However, we moved the file info to the final section of the file, which can be loaded as one block at the time the HFile is being opened. Also, we do not store comparator in the version 2 file info anymore. Instead, we store it in the fixed file trailer. This is because we need to know the comparator at the time of parsing the load-on-open section of the HFile.</para></section><section><title>
Fixed file trailer format differences between versions 1 and 2</title>
<para>The following table shows common and different fields between fixed file trailers in versions 1 and 2. Note that the size of the trailer is different depending on the version, so it is “fixed” only within one version. However, the version is always stored as the last four-byte integer in the file. </para>
<para/>
<informaltable frame="all">
<tgroup cols="2">
<colspec colname='c1'/>
<colspec colname='c2'/>
<tbody>
<row>
<entry>
<para>Version 1 </para>
</entry>
<entry>
<para>Version 2 </para>
</entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>File info offset (long) </para>
</entry>
</row>
<row>
<entry>
<para>Data index offset (long) </para>
</entry>
<entry>
<para>loadOnOpenOffset (long)</para>
<para><emphasis>The offset of the section that we need toload when opening the file.</emphasis></para>
</entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>Number of data index entries (int) </para>
</entry>
</row>
<row>
<entry>
<para>metaIndexOffset (long)</para>
<para>This field is not being used by the version 1 reader, so we removed it from version 2.</para>
</entry>
<entry>
<para>uncompressedDataIndexSize (long)</para>
<para>The total uncompressed size of the whole data block index, including root-level, intermediate-level, and leaf-level blocks.</para>
</entry>
</row>
<row>
<entry namest="c1" nameend="c2" align="center">
<para>Number of meta index entries (int) </para>
</entry>
</row>
<row>
<entry namest="c1" nameend="c2" align="center">
<para>Total uncompressed bytes (long) </para>
</entry>
</row>
<row>
<entry>
<para>numEntries (int) </para>
</entry>
<entry>
<para>numEntries (long) </para>
</entry>
</row>
<row>
<entry namest="c1" nameend="c2" align="center">
<para>Compression codec: 0 = LZO, 1 = GZ, 2 = NONE (int) </para>
</entry>
</row>
<row>
<entry>
<para></para>
</entry>
<entry>
<para>The number of levels in the data block index (int) </para>
</entry>
</row>
<row>
<entry>
<para></para>
</entry>
<entry>
<para>firstDataBlockOffset (long)</para>
<para>The offset of the first first data block. Used when scanning. </para>
</entry>
</row>
<row>
<entry>
<para></para>
</entry>
<entry>
<para>lastDataBlockEnd (long)</para>
<para>The offset of the first byte after the last key/value data block. We don't need to go beyond this offset when scanning. </para>
</entry>
</row>
<row>
<entry>
<para>Version: 1 (int) </para>
</entry>
<entry>
<para>Version: 2 (int) </para>
</entry>
</row></tbody></tgroup>
</informaltable>
<para/></section>
<section><title>getShortMidpointKey(an optimization for data index block)</title>
<para>Note: this optimization was introduced in HBase 0.95+</para>
<para>HFiles contain many blocks that contain a range of sorted Cells. Each cell has a key. To save IO when reading Cells, the HFile also has an index that maps a Cell's start key to the offset of the beginning of a particular block. Prior to this optimization, HBase would use the key of the first cell in each data block as the index key.</para>
<para>In HBASE-7845, we generate a new key that is lexicographically larger than the last key of the previous block and lexicographically equal or smaller than the start key of the current block. While actual keys can potentially be very long, this "fake key" or "virtual key" can be much shorter. For example, if the stop key of previous block is "the quick brown fox", the start key of current block is "the who", we could use "the r" as our virtual key in our hfile index.</para>
<para>There are two benefits to this:</para>
<itemizedlist>
<listitem><para>having shorter keys reduces the hfile index size, (allowing us to keep more indexes in memory), and</para></listitem>
<listitem><para>using something closer to the end key of the previous block allows us to avoid a potential extra IO when the target key lives in between the "virtual key" and the key of the first element in the target block.</para></listitem>
</itemizedlist>
<para>This optimization (implemented by the getShortMidpointKey method) is inspired by LevelDB's ByteWiseComparatorImpl::FindShortestSeparator() and FindShortSuccessor().</para>
</section>
</section>
<section xml:id="hfilev3">
<title>HBase File Format with Security Enhancements (version 3)</title>
<para>Note: this feature was introduced in HBase 0.98</para>
<section xml:id="hfilev3.motivation">
<title>Motivation </title>
<para>
Version 3 of HFile makes changes needed to ease management of encryption at rest and
cell-level metadata (which in turn is needed for cell-level ACLs and cell-level visibility
labels). For more information see <xref linkend="hbase.encryption.server"/>,
<xref linkend="hbase.tags"/>, <xref linkend="hbase.accesscontrol.configuration"/>, and
<xref linkend="hbase.visibility.labels"/>.
</para>
</section>
<section xml:id="hfilev3.overview">
<title>Overview</title>
<para>
The version of HBase introducing the above features reads HFiles in versions 1, 2, and 3 but
only writes version 3 HFiles. Version 3 HFiles are structured the same as version 2 HFiles.
For more information see <xref linkend="hfilev2.overview"/>.
</para>
</section>
<section xml:id="hvilev3.infoblock">
<title>File Info Block in Version 3</title>
<para>
Version 3 added two additional pieces of information to the reserved keys in the file info
block.
<informaltable frame="all">
<tgroup cols="2">
<tbody>
<row>
<entry>
<para>hfile.MAX_TAGS_LEN</para>
</entry>
<entry>
<para>
The maximum number of bytes needed to store the serialized tags for any single
cell in this hfile (int)
</para>
</entry>
</row>
<row>
<entry>
<para>hfile.TAGS_COMPRESSED</para>
</entry>
<entry>
<para>Does the block encoder for this hfile compress tags? (boolean)</para>
<para>
Should only be present if <classname>hfile.MAX_TAGS_LEN</classname> is also
present.
</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
When reading a Version 3 HFile the presence of <classname>MAX_TAGS_LEN</classname> is used
to determine how to deserialize the cells within a data block. Therefore, consumers must
read the file's info block prior to reading any data blocks.
</para>
<para>
When writing a Version 3 HFile, HBase will always include <classname>MAX_TAGS_LEN
</classname> when flushing the memstore to underlying filesystem and when using prefix tree
encoding for data blocks, as described in <xref linkend="compression"/>. When compacting
extant files, the default writer will omit <classname>MAX_TAGS_LEN</classname> if all of the
files selected do not themselves contain any cells with tags. See
<xref linkend="compaction"/> for details on the compaction file selection algorithm.
</para>
</section>
<section xml:id="hfilev3.datablock">
<title>Data Blocks in Version 3</title>
<para>
Within an HFile, HBase cells are stored in data blocks as a sequence of KeyValues (see <xref
linkend="hfilev1.overview"/>, or <link xlink:href=
"http://www.larsgeorge.com/2009/10/hbase-architecture-101-storage.html">Lars George's
excellent introduction to HBase Storage</link>). In version 3, these KeyValue optionally
will include a set of 0 or more tags:
<informaltable frame="all">
<tgroup cols="2">
<colspec colname='c1'/>
<colspec colname='c2'/>
<tbody>
<row>
<entry>
<para>Version 1 &amp; 2</para>
<para>Version 3 without MAX_TAGS_LEN</para>
</entry>
<entry><para>Version 3 with MAX_TAGS_LEN</para></entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>Key Length (4 bytes)</para>
</entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>Value Length (4 bytes)</para>
</entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>Key bytes (variable)</para>
</entry>
</row>
<row>
<entry align="center" namest="c1" nameend="c2">
<para>Value bytes (variable)</para>
</entry>
</row>
<row>
<entry align="center" namest="c2" nameend="c2">
<para>Tags Length (2 bytes)</para>
</entry>
</row>
<row>
<entry align="center" namest="c2" nameend="c2">
<para>Tags bytes (variable)</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
If the info block for a given HFile contains an entry for
<classname>MAX_TAGS_LEN</classname> each cell will have the length of that cell's tags
included, even if that length is zero. The actual tags are stored as a sequence of tag
length (2 bytes), tag type (1 byte), tag bytes (variable). The format an individual tag's
bytes depends on the tag type.
</para>
<para>
Note that the dependence on the contents of the info block implies that prior to reading
any data blocks you must first process a file's info block. It also implies that prior to
writing a data block you must know if the file's info block will include
<classname>MAX_TAGS_LEN</classname>.
</para>
</section>
<section xml:id="hfilev3.fixedtrailer">
<title>Fixed File Trailer in Version 3</title>
<para>
The fixed file trailers written with HFile version 3 are always serialized with protocol
buffers. Additionally, it adds an optional field to the version 2 protocol buffer named
encryption_key. If HBase is configured to encrypt HFiles this field will store a data
encryption key for this particular HFile, encrypted with the current cluster master key
using AES. For more information see <xref linkend="hbase.encryption.server"/>.
</para>
</section>
</section>
</appendix>

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="asf"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>HBase and the Apache Software Foundation</title>
<para>HBase is a project in the Apache Software Foundation and as such there are responsibilities to the ASF to ensure
a healthy project.</para>
<section xml:id="asf.devprocess"><title>ASF Development Process</title>
<para>See the <link xlink:href="http://www.apache.org/dev/#committers">Apache Development Process page</link>
for all sorts of information on how the ASF is structured (e.g., PMC, committers, contributors), to tips on contributing
and getting involved, and how open-source works at ASF.
</para>
</section>
<section xml:id="asf.reporting"><title>ASF Board Reporting</title>
<para>Once a quarter, each project in the ASF portfolio submits a report to the ASF board. This is done by the HBase project
lead and the committers. See <link xlink:href="http://www.apache.org/foundation/board/reporting">ASF board reporting</link> for more information.
</para>
</section>
</appendix>

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<book
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook"
xml:id="book">
<info>
<title><link
xlink:href="http://www.hbase.org"> The Apache HBase&#153; Reference Guide </link></title>
<subtitle><link
xlink:href="http://www.hbase.org">
<inlinemediaobject>
<imageobject>
<imagedata
align="center"
valign="left"
fileref="hbase_logo.png" />
</imageobject>
</inlinemediaobject>
<inlinemediaobject>
<imageobject>
<imagedata
align="center"
valign="right"
fileref="jumping-orca_rotated_25percent.png" />
</imageobject>
</inlinemediaobject>
</link>
</subtitle>
<copyright>
<year>2014</year>
<holder>Apache Software Foundation. All Rights Reserved. Apache Hadoop, Hadoop, MapReduce,
HDFS, Zookeeper, HBase, and the HBase project logo are trademarks of the Apache Software
Foundation. </holder>
</copyright>
<abstract>
<para>This is the official reference guide of <link
xlink:href="http://www.hbase.org">Apache HBase&#153;</link>, a distributed, versioned, big
data store built on top of <link
xlink:href="http://hadoop.apache.org/">Apache Hadoop&#153;</link> and <link
xlink:href="http://zookeeper.apache.org/">Apache ZooKeeper&#153;</link>. </para>
</abstract>
<revhistory>
<revision>
<revnumber>
<?eval ${project.version}?>
</revnumber>
<date>
<?eval ${buildDate}?>
</date>
</revision>
</revhistory>
</info>
<!--XInclude some chapters-->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="preface.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="getting_started.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="configuration.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="upgrading.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="shell.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="datamodel.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="schema_design.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="mapreduce.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="security.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="architecture.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="hbase_apis.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="external_apis.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="thrift_filter_language.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="cp.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="performance.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="troubleshooting.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="case_studies.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ops_mgt.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="developer.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="unit_testing.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="zookeeper.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="community.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendix_contributing_to_documentation.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="faq.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="hbck_in_depth.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendix_acl_matrix.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="compression.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sql.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ycsb.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendix_hfile_format.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="other_info.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="hbase_history.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="asf.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="orca.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tracing.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="rpc.xml" />
<index xml:id="book_index">
<title>Index</title>
</index>
</book>

View File

@ -1,239 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
version="5.0"
xml:id="casestudies"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Apache HBase Case Studies</title>
<section
xml:id="casestudies.overview">
<title>Overview</title>
<para> This chapter will describe a variety of performance and troubleshooting case studies that
can provide a useful blueprint on diagnosing Apache HBase cluster issues. </para>
<para> For more information on Performance and Troubleshooting, see <xref
linkend="performance" /> and <xref
linkend="trouble" />. </para>
</section>
<section
xml:id="casestudies.schema">
<title>Schema Design</title>
<para>See the schema design case studies here: <xref
linkend="schema.casestudies" />
</para>
</section>
<!-- schema design -->
<section
xml:id="casestudies.perftroub">
<title>Performance/Troubleshooting</title>
<section
xml:id="casestudies.slownode">
<title>Case Study #1 (Performance Issue On A Single Node)</title>
<section>
<title>Scenario</title>
<para> Following a scheduled reboot, one data node began exhibiting unusual behavior.
Routine MapReduce jobs run against HBase tables which regularly completed in five or six
minutes began taking 30 or 40 minutes to finish. These jobs were consistently found to be
waiting on map and reduce tasks assigned to the troubled data node (e.g., the slow map
tasks all had the same Input Split). The situation came to a head during a distributed
copy, when the copy was severely prolonged by the lagging node. </para>
</section>
<section>
<title>Hardware</title>
<itemizedlist>
<title>Datanodes:</title>
<listitem>
<para>Two 12-core processors</para>
</listitem>
<listitem>
<para>Six Enerprise SATA disks</para>
</listitem>
<listitem>
<para>24GB of RAM</para>
</listitem>
<listitem>
<para>Two bonded gigabit NICs</para>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Network:</title>
<listitem>
<para>10 Gigabit top-of-rack switches</para>
</listitem>
<listitem>
<para>20 Gigabit bonded interconnects between racks.</para>
</listitem>
</itemizedlist>
</section>
<section>
<title>Hypotheses</title>
<section>
<title>HBase "Hot Spot" Region</title>
<para> We hypothesized that we were experiencing a familiar point of pain: a "hot spot"
region in an HBase table, where uneven key-space distribution can funnel a huge number
of requests to a single HBase region, bombarding the RegionServer process and cause slow
response time. Examination of the HBase Master status page showed that the number of
HBase requests to the troubled node was almost zero. Further, examination of the HBase
logs showed that there were no region splits, compactions, or other region transitions
in progress. This effectively ruled out a "hot spot" as the root cause of the observed
slowness. </para>
</section>
<section>
<title>HBase Region With Non-Local Data</title>
<para> Our next hypothesis was that one of the MapReduce tasks was requesting data from
HBase that was not local to the datanode, thus forcing HDFS to request data blocks from
other servers over the network. Examination of the datanode logs showed that there were
very few blocks being requested over the network, indicating that the HBase region was
correctly assigned, and that the majority of the necessary data was located on the node.
This ruled out the possibility of non-local data causing a slowdown. </para>
</section>
<section>
<title>Excessive I/O Wait Due To Swapping Or An Over-Worked Or Failing Hard Disk</title>
<para> After concluding that the Hadoop and HBase were not likely to be the culprits, we
moved on to troubleshooting the datanode's hardware. Java, by design, will periodically
scan its entire memory space to do garbage collection. If system memory is heavily
overcommitted, the Linux kernel may enter a vicious cycle, using up all of its resources
swapping Java heap back and forth from disk to RAM as Java tries to run garbage
collection. Further, a failing hard disk will often retry reads and/or writes many times
before giving up and returning an error. This can manifest as high iowait, as running
processes wait for reads and writes to complete. Finally, a disk nearing the upper edge
of its performance envelope will begin to cause iowait as it informs the kernel that it
cannot accept any more data, and the kernel queues incoming data into the dirty write
pool in memory. However, using <code>vmstat(1)</code> and <code>free(1)</code>, we could
see that no swap was being used, and the amount of disk IO was only a few kilobytes per
second. </para>
</section>
<section>
<title>Slowness Due To High Processor Usage</title>
<para> Next, we checked to see whether the system was performing slowly simply due to very
high computational load. <code>top(1)</code> showed that the system load was higher than
normal, but <code>vmstat(1)</code> and <code>mpstat(1)</code> showed that the amount of
processor being used for actual computation was low. </para>
</section>
<section>
<title>Network Saturation (The Winner)</title>
<para> Since neither the disks nor the processors were being utilized heavily, we moved on
to the performance of the network interfaces. The datanode had two gigabit ethernet
adapters, bonded to form an active-standby interface. <code>ifconfig(8)</code> showed
some unusual anomalies, namely interface errors, overruns, framing errors. While not
unheard of, these kinds of errors are exceedingly rare on modern hardware which is
operating as it should: </para>
<screen language="bourne">
$ /sbin/ifconfig bond0
bond0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:10.x.x.x Bcast:10.x.x.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:2990700159 errors:12 dropped:0 overruns:1 frame:6 &lt;--- Look Here! Errors!
TX packets:3443518196 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2416328868676 (2.4 TB) TX bytes:3464991094001 (3.4 TB)
</screen>
<para> These errors immediately lead us to suspect that one or more of the ethernet
interfaces might have negotiated the wrong line speed. This was confirmed both by
running an ICMP ping from an external host and observing round-trip-time in excess of
700ms, and by running <code>ethtool(8)</code> on the members of the bond interface and
discovering that the active interface was operating at 100Mbs/, full duplex. </para>
<screen language="bourne">
$ sudo ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Link partner advertised link modes: Not reported
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: No
Speed: 100Mb/s &lt;--- Look Here! Should say 1000Mb/s!
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: umbg
Wake-on: g
Current message level: 0x00000003 (3)
Link detected: yes
</screen>
<para> In normal operation, the ICMP ping round trip time should be around 20ms, and the
interface speed and duplex should read, "1000MB/s", and, "Full", respectively. </para>
</section>
</section>
<section>
<title>Resolution</title>
<para> After determining that the active ethernet adapter was at the incorrect speed, we
used the <code>ifenslave(8)</code> command to make the standby interface the active
interface, which yielded an immediate improvement in MapReduce performance, and a 10 times
improvement in network throughput: </para>
<para> On the next trip to the datacenter, we determined that the line speed issue was
ultimately caused by a bad network cable, which was replaced. </para>
</section>
</section>
<!-- case study -->
<section
xml:id="casestudies.perf.1">
<title>Case Study #2 (Performance Research 2012)</title>
<para> Investigation results of a self-described "we're not sure what's wrong, but it seems
slow" problem. <link
xlink:href="http://gbif.blogspot.com/2012/03/hbase-performance-evaluation-continued.html">http://gbif.blogspot.com/2012/03/hbase-performance-evaluation-continued.html</link>
</para>
</section>
<section
xml:id="casestudies.perf.2">
<title>Case Study #3 (Performance Research 2010))</title>
<para> Investigation results of general cluster performance from 2010. Although this research
is on an older version of the codebase, this writeup is still very useful in terms of
approach. <link
xlink:href="http://hstack.org/hbase-performance-testing/">http://hstack.org/hbase-performance-testing/</link>
</para>
</section>
<section
xml:id="casestudies.max.transfer.threads">
<title>Case Study #4 (max.transfer.threads Config)</title>
<para> Case study of configuring <code>max.transfer.threads</code> (previously known as
<code>xcievers</code>) and diagnosing errors from misconfigurations. <link
xlink:href="http://www.larsgeorge.com/2012/03/hadoop-hbase-and-xceivers.html">http://www.larsgeorge.com/2012/03/hadoop-hbase-and-xceivers.html</link>
</para>
<para> See also <xref
linkend="dfs.datanode.max.transfer.threads" />. </para>
</section>
</section>
<!-- performance/troubleshooting -->
</chapter>

View File

@ -1,149 +0,0 @@
<?xml version="1.0"?>
<chapter
xml:id="community"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Community</title>
<section
xml:id="decisions">
<title>Decisions</title>
<section
xml:id="feature_branches">
<title>Feature Branches</title>
<para>Feature Branches are easy to make. You do not have to be a committer to make one. Just
request the name of your branch be added to JIRA up on the developer's mailing list and a
committer will add it for you. Thereafter you can file issues against your feature branch in
Apache HBase JIRA. Your code you keep elsewhere -- it should be public so it can be observed
-- and you can update dev mailing list on progress. When the feature is ready for commit, 3
+1s from committers will get your feature merged. See <link
xlink:href="http://search-hadoop.com/m/asM982C5FkS1">HBase, mail # dev - Thoughts
about large feature dev branches</link></para>
</section>
<section
xml:id="patchplusonepolicy">
<title>Patch +1 Policy</title>
<para> The below policy is something we put in place 09/2012. It is a suggested policy rather
than a hard requirement. We want to try it first to see if it works before we cast it in
stone. </para>
<para> Apache HBase is made of <link
xlink:href="https://issues.apache.org/jira/browse/HBASE#selectedTab=com.atlassian.jira.plugin.system.project%3Acomponents-panel">components</link>.
Components have one or more <xref
linkend="OWNER" />s. See the 'Description' field on the <link
xlink:href="https://issues.apache.org/jira/browse/HBASE#selectedTab=com.atlassian.jira.plugin.system.project%3Acomponents-panel">components</link>
JIRA page for who the current owners are by component. </para>
<para> Patches that fit within the scope of a single Apache HBase component require, at least,
a +1 by one of the component's owners before commit. If owners are absent -- busy or
otherwise -- two +1s by non-owners will suffice. </para>
<para> Patches that span components need at least two +1s before they can be committed,
preferably +1s by owners of components touched by the x-component patch (TODO: This needs
tightening up but I think fine for first pass). </para>
<para> Any -1 on a patch by anyone vetos a patch; it cannot be committed until the
justification for the -1 is addressed. </para>
</section>
<section
xml:id="hbase.fix.version.in.JIRA">
<title>How to set fix version in JIRA on issue resolve</title>
<para>Here is how <link
xlink:href="http://search-hadoop.com/m/azemIi5RCJ1">we agreed</link> to set versions in
JIRA when we resolve an issue. If trunk is going to be 0.98.0 then: </para>
<itemizedlist>
<listitem>
<para> Commit only to trunk: Mark with 0.98 </para>
</listitem>
<listitem>
<para> Commit to 0.95 and trunk : Mark with 0.98, and 0.95.x </para>
</listitem>
<listitem>
<para> Commit to 0.94.x and 0.95, and trunk: Mark with 0.98, 0.95.x, and 0.94.x </para>
</listitem>
<listitem>
<para> Commit to 89-fb: Mark with 89-fb. </para>
</listitem>
<listitem>
<para> Commit site fixes: no version </para>
</listitem>
</itemizedlist>
</section>
<section
xml:id="hbase.when.to.close.JIRA">
<title>Policy on when to set a RESOLVED JIRA as CLOSED</title>
<para>We <link
xlink:href="http://search-hadoop.com/m/4cIKs1iwXMS1">agreed</link> that for issues that
list multiple releases in their <emphasis>Fix Version/s</emphasis> field, CLOSE the issue on
the release of any of the versions listed; subsequent change to the issue must happen in a
new JIRA. </para>
</section>
<section
xml:id="no.permanent.state.in.zk">
<title>Only transient state in ZooKeeper!</title>
<para> You should be able to kill the data in zookeeper and hbase should ride over it
recreating the zk content as it goes. This is an old adage around these parts. We just made
note of it now. We also are currently in violation of this basic tenet -- replication at
least keeps permanent state in zk -- but we are working to undo this breaking of a golden
rule. </para>
</section>
</section>
<section
xml:id="community.roles">
<title>Community Roles</title>
<section
xml:id="OWNER">
<title>Component Owner/Lieutenant</title>
<para> Component owners are listed in the description field on this Apache HBase JIRA <link
xlink:href="https://issues.apache.org/jira/browse/HBASE#selectedTab=com.atlassian.jira.plugin.system.project%3Acomponents-panel">components</link>
page. The owners are listed in the 'Description' field rather than in the 'Component Lead'
field because the latter only allows us list one individual whereas it is encouraged that
components have multiple owners. </para>
<para> Owners or component lieutenants are volunteers who are (usually, but not necessarily)
expert in their component domain and may have an agenda on how they think their Apache HBase
component should evolve. </para>
<orderedlist>
<title>Component Owner Duties</title>
<listitem>
<para> Owners will try and review patches that land within their component's scope.
</para>
</listitem>
<listitem>
<para> If applicable, if an owner has an agenda, they will publish their goals or the
design toward which they are driving their component </para>
</listitem>
</orderedlist>
<para> If you would like to be volunteer as a component owner, just write the dev list and
we'll sign you up. Owners do not need to be committers. </para>
</section>
</section>
<section
xml:id="hbase.commit.msg.format">
<title>Commit Message format</title>
<para>We <link
xlink:href="http://search-hadoop.com/m/Gwxwl10cFHa1">agreed</link> to the following SVN
commit message format:
<programlisting>HBASE-xxxxx &lt;title>. (&lt;contributor>)</programlisting> If the person
making the commit is the contributor, leave off the '(&lt;contributor>)' element. </para>
</section>
</chapter>

View File

@ -1,535 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="compression"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Compression and Data Block Encoding In
HBase<indexterm><primary>Compression</primary><secondary>Data Block
Encoding</secondary><seealso>codecs</seealso></indexterm></title>
<note>
<para>Codecs mentioned in this section are for encoding and decoding data blocks or row keys.
For information about replication codecs, see <xref
linkend="cluster.replication.preserving.tags" />.</para>
</note>
<para>Some of the information in this section is pulled from a <link
xlink:href="http://search-hadoop.com/m/lL12B1PFVhp1/v=threaded">discussion</link> on the
HBase Development mailing list.</para>
<para>HBase supports several different compression algorithms which can be enabled on a
ColumnFamily. Data block encoding attempts to limit duplication of information in keys, taking
advantage of some of the fundamental designs and patterns of HBase, such as sorted row keys
and the schema of a given table. Compressors reduce the size of large, opaque byte arrays in
cells, and can significantly reduce the storage space needed to store uncompressed
data.</para>
<para>Compressors and data block encoding can be used together on the same ColumnFamily.</para>
<formalpara>
<title>Changes Take Effect Upon Compaction</title>
<para>If you change compression or encoding for a ColumnFamily, the changes take effect during
compaction.</para>
</formalpara>
<para>Some codecs take advantage of capabilities built into Java, such as GZip compression.
Others rely on native libraries. Native libraries may be available as part of Hadoop, such as
LZ4. In this case, HBase only needs access to the appropriate shared library. Other codecs,
such as Google Snappy, need to be installed first. Some codecs are licensed in ways that
conflict with HBase's license and cannot be shipped as part of HBase.</para>
<para>This section discusses common codecs that are used and tested with HBase. No matter what
codec you use, be sure to test that it is installed correctly and is available on all nodes in
your cluster. Extra operational steps may be necessary to be sure that codecs are available on
newly-deployed nodes. You can use the <xref
linkend="compression.test" /> utility to check that a given codec is correctly
installed.</para>
<para>To configure HBase to use a compressor, see <xref
linkend="compressor.install" />. To enable a compressor for a ColumnFamily, see <xref
linkend="changing.compression" />. To enable data block encoding for a ColumnFamily, see
<xref linkend="data.block.encoding.enable" />.</para>
<itemizedlist>
<title>Block Compressors</title>
<listitem>
<para>none</para>
</listitem>
<listitem>
<para>Snappy</para>
</listitem>
<listitem>
<para>LZO</para>
</listitem>
<listitem>
<para>LZ4</para>
</listitem>
<listitem>
<para>GZ</para>
</listitem>
</itemizedlist>
<itemizedlist xml:id="data.block.encoding.types">
<title>Data Block Encoding Types</title>
<listitem>
<para>Prefix - Often, keys are very similar. Specifically, keys often share a common prefix
and only differ near the end. For instance, one key might be
<literal>RowKey:Family:Qualifier0</literal> and the next key might be
<literal>RowKey:Family:Qualifier1</literal>. In Prefix encoding, an extra column is
added which holds the length of the prefix shared between the current key and the previous
key. Assuming the first key here is totally different from the key before, its prefix
length is 0. The second key's prefix length is <literal>23</literal>, since they have the
first 23 characters in common.</para>
<para>Obviously if the keys tend to have nothing in common, Prefix will not provide much
benefit.</para>
<para>The following image shows a hypothetical ColumnFamily with no data block encoding.</para>
<figure>
<title>ColumnFamily with No Encoding</title>
<mediaobject>
<imageobject>
<imagedata fileref="data_block_no_encoding.png" width="800"/>
</imageobject>
<caption><para>A ColumnFamily with no encoding></para></caption>
</mediaobject>
</figure>
<para>Here is the same data with prefix data encoding.</para>
<figure>
<title>ColumnFamily with Prefix Encoding</title>
<mediaobject>
<imageobject>
<imagedata fileref="data_block_prefix_encoding.png" width="800"/>
</imageobject>
<caption><para>A ColumnFamily with prefix encoding</para></caption>
</mediaobject>
</figure>
</listitem>
<listitem>
<para>Diff - Diff encoding expands upon Prefix encoding. Instead of considering the key
sequentially as a monolithic series of bytes, each key field is split so that each part of
the key can be compressed more efficiently. Two new fields are added: timestamp and type.
If the ColumnFamily is the same as the previous row, it is omitted from the current row.
If the key length, value length or type are the same as the previous row, the field is
omitted. In addition, for increased compression, the timestamp is stored as a Diff from
the previous row's timestamp, rather than being stored in full. Given the two row keys in
the Prefix example, and given an exact match on timestamp and the same type, neither the
value length, or type needs to be stored for the second row, and the timestamp value for
the second row is just 0, rather than a full timestamp.</para>
<para>Diff encoding is disabled by default because writing and scanning are slower but more
data is cached.</para>
<para>This image shows the same ColumnFamily from the previous images, with Diff encoding.</para>
<figure>
<title>ColumnFamily with Diff Encoding</title>
<mediaobject>
<imageobject>
<imagedata fileref="data_block_diff_encoding.png" width="800"/>
</imageobject>
<caption><para>A ColumnFamily with diff encoding</para></caption>
</mediaobject>
</figure>
</listitem>
<listitem>
<para>Fast Diff - Fast Diff works similar to Diff, but uses a faster implementation. It also
adds another field which stores a single bit to track whether the data itself is the same
as the previous row. If it is, the data is not stored again. Fast Diff is the recommended
codec to use if you have long keys or many columns. The data format is nearly identical to
Diff encoding, so there is not an image to illustrate it.</para>
</listitem>
<listitem>
<para>Prefix Tree encoding was introduced as an experimental feature in HBase 0.96. It
provides similar memory savings to the Prefix, Diff, and Fast Diff encoder, but provides
faster random access at a cost of slower encoding speed. Prefix Tree may be appropriate
for applications that have high block cache hit ratios. It introduces new 'tree' fields
for the row and column. The row tree field contains a list of offsets/references
corresponding to the cells in that row. This allows for a good deal of compression. For
more details about Prefix Tree encoding, see <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-4676">HBASE-4676</link>. It is
difficult to graphically illustrate a prefix tree, so no image is included. See the
Wikipedia article for <link
xlink:href="http://en.wikipedia.org/wiki/Trie">Trie</link> for more general information
about this data structure.</para>
</listitem>
</itemizedlist>
<section>
<title>Which Compressor or Data Block Encoder To Use</title>
<para>The compression or codec type to use depends on the characteristics of your data.
Choosing the wrong type could cause your data to take more space rather than less, and can
have performance implications. In general, you need to weigh your options between smaller
size and faster compression/decompression. Following are some general guidelines, expanded from a discussion at <link xlink:href="http://search-hadoop.com/m/lL12B1PFVhp1">Documenting Guidance on compression and codecs</link>. </para>
<itemizedlist>
<listitem>
<para>If you have long keys (compared to the values) or many columns, use a prefix
encoder. FAST_DIFF is recommended, as more testing is needed for Prefix Tree
encoding.</para>
</listitem>
<listitem>
<para>If the values are large (and not precompressed, such as images), use a data block
compressor.</para>
</listitem>
<listitem>
<para>Use GZIP for <firstterm>cold data</firstterm>, which is accessed infrequently. GZIP
compression uses more CPU resources than Snappy or LZO, but provides a higher
compression ratio.</para>
</listitem>
<listitem>
<para>Use Snappy or LZO for <firstterm>hot data</firstterm>, which is accessed
frequently. Snappy and LZO use fewer CPU resources than GZIP, but do not provide as high
of a compression ratio.</para>
</listitem>
<listitem>
<para>In most cases, enabling Snappy or LZO by default is a good choice, because they have
a low performance overhead and provide space savings.</para>
</listitem>
<listitem>
<para>Before Snappy became available by Google in 2011, LZO was the default. Snappy has
similar qualities as LZO but has been shown to perform better.</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="hadoop.native.lib">
<title>Making use of Hadoop Native Libraries in HBase</title>
<para>The Hadoop shared library has a bunch of facility including
compression libraries and fast crc'ing. To make this facility available
to HBase, do the following. HBase/Hadoop will fall back to use
alternatives if it cannot find the native library versions -- or
fail outright if you asking for an explicit compressor and there is
no alternative available.</para>
<para>If you see the following in your HBase logs, you know that HBase was unable
to locate the Hadoop native libraries:
<programlisting>2014-08-07 09:26:20,139 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable</programlisting>
If the libraries loaded successfully, the WARN message does not show.
</para>
<para>Lets presume your Hadoop shipped with a native library that
suits the platform you are running HBase on. To check if the Hadoop
native library is available to HBase, run the following tool (available in
Hadoop 2.1 and greater):
<programlisting>$ ./bin/hbase --config ~/conf_hbase org.apache.hadoop.util.NativeLibraryChecker
2014-08-26 13:15:38,717 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Native library checking:
hadoop: false
zlib: false
snappy: false
lz4: false
bzip2: false
2014-08-26 13:15:38,863 INFO [main] util.ExitUtil: Exiting with status 1</programlisting>
Above shows that the native hadoop library is not available in HBase context.
</para>
<para>To fix the above, either copy the Hadoop native libraries local or symlink to
them if the Hadoop and HBase stalls are adjacent in the filesystem.
You could also point at their location by setting the <varname>LD_LIBRARY_PATH</varname> environment
variable.</para>
<para>Where the JVM looks to find native librarys is "system dependent"
(See <classname>java.lang.System#loadLibrary(name)</classname>). On linux, by default,
is going to look in <filename>lib/native/PLATFORM</filename> where <varname>PLATFORM</varname>
is the label for the platform your HBase is installed on.
On a local linux machine, it seems to be the concatenation of the java properties
<varname>os.name</varname> and <varname>os.arch</varname> followed by whether 32 or 64 bit.
HBase on startup prints out all of the java system properties so find the os.name and os.arch
in the log. For example:
<programlisting>....
2014-08-06 15:27:22,853 INFO [main] zookeeper.ZooKeeper: Client environment:os.name=Linux
2014-08-06 15:27:22,853 INFO [main] zookeeper.ZooKeeper: Client environment:os.arch=amd64
...
</programlisting>
So in this case, the PLATFORM string is <varname>Linux-amd64-64</varname>.
Copying the Hadoop native libraries or symlinking at <filename>lib/native/Linux-amd64-64</filename>
will ensure they are found. Check with the Hadoop <filename>NativeLibraryChecker</filename>.
</para>
<para>Here is example of how to point at the Hadoop libs with <varname>LD_LIBRARY_PATH</varname>
environment variable:
<programlisting>$ LD_LIBRARY_PATH=~/hadoop-2.5.0-SNAPSHOT/lib/native ./bin/hbase --config ~/conf_hbase org.apache.hadoop.util.NativeLibraryChecker
2014-08-26 13:42:49,332 INFO [main] bzip2.Bzip2Factory: Successfully loaded &amp; initialized native-bzip2 library system-native
2014-08-26 13:42:49,337 INFO [main] zlib.ZlibFactory: Successfully loaded &amp; initialized native-zlib library
Native library checking:
hadoop: true /home/stack/hadoop-2.5.0-SNAPSHOT/lib/native/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/lib64/libsnappy.so.1
lz4: true revision:99
bzip2: true /lib64/libbz2.so.1</programlisting>
Set in <filename>hbase-env.sh</filename> the LD_LIBRARY_PATH environment variable when starting your HBase.
</para>
</section>
<section>
<title>Compressor Configuration, Installation, and Use</title>
<section
xml:id="compressor.install">
<title>Configure HBase For Compressors</title>
<para>Before HBase can use a given compressor, its libraries need to be available. Due to
licensing issues, only GZ compression is available to HBase (via native Java libraries) in
a default installation. Other compression libraries are available via the shared library
bundled with your hadoop. The hadoop native library needs to be findable when HBase
starts. See </para>
<section>
<title>Compressor Support On the Master</title>
<para>A new configuration setting was introduced in HBase 0.95, to check the Master to
determine which data block encoders are installed and configured on it, and assume that
the entire cluster is configured the same. This option,
<code>hbase.master.check.compression</code>, defaults to <literal>true</literal>. This
prevents the situation described in <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-6370">HBASE-6370</link>, where
a table is created or modified to support a codec that a region server does not support,
leading to failures that take a long time to occur and are difficult to debug. </para>
<para>If <code>hbase.master.check.compression</code> is enabled, libraries for all desired
compressors need to be installed and configured on the Master, even if the Master does
not run a region server.</para>
</section>
<section>
<title>Install GZ Support Via Native Libraries</title>
<para>HBase uses Java's built-in GZip support unless the native Hadoop libraries are
available on the CLASSPATH. The recommended way to add libraries to the CLASSPATH is to
set the environment variable <envar>HBASE_LIBRARY_PATH</envar> for the user running
HBase. If native libraries are not available and Java's GZIP is used, <literal>Got
brand-new compressor</literal> reports will be present in the logs. See <xref
linkend="brand.new.compressor" />).</para>
</section>
<section
xml:id="lzo.compression">
<title>Install LZO Support</title>
<para>HBase cannot ship with LZO because of incompatibility between HBase, which uses an
Apache Software License (ASL) and LZO, which uses a GPL license. See the <link
xlink:href="http://wiki.apache.org/hadoop/UsingLzoCompression">Using LZO
Compression</link> wiki page for information on configuring LZO support for HBase. </para>
<para>If you depend upon LZO compression, consider configuring your RegionServers to fail
to start if LZO is not available. See <xref
linkend="hbase.regionserver.codecs" />.</para>
</section>
<section
xml:id="lz4.compression">
<title>Configure LZ4 Support</title>
<para>LZ4 support is bundled with Hadoop. Make sure the hadoop shared library
(libhadoop.so) is accessible when you start
HBase. After configuring your platform (see <xref
linkend="hbase.native.platform" />), you can make a symbolic link from HBase to the native Hadoop
libraries. This assumes the two software installs are colocated. For example, if my
'platform' is Linux-amd64-64:
<programlisting language="bourne">$ cd $HBASE_HOME
$ mkdir lib/native
$ ln -s $HADOOP_HOME/lib/native lib/native/Linux-amd64-64</programlisting>
Use the compression tool to check that LZ4 is installed on all nodes. Start up (or restart)
HBase. Afterward, you can create and alter tables to enable LZ4 as a
compression codec.:
<screen>
hbase(main):003:0> <userinput>alter 'TestTable', {NAME => 'info', COMPRESSION => 'LZ4'}</userinput>
</screen>
</para>
</section>
<section
xml:id="snappy.compression.installation">
<title>Install Snappy Support</title>
<para>HBase does not ship with Snappy support because of licensing issues. You can install
Snappy binaries (for instance, by using <command>yum install snappy</command> on CentOS)
or build Snappy from source. After installing Snappy, search for the shared library,
which will be called <filename>libsnappy.so.X</filename> where X is a number. If you
built from source, copy the shared library to a known location on your system, such as
<filename>/opt/snappy/lib/</filename>.</para>
<para>In addition to the Snappy library, HBase also needs access to the Hadoop shared
library, which will be called something like <filename>libhadoop.so.X.Y</filename>,
where X and Y are both numbers. Make note of the location of the Hadoop library, or copy
it to the same location as the Snappy library.</para>
<note>
<para>The Snappy and Hadoop libraries need to be available on each node of your cluster.
See <xref
linkend="compression.test" /> to find out how to test that this is the case.</para>
<para>See <xref
linkend="hbase.regionserver.codecs" /> to configure your RegionServers to fail to
start if a given compressor is not available.</para>
</note>
<para>Each of these library locations need to be added to the environment variable
<envar>HBASE_LIBRARY_PATH</envar> for the operating system user that runs HBase. You
need to restart the RegionServer for the changes to take effect.</para>
</section>
<section
xml:id="compression.test">
<title>CompressionTest</title>
<para>You can use the CompressionTest tool to verify that your compressor is available to
HBase:</para>
<screen language="bourne">
$ hbase org.apache.hadoop.hbase.util.CompressionTest hdfs://<replaceable>host/path/to/hbase</replaceable> snappy
</screen>
</section>
<section
xml:id="hbase.regionserver.codecs">
<title>Enforce Compression Settings On a RegionServer</title>
<para>You can configure a RegionServer so that it will fail to restart if compression is
configured incorrectly, by adding the option hbase.regionserver.codecs to the
<filename>hbase-site.xml</filename>, and setting its value to a comma-separated list
of codecs that need to be available. For example, if you set this property to
<literal>lzo,gz</literal>, the RegionServer would fail to start if both compressors
were not available. This would prevent a new server from being added to the cluster
without having codecs configured properly.</para>
</section>
</section>
<section
xml:id="changing.compression">
<title>Enable Compression On a ColumnFamily</title>
<para>To enable compression for a ColumnFamily, use an <code>alter</code> command. You do
not need to re-create the table or copy data. If you are changing codecs, be sure the old
codec is still available until all the old StoreFiles have been compacted.</para>
<example>
<title>Enabling Compression on a ColumnFamily of an Existing Table using HBase
Shell</title>
<screen><![CDATA[
hbase> disable 'test'
hbase> alter 'test', {NAME => 'cf', COMPRESSION => 'GZ'}
hbase> enable 'test']]>
</screen>
</example>
<example>
<title>Creating a New Table with Compression On a ColumnFamily</title>
<screen><![CDATA[
hbase> create 'test2', { NAME => 'cf2', COMPRESSION => 'SNAPPY' }
]]></screen>
</example>
<example>
<title>Verifying a ColumnFamily's Compression Settings</title>
<screen><![CDATA[
hbase> describe 'test'
DESCRIPTION ENABLED
'test', {NAME => 'cf', DATA_BLOCK_ENCODING => 'NONE false
', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0',
VERSIONS => '1', COMPRESSION => 'GZ', MIN_VERSIONS
=> '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'fa
lse', BLOCKSIZE => '65536', IN_MEMORY => 'false', B
LOCKCACHE => 'true'}
1 row(s) in 0.1070 seconds
]]></screen>
</example>
</section>
<section>
<title>Testing Compression Performance</title>
<para>HBase includes a tool called LoadTestTool which provides mechanisms to test your
compression performance. You must specify either <literal>-write</literal> or
<literal>-update-read</literal> as your first parameter, and if you do not specify another
parameter, usage advice is printed for each option.</para>
<example>
<title><command>LoadTestTool</command> Usage</title>
<screen language="bourne"><![CDATA[
$ bin/hbase org.apache.hadoop.hbase.util.LoadTestTool -h
usage: bin/hbase org.apache.hadoop.hbase.util.LoadTestTool <options>
Options:
-batchupdate Whether to use batch as opposed to separate
updates for every column in a row
-bloom <arg> Bloom filter type, one of [NONE, ROW, ROWCOL]
-compression <arg> Compression type, one of [LZO, GZ, NONE, SNAPPY,
LZ4]
-data_block_encoding <arg> Encoding algorithm (e.g. prefix compression) to
use for data blocks in the test column family, one
of [NONE, PREFIX, DIFF, FAST_DIFF, PREFIX_TREE].
-encryption <arg> Enables transparent encryption on the test table,
one of [AES]
-generator <arg> The class which generates load for the tool. Any
args for this class can be passed as colon
separated after class name
-h,--help Show usage
-in_memory Tries to keep the HFiles of the CF inmemory as far
as possible. Not guaranteed that reads are always
served from inmemory
-init_only Initialize the test table only, don't do any
loading
-key_window <arg> The 'key window' to maintain between reads and
writes for concurrent write/read workload. The
default is 0.
-max_read_errors <arg> The maximum number of read errors to tolerate
before terminating all reader threads. The default
is 10.
-multiput Whether to use multi-puts as opposed to separate
puts for every column in a row
-num_keys <arg> The number of keys to read/write
-num_tables <arg> A positive integer number. When a number n is
speicfied, load test tool will load n table
parallely. -tn parameter value becomes table name
prefix. Each table name is in format
<tn>_1...<tn>_n
-read <arg> <verify_percent>[:<#threads=20>]
-regions_per_server <arg> A positive integer number. When a number n is
specified, load test tool will create the test
table with n regions per server
-skip_init Skip the initialization; assume test table already
exists
-start_key <arg> The first key to read/write (a 0-based index). The
default value is 0.
-tn <arg> The name of the table to read or write
-update <arg> <update_percent>[:<#threads=20>][:<#whether to
ignore nonce collisions=0>]
-write <arg> <avg_cols_per_key>:<avg_data_size>[:<#threads=20>]
-zk <arg> ZK quorum as comma-separated host names without
port numbers
-zk_root <arg> name of parent znode in zookeeper
]]></screen>
</example>
<example>
<title>Example Usage of LoadTestTool</title>
<screen language="bourne">
$ hbase org.apache.hadoop.hbase.util.LoadTestTool -write 1:10:100 -num_keys 1000000
-read 100:30 -num_tables 1 -data_block_encoding NONE -tn load_test_tool_NONE
</screen>
</example>
</section>
</section>
<section xml:id="data.block.encoding.enable">
<title>Enable Data Block Encoding</title>
<para>Codecs are built into HBase so no extra configuration is needed. Codecs are enabled on a
table by setting the <code>DATA_BLOCK_ENCODING</code> property. Disable the table before
altering its DATA_BLOCK_ENCODING setting. Following is an example using HBase Shell:</para>
<example>
<title>Enable Data Block Encoding On a Table</title>
<screen><![CDATA[
hbase> disable 'test'
hbase> alter 'test', { NAME => 'cf', DATA_BLOCK_ENCODING => 'FAST_DIFF' }
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 2.2820 seconds
hbase> enable 'test'
0 row(s) in 0.1580 seconds
]]></screen>
</example>
<example>
<title>Verifying a ColumnFamily's Data Block Encoding</title>
<screen><![CDATA[
hbase> describe 'test'
DESCRIPTION ENABLED
'test', {NAME => 'cf', DATA_BLOCK_ENCODING => 'FAST true
_DIFF', BLOOMFILTER => 'ROW', REPLICATION_SCOPE =>
'0', VERSIONS => '1', COMPRESSION => 'GZ', MIN_VERS
IONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS =
> 'false', BLOCKSIZE => '65536', IN_MEMORY => 'fals
e', BLOCKCACHE => 'true'}
1 row(s) in 0.0650 seconds
]]></screen>
</example>
</section>
</appendix>

File diff suppressed because it is too large Load Diff

View File

@ -1,431 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
version="5.0"
xml:id="cp"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Apache HBase Coprocessors</title>
<para> HBase coprocessors are modeled after the coprocessors which are part of Google's BigTable
(<link xlink:href="http://www.scribd.com/doc/21631448/Dean-Keynote-Ladis2009"/>, pages
66-67.). Coprocessors function in a similar way to Linux kernel modules. They provide a way to
run server-level code against locally-stored data. The functionality they provide is very
powerful, but also carries great risk and can have adverse effects on the system, at the level
of the operating system. The information in this chapter is primarily sourced and heavily reused
from Mingjie Lai's blog post at <link
xlink:href="https://blogs.apache.org/hbase/entry/coprocessor_introduction"/>. </para>
<para> Coprocessors are not designed to be used by end users of HBase, but by HBase developers who
need to add specialized functionality to HBase. One example of the use of coprocessors is
pluggable compaction and scan policies, which are provided as coprocessors in <link
xlink:href="HBASE-6427">HBASE-6427</link>. </para>
<section>
<title>Coprocessor Framework</title>
<para>The implementation of HBase coprocessors diverges from the BigTable implementation. The
HBase framework provides a library and runtime environment for executing user code within the
HBase region server and master processes. </para>
<para> The framework API is provided in the <link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/coprocessor/package-summary.html">coprocessor</link>
package.</para>
<para>Two different types of coprocessors are provided by the framework, based on their
scope.</para>
<variablelist>
<title>Types of Coprocessors</title>
<varlistentry>
<term>System Coprocessors</term>
<listitem>
<para>System coprocessors are loaded globally on all tables and regions hosted by a region
server.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Table Coprocessors</term>
<listitem>
<para>You can specify which coprocessors should be loaded on all regions for a table on a
per-table basis.</para>
</listitem>
</varlistentry>
</variablelist>
<para>The framework provides two different aspects of extensions as well:
<firstterm>observers</firstterm> and <firstterm>endpoints</firstterm>.</para>
<variablelist>
<varlistentry>
<term>Observers</term>
<listitem>
<para>Observers are analogous to triggers in conventional databases. They allow you to
insert user code by overriding upcall methods provided by the coprocessor framework.
Callback functions are executed from core HBase code when events occur. Callbacks are
handled by the framework, and the coprocessor itself only needs to insert the extended
or alternate functionality.</para>
<variablelist>
<title>Provided Observer Interfaces</title>
<varlistentry>
<term><link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/coprocessor/RegionObserver.html">RegionObserver</link></term>
<listitem>
<para>A RegionObserver provides hooks for data manipulation events, such as Get,
Put, Delete, Scan. An instance of a RegionObserver coprocessor exists for each
table region. The scope of the observations a RegionObserver can make is
constrained to that region. </para>
</listitem>
</varlistentry>
<varlistentry>
<term><link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.html">RegionServerObserver</link></term>
<listitem>
<para>A RegionServerObserver provides for operations related to the RegionServer,
such as stopping the RegionServer and performing operations before or after
merges, commits, or rollbacks.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/coprocessor/WALObserver.html">WALObserver</link></term>
<listitem>
<para>A WALObserver provides hooks for operations related to the write-ahead log
(WAL). You can observe or intercept WAL writing and reconstruction events. A
WALObserver runs in the context of WAL processing. A single WALObserver exists on
a single region server.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/coprocessor/MasterObserver.html">MasterObserver</link></term>
<listitem>
<para>A MasterObserver provides hooks for DDL-type operation, such as create,
delete, modify table. The MasterObserver runs within the context of the HBase
master. </para>
</listitem>
</varlistentry>
</variablelist>
<para>More than one observer of a given type can be loaded at once. Multiple observers are
chained to execute sequentially by order of assigned priority. Nothing prevents a
coprocessor implementor from communicating internally among its installed
observers.</para>
<para>An observer of a higher priority can preempt lower-priority observers by throwing an
IOException or a subclass of IOException.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Endpoints (HBase 0.96.x and later)</term>
<listitem>
<para>The implementation for endpoints changed significantly in HBase 0.96.x due to the
introduction of protocol buffers (protobufs) (<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-5448">HBASE-5488</link>). If
you created endpoints before 0.96.x, you will need to rewrite them. Endpoints are now
defined and callable as protobuf services, rather than endpoint invocations passed
through as Writable blobs</para>
<para>Dynamic RPC endpoints resemble stored procedures. An endpoint can be invoked at any
time from the client. When it is invoked, it is executed remotely at the target region
or regions, and results of the executions are returned to the client.</para>
<para>The endpoint implementation is installed on the server and is invoked using HBase
RPC. The client library provides convenience methods for invoking these dynamic
interfaces. </para>
<para>An endpoint, like an observer, can communicate with any installed observers. This
allows you to plug new features into HBase without modifying or recompiling HBase
itself.</para>
<itemizedlist>
<title>Steps to Implement an Endpoint</title>
<listitem><para>Define the coprocessor service and related messages in a <filename>.proto</filename> file</para></listitem>
<listitem><para>Run the <command>protoc</command> command to generate the code.</para></listitem>
<listitem><para>Write code to implement the following:</para>
<itemizedlist>
<listitem><para>the generated protobuf Service interface</para></listitem>
<listitem>
<para>the new <link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTable.html#coprocessorService(byte[])">org.apache.hadoop.hbase.coprocessor.CoprocessorService</link>
interface (required for the <link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.html">RegionCoprocessorHost</link>
to register the exposed service)</para></listitem>
</itemizedlist>
</listitem>
<listitem><para>The client calls the new HTable.coprocessorService() methods to perform the endpoint RPCs.</para></listitem>
</itemizedlist>
<para>For more information and examples, refer to the API documentation for the <link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/coprocessor/package-summary.html">coprocessor</link>
package, as well as the included RowCount example in the
<filename>/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/</filename>
of the HBase source.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Endpoints (HBase 0.94.x and earlier)</term>
<listitem>
<para>Dynamic RPC endpoints resemble stored procedures. An endpoint can be invoked at any
time from the client. When it is invoked, it is executed remotely at the target region
or regions, and results of the executions are returned to the client.</para>
<para>The endpoint implementation is installed on the server and is invoked using HBase
RPC. The client library provides convenience methods for invoking these dynamic
interfaces. </para>
<para>An endpoint, like an observer, can communicate with any installed observers. This
allows you to plug new features into HBase without modifying or recompiling HBase
itself.</para>
<itemizedlist>
<title>Steps to Implement an Endpoint</title>
<listitem>
<bridgehead>Server-Side</bridgehead>
<itemizedlist>
<listitem>
<para>Create new protocol interface which extends CoprocessorProtocol.</para>
</listitem>
<listitem>
<para>Implement the Endpoint interface. The implementation will be loaded into and
executed from the region context.</para>
</listitem>
<listitem>
<para>Extend the abstract class BaseEndpointCoprocessor. This convenience class
hides some internal details that the implementer does not need to be concerned
about, ˆ such as coprocessor framework class loading.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<bridgehead>Client-Side</bridgehead>
<para>Endpoint can be invoked by two new HBase client APIs:</para>
<itemizedlist>
<listitem>
<para><code>HTableInterface.coprocessorProxy(Class&lt;T&gt; protocol, byte[]
row)</code> for executing against a single region</para>
</listitem>
<listitem>
<para><code>HTableInterface.coprocessorExec(Class&lt;T&gt; protocol, byte[]
startKey, byte[] endKey, Batch.Call&lt;T,R&gt; callable)</code> for executing
over a range of regions</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
</variablelist>
</section>
<section>
<title>Examples</title>
<para>An example of an observer is included in
<filename>hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestZooKeeperScanPolicyObserver.java</filename>.
Several endpoint examples are included in the same directory.</para>
</section>
<section>
<title>Building A Coprocessor</title>
<para>Before you can build a processor, it must be developed, compiled, and packaged in a JAR
file. The next step is to configure the coprocessor framework to use your coprocessor. You can
load the coprocessor from your HBase configuration, so that the coprocessor starts with HBase,
or you can configure the coprocessor from the HBase shell, as a table attribute, so that it is
loaded dynamically when the table is opened or reopened.</para>
<section>
<title>Load from Configuration</title>
<para> To configure a coprocessor to be loaded when HBase starts, modify the RegionServer's
<filename>hbase-site.xml</filename> and configure one of the following properties, based
on the type of observer you are configuring: </para>
<itemizedlist>
<listitem>
<para><code>hbase.coprocessor.region.classes</code>for RegionObservers and
Endpoints</para>
</listitem>
<listitem>
<para><code>hbase.coprocessor.wal.classes</code>for WALObservers</para>
</listitem>
<listitem>
<para><code>hbase.coprocessor.master.classes</code>for MasterObservers</para>
</listitem>
</itemizedlist>
<example>
<title>Example RegionObserver Configuration</title>
<para>In this example, one RegionObserver is configured for all the HBase tables.</para>
<screen language="xml"><![CDATA[
<property>
<name>hbase.coprocessor.region.classes</name>
<value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>
</property> ]]>
</screen>
</example>
<para> If multiple classes are specified for loading, the class names must be comma-separated.
The framework attempts to load all the configured classes using the default class loader.
Therefore, the jar file must reside on the server-side HBase classpath.</para>
<para>Coprocessors which are loaded in this way will be active on all regions of
all tables. These are the system coprocessor introduced earlier. The first listed
coprocessors will be assigned the priority <literal>Coprocessor.Priority.SYSTEM</literal>.
Each subsequent coprocessor in the list will have its priority value incremented by one
(which reduces its priority, because priorities have the natural sort order of Integers). </para>
<para>When calling out to registered observers, the framework executes their callbacks methods
in the sorted order of their priority. Ties are broken arbitrarily.</para>
</section>
<section>
<title>Load from the HBase Shell</title>
<para> You can load a coprocessor on a specific table via a table attribute. The following
example will load the <systemitem>FooRegionObserver</systemitem> observer when table
<systemitem>t1</systemitem> is read or re-read. </para>
<example>
<title>Load a Coprocessor On a Table Using HBase Shell</title>
<screen>
hbase(main):005:0> <userinput>alter 't1', METHOD => 'table_att',
'coprocessor'=>'hdfs:///foo.jar|com.foo.FooRegionObserver|1001|arg1=1,arg2=2'</userinput>
<computeroutput>Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.0730 seconds</computeroutput>
hbase(main):006:0> <userinput>describe 't1'</userinput>
<computeroutput>DESCRIPTION ENABLED
{NAME => 't1', coprocessor$1 => 'hdfs:///foo.jar|com.foo.FooRegio false
nObserver|1001|arg1=1,arg2=2', FAMILIES => [{NAME => 'c1', DATA_B
LOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE
=> '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS =>
'0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZ
E => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLO
CKCACHE => 'true'}, {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE',
BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3'
, COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647'
, KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY
=> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0190 seconds</computeroutput>
</screen>
</example>
<para>The coprocessor framework will try to read the class information from the coprocessor
table attribute value. The value contains four pieces of information which are separated by
the <literal>|</literal> character.</para>
<itemizedlist>
<listitem>
<para>File path: The jar file containing the coprocessor implementation must be in a
location where all region servers can read it. You could copy the file onto the local
disk on each region server, but it is recommended to store it in HDFS.</para>
</listitem>
<listitem>
<para>Class name: The full class name of the coprocessor.</para>
</listitem>
<listitem>
<para>Priority: An integer. The framework will determine the execution sequence of all
configured observers registered at the same hook using priorities. This field can be
left blank. In that case the framework will assign a default priority value.</para>
</listitem>
<listitem>
<para>Arguments: This field is passed to the coprocessor implementation.</para>
</listitem>
</itemizedlist>
<example>
<title>Unload a Coprocessor From a Table Using HBase Shell</title>
<screen>
hbase(main):007:0> <userinput>alter 't1', METHOD => 'table_att_unset',</userinput>
hbase(main):008:0* <userinput>NAME => 'coprocessor$1'</userinput>
<computeroutput>Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.1130 seconds</computeroutput>
hbase(main):009:0> <userinput>describe 't1'</userinput>
<computeroutput>DESCRIPTION ENABLED
{NAME => 't1', FAMILIES => [{NAME => 'c1', DATA_BLOCK_ENCODING => false
'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSION
S => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '214
7483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN
_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true
'}, {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER =>
'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_C
ELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCO
DE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0180 seconds </computeroutput>
</screen>
</example>
<warning>
<para>There is no guarantee that the framework will load a given coprocessor successfully.
For example, the shell command neither guarantees a jar file exists at a particular
location nor verifies whether the given class is actually contained in the jar file.
</para>
</warning>
</section>
</section>
<section>
<title>Check the Status of a Coprocessor</title>
<para>To check the status of a coprocessor after it has been configured, use the
<command>status</command> HBase Shell command.</para>
<screen>
hbase(main):020:0> <userinput>status 'detailed'</userinput>
<computeroutput>version 0.92-tm-6
0 regionsInTransition
master coprocessors: []
1 live servers
localhost:52761 1328082515520
requestsPerSecond=3, numberOfOnlineRegions=3, usedHeapMB=32, maxHeapMB=995
-ROOT-,,0
numberOfStores=1, numberOfStorefiles=1, storefileUncompressedSizeMB=0, storefileSizeMB=0, memstoreSizeMB=0,
storefileIndexSizeMB=0, readRequestsCount=54, writeRequestsCount=1, rootIndexSizeKB=0, totalStaticIndexSizeKB=0,
totalStaticBloomSizeKB=0, totalCompactingKVs=0, currentCompactedKVs=0, compactionProgressPct=NaN, coprocessors=[]
.META.,,1
numberOfStores=1, numberOfStorefiles=0, storefileUncompressedSizeMB=0, storefileSizeMB=0, memstoreSizeMB=0,
storefileIndexSizeMB=0, readRequestsCount=97, writeRequestsCount=4, rootIndexSizeKB=0, totalStaticIndexSizeKB=0,
totalStaticBloomSizeKB=0, totalCompactingKVs=0, currentCompactedKVs=0, compactionProgressPct=NaN, coprocessors=[]
t1,,1328082575190.c0491168a27620ffe653ec6c04c9b4d1.
numberOfStores=2, numberOfStorefiles=1, storefileUncompressedSizeMB=0, storefileSizeMB=0, memstoreSizeMB=0,
storefileIndexSizeMB=0, readRequestsCount=0, writeRequestsCount=0, rootIndexSizeKB=0, totalStaticIndexSizeKB=0,
totalStaticBloomSizeKB=0, totalCompactingKVs=0, currentCompactedKVs=0, compactionProgressPct=NaN,
coprocessors=[AggregateImplementation]
0 dead servers </computeroutput>
</screen>
</section>
<section>
<title>Monitor Time Spent in Coprocessors</title>
<para>HBase 0.98.5 introduced the ability to monitor some statistics relating to the amount of
time spent executing a given coprocessor. You can see these statistics via the HBase Metrics
framework (see <xref linkend="hbase_metrics"/> or the Web UI for a given Region Server, via
the <guilabel>Coprocessor Metrics</guilabel> tab. These statistics are valuable for debugging
and benchmarking the performance impact of a given coprocessor on your cluster. Tracked
statistics include min, max, average, and 90th, 95th, and 99th percentile. All times are shown
in milliseconds. The statistics are calculated over coprocessor
execution samples recorded during the reporting interval, which is 10 seconds by default. The
metrics sampling rate as described in <xref linkend="hbase_metrics" />.</para>
<figure>
<title>Coprocessor Metrics UI</title>
<mediaobject>
<imageobject>
<imagedata fileref="coprocessor_stats.png" width="100%"/>
</imageobject>
<caption>
<para>The Coprocessor Metrics UI shows statistics about time spent executing a given
coprocessor, including min, max, average, and 90th, 95th, and 99th percentile.</para>
</caption>
</mediaobject>
</figure>
</section>
<section>
<title>Status of Coprocessors in HBase</title>
<para> Coprocessors and the coprocessor framework are evolving rapidly and work is ongoing on
several different JIRAs. </para>
</section>
</chapter>

View File

@ -1,129 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<xsl:import href="urn:docbkx:stylesheet/docbook.xsl"/>
<xsl:import href="urn:docbkx:stylesheet/highlight.xsl"/>
<!--###################################################
Paper & Page Size
################################################### -->
<!-- Paper type, no headers on blank pages, no double sided printing -->
<xsl:param name="paper.type" select="'USletter'"/>
<xsl:param name="double.sided">0</xsl:param>
<xsl:param name="headers.on.blank.pages">0</xsl:param>
<xsl:param name="footers.on.blank.pages">0</xsl:param>
<!-- Space between paper border and content (chaotic stuff, don't touch) -->
<xsl:param name="page.margin.top">5mm</xsl:param>
<xsl:param name="region.before.extent">10mm</xsl:param>
<xsl:param name="body.margin.top">10mm</xsl:param>
<xsl:param name="body.margin.bottom">15mm</xsl:param>
<xsl:param name="region.after.extent">10mm</xsl:param>
<xsl:param name="page.margin.bottom">0mm</xsl:param>
<xsl:param name="page.margin.outer">18mm</xsl:param>
<xsl:param name="page.margin.inner">18mm</xsl:param>
<!-- No intendation of Titles -->
<xsl:param name="title.margin.left">0pc</xsl:param>
<!--###################################################
Fonts & Styles
################################################### -->
<!-- Left aligned text and no hyphenation -->
<xsl:param name="alignment">justify</xsl:param>
<xsl:param name="hyphenate">true</xsl:param>
<!-- Default Font size -->
<xsl:param name="body.font.master">11</xsl:param>
<xsl:param name="body.font.small">8</xsl:param>
<!-- Line height in body text -->
<xsl:param name="line-height">1.4</xsl:param>
<!-- Force line break in long URLs -->
<xsl:param name="ulink.hyphenate.chars">/&amp;?</xsl:param>
<xsl:param name="ulink.hyphenate">&#x200B;</xsl:param>
<!-- Monospaced fonts are smaller than regular text -->
<xsl:attribute-set name="monospace.properties">
<xsl:attribute name="font-family">
<xsl:value-of select="$monospace.font.family"/>
</xsl:attribute>
<xsl:attribute name="font-size">0.8em</xsl:attribute>
<xsl:attribute name="wrap-option">wrap</xsl:attribute>
<xsl:attribute name="hyphenate">true</xsl:attribute>
</xsl:attribute-set>
<!-- add page break after abstract block -->
<xsl:attribute-set name="abstract.properties">
<xsl:attribute name="break-after">page</xsl:attribute>
</xsl:attribute-set>
<!-- add page break after toc -->
<xsl:attribute-set name="toc.margin.properties">
<xsl:attribute name="break-after">page</xsl:attribute>
</xsl:attribute-set>
<!-- add page break after first level sections -->
<xsl:attribute-set name="section.level1.properties">
<xsl:attribute name="break-after">page</xsl:attribute>
</xsl:attribute-set>
<!-- Show only Sections up to level 3 in the TOCs -->
<xsl:param name="toc.section.depth">2</xsl:param>
<!-- Dot and Whitespace as separator in TOC between Label and Title-->
<xsl:param name="autotoc.label.separator" select="'. '"/>
<!-- program listings / examples formatting -->
<xsl:attribute-set name="monospace.verbatim.properties">
<xsl:attribute name="font-family">Courier</xsl:attribute>
<xsl:attribute name="font-size">8pt</xsl:attribute>
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
</xsl:attribute-set>
<xsl:param name="shade.verbatim" select="1" />
<xsl:attribute-set name="shade.verbatim.style">
<xsl:attribute name="background-color">#E8E8E8</xsl:attribute>
<xsl:attribute name="border-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-color">#575757</xsl:attribute>
<xsl:attribute name="padding">3pt</xsl:attribute>
</xsl:attribute-set>
<!-- callouts customization -->
<xsl:param name="callout.unicode" select="1" />
<xsl:param name="callout.graphics" select="0" />
<xsl:param name="callout.defaultcolumn">90</xsl:param>
<!-- Syntax Highlighting -->
</xsl:stylesheet>

View File

@ -1,49 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<xsl:import href="urn:docbkx:stylesheet"/>
<xsl:import href="urn:docbkx:stylesheet/highlight.xsl"/>
<xsl:output method="html" encoding="UTF-8" indent="no"/>
<xsl:template name="user.header.content">
<script type="text/javascript">
var disqus_shortname = 'hbase'; // required: replace example with your forum shortname
var disqus_url = 'http://hbase.apache.org/book/<xsl:value-of select="@xml:id" />.html';
<!--var disqus_identifier = '<xsl:value-of select="@xml:id" />';--></script>
</xsl:template>
<xsl:template name="user.footer.content">
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,865 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
xml:id="datamodel"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Data Model</title>
<para>In HBase, data is stored in tables, which have rows and columns. This is a terminology
overlap with relational databases (RDBMSs), but this is not a helpful analogy. Instead, it can
be helpful to think of an HBase table as a multi-dimensional map.</para>
<variablelist>
<title>HBase Data Model Terminology</title>
<varlistentry>
<term>Table</term>
<listitem>
<para>An HBase table consists of multiple rows.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Row</term>
<listitem>
<para>A row in HBase consists of a row key and one or more columns with values associated
with them. Rows are sorted alphabetically by the row key as they are stored. For this
reason, the design of the row key is very important. The goal is to store data in such a
way that related rows are near each other. A common row key pattern is a website domain.
If your row keys are domains, you should probably store them in reverse (org.apache.www,
org.apache.mail, org.apache.jira). This way, all of the Apache domains are near each
other in the table, rather than being spread out based on the first letter of the
subdomain.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Column</term>
<listitem>
<para>A column in HBase consists of a column family and a column qualifier, which are
delimited by a <literal>:</literal> (colon) character.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Column Family</term>
<listitem>
<para>Column families physically colocate a set of columns and their values, often for
performance reasons. Each column family has a set of storage properties, such as whether
its values should be cached in memory, how its data is compressed or its row keys are
encoded, and others. Each row in a table has the same column
families, though a given row might not store anything in a given column family.</para>
<para>Column families are specified when you create your table, and influence the way your
data is stored in the underlying filesystem. Therefore, the column families should be
considered carefully during schema design.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Column Qualifier</term>
<listitem>
<para>A column qualifier is added to a column family to provide the index for a given
piece of data. Given a column family <literal>content</literal>, a column qualifier
might be <literal>content:html</literal>, and another might be
<literal>content:pdf</literal>. Though column families are fixed at table creation,
column qualifiers are mutable and may differ greatly between rows.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Cell</term>
<listitem>
<para>A cell is a combination of row, column family, and column qualifier, and contains a
value and a timestamp, which represents the value's version.</para>
<para>A cell's value is an uninterpreted array of bytes.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Timestamp</term>
<listitem>
<para>A timestamp is written alongside each value, and is the identifier for a given
version of a value. By default, the timestamp represents the time on the RegionServer
when the data was written, but you can specify a different timestamp value when you put
data into the cell.</para>
<caution>
<para>Direct manipulation of timestamps is an advanced feature which is only exposed for
special cases that are deeply integrated with HBase, and is discouraged in general.
Encoding a timestamp at the application level is the preferred pattern.</para>
</caution>
<para>You can specify the maximum number of versions of a value that HBase retains, per column
family. When the maximum number of versions is reached, the oldest versions are
eventually deleted. By default, only the newest version is kept.</para>
</listitem>
</varlistentry>
</variablelist>
<section
xml:id="conceptual.view">
<title>Conceptual View</title>
<para>You can read a very understandable explanation of the HBase data model in the blog post <link
xlink:href="http://jimbojw.com/wiki/index.php?title=Understanding_Hbase_and_BigTable">Understanding
HBase and BigTable</link> by Jim R. Wilson. Another good explanation is available in the
PDF <link
xlink:href="http://0b4af6cdc2f0c5998459-c0245c5c937c5dedcca3f1764ecc9b2f.r43.cf2.rackcdn.com/9353-login1210_khurana.pdf">Introduction
to Basic Schema Design</link> by Amandeep Khurana. It may help to read different
perspectives to get a solid understanding of HBase schema design. The linked articles cover
the same ground as the information in this section.</para>
<para> The following example is a slightly modified form of the one on page 2 of the <link
xlink:href="http://research.google.com/archive/bigtable.html">BigTable</link> paper. There
is a table called <varname>webtable</varname> that contains two rows
(<literal>com.cnn.www</literal>
and <literal>com.example.www</literal>), three column families named
<varname>contents</varname>, <varname>anchor</varname>, and <varname>people</varname>. In
this example, for the first row (<literal>com.cnn.www</literal>),
<varname>anchor</varname> contains two columns (<varname>anchor:cssnsi.com</varname>,
<varname>anchor:my.look.ca</varname>) and <varname>contents</varname> contains one column
(<varname>contents:html</varname>). This example contains 5 versions of the row with the
row key <literal>com.cnn.www</literal>, and one version of the row with the row key
<literal>com.example.www</literal>. The <varname>contents:html</varname> column qualifier contains the entire
HTML of a given website. Qualifiers of the <varname>anchor</varname> column family each
contain the external site which links to the site represented by the row, along with the
text it used in the anchor of its link. The <varname>people</varname> column family represents
people associated with the site.
</para>
<note>
<title>Column Names</title>
<para> By convention, a column name is made of its column family prefix and a
<emphasis>qualifier</emphasis>. For example, the column
<emphasis>contents:html</emphasis> is made up of the column family
<varname>contents</varname> and the <varname>html</varname> qualifier. The colon
character (<literal>:</literal>) delimits the column family from the column family
<emphasis>qualifier</emphasis>. </para>
</note>
<table
frame="all">
<title>Table <varname>webtable</varname></title>
<tgroup
cols="5"
align="left"
colsep="1"
rowsep="1">
<colspec
colname="c1" />
<colspec
colname="c2" />
<colspec
colname="c3" />
<colspec
colname="c4" />
<colspec
colname="c5" />
<thead>
<row>
<entry>Row Key</entry>
<entry>Time Stamp</entry>
<entry>ColumnFamily <varname>contents</varname></entry>
<entry>ColumnFamily <varname>anchor</varname></entry>
<entry>ColumnFamily <varname>people</varname></entry>
</row>
</thead>
<tbody>
<row>
<entry>"com.cnn.www"</entry>
<entry>t9</entry>
<entry />
<entry><varname>anchor:cnnsi.com</varname> = "CNN"</entry>
<entry />
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t8</entry>
<entry />
<entry><varname>anchor:my.look.ca</varname> = "CNN.com"</entry>
<entry />
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t6</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
<entry />
<entry />
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t5</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
<entry />
<entry />
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t3</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
<entry />
<entry />
</row>
<row>
<entry>"com.example.www"</entry>
<entry>t5</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
<entry></entry>
<entry>people:author = "John Doe"</entry>
</row>
</tbody>
</tgroup>
</table>
<para>Cells in this table that appear to be empty do not take space, or in fact exist, in
HBase. This is what makes HBase "sparse." A tabular view is not the only possible way to
look at data in HBase, or even the most accurate. The following represents the same
information as a multi-dimensional map. This is only a mock-up for illustrative
purposes and may not be strictly accurate.</para>
<programlisting><![CDATA[
{
"com.cnn.www": {
contents: {
t6: contents:html: "<html>..."
t5: contents:html: "<html>..."
t3: contents:html: "<html>..."
}
anchor: {
t9: anchor:cnnsi.com = "CNN"
t8: anchor:my.look.ca = "CNN.com"
}
people: {}
}
"com.example.www": {
contents: {
t5: contents:html: "<html>..."
}
anchor: {}
people: {
t5: people:author: "John Doe"
}
}
}
]]></programlisting>
</section>
<section
xml:id="physical.view">
<title>Physical View</title>
<para> Although at a conceptual level tables may be viewed as a sparse set of rows, they are
physically stored by column family. A new column qualifier (column_family:column_qualifier)
can be added to an existing column family at any time.</para>
<table
frame="all">
<title>ColumnFamily <varname>anchor</varname></title>
<tgroup
cols="3"
align="left"
colsep="1"
rowsep="1">
<colspec
colname="c1" />
<colspec
colname="c2" />
<colspec
colname="c3" />
<thead>
<row>
<entry>Row Key</entry>
<entry>Time Stamp</entry>
<entry>Column Family <varname>anchor</varname></entry>
</row>
</thead>
<tbody>
<row>
<entry>"com.cnn.www"</entry>
<entry>t9</entry>
<entry><varname>anchor:cnnsi.com</varname> = "CNN"</entry>
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t8</entry>
<entry><varname>anchor:my.look.ca</varname> = "CNN.com"</entry>
</row>
</tbody>
</tgroup>
</table>
<table
frame="all">
<title>ColumnFamily <varname>contents</varname></title>
<tgroup
cols="3"
align="left"
colsep="1"
rowsep="1">
<colspec
colname="c1" />
<colspec
colname="c2" />
<colspec
colname="c3" />
<thead>
<row>
<entry>Row Key</entry>
<entry>Time Stamp</entry>
<entry>ColumnFamily "contents:"</entry>
</row>
</thead>
<tbody>
<row>
<entry>"com.cnn.www"</entry>
<entry>t6</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t5</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
</row>
<row>
<entry>"com.cnn.www"</entry>
<entry>t3</entry>
<entry><varname>contents:html</varname> = "&lt;html&gt;..."</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The empty cells shown in the
conceptual view are not stored at all.
Thus a request for the value of the <varname>contents:html</varname> column at time stamp
<literal>t8</literal> would return no value. Similarly, a request for an
<varname>anchor:my.look.ca</varname> value at time stamp <literal>t9</literal> would
return no value. However, if no timestamp is supplied, the most recent value for a
particular column would be returned. Given multiple versions, the most recent is also the
first one found, since timestamps
are stored in descending order. Thus a request for the values of all columns in the row
<varname>com.cnn.www</varname> if no timestamp is specified would be: the value of
<varname>contents:html</varname> from timestamp <literal>t6</literal>, the value of
<varname>anchor:cnnsi.com</varname> from timestamp <literal>t9</literal>, the value of
<varname>anchor:my.look.ca</varname> from timestamp <literal>t8</literal>. </para>
<para>For more information about the internals of how Apache HBase stores data, see <xref
linkend="regions.arch" />. </para>
</section>
<section
xml:id="namespace">
<title>Namespace</title>
<para> A namespace is a logical grouping of tables analogous to a database in relation
database systems. This abstraction lays the groundwork for upcoming multi-tenancy related
features: <itemizedlist>
<listitem>
<para>Quota Management (HBASE-8410) - Restrict the amount of resources (ie regions,
tables) a namespace can consume.</para>
</listitem>
<listitem>
<para>Namespace Security Administration (HBASE-9206) - provide another level of security
administration for tenants.</para>
</listitem>
<listitem>
<para>Region server groups (HBASE-6721) - A namespace/table can be pinned onto a subset
of regionservers thus guaranteeing a course level of isolation.</para>
</listitem>
</itemizedlist>
</para>
<section
xml:id="namespace_creation">
<title>Namespace management</title>
<para> A namespace can be created, removed or altered. Namespace membership is determined
during table creation by specifying a fully-qualified table name of the form:</para>
<programlisting language="xml"><![CDATA[<table namespace>:<table qualifier>]]></programlisting>
<example>
<title>Examples</title>
<programlisting language="bourne">
#Create a namespace
create_namespace 'my_ns'
</programlisting>
<programlisting language="bourne">
#create my_table in my_ns namespace
create 'my_ns:my_table', 'fam'
</programlisting>
<programlisting language="bourne">
#drop namespace
drop_namespace 'my_ns'
</programlisting>
<programlisting language="bourne">
#alter namespace
alter_namespace 'my_ns', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}
</programlisting>
</example>
</section>
<section
xml:id="namespace_special">
<title>Predefined namespaces</title>
<para> There are two predefined special namespaces: </para>
<itemizedlist>
<listitem>
<para>hbase - system namespace, used to contain hbase internal tables</para>
</listitem>
<listitem>
<para>default - tables with no explicit specified namespace will automatically fall into
this namespace.</para>
</listitem>
</itemizedlist>
<example>
<title>Examples</title>
<programlisting language="bourne">
#namespace=foo and table qualifier=bar
create 'foo:bar', 'fam'
#namespace=default and table qualifier=bar
create 'bar', 'fam'
</programlisting>
</example>
</section>
</section>
<section
xml:id="table">
<title>Table</title>
<para> Tables are declared up front at schema definition time. </para>
</section>
<section
xml:id="row">
<title>Row</title>
<para>Row keys are uninterrpreted bytes. Rows are lexicographically sorted with the lowest
order appearing first in a table. The empty byte array is used to denote both the start and
end of a tables' namespace.</para>
</section>
<section
xml:id="columnfamily">
<title>Column Family<indexterm><primary>Column Family</primary></indexterm></title>
<para> Columns in Apache HBase are grouped into <emphasis>column families</emphasis>. All
column members of a column family have the same prefix. For example, the columns
<emphasis>courses:history</emphasis> and <emphasis>courses:math</emphasis> are both
members of the <emphasis>courses</emphasis> column family. The colon character
(<literal>:</literal>) delimits the column family from the <indexterm><primary>column
family qualifier</primary><secondary>Column Family Qualifier</secondary></indexterm>.
The column family prefix must be composed of <emphasis>printable</emphasis> characters. The
qualifying tail, the column family <emphasis>qualifier</emphasis>, can be made of any
arbitrary bytes. Column families must be declared up front at schema definition time whereas
columns do not need to be defined at schema time but can be conjured on the fly while the
table is up an running.</para>
<para>Physically, all column family members are stored together on the filesystem. Because
tunings and storage specifications are done at the column family level, it is advised that
all column family members have the same general access pattern and size
characteristics.</para>
</section>
<section
xml:id="cells">
<title>Cells<indexterm><primary>Cells</primary></indexterm></title>
<para>A <emphasis>{row, column, version} </emphasis>tuple exactly specifies a
<literal>cell</literal> in HBase. Cell content is uninterrpreted bytes</para>
</section>
<section
xml:id="data_model_operations">
<title>Data Model Operations</title>
<para>The four primary data model operations are Get, Put, Scan, and Delete. Operations are
applied via <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html">Table</link>
instances.
</para>
<section
xml:id="get">
<title>Get</title>
<para><link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html">Get</link>
returns attributes for a specified row. Gets are executed via <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#get(org.apache.hadoop.hbase.client.Get)">
Table.get</link>. </para>
</section>
<section
xml:id="put">
<title>Put</title>
<para><link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Put.html">Put</link>
either adds new rows to a table (if the key is new) or can update existing rows (if the
key already exists). Puts are executed via <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#put(org.apache.hadoop.hbase.client.Put)">
Table.put</link> (writeBuffer) or <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#batch(java.util.List, java.lang.Object[])">
Table.batch</link> (non-writeBuffer). </para>
</section>
<section
xml:id="scan">
<title>Scans</title>
<para><link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html">Scan</link>
allow iteration over multiple rows for specified attributes. </para>
<para>The following is an example of a Scan on a Table instance. Assume that a table is
populated with rows with keys "row1", "row2", "row3", and then another set of rows with
the keys "abc1", "abc2", and "abc3". The following example shows how to set a Scan
instance to return the rows beginning with "row".</para>
<programlisting language="java">
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Table table = ... // instantiate a Table instance
Scan scan = new Scan();
scan.addColumn(CF, ATTR);
scan.setRowPrefixFilter(Bytes.toBytes("row"));
ResultScanner rs = table.getScanner(scan);
try {
for (Result r = rs.next(); r != null; r = rs.next()) {
// process result...
} finally {
rs.close(); // always close the ResultScanner!
</programlisting>
<para>Note that generally the easiest way to specify a specific stop point for a scan is by
using the <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/InclusiveStopFilter.html">InclusiveStopFilter</link>
class. </para>
</section>
<section
xml:id="delete">
<title>Delete</title>
<para><link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Delete.html">Delete</link>
removes a row from a table. Deletes are executed via <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#delete(org.apache.hadoop.hbase.client.Delete)">
HTable.delete</link>. </para>
<para>HBase does not modify data in place, and so deletes are handled by creating new
markers called <emphasis>tombstones</emphasis>. These tombstones, along with the dead
values, are cleaned up on major compactions. </para>
<para>See <xref
linkend="version.delete" /> for more information on deleting versions of columns, and
see <xref
linkend="compaction" /> for more information on compactions. </para>
</section>
</section>
<section
xml:id="versions">
<title>Versions<indexterm><primary>Versions</primary></indexterm></title>
<para>A <emphasis>{row, column, version} </emphasis>tuple exactly specifies a
<literal>cell</literal> in HBase. It's possible to have an unbounded number of cells where
the row and column are the same but the cell address differs only in its version
dimension.</para>
<para>While rows and column keys are expressed as bytes, the version is specified using a long
integer. Typically this long contains time instances such as those returned by
<code>java.util.Date.getTime()</code> or <code>System.currentTimeMillis()</code>, that is:
<quote>the difference, measured in milliseconds, between the current time and midnight,
January 1, 1970 UTC</quote>.</para>
<para>The HBase version dimension is stored in decreasing order, so that when reading from a
store file, the most recent values are found first.</para>
<para>There is a lot of confusion over the semantics of <literal>cell</literal> versions, in
HBase. In particular:</para>
<itemizedlist>
<listitem>
<para>If multiple writes to a cell have the same version, only the last written is
fetchable.</para>
</listitem>
<listitem>
<para>It is OK to write cells in a non-increasing version order.</para>
</listitem>
</itemizedlist>
<para>Below we describe how the version dimension in HBase currently works. See <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-2406">HBASE-2406</link> for
discussion of HBase versions. <link
xlink:href="http://outerthought.org/blog/417-ot.html">Bending time in HBase</link>
makes for a good read on the version, or time, dimension in HBase. It has more detail on
versioning than is provided here. As of this writing, the limiitation
<emphasis>Overwriting values at existing timestamps</emphasis> mentioned in the
article no longer holds in HBase. This section is basically a synopsis of this article
by Bruno Dumon.</para>
<section xml:id="specify.number.of.versions">
<title>Specifying the Number of Versions to Store</title>
<para>The maximum number of versions to store for a given column is part of the column
schema and is specified at table creation, or via an <command>alter</command> command, via
<code>HColumnDescriptor.DEFAULT_VERSIONS</code>. Prior to HBase 0.96, the default number
of versions kept was <literal>3</literal>, but in 0.96 and newer has been changed to
<literal>1</literal>.</para>
<example>
<title>Modify the Maximum Number of Versions for a Column</title>
<para>This example uses HBase Shell to keep a maximum of 5 versions of column
<code>f1</code>. You could also use <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HColumnDescriptor.html"
>HColumnDescriptor</link>.</para>
<screen><![CDATA[hbase> alter t1, NAME => f1, VERSIONS => 5]]></screen>
</example>
<example>
<title>Modify the Minimum Number of Versions for a Column</title>
<para>You can also specify the minimum number of versions to store. By default, this is
set to 0, which means the feature is disabled. The following example sets the minimum
number of versions on field <code>f1</code> to <literal>2</literal>, via HBase Shell.
You could also use <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HColumnDescriptor.html"
>HColumnDescriptor</link>.</para>
<screen><![CDATA[hbase> alter t1, NAME => f1, MIN_VERSIONS => 2]]></screen>
</example>
<para>Starting with HBase 0.98.2, you can specify a global default for the maximum number of
versions kept for all newly-created columns, by setting
<option>hbase.column.max.version</option> in <filename>hbase-site.xml</filename>. See
<xref linkend="hbase.column.max.version"/>.</para>
</section>
<section
xml:id="versions.ops">
<title>Versions and HBase Operations</title>
<para>In this section we look at the behavior of the version dimension for each of the core
HBase operations.</para>
<section>
<title>Get/Scan</title>
<para>Gets are implemented on top of Scans. The below discussion of <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html">Get</link>
applies equally to <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html">Scans</link>.</para>
<para>By default, i.e. if you specify no explicit version, when doing a
<literal>get</literal>, the cell whose version has the largest value is returned
(which may or may not be the latest one written, see later). The default behavior can be
modified in the following ways:</para>
<itemizedlist>
<listitem>
<para>to return more than one version, see <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html#setMaxVersions()">Get.setMaxVersions()</link></para>
</listitem>
<listitem>
<para>to return versions other than the latest, see <link
xlink:href="???">Get.setTimeRange()</link></para>
<para>To retrieve the latest version that is less than or equal to a given value, thus
giving the 'latest' state of the record at a certain point in time, just use a range
from 0 to the desired version and set the max versions to 1.</para>
</listitem>
</itemizedlist>
</section>
<section
xml:id="default_get_example">
<title>Default Get Example</title>
<para>The following Get will only retrieve the current version of the row</para>
<programlisting language="java">
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Get get = new Get(Bytes.toBytes("row1"));
Result r = table.get(get);
byte[] b = r.getValue(CF, ATTR); // returns current version of value
</programlisting>
</section>
<section
xml:id="versioned_get_example">
<title>Versioned Get Example</title>
<para>The following Get will return the last 3 versions of the row.</para>
<programlisting language="java">
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Get get = new Get(Bytes.toBytes("row1"));
get.setMaxVersions(3); // will return last 3 versions of row
Result r = table.get(get);
byte[] b = r.getValue(CF, ATTR); // returns current version of value
List&lt;KeyValue&gt; kv = r.getColumn(CF, ATTR); // returns all versions of this column
</programlisting>
</section>
<section>
<title>Put</title>
<para>Doing a put always creates a new version of a <literal>cell</literal>, at a certain
timestamp. By default the system uses the server's <literal>currentTimeMillis</literal>,
but you can specify the version (= the long integer) yourself, on a per-column level.
This means you could assign a time in the past or the future, or use the long value for
non-time purposes.</para>
<para>To overwrite an existing value, do a put at exactly the same row, column, and
version as that of the cell you would overshadow.</para>
<section
xml:id="implicit_version_example">
<title>Implicit Version Example</title>
<para>The following Put will be implicitly versioned by HBase with the current
time.</para>
<programlisting language="java">
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Put put = new Put(Bytes.toBytes(row));
put.add(CF, ATTR, Bytes.toBytes( data));
table.put(put);
</programlisting>
</section>
<section
xml:id="explicit_version_example">
<title>Explicit Version Example</title>
<para>The following Put has the version timestamp explicitly set.</para>
<programlisting language="java">
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR = "attr".getBytes();
...
Put put = new Put( Bytes.toBytes(row));
long explicitTimeInMs = 555; // just an example
put.add(CF, ATTR, explicitTimeInMs, Bytes.toBytes(data));
table.put(put);
</programlisting>
<para>Caution: the version timestamp is internally by HBase for things like time-to-live
calculations. It's usually best to avoid setting this timestamp yourself. Prefer using
a separate timestamp attribute of the row, or have the timestamp a part of the rowkey,
or both. </para>
</section>
</section>
<section
xml:id="version.delete">
<title>Delete</title>
<para>There are three different types of internal delete markers. See Lars Hofhansl's blog
for discussion of his attempt adding another, <link
xlink:href="http://hadoop-hbase.blogspot.com/2012/01/scanning-in-hbase.html">Scanning
in HBase: Prefix Delete Marker</link>. </para>
<itemizedlist>
<listitem>
<para>Delete: for a specific version of a column.</para>
</listitem>
<listitem>
<para>Delete column: for all versions of a column.</para>
</listitem>
<listitem>
<para>Delete family: for all columns of a particular ColumnFamily</para>
</listitem>
</itemizedlist>
<para>When deleting an entire row, HBase will internally create a tombstone for each
ColumnFamily (i.e., not each individual column). </para>
<para>Deletes work by creating <emphasis>tombstone</emphasis> markers. For example, let's
suppose we want to delete a row. For this you can specify a version, or else by default
the <literal>currentTimeMillis</literal> is used. What this means is <quote>delete all
cells where the version is less than or equal to this version</quote>. HBase never
modifies data in place, so for example a delete will not immediately delete (or mark as
deleted) the entries in the storage file that correspond to the delete condition.
Rather, a so-called <emphasis>tombstone</emphasis> is written, which will mask the
deleted values. When HBase does a major compaction, the tombstones are processed to
actually remove the dead values, together with the tombstones themselves. If the version
you specified when deleting a row is larger than the version of any value in the row,
then you can consider the complete row to be deleted.</para>
<para>For an informative discussion on how deletes and versioning interact, see the thread <link
xlink:href="http://comments.gmane.org/gmane.comp.java.hadoop.hbase.user/28421">Put w/
timestamp -> Deleteall -> Put w/ timestamp fails</link> up on the user mailing
list.</para>
<para>Also see <xref
linkend="keyvalue" /> for more information on the internal KeyValue format. </para>
<para>Delete markers are purged during the next major compaction of the store, unless the
<option>KEEP_DELETED_CELLS</option> option is set in the column family. To keep the
deletes for a configurable amount of time, you can set the delete TTL via the
<option>hbase.hstore.time.to.purge.deletes</option> property in
<filename>hbase-site.xml</filename>. If
<option>hbase.hstore.time.to.purge.deletes</option> is not set, or set to 0, all
delete markers, including those with timestamps in the future, are purged during the
next major compaction. Otherwise, a delete marker with a timestamp in the future is kept
until the major compaction which occurs after the time represented by the marker's
timestamp plus the value of <option>hbase.hstore.time.to.purge.deletes</option>, in
milliseconds. </para>
<note>
<para>This behavior represents a fix for an unexpected change that was introduced in
HBase 0.94, and was fixed in <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-10118">HBASE-10118</link>.
The change has been backported to HBase 0.94 and newer branches.</para>
</note>
</section>
</section>
<section>
<title>Current Limitations</title>
<section>
<title>Deletes mask Puts</title>
<para>Deletes mask puts, even puts that happened after the delete
was entered. See <link xlink:href="https://issues.apache.org/jira/browse/HBASE-2256"
>HBASE-2256</link>. Remember that a delete writes a tombstone, which only
disappears after then next major compaction has run. Suppose you do
a delete of everything &lt;= T. After this you do a new put with a
timestamp &lt;= T. This put, even if it happened after the delete,
will be masked by the delete tombstone. Performing the put will not
fail, but when you do a get you will notice the put did have no
effect. It will start working again after the major compaction has
run. These issues should not be a problem if you use
always-increasing versions for new puts to a row. But they can occur
even if you do not care about time: just do delete and put
immediately after each other, and there is some chance they happen
within the same millisecond.</para>
</section>
<section
xml:id="major.compactions.change.query.results">
<title>Major compactions change query results</title>
<para><quote>...create three cell versions at t1, t2 and t3, with a maximum-versions
setting of 2. So when getting all versions, only the values at t2 and t3 will be
returned. But if you delete the version at t2 or t3, the one at t1 will appear again.
Obviously, once a major compaction has run, such behavior will not be the case
anymore...</quote> (See <emphasis>Garbage Collection</emphasis> in <link
xlink:href="http://outerthought.org/blog/417-ot.html">Bending time in
HBase</link>.)</para>
</section>
</section>
</section>
<section xml:id="dm.sort">
<title>Sort Order</title>
<para>All data model operations HBase return data in sorted order. First by row,
then by ColumnFamily, followed by column qualifier, and finally timestamp (sorted
in reverse, so newest records are returned first).
</para>
</section>
<section xml:id="dm.column.metadata">
<title>Column Metadata</title>
<para>There is no store of column metadata outside of the internal KeyValue instances for a ColumnFamily.
Thus, while HBase can support not only a wide number of columns per row, but a heterogenous set of columns
between rows as well, it is your responsibility to keep track of the column names.
</para>
<para>The only way to get a complete set of columns that exist for a ColumnFamily is to process all the rows.
For more information about how HBase stores data internally, see <xref linkend="keyvalue" />.
</para>
</section>
<section xml:id="joins"><title>Joins</title>
<para>Whether HBase supports joins is a common question on the dist-list, and there is a simple answer: it doesn't,
at not least in the way that RDBMS' support them (e.g., with equi-joins or outer-joins in SQL). As has been illustrated
in this chapter, the read data model operations in HBase are Get and Scan.
</para>
<para>However, that doesn't mean that equivalent join functionality can't be supported in your application, but
you have to do it yourself. The two primary strategies are either denormalizing the data upon writing to HBase,
or to have lookup tables and do the join between HBase tables in your application or MapReduce code (and as RDBMS'
demonstrate, there are several strategies for this depending on the size of the tables, e.g., nested loops vs.
hash-joins). So which is the best approach? It depends on what you are trying to do, and as such there isn't a single
answer that works for every use case.
</para>
</section>
<section xml:id="acid"><title>ACID</title>
<para>See <link xlink:href="http://hbase.apache.org/acid-semantics.html">ACID Semantics</link>.
Lars Hofhansl has also written a note on
<link xlink:href="http://hadoop-hbase.blogspot.com/2012/03/acid-in-hbase.html">ACID in HBase</link>.</para>
</section>
</chapter>

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
version="5.0"
xml:id="external_apis"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Apache HBase External APIs</title>
<para> This chapter will cover access to Apache HBase either through non-Java languages, or
through custom protocols. For information on using the native HBase APIs, refer to <link
xlink:href="http://hbase.apache.org/apidocs/index.html">User API Reference</link> and the new <xref
linkend="hbase_apis" /> chapter. </para>
<section xml:id="nonjava.jvm">
<title>Non-Java Languages Talking to the JVM</title>
<para>Currently the documentation on this topic in the
<link xlink:href="http://wiki.apache.org/hadoop/Hbase">Apache HBase Wiki</link>.
See also the <link xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/thrift/package-summary.html#package_description">Thrift API Javadoc</link>.
</para>
</section>
<section xml:id="rest">
<title>REST</title>
<para>Currently most of the documentation on REST exists in the
<link xlink:href="http://wiki.apache.org/hadoop/Hbase/Stargate">Apache HBase Wiki on REST</link> (The REST gateway used to be
called 'Stargate'). There are also a nice set of blogs on <link xlink:href="http://blog.cloudera.com/blog/2013/03/how-to-use-the-apache-hbase-rest-interface-part-1/">How-to: Use the Apache HBase REST Interface</link>
by Jesse Anderson.
</para>
<para>
To run your REST server under SSL, set hbase.rest.ssl.enabled to true and also set the
following configs when you launch the REST server:(See example commands in
<xref linkend="JMX_config" />)
<programlisting>
hbase.rest.ssl.keystore.store
hbase.rest.ssl.keystore.password
hbase.rest.ssl.keystore.keypassword</programlisting>
</para>
<para>
HBase ships a simple REST client, see <link xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/rest/client/package-summary.html">REST client</link> package for details.
To enable SSL support for it, please also import your certificate into local java
cacerts keystore:
<screen language="bourne">keytool -import -trustcacerts -file /home/user/restserver.cert -keystore $JAVA_HOME/jre/lib/security/cacerts</screen>
</para>
</section> <!-- rest -->
<section>
<title>Thrift</title>
<para>Documentation about Thrift has moved to <xref linkend="thrift" />.</para>
</section> <!-- thrift -->
<section xml:id="c">
<title>C/C++ Apache HBase Client</title>
<para>FB's Chip Turner wrote a pure C/C++ client. <link xlink:href="https://github.com/facebook/native-cpp-hbase-client">Check it out</link>.
</para>
</section>
</chapter>

View File

@ -1,270 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="faq"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title >FAQ</title>
<qandaset defaultlabel='qanda'>
<qandadiv><title>General</title>
<qandaentry>
<question><para>When should I use HBase?</para></question>
<answer>
<para>See the <xref linkend="arch.overview" /> in the Architecture chapter.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>Are there other HBase FAQs?</para></question>
<answer>
<para>
See the FAQ that is up on the wiki, <link xlink:href="http://wiki.apache.org/hadoop/Hbase/FAQ">HBase Wiki FAQ</link>.
</para>
</answer>
</qandaentry>
<qandaentry xml:id="faq.sql">
<question><para>Does HBase support SQL?</para></question>
<answer>
<para>
Not really. SQL-ish support for HBase via <link xlink:href="http://hive.apache.org/">Hive</link> is in development, however Hive is based on MapReduce which is not generally suitable for low-latency requests.
See the <xref linkend="datamodel" /> section for examples on the HBase client.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>How can I find examples of NoSQL/HBase?</para></question>
<answer>
<para>See the link to the BigTable paper in <xref linkend="other.info" /> in the appendix, as
well as the other papers.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>What is the history of HBase?</para></question>
<answer>
<para>See <xref linkend="hbase.history"/>.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv>
<title>Upgrading</title>
<qandaentry>
<question>
<para>How do I upgrade Maven-managed projects from HBase 0.94 to HBase 0.96+?</para>
</question>
<answer>
<para>In HBase 0.96, the project moved to a modular structure. Adjust your project's
dependencies to rely upon the <filename>hbase-client</filename> module or another
module as appropriate, rather than a single JAR. You can model your Maven depency
after one of the following, depending on your targeted version of HBase. See <xref
linkend="upgrade0.96"/> or <xref linkend="upgrade0.98"/> for more
information.</para>
<example>
<title>Maven Dependency for HBase 0.98</title>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.98.5-hadoop2</version>
</dependency>
]]></programlisting>
</example>
<example>
<title>Maven Dependency for HBase 0.96</title>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.96.2-hadoop2</version>
</dependency>
]]></programlisting>
</example>
<example>
<title>Maven Dependency for HBase 0.94</title>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.94.3</version>
</dependency>
]]></programlisting>
</example>
</answer>
</qandaentry>
</qandadiv>
<qandadiv xml:id="faq.arch"><title>Architecture</title>
<qandaentry xml:id="faq.arch.regions">
<question><para>How does HBase handle Region-RegionServer assignment and locality?</para></question>
<answer>
<para>
See <xref linkend="regions.arch" />.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv xml:id="faq.config"><title>Configuration</title>
<qandaentry xml:id="faq.config.started">
<question><para>How can I get started with my first cluster?</para></question>
<answer>
<para>
See <xref linkend="quickstart" />.
</para>
</answer>
</qandaentry>
<qandaentry xml:id="faq.config.options">
<question><para>Where can I learn about the rest of the configuration options?</para></question>
<answer>
<para>
See <xref linkend="configuration" />.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv xml:id="faq.design"><title>Schema Design / Data Access</title>
<qandaentry xml:id="faq.design.schema">
<question><para>How should I design my schema in HBase?</para></question>
<answer>
<para>
See <xref linkend="datamodel" /> and <xref linkend="schema" />
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>
How can I store (fill in the blank) in HBase?
</para></question>
<answer>
<para>
See <xref linkend="supported.datatypes" />.
</para>
</answer>
</qandaentry>
<qandaentry xml:id="secondary.indices">
<question><para>
How can I handle secondary indexes in HBase?
</para></question>
<answer>
<para>
See <xref linkend="secondary.indexes" />
</para>
</answer>
</qandaentry>
<qandaentry xml:id="faq.changing.rowkeys">
<question><para>Can I change a table's rowkeys?</para></question>
<answer>
<para> This is a very common question. You can't. See <xref
linkend="changing.rowkeys"/>. </para>
</answer>
</qandaentry>
<qandaentry xml:id="faq.apis">
<question><para>What APIs does HBase support?</para></question>
<answer>
<para>
See <xref linkend="datamodel" />, <xref linkend="client" /> and <xref linkend="nonjava.jvm"/>.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv xml:id="faq.mapreduce"><title>MapReduce</title>
<qandaentry xml:id="faq.mapreduce.use">
<question><para>How can I use MapReduce with HBase?</para></question>
<answer>
<para>
See <xref linkend="mapreduce" />
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv><title>Performance and Troubleshooting</title>
<qandaentry>
<question><para>
How can I improve HBase cluster performance?
</para></question>
<answer>
<para>
See <xref linkend="performance" />.
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>
How can I troubleshoot my HBase cluster?
</para></question>
<answer>
<para>
See <xref linkend="trouble" />.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv xml:id="ec2"><title>Amazon EC2</title>
<qandaentry>
<question><para>
I am running HBase on Amazon EC2 and...
</para></question>
<answer>
<para>
EC2 issues are a special case. See Troubleshooting <xref linkend="trouble.ec2" /> and Performance <xref linkend="perf.ec2" /> sections.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv><title xml:id="faq.operations">Operations</title>
<qandaentry>
<question><para>
How do I manage my HBase cluster?
</para></question>
<answer>
<para>
See <xref linkend="ops_mgt" />
</para>
</answer>
</qandaentry>
<qandaentry>
<question><para>
How do I back up my HBase cluster?
</para></question>
<answer>
<para>
See <xref linkend="ops.backup" />
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv><title>HBase in Action</title>
<qandaentry>
<question><para>Where can I find interesting videos and presentations on HBase?</para></question>
<answer>
<para>
See <xref linkend="other.info" />
</para>
</answer>
</qandaentry>
</qandadiv>
</qandaset>
</appendix>

View File

@ -1,728 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
version="5.0"
xml:id="getting_started"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Getting Started</title>
<section>
<title>Introduction</title>
<para><xref linkend="quickstart"/> will get you up and running on a single-node, standalone
instance of HBase, followed by a pseudo-distributed single-machine instance, and finally a
fully-distributed cluster. </para>
</section>
<section
xml:id="quickstart">
<title>Quick Start - Standalone HBase</title>
<para>This guide describes setup of a standalone HBase instance running against the local
filesystem. This is not an appropriate configuration for a production instance of HBase, but
will allow you to experiment with HBase. This section shows you how to create a table in
HBase using the <command>hbase shell</command> CLI, insert rows into the table, perform put
and scan operations against the table, enable or disable the table, and start and stop HBase.
Apart from downloading HBase, this procedure should take less than 10 minutes.</para>
<warning
xml:id="local.fs.durability">
<title>Local Filesystem and Durability</title>
<para><emphasis>The below advice is for HBase 0.98.2 and earlier releases only. This is fixed
in HBase 0.98.3 and beyond. See <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-11272">HBASE-11272</link> and
<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-11218">HBASE-11218</link>.</emphasis></para>
<para>Using HBase with a local filesystem does not guarantee durability. The HDFS
local filesystem implementation will lose edits if files are not properly closed. This is
very likely to happen when you are experimenting with new software, starting and stopping
the daemons often and not always cleanly. You need to run HBase on HDFS
to ensure all writes are preserved. Running against the local filesystem is intended as a
shortcut to get you familiar with how the general system works, as the very first phase of
evaluation. See <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-3696" /> and its associated issues
for more details about the issues of running on the local filesystem.</para>
</warning>
<note
xml:id="loopback.ip.getting.started">
<title>Loopback IP - HBase 0.94.x and earlier</title>
<para><emphasis>The below advice is for hbase-0.94.x and older versions only. This is fixed in
hbase-0.96.0 and beyond.</emphasis></para>
<para>Prior to HBase 0.94.x, HBase expected the loopback IP address to be 127.0.0.1. Ubuntu
and some other distributions default to 127.0.1.1 and this will cause problems for you . See <link
xlink:href="http://blog.devving.com/why-does-hbase-care-about-etchosts/">Why does HBase
care about /etc/hosts?</link> for detail.</para>
<example>
<title>Example /etc/hosts File for Ubuntu</title>
<para>The following <filename>/etc/hosts</filename> file works correctly for HBase 0.94.x
and earlier, on Ubuntu. Use this as a template if you run into trouble.</para>
<screen>
127.0.0.1 localhost
127.0.0.1 ubuntu.ubuntu-domain ubuntu
</screen>
</example>
</note>
<section>
<title>JDK Version Requirements</title>
<para>HBase requires that a JDK be installed. See <xref linkend="java" /> for information
about supported JDK versions.</para>
</section>
<section>
<title>Get Started with HBase</title>
<procedure>
<title>Download, Configure, and Start HBase</title>
<step>
<para>Choose a download site from this list of <link
xlink:href="http://www.apache.org/dyn/closer.cgi/hbase/">Apache Download Mirrors</link>.
Click on the suggested top link. This will take you to a mirror of <emphasis>HBase
Releases</emphasis>. Click on the folder named <filename>stable</filename> and then
download the binary file that ends in <filename>.tar.gz</filename> to your local filesystem. Be
sure to choose the version that corresponds with the version of Hadoop you are likely to use
later. In most cases, you should choose the file for Hadoop 2, which will be called something
like <filename>hbase-0.98.3-hadoop2-bin.tar.gz</filename>. Do not download the file ending in
<filename>src.tar.gz</filename> for now.</para>
</step>
<step>
<para>Extract the downloaded file, and change to the newly-created directory.</para>
<screen language="bourne">
$ tar xzvf hbase-<![CDATA[<?eval ${project.version}?>]]>-hadoop2-bin.tar.gz
$ cd hbase-<![CDATA[<?eval ${project.version}?>]]>-hadoop2/
</screen>
</step>
<step>
<para>For HBase 0.98.5 and later, you are required to set the <envar>JAVA_HOME</envar>
environment variable before starting HBase. Prior to 0.98.5, HBase attempted to detect
the location of Java if the variables was not set. You can set the variable via your
operating system's usual mechanism, but HBase provides a central mechanism,
<filename>conf/hbase-env.sh</filename>. Edit this file, uncomment the line starting
with <literal>JAVA_HOME</literal>, and set it to the appropriate location for your
operating system. The <envar>JAVA_HOME</envar> variable should be set to a directory
which contains the executable file <filename>bin/java</filename>. Most modern Linux
operating systems provide a mechanism, such as /usr/bin/alternatives on RHEL or CentOS,
for transparently switching between versions of executables such as Java. In this case,
you can set <envar>JAVA_HOME</envar> to the directory containing the symbolic link to
<filename>bin/java</filename>, which is usually <filename>/usr</filename>.</para>
<screen>JAVA_HOME=/usr</screen>
<note>
<para>These instructions assume that each node of your cluster uses the same
configuration. If this is not the case, you may need to set <envar>JAVA_HOME</envar>
separately for each node.</para>
</note>
</step>
<step>
<para>Edit <filename>conf/hbase-site.xml</filename>, which is the main HBase configuration
file. At this time, you only need to specify the directory on the local filesystem where
HBase and Zookeeper write data. By default, a new directory is created under /tmp. Many
servers are configured to delete the contents of /tmp upon reboot, so you should store
the data elsewhere. The following configuration will store HBase's data in the
<filename>hbase</filename> directory, in the home directory of the user called
<systemitem>testuser</systemitem>. Paste the <markup>&lt;property&gt;</markup> tags beneath the
<markup>&lt;configuration&gt;</markup> tags, which should be empty in a new HBase install.</para>
<example>
<title>Example <filename>hbase-site.xml</filename> for Standalone HBase</title>
<programlisting language="xml"><![CDATA[
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/testuser/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/testuser/zookeeper</value>
</property>
</configuration>
]]>
</programlisting>
</example>
<para>You do not need to create the HBase data directory. HBase will do this for you. If
you create the directory, HBase will attempt to do a migration, which is not what you
want.</para>
</step>
<step xml:id="start_hbase">
<para>The <filename>bin/start-hbase.sh</filename> script is provided as a convenient way
to start HBase. Issue the command, and if all goes well, a message is logged to standard
output showing that HBase started successfully. You can use the <command>jps</command>
command to verify that you have one running process called <literal>HMaster</literal>.
In standalone mode HBase runs all daemons within this single JVM, i.e. the HMaster, a
single HRegionServer, and the ZooKeeper daemon.</para>
<note><para>Java needs to be installed and available. If you get an error indicating that
Java is not installed, but it is on your system, perhaps in a non-standard location,
edit the <filename>conf/hbase-env.sh</filename> file and modify the
<envar>JAVA_HOME</envar> setting to point to the directory that contains
<filename>bin/java</filename> your system.</para></note>
</step>
</procedure>
<procedure xml:id="shell_exercises">
<title>Use HBase For the First Time</title>
<step>
<title>Connect to HBase.</title>
<para>Connect to your running instance of HBase using the <command>hbase shell</command>
command, located in the <filename>bin/</filename> directory of your HBase
install. In this example, some usage and version information that is printed when you
start HBase Shell has been omitted. The HBase Shell prompt ends with a
<literal>&gt;</literal> character.</para>
<screen language="bourne">
$ <userinput>./bin/hbase shell</userinput>
hbase(main):001:0&gt;
</screen>
</step>
<step>
<title>Display HBase Shell Help Text.</title>
<para>Type <literal>help</literal> and press Enter, to display some basic usage
information for HBase Shell, as well as several example commands. Notice that table
names, rows, columns all must be enclosed in quote characters.</para>
</step>
<step>
<title>Create a table.</title>
<para>Use the <code>create</code> command to create a new table. You must specify the
table name and the ColumnFamily name.</para>
<screen>
hbase&gt; <userinput>create 'test', 'cf'</userinput>
0 row(s) in 1.2200 seconds
</screen>
</step>
<step>
<title>List Information About your Table</title>
<para>Use the <code>list</code> command to </para>
<screen>
hbase&gt; <userinput>list 'test'</userinput>
TABLE
test
1 row(s) in 0.0350 seconds
=> ["test"]
</screen>
</step>
<step>
<title>Put data into your table.</title>
<para>To put data into your table, use the <code>put</code> command.</para>
<screen>
hbase&gt; <userinput>put 'test', 'row1', 'cf:a', 'value1'</userinput>
0 row(s) in 0.1770 seconds
hbase&gt; <userinput>put 'test', 'row2', 'cf:b', 'value2'</userinput>
0 row(s) in 0.0160 seconds
hbase&gt; <userinput>put 'test', 'row3', 'cf:c', 'value3'</userinput>
0 row(s) in 0.0260 seconds
</screen>
<para>Here, we insert three values, one at a time. The first insert is at
<literal>row1</literal>, column <literal>cf:a</literal>, with a value of
<literal>value1</literal>. Columns in HBase are comprised of a column family prefix,
<literal>cf</literal> in this example, followed by a colon and then a column qualifier
suffix, <literal>a</literal> in this case.</para>
</step>
<step>
<title>Scan the table for all data at once.</title>
<para>One of the ways to get data from HBase is to scan. Use the <command>scan</command>
command to scan the table for data. You can limit your scan, but for now, all data is
fetched.</para>
<screen>
hbase&gt; <userinput>scan 'test'</userinput>
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1403759475114, value=value1
row2 column=cf:b, timestamp=1403759492807, value=value2
row3 column=cf:c, timestamp=1403759503155, value=value3
3 row(s) in 0.0440 seconds
</screen>
</step>
<step>
<title>Get a single row of data.</title>
<para>To get a single row of data at a time, use the <command>get</command> command.</para>
<screen>
hbase&gt; <userinput>get 'test', 'row1'</userinput>
COLUMN CELL
cf:a timestamp=1403759475114, value=value1
1 row(s) in 0.0230 seconds
</screen>
</step>
<step>
<title>Disable a table.</title>
<para>If you want to delete a table or change its settings, as well as in some other
situations, you need to disable the table first, using the <code>disable</code>
command. You can re-enable it using the <code>enable</code> command.</para>
<screen>
hbase&gt; disable 'test'
0 row(s) in 1.6270 seconds
hbase&gt; enable 'test'
0 row(s) in 0.4500 seconds
</screen>
<para>Disable the table again if you tested the <command>enable</command> command above:</para>
<screen>
hbase&gt; disable 'test'
0 row(s) in 1.6270 seconds
</screen>
</step>
<step>
<title>Drop the table.</title>
<para>To drop (delete) a table, use the <code>drop</code> command.</para>
<screen>
hbase&gt; drop 'test'
0 row(s) in 0.2900 seconds
</screen>
</step>
<step>
<title>Exit the HBase Shell.</title>
<para>To exit the HBase Shell and disconnect from your cluster, use the
<command>quit</command> command. HBase is still running in the background.</para>
</step>
</procedure>
<procedure
xml:id="stopping">
<title>Stop HBase</title>
<step>
<para>In the same way that the <filename>bin/start-hbase.sh</filename> script is provided
to conveniently start all HBase daemons, the <filename>bin/stop-hbase.sh</filename>
script stops them.</para>
<screen language="bourne">
$ ./bin/stop-hbase.sh
stopping hbase....................
$
</screen>
</step>
<step>
<para>After issuing the command, it can take several minutes for the processes to shut
down. Use the <command>jps</command> to be sure that the HMaster and HRegionServer
processes are shut down.</para>
</step>
</procedure>
</section>
<section xml:id="quickstart-pseudo">
<title>Intermediate - Pseudo-Distributed Local Install</title>
<para>After working your way through <xref linkend="quickstart" />, you can re-configure HBase
to run in pseudo-distributed mode. Pseudo-distributed mode means
that HBase still runs completely on a single host, but each HBase daemon (HMaster,
HRegionServer, and Zookeeper) runs as a separate process. By default, unless you configure the
<code>hbase.rootdir</code> property as described in <xref linkend="quickstart" />, your data
is still stored in <filename>/tmp/</filename>. In this walk-through, we store your data in
HDFS instead, assuming you have HDFS available. You can skip the HDFS configuration to
continue storing your data in the local filesystem.</para>
<note>
<title>Hadoop Configuration</title>
<para>This procedure assumes that you have configured Hadoop and HDFS on your local system
and or a remote system, and that they are running and available. It also assumes you are
using Hadoop 2. Currently, the documentation on the Hadoop website does not include a
quick start for Hadoop 2, but the guide at <link
xlink:href="http://www.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide">http://www.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide</link>
is a good starting point.</para>
</note>
<procedure>
<step>
<title>Stop HBase if it is running.</title>
<para>If you have just finished <xref linkend="quickstart" /> and HBase is still running,
stop it. This procedure will create a totally new directory where HBase will store its
data, so any databases you created before will be lost.</para>
</step>
<step>
<title>Configure HBase.</title>
<para>
Edit the <filename>hbase-site.xml</filename> configuration. First, add the following
property. which directs HBase to run in distributed mode, with one JVM instance per
daemon.
</para>
<programlisting language="xml"><![CDATA[
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
]]></programlisting>
<para>Next, change the <code>hbase.rootdir</code> from the local filesystem to the address
of your HDFS instance, using the <code>hdfs:////</code> URI syntax. In this example,
HDFS is running on the localhost at port 8020.</para>
<programlisting language="xml"><![CDATA[
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:8020/hbase</value>
</property>
]]>
</programlisting>
<para>You do not need to create the directory in HDFS. HBase will do this for you. If you
create the directory, HBase will attempt to do a migration, which is not what you
want.</para>
</step>
<step>
<title>Start HBase.</title>
<para>Use the <filename>bin/start-hbase.sh</filename> command to start HBase. If your
system is configured correctly, the <command>jps</command> command should show the
HMaster and HRegionServer processes running.</para>
</step>
<step>
<title>Check the HBase directory in HDFS.</title>
<para>If everything worked correctly, HBase created its directory in HDFS. In the
configuration above, it is stored in <filename>/hbase/</filename> on HDFS. You can use
the <command>hadoop fs</command> command in Hadoop's <filename>bin/</filename> directory
to list this directory.</para>
<screen language="bourne">
$ <userinput>./bin/hadoop fs -ls /hbase</userinput>
Found 7 items
drwxr-xr-x - hbase users 0 2014-06-25 18:58 /hbase/.tmp
drwxr-xr-x - hbase users 0 2014-06-25 21:49 /hbase/WALs
drwxr-xr-x - hbase users 0 2014-06-25 18:48 /hbase/corrupt
drwxr-xr-x - hbase users 0 2014-06-25 18:58 /hbase/data
-rw-r--r-- 3 hbase users 42 2014-06-25 18:41 /hbase/hbase.id
-rw-r--r-- 3 hbase users 7 2014-06-25 18:41 /hbase/hbase.version
drwxr-xr-x - hbase users 0 2014-06-25 21:49 /hbase/oldWALs
</screen>
</step>
<step>
<title>Create a table and populate it with data.</title>
<para>You can use the HBase Shell to create a table, populate it with data, scan and get
values from it, using the same procedure as in <xref linkend="shell_exercises" />.</para>
</step>
<step>
<title>Start and stop a backup HBase Master (HMaster) server.</title>
<note>
<para>Running multiple HMaster instances on the same hardware does not make sense in a
production environment, in the same way that running a pseudo-distributed cluster does
not make sense for production. This step is offered for testing and learning purposes
only.</para>
</note>
<para>The HMaster server controls the HBase cluster. You can start up to 9 backup HMaster
servers, which makes 10 total HMasters, counting the primary. To start a backup HMaster,
use the <command>local-master-backup.sh</command>. For each backup master you want to
start, add a parameter representing the port offset for that master. Each HMaster uses
three ports (16010, 16020, and 16030 by default). The port offset is added to these ports, so
using an offset of 2, the backup HMaster would use ports 16012, 16022, and 16032. The
following command starts 3 backup servers using ports 16012/16022/16032, 16013/16023/16033,
and 16015/16025/16035.</para>
<screen language="bourne">
$ ./bin/local-master-backup.sh 2 3 5
</screen>
<para>To kill a backup master without killing the entire cluster, you need to find its
process ID (PID). The PID is stored in a file with a name like
<filename>/tmp/hbase-<replaceable>USER</replaceable>-<replaceable>X</replaceable>-master.pid</filename>.
The only contents of the file are the PID. You can use the <command>kill -9</command>
command to kill that PID. The following command will kill the master with port offset 1,
but leave the cluster running:</para>
<screen language="bourne">
$ cat /tmp/hbase-testuser-1-master.pid |xargs kill -9
</screen>
</step>
<step>
<title>Start and stop additional RegionServers</title>
<para>The HRegionServer manages the data in its StoreFiles as directed by the HMaster.
Generally, one HRegionServer runs per node in the cluster. Running multiple
HRegionServers on the same system can be useful for testing in pseudo-distributed mode.
The <command>local-regionservers.sh</command> command allows you to run multiple
RegionServers. It works in a similar way to the
<command>local-master-backup.sh</command> command, in that each parameter you provide
represents the port offset for an instance. Each RegionServer requires two ports, and
the default ports are 16020 and 16030. However, the base ports for additional RegionServers
are not the default ports since the default ports are used by the HMaster, which is also
a RegionServer since HBase version 1.0.0. The base ports are 16200 and 16300 instead.
You can run 99 additional RegionServers that are not a HMaster or backup HMaster,
on a server. The following command starts four additional RegionServers, running on
sequential ports starting at 16202/16302 (base ports 16200/16300 plus 2).</para>
<screen language="bourne">
$ .bin/local-regionservers.sh start 2 3 4 5
</screen>
<para>To stop a RegionServer manually, use the <command>local-regionservers.sh</command>
command with the <literal>stop</literal> parameter and the offset of the server to
stop.</para>
<screen language="bourne">$ .bin/local-regionservers.sh stop 3</screen>
</step>
<step>
<title>Stop HBase.</title>
<para>You can stop HBase the same way as in the <xref
linkend="quickstart" /> procedure, using the
<filename>bin/stop-hbase.sh</filename> command.</para>
</step>
</procedure>
</section>
<section xml:id="quickstart-fully-distributed">
<title>Advanced - Fully Distributed</title>
<para>In reality, you need a fully-distributed configuration to fully test HBase and to use it
in real-world scenarios. In a distributed configuration, the cluster contains multiple
nodes, each of which runs one or more HBase daemon. These include primary and backup Master
instances, multiple Zookeeper nodes, and multiple RegionServer nodes.</para>
<para>This advanced quickstart adds two more nodes to your cluster. The architecture will be
as follows:</para>
<table>
<title>Distributed Cluster Demo Architecture</title>
<tgroup cols="4">
<thead>
<row>
<entry>Node Name</entry>
<entry>Master</entry>
<entry>ZooKeeper</entry>
<entry>RegionServer</entry>
</row>
</thead>
<tbody>
<row>
<entry>node-a.example.com</entry>
<entry>yes</entry>
<entry>yes</entry>
<entry>no</entry>
</row>
<row>
<entry>node-b.example.com</entry>
<entry>backup</entry>
<entry>yes</entry>
<entry>yes</entry>
</row>
<row>
<entry>node-c.example.com</entry>
<entry>no</entry>
<entry>yes</entry>
<entry>yes</entry>
</row>
</tbody>
</tgroup>
</table>
<para>This quickstart assumes that each node is a virtual machine and that they are all on the
same network. It builds upon the previous quickstart, <xref linkend="quickstart-pseudo" />,
assuming that the system you configured in that procedure is now <code>node-a</code>. Stop HBase on <code>node-a</code>
before continuing.</para>
<note>
<para>Be sure that all the nodes have full access to communicate, and that no firewall rules
are in place which could prevent them from talking to each other. If you see any errors like
<literal>no route to host</literal>, check your firewall.</para>
</note>
<procedure xml:id="passwordless.ssh.quickstart">
<title>Configure Password-Less SSH Access</title>
<para><code>node-a</code> needs to be able to log into <code>node-b</code> and
<code>node-c</code> (and to itself) in order to start the daemons. The easiest way to accomplish this is
to use the same username on all hosts, and configure password-less SSH login from
<code>node-a</code> to each of the others. </para>
<step>
<title>On <code>node-a</code>, generate a key pair.</title>
<para>While logged in as the user who will run HBase, generate a SSH key pair, using the
following command:
</para>
<screen language="bourne">$ ssh-keygen -t rsa</screen>
<para>If the command succeeds, the location of the key pair is printed to standard output.
The default name of the public key is <filename>id_rsa.pub</filename>.</para>
</step>
<step>
<title>Create the directory that will hold the shared keys on the other nodes.</title>
<para>On <code>node-b</code> and <code>node-c</code>, log in as the HBase user and create
a <filename>.ssh/</filename> directory in the user's home directory, if it does not
already exist. If it already exists, be aware that it may already contain other keys.</para>
</step>
<step>
<title>Copy the public key to the other nodes.</title>
<para>Securely copy the public key from <code>node-a</code> to each of the nodes, by
using the <command>scp</command> or some other secure means. On each of the other nodes,
create a new file called <filename>.ssh/authorized_keys</filename> <emphasis>if it does
not already exist</emphasis>, and append the contents of the
<filename>id_rsa.pub</filename> file to the end of it. Note that you also need to do
this for <code>node-a</code> itself.</para>
<screen language="bourne">$ cat id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys</screen>
</step>
<step>
<title>Test password-less login.</title>
<para>If you performed the procedure correctly, if you SSH from <code>node-a</code> to
either of the other nodes, using the same username, you should not be prompted for a password.
</para>
</step>
<step>
<para>Since <code>node-b</code> will run a backup Master, repeat the procedure above,
substituting <code>node-b</code> everywhere you see <code>node-a</code>. Be sure not to
overwrite your existing <filename>.ssh/authorized_keys</filename> files, but concatenate
the new key onto the existing file using the <code>&gt;&gt;</code> operator rather than
the <code>&gt;</code> operator.</para>
</step>
</procedure>
<procedure>
<title>Prepare <code>node-a</code></title>
<para><code>node-a</code> will run your primary master and ZooKeeper processes, but no
RegionServers.</para>
<step>
<title>Stop the RegionServer from starting on <code>node-a</code>.</title>
<para>Edit <filename>conf/regionservers</filename> and remove the line which contains
<literal>localhost</literal>. Add lines with the hostnames or IP addresses for
<code>node-b</code> and <code>node-c</code>. Even if you did want to run a
RegionServer on <code>node-a</code>, you should refer to it by the hostname the other
servers would use to communicate with it. In this case, that would be
<literal>node-a.example.com</literal>. This enables you to distribute the
configuration to each node of your cluster any hostname conflicts. Save the file.</para>
</step>
<step>
<title>Configure HBase to use <code>node-b</code> as a backup master.</title>
<para>Create a new file in <filename>conf/</filename> called
<filename>backup-masters</filename>, and add a new line to it with the hostname for
<code>node-b</code>. In this demonstration, the hostname is
<literal>node-b.example.com</literal>.</para>
</step>
<step>
<title>Configure ZooKeeper</title>
<para>In reality, you should carefully consider your ZooKeeper configuration. You can find
out more about configuring ZooKeeper in <xref
linkend="zookeeper" />. This configuration will direct HBase to start and manage a
ZooKeeper instance on each node of the cluster.</para>
<para>On <code>node-a</code>, edit <filename>conf/hbase-site.xml</filename> and add the
following properties.</para>
<programlisting language="bourne"><![CDATA[
<property>
<name>hbase.zookeeper.quorum</name>
<value>node-a.example.com,node-b.example.com,node-c.example.com</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/zookeeper</value>
</property>
]]></programlisting>
</step>
<step>
<para>Everywhere in your configuration that you have referred to <code>node-a</code> as
<literal>localhost</literal>, change the reference to point to the hostname that
the other nodes will use to refer to <code>node-a</code>. In these examples, the
hostname is <literal>node-a.example.com</literal>.</para>
</step>
</procedure>
<procedure>
<title>Prepare <code>node-b</code> and <code>node-c</code></title>
<para><code>node-b</code> will run a backup master server and a ZooKeeper instance.</para>
<step>
<title>Download and unpack HBase.</title>
<para>Download and unpack HBase to <code>node-b</code>, just as you did for the standalone
and pseudo-distributed quickstarts.</para>
</step>
<step>
<title>Copy the configuration files from <code>node-a</code> to <code>node-b</code>.and
<code>node-c</code>.</title>
<para>Each node of your cluster needs to have the same configuration information. Copy the
contents of the <filename>conf/</filename> directory to the <filename>conf/</filename>
directory on <code>node-b</code> and <code>node-c</code>.</para>
</step>
</procedure>
<procedure>
<title>Start and Test Your Cluster</title>
<step>
<title>Be sure HBase is not running on any node.</title>
<para>If you forgot to stop HBase from previous testing, you will have errors. Check to
see whether HBase is running on any of your nodes by using the <command>jps</command>
command. Look for the processes <literal>HMaster</literal>,
<literal>HRegionServer</literal>, and <literal>HQuorumPeer</literal>. If they exist,
kill them.</para>
</step>
<step>
<title>Start the cluster.</title>
<para>On <code>node-a</code>, issue the <command>start-hbase.sh</command> command. Your
output will be similar to that below.</para>
<screen language="bourne">
$ <userinput>bin/start-hbase.sh</userinput>
node-c.example.com: starting zookeeper, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-zookeeper-node-c.example.com.out
node-a.example.com: starting zookeeper, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-zookeeper-node-a.example.com.out
node-b.example.com: starting zookeeper, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-zookeeper-node-b.example.com.out
starting master, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-master-node-a.example.com.out
node-c.example.com: starting regionserver, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-regionserver-node-c.example.com.out
node-b.example.com: starting regionserver, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-regionserver-node-b.example.com.out
node-b.example.com: starting master, logging to /home/hbuser/hbase-0.98.3-hadoop2/bin/../logs/hbase-hbuser-master-nodeb.example.com.out
</screen>
<para>ZooKeeper starts first, followed by the master, then the RegionServers, and finally
the backup masters. </para>
</step>
<step>
<title>Verify that the processes are running.</title>
<para>On each node of the cluster, run the <command>jps</command> command and verify that
the correct processes are running on each server. You may see additional Java processes
running on your servers as well, if they are used for other purposes.</para>
<example>
<title><code>node-a</code> <command>jps</command> Output</title>
<screen language="bourne">
$ <userinput>jps</userinput>
20355 Jps
20071 HQuorumPeer
20137 HMaster
</screen>
</example>
<example>
<title><code>node-b</code> <command>jps</command> Output</title>
<screen language="bourne">
$ <userinput>jps</userinput>
15930 HRegionServer
16194 Jps
15838 HQuorumPeer
16010 HMaster
</screen>
</example>
<example>
<title><code>node-c</code> <command>jps</command> Output</title>
<screen language="bourne">
$ <userinput>jps</userinput>
13901 Jps
13639 HQuorumPeer
13737 HRegionServer
</screen>
</example>
<note>
<title>ZooKeeper Process Name</title>
<para>The <code>HQuorumPeer</code> process is a ZooKeeper instance which is controlled
and started by HBase. If you use ZooKeeper this way, it is limited to one instance per
cluster node, , and is appropriate for testing only. If ZooKeeper is run outside of
HBase, the process is called <code>QuorumPeer</code>. For more about ZooKeeper
configuration, including using an external ZooKeeper instance with HBase, see <xref
linkend="zookeeper" />.</para>
</note>
</step>
<step>
<title>Browse to the Web UI.</title>
<note>
<title>Web UI Port Changes</title>
<para>In HBase newer than 0.98.x, the HTTP ports used by the HBase Web UI changed from
60010 for the Master and 60030 for each RegionServer to 16610 for the Master and 16030
for the RegionServer.</para>
</note>
<para>If everything is set up correctly, you should be able to connect to the UI for the
Master <literal>http://node-a.example.com:60110/</literal> or the secondary master at
<literal>http://node-b.example.com:60110/</literal> for the secondary master, using a
web browser. If you can connect via <code>localhost</code> but not from another host,
check your firewall rules. You can see the web UI for each of the RegionServers at port
60130 of their IP addresses, or by clicking their links in the web UI for the
Master.</para>
</step>
<step>
<title>Test what happens when nodes or services disappear.</title>
<para>With a three-node cluster like you have configured, things will not be very
resilient. Still, you can test what happens when the primary Master or a RegionServer
disappears, by killing the processes and watching the logs.</para>
</step>
</procedure>
</section>
<section>
<title>Where to go next</title>
<para>The next chapter, <xref
linkend="configuration" />, gives more information about the different HBase run modes,
system requirements for running HBase, and critical configuration areas for setting up a
distributed HBase cluster.</para>
</section>
</section>
</chapter>

View File

@ -1,561 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<glossary xml:id="hbase_default_configurations" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://docbook.org/ns/docbook"><title>HBase Default Configuration</title><para>
The documentation below is generated using the default hbase configuration file,
<filename>hbase-default.xml</filename>, as source.
</para><glossentry xml:id="hbase.tmp.dir"><glossterm><varname>hbase.tmp.dir</varname></glossterm><glossdef><para>Temporary directory on the local filesystem.
Change this setting to point to a location more permanent
than '/tmp', the usual resolve for java.io.tmpdir, as the
'/tmp' directory is cleared on machine restart.</para><formalpara><title>Default</title><para><varname>${java.io.tmpdir}/hbase-${user.name}</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rootdir"><glossterm><varname>hbase.rootdir</varname></glossterm><glossdef><para>The directory shared by region servers and into
which HBase persists. The URL should be 'fully-qualified'
to include the filesystem scheme. For example, to specify the
HDFS directory '/hbase' where the HDFS instance's namenode is
running at namenode.example.org on port 9000, set this value to:
hdfs://namenode.example.org:9000/hbase. By default, we write
to whatever ${hbase.tmp.dir} is set too -- usually /tmp --
so change this configuration or else all data will be lost on
machine restart.</para><formalpara><title>Default</title><para><varname>${hbase.tmp.dir}/hbase</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.cluster.distributed"><glossterm><varname>hbase.cluster.distributed</varname></glossterm><glossdef><para>The mode the cluster will be in. Possible values are
false for standalone mode and true for distributed mode. If
false, startup will run all HBase and ZooKeeper daemons together
in the one JVM.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.quorum"><glossterm><varname>hbase.zookeeper.quorum</varname></glossterm><glossdef><para>Comma separated list of servers in the ZooKeeper ensemble
(This config. should have been named hbase.zookeeper.ensemble).
For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
By default this is set to localhost for local and pseudo-distributed modes
of operation. For a fully-distributed setup, this should be set to a full
list of ZooKeeper ensemble servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
this is the list of servers which hbase will start/stop ZooKeeper on as
part of cluster start/stop. Client-side, we will take this list of
ensemble members and put it together with the hbase.zookeeper.clientPort
config. and pass it into zookeeper constructor as the connectString
parameter.</para><formalpara><title>Default</title><para><varname>localhost</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.local.dir"><glossterm><varname>hbase.local.dir</varname></glossterm><glossdef><para>Directory on the local filesystem to be used
as a local storage.</para><formalpara><title>Default</title><para><varname>${hbase.tmp.dir}/local/</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.info.port"><glossterm><varname>hbase.master.info.port</varname></glossterm><glossdef><para>The port for the HBase Master web UI.
Set to -1 if you do not want a UI instance run.</para><formalpara><title>Default</title><para><varname>16010</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.info.bindAddress"><glossterm><varname>hbase.master.info.bindAddress</varname></glossterm><glossdef><para>The bind address for the HBase Master web UI
</para><formalpara><title>Default</title><para><varname>0.0.0.0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.logcleaner.plugins"><glossterm><varname>hbase.master.logcleaner.plugins</varname></glossterm><glossdef><para>A comma-separated list of BaseLogCleanerDelegate invoked by
the LogsCleaner service. These WAL cleaners are called in order,
so put the cleaner that prunes the most files in front. To
implement your own BaseLogCleanerDelegate, just put it in HBase's classpath
and add the fully qualified class name here. Always add the above
default log cleaners in the list.</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.master.cleaner.TimeToLiveLogCleaner</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.logcleaner.ttl"><glossterm><varname>hbase.master.logcleaner.ttl</varname></glossterm><glossdef><para>Maximum time a WAL can stay in the .oldlogdir directory,
after which it will be cleaned by a Master thread.</para><formalpara><title>Default</title><para><varname>600000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.hfilecleaner.plugins"><glossterm><varname>hbase.master.hfilecleaner.plugins</varname></glossterm><glossdef><para>A comma-separated list of BaseHFileCleanerDelegate invoked by
the HFileCleaner service. These HFiles cleaners are called in order,
so put the cleaner that prunes the most files in front. To
implement your own BaseHFileCleanerDelegate, just put it in HBase's classpath
and add the fully qualified class name here. Always add the above
default log cleaners in the list as they will be overwritten in
hbase-site.xml.</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.catalog.timeout"><glossterm><varname>hbase.master.catalog.timeout</varname></glossterm><glossdef><para>Timeout value for the Catalog Janitor from the master to
META.</para><formalpara><title>Default</title><para><varname>600000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.infoserver.redirect"><glossterm><varname>hbase.master.infoserver.redirect</varname></glossterm><glossdef><para>Whether or not the Master listens to the Master web
UI port (hbase.master.info.port) and redirects requests to the web
UI server shared by the Master and RegionServer.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.port"><glossterm><varname>hbase.regionserver.port</varname></glossterm><glossdef><para>The port the HBase RegionServer binds to.</para><formalpara><title>Default</title><para><varname>16020</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.info.port"><glossterm><varname>hbase.regionserver.info.port</varname></glossterm><glossdef><para>The port for the HBase RegionServer web UI
Set to -1 if you do not want the RegionServer UI to run.</para><formalpara><title>Default</title><para><varname>16030</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.info.bindAddress"><glossterm><varname>hbase.regionserver.info.bindAddress</varname></glossterm><glossdef><para>The address for the HBase RegionServer web UI</para><formalpara><title>Default</title><para><varname>0.0.0.0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.info.port.auto"><glossterm><varname>hbase.regionserver.info.port.auto</varname></glossterm><glossdef><para>Whether or not the Master or RegionServer
UI should search for a port to bind to. Enables automatic port
search if hbase.regionserver.info.port is already in use.
Useful for testing, turned off by default.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.handler.count"><glossterm><varname>hbase.regionserver.handler.count</varname></glossterm><glossdef><para>Count of RPC Listener instances spun up on RegionServers.
Same property is used by the Master for count of master handlers.</para><formalpara><title>Default</title><para><varname>30</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.ipc.server.callqueue.handler.factor"><glossterm><varname>hbase.ipc.server.callqueue.handler.factor</varname></glossterm><glossdef><para>Factor to determine the number of call queues.
A value of 0 means a single queue shared between all the handlers.
A value of 1 means that each handler has its own queue.</para><formalpara><title>Default</title><para><varname>0.1</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.ipc.server.callqueue.read.ratio"><glossterm><varname>hbase.ipc.server.callqueue.read.ratio</varname></glossterm><glossdef><para>Split the call queues into read and write queues.
The specified interval (which should be between 0.0 and 1.0)
will be multiplied by the number of call queues.
A value of 0 indicate to not split the call queues, meaning that both read and write
requests will be pushed to the same set of queues.
A value lower than 0.5 means that there will be less read queues than write queues.
A value of 0.5 means there will be the same number of read and write queues.
A value greater than 0.5 means that there will be more read queues than write queues.
A value of 1.0 means that all the queues except one are used to dispatch read requests.
Example: Given the total number of call queues being 10
a read.ratio of 0 means that: the 10 queues will contain both read/write requests.
a read.ratio of 0.3 means that: 3 queues will contain only read requests
and 7 queues will contain only write requests.
a read.ratio of 0.5 means that: 5 queues will contain only read requests
and 5 queues will contain only write requests.
a read.ratio of 0.8 means that: 8 queues will contain only read requests
and 2 queues will contain only write requests.
a read.ratio of 1 means that: 9 queues will contain only read requests
and 1 queues will contain only write requests.
</para><formalpara><title>Default</title><para><varname>0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.ipc.server.callqueue.scan.ratio"><glossterm><varname>hbase.ipc.server.callqueue.scan.ratio</varname></glossterm><glossdef><para>Given the number of read call queues, calculated from the total number
of call queues multiplied by the callqueue.read.ratio, the scan.ratio property
will split the read call queues into small-read and long-read queues.
A value lower than 0.5 means that there will be less long-read queues than short-read queues.
A value of 0.5 means that there will be the same number of short-read and long-read queues.
A value greater than 0.5 means that there will be more long-read queues than short-read queues
A value of 0 or 1 indicate to use the same set of queues for gets and scans.
Example: Given the total number of read call queues being 8
a scan.ratio of 0 or 1 means that: 8 queues will contain both long and short read requests.
a scan.ratio of 0.3 means that: 2 queues will contain only long-read requests
and 6 queues will contain only short-read requests.
a scan.ratio of 0.5 means that: 4 queues will contain only long-read requests
and 4 queues will contain only short-read requests.
a scan.ratio of 0.8 means that: 6 queues will contain only long-read requests
and 2 queues will contain only short-read requests.
</para><formalpara><title>Default</title><para><varname>0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.msginterval"><glossterm><varname>hbase.regionserver.msginterval</varname></glossterm><glossdef><para>Interval between messages from the RegionServer to Master
in milliseconds.</para><formalpara><title>Default</title><para><varname>3000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.regionSplitLimit"><glossterm><varname>hbase.regionserver.regionSplitLimit</varname></glossterm><glossdef><para>Limit for the number of regions after which no more region
splitting should take place. This is not a hard limit for the number of
regions but acts as a guideline for the regionserver to stop splitting after
a certain limit. Default is MAX_INT; i.e. do not block splitting.</para><formalpara><title>Default</title><para><varname>2147483647</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.logroll.period"><glossterm><varname>hbase.regionserver.logroll.period</varname></glossterm><glossdef><para>Period at which we will roll the commit log regardless
of how many edits it has.</para><formalpara><title>Default</title><para><varname>3600000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.logroll.errors.tolerated"><glossterm><varname>hbase.regionserver.logroll.errors.tolerated</varname></glossterm><glossdef><para>The number of consecutive WAL close errors we will allow
before triggering a server abort. A setting of 0 will cause the
region server to abort if closing the current WAL writer fails during
log rolling. Even a small value (2 or 3) will allow a region server
to ride over transient HDFS errors.</para><formalpara><title>Default</title><para><varname>2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.hlog.reader.impl"><glossterm><varname>hbase.regionserver.hlog.reader.impl</varname></glossterm><glossdef><para>The WAL file reader implementation.</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.hlog.writer.impl"><glossterm><varname>hbase.regionserver.hlog.writer.impl</varname></glossterm><glossdef><para>The WAL file writer implementation.</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.distributed.log.replay"><glossterm><varname>hbase.master.distributed.log.replay</varname></glossterm><glossdef><para>Enable 'distributed log replay' as default engine splitting
WAL files on server crash. This default is new in hbase 1.0. To fall
back to the old mode 'distributed log splitter', set the value to
'false'. 'Disributed log replay' improves MTTR because it does not
write intermediate files. 'DLR' required that 'hfile.format.version'
be set to version 3 or higher.
</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.global.memstore.size"><glossterm><varname>hbase.regionserver.global.memstore.size</varname></glossterm><glossdef><para>Maximum size of all memstores in a region server before new
updates are blocked and flushes are forced. Defaults to 40% of heap.
Updates are blocked and flushes are forced until size of all memstores
in a region server hits hbase.regionserver.global.memstore.size.lower.limit.</para><formalpara><title>Default</title><para><varname>0.4</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.global.memstore.size.lower.limit"><glossterm><varname>hbase.regionserver.global.memstore.size.lower.limit</varname></glossterm><glossdef><para>Maximum size of all memstores in a region server before flushes are forced.
Defaults to 95% of hbase.regionserver.global.memstore.size.
A 100% value for this value causes the minimum possible flushing to occur when updates are
blocked due to memstore limiting.</para><formalpara><title>Default</title><para><varname>0.95</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.optionalcacheflushinterval"><glossterm><varname>hbase.regionserver.optionalcacheflushinterval</varname></glossterm><glossdef><para>
Maximum amount of time an edit lives in memory before being automatically flushed.
Default 1 hour. Set it to 0 to disable automatic flushing.</para><formalpara><title>Default</title><para><varname>3600000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.catalog.timeout"><glossterm><varname>hbase.regionserver.catalog.timeout</varname></glossterm><glossdef><para>Timeout value for the Catalog Janitor from the regionserver to META.</para><formalpara><title>Default</title><para><varname>600000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.dns.interface"><glossterm><varname>hbase.regionserver.dns.interface</varname></glossterm><glossdef><para>The name of the Network Interface from which a region server
should report its IP address.</para><formalpara><title>Default</title><para><varname>default</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.dns.nameserver"><glossterm><varname>hbase.regionserver.dns.nameserver</varname></glossterm><glossdef><para>The host name or IP address of the name server (DNS)
which a region server should use to determine the host name used by the
master for communication and display purposes.</para><formalpara><title>Default</title><para><varname>default</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.region.split.policy"><glossterm><varname>hbase.regionserver.region.split.policy</varname></glossterm><glossdef><para>
A split policy determines when a region should be split. The various other split policies that
are available currently are ConstantSizeRegionSplitPolicy, DisabledRegionSplitPolicy,
DelimitedKeyPrefixRegionSplitPolicy, KeyPrefixRegionSplitPolicy etc.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.regionserver.IncreasingToUpperBoundRegionSplitPolicy</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="zookeeper.session.timeout"><glossterm><varname>zookeeper.session.timeout</varname></glossterm><glossdef><para>ZooKeeper session timeout in milliseconds. It is used in two different ways.
First, this value is used in the ZK client that HBase uses to connect to the ensemble.
It is also used by HBase when it starts a ZK server and it is passed as the 'maxSessionTimeout'. See
http://hadoop.apache.org/zookeeper/docs/current/zookeeperProgrammers.html#ch_zkSessions.
For example, if a HBase region server connects to a ZK ensemble that's also managed by HBase, then the
session timeout will be the one specified by this configuration. But, a region server that connects
to an ensemble managed with a different configuration will be subjected that ensemble's maxSessionTimeout. So,
even though HBase might propose using 90 seconds, the ensemble can have a max timeout lower than this and
it will take precedence. The current default that ZK ships with is 40 seconds, which is lower than HBase's.
</para><formalpara><title>Default</title><para><varname>90000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="zookeeper.znode.parent"><glossterm><varname>zookeeper.znode.parent</varname></glossterm><glossdef><para>Root ZNode for HBase in ZooKeeper. All of HBase's ZooKeeper
files that are configured with a relative path will go under this node.
By default, all of HBase's ZooKeeper file path are configured with a
relative path, so they will all go under this directory unless changed.</para><formalpara><title>Default</title><para><varname>/hbase</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="zookeeper.znode.rootserver"><glossterm><varname>zookeeper.znode.rootserver</varname></glossterm><glossdef><para>Path to ZNode holding root region location. This is written by
the master and read by clients and region servers. If a relative path is
given, the parent folder will be ${zookeeper.znode.parent}. By default,
this means the root location is stored at /hbase/root-region-server.</para><formalpara><title>Default</title><para><varname>root-region-server</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="zookeeper.znode.acl.parent"><glossterm><varname>zookeeper.znode.acl.parent</varname></glossterm><glossdef><para>Root ZNode for access control lists.</para><formalpara><title>Default</title><para><varname>acl</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.dns.interface"><glossterm><varname>hbase.zookeeper.dns.interface</varname></glossterm><glossdef><para>The name of the Network Interface from which a ZooKeeper server
should report its IP address.</para><formalpara><title>Default</title><para><varname>default</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.dns.nameserver"><glossterm><varname>hbase.zookeeper.dns.nameserver</varname></glossterm><glossdef><para>The host name or IP address of the name server (DNS)
which a ZooKeeper server should use to determine the host name used by the
master for communication and display purposes.</para><formalpara><title>Default</title><para><varname>default</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.peerport"><glossterm><varname>hbase.zookeeper.peerport</varname></glossterm><glossdef><para>Port used by ZooKeeper peers to talk to each other.
See http://hadoop.apache.org/zookeeper/docs/r3.1.1/zookeeperStarted.html#sc_RunningReplicatedZooKeeper
for more information.</para><formalpara><title>Default</title><para><varname>2888</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.leaderport"><glossterm><varname>hbase.zookeeper.leaderport</varname></glossterm><glossdef><para>Port used by ZooKeeper for leader election.
See http://hadoop.apache.org/zookeeper/docs/r3.1.1/zookeeperStarted.html#sc_RunningReplicatedZooKeeper
for more information.</para><formalpara><title>Default</title><para><varname>3888</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.useMulti"><glossterm><varname>hbase.zookeeper.useMulti</varname></glossterm><glossdef><para>Instructs HBase to make use of ZooKeeper's multi-update functionality.
This allows certain ZooKeeper operations to complete more quickly and prevents some issues
with rare Replication failure scenarios (see the release note of HBASE-2611 for an example).
IMPORTANT: only set this to true if all ZooKeeper servers in the cluster are on version 3.4+
and will not be downgraded. ZooKeeper versions before 3.4 do not support multi-update and
will not fail gracefully if multi-update is invoked (see ZOOKEEPER-1495).</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.config.read.zookeeper.config"><glossterm><varname>hbase.config.read.zookeeper.config</varname></glossterm><glossdef><para>
Set to true to allow HBaseConfiguration to read the
zoo.cfg file for ZooKeeper properties. Switching this to true
is not recommended, since the functionality of reading ZK
properties from a zoo.cfg file has been deprecated.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.property.initLimit"><glossterm><varname>hbase.zookeeper.property.initLimit</varname></glossterm><glossdef><para>Property from ZooKeeper's config zoo.cfg.
The number of ticks that the initial synchronization phase can take.</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.property.syncLimit"><glossterm><varname>hbase.zookeeper.property.syncLimit</varname></glossterm><glossdef><para>Property from ZooKeeper's config zoo.cfg.
The number of ticks that can pass between sending a request and getting an
acknowledgment.</para><formalpara><title>Default</title><para><varname>5</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.property.dataDir"><glossterm><varname>hbase.zookeeper.property.dataDir</varname></glossterm><glossdef><para>Property from ZooKeeper's config zoo.cfg.
The directory where the snapshot is stored.</para><formalpara><title>Default</title><para><varname>${hbase.tmp.dir}/zookeeper</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.property.clientPort"><glossterm><varname>hbase.zookeeper.property.clientPort</varname></glossterm><glossdef><para>Property from ZooKeeper's config zoo.cfg.
The port at which the clients will connect.</para><formalpara><title>Default</title><para><varname>2181</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.zookeeper.property.maxClientCnxns"><glossterm><varname>hbase.zookeeper.property.maxClientCnxns</varname></glossterm><glossdef><para>Property from ZooKeeper's config zoo.cfg.
Limit on number of concurrent connections (at the socket level) that a
single client, identified by IP address, may make to a single member of
the ZooKeeper ensemble. Set high to avoid zk connection issues running
standalone and pseudo-distributed.</para><formalpara><title>Default</title><para><varname>300</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.write.buffer"><glossterm><varname>hbase.client.write.buffer</varname></glossterm><glossdef><para>Default size of the HTable client write buffer in bytes.
A bigger buffer takes more memory -- on both the client and server
side since server instantiates the passed write buffer to process
it -- but a larger buffer size reduces the number of RPCs made.
For an estimate of server-side memory-used, evaluate
hbase.client.write.buffer * hbase.regionserver.handler.count</para><formalpara><title>Default</title><para><varname>2097152</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.pause"><glossterm><varname>hbase.client.pause</varname></glossterm><glossdef><para>General client pause value. Used mostly as value to wait
before running a retry of a failed get, region lookup, etc.
See hbase.client.retries.number for description of how we backoff from
this initial pause amount and how this pause works w/ retries.</para><formalpara><title>Default</title><para><varname>100</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.retries.number"><glossterm><varname>hbase.client.retries.number</varname></glossterm><glossdef><para>Maximum retries. Used as maximum for all retryable
operations such as the getting of a cell's value, starting a row update,
etc. Retry interval is a rough function based on hbase.client.pause. At
first we retry at this interval but then with backoff, we pretty quickly reach
retrying every ten seconds. See HConstants#RETRY_BACKOFF for how the backup
ramps up. Change this setting and hbase.client.pause to suit your workload.</para><formalpara><title>Default</title><para><varname>35</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.max.total.tasks"><glossterm><varname>hbase.client.max.total.tasks</varname></glossterm><glossdef><para>The maximum number of concurrent tasks a single HTable instance will
send to the cluster.</para><formalpara><title>Default</title><para><varname>100</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.max.perserver.tasks"><glossterm><varname>hbase.client.max.perserver.tasks</varname></glossterm><glossdef><para>The maximum number of concurrent tasks a single HTable instance will
send to a single region server.</para><formalpara><title>Default</title><para><varname>5</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.max.perregion.tasks"><glossterm><varname>hbase.client.max.perregion.tasks</varname></glossterm><glossdef><para>The maximum number of concurrent connections the client will
maintain to a single Region. That is, if there is already
hbase.client.max.perregion.tasks writes in progress for this region, new puts
won't be sent to this region until some writes finishes.</para><formalpara><title>Default</title><para><varname>1</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.scanner.caching"><glossterm><varname>hbase.client.scanner.caching</varname></glossterm><glossdef><para>Number of rows that will be fetched when calling next
on a scanner if it is not served from (local, client) memory. Higher
caching values will enable faster scanners but will eat up more memory
and some calls of next may take longer and longer times when the cache is empty.
Do not set this value such that the time between invocations is greater
than the scanner timeout; i.e. hbase.client.scanner.timeout.period</para><formalpara><title>Default</title><para><varname>100</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.keyvalue.maxsize"><glossterm><varname>hbase.client.keyvalue.maxsize</varname></glossterm><glossdef><para>Specifies the combined maximum allowed size of a KeyValue
instance. This is to set an upper boundary for a single entry saved in a
storage file. Since they cannot be split it helps avoiding that a region
cannot be split any further because the data is too large. It seems wise
to set this to a fraction of the maximum region size. Setting it to zero
or less disables the check.</para><formalpara><title>Default</title><para><varname>10485760</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.scanner.timeout.period"><glossterm><varname>hbase.client.scanner.timeout.period</varname></glossterm><glossdef><para>Client scanner lease period in milliseconds.</para><formalpara><title>Default</title><para><varname>60000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.client.localityCheck.threadPoolSize"><glossterm><varname>hbase.client.localityCheck.threadPoolSize</varname></glossterm><glossdef><para/><formalpara><title>Default</title><para><varname>2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.bulkload.retries.number"><glossterm><varname>hbase.bulkload.retries.number</varname></glossterm><glossdef><para>Maximum retries. This is maximum number of iterations
to atomic bulk loads are attempted in the face of splitting operations
0 means never give up.</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.balancer.period&#10; "><glossterm><varname>hbase.balancer.period
</varname></glossterm><glossdef><para>Period at which the region balancer runs in the Master.</para><formalpara><title>Default</title><para><varname>300000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regions.slop"><glossterm><varname>hbase.regions.slop</varname></glossterm><glossdef><para>Rebalance if any regionserver has average + (average * slop) regions.</para><formalpara><title>Default</title><para><varname>0.2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.server.thread.wakefrequency"><glossterm><varname>hbase.server.thread.wakefrequency</varname></glossterm><glossdef><para>Time to sleep in between searches for work (in milliseconds).
Used as sleep interval by service threads such as log roller.</para><formalpara><title>Default</title><para><varname>10000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.server.versionfile.writeattempts"><glossterm><varname>hbase.server.versionfile.writeattempts</varname></glossterm><glossdef><para>
How many time to retry attempting to write a version file
before just aborting. Each attempt is seperated by the
hbase.server.thread.wakefrequency milliseconds.</para><formalpara><title>Default</title><para><varname>3</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.memstore.flush.size"><glossterm><varname>hbase.hregion.memstore.flush.size</varname></glossterm><glossdef><para>
Memstore will be flushed to disk if size of the memstore
exceeds this number of bytes. Value is checked by a thread that runs
every hbase.server.thread.wakefrequency.</para><formalpara><title>Default</title><para><varname>134217728</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.percolumnfamilyflush.size.lower.bound"><glossterm><varname>hbase.hregion.percolumnfamilyflush.size.lower.bound</varname></glossterm><glossdef><para>
If FlushLargeStoresPolicy is used, then every time that we hit the
total memstore limit, we find out all the column families whose memstores
exceed this value, and only flush them, while retaining the others whose
memstores are lower than this limit. If none of the families have their
memstore size more than this, all the memstores will be flushed
(just as usual). This value should be less than half of the total memstore
threshold (hbase.hregion.memstore.flush.size).
</para><formalpara><title>Default</title><para><varname>16777216</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.preclose.flush.size"><glossterm><varname>hbase.hregion.preclose.flush.size</varname></glossterm><glossdef><para>
If the memstores in a region are this size or larger when we go
to close, run a "pre-flush" to clear out memstores before we put up
the region closed flag and take the region offline. On close,
a flush is run under the close flag to empty memory. During
this time the region is offline and we are not taking on any writes.
If the memstore content is large, this flush could take a long time to
complete. The preflush is meant to clean out the bulk of the memstore
before putting up the close flag and taking the region offline so the
flush that runs under the close flag has little to do.</para><formalpara><title>Default</title><para><varname>5242880</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.memstore.block.multiplier"><glossterm><varname>hbase.hregion.memstore.block.multiplier</varname></glossterm><glossdef><para>
Block updates if memstore has hbase.hregion.memstore.block.multiplier
times hbase.hregion.memstore.flush.size bytes. Useful preventing
runaway memstore during spikes in update traffic. Without an
upper-bound, memstore fills such that when it flushes the
resultant flush files take a long time to compact or split, or
worse, we OOME.</para><formalpara><title>Default</title><para><varname>4</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.memstore.mslab.enabled"><glossterm><varname>hbase.hregion.memstore.mslab.enabled</varname></glossterm><glossdef><para>
Enables the MemStore-Local Allocation Buffer,
a feature which works to prevent heap fragmentation under
heavy write loads. This can reduce the frequency of stop-the-world
GC pauses on large heaps.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.max.filesize"><glossterm><varname>hbase.hregion.max.filesize</varname></glossterm><glossdef><para>
Maximum HFile size. If the sum of the sizes of a region's HFiles has grown to exceed this
value, the region is split in two.</para><formalpara><title>Default</title><para><varname>10737418240</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.majorcompaction"><glossterm><varname>hbase.hregion.majorcompaction</varname></glossterm><glossdef><para>Time between major compactions, expressed in milliseconds. Set to 0 to disable
time-based automatic major compactions. User-requested and size-based major compactions will
still run. This value is multiplied by hbase.hregion.majorcompaction.jitter to cause
compaction to start at a somewhat-random time during a given window of time. The default value
is 7 days, expressed in milliseconds. If major compactions are causing disruption in your
environment, you can configure them to run at off-peak times for your deployment, or disable
time-based major compactions by setting this parameter to 0, and run major compactions in a
cron job or by another external mechanism.</para><formalpara><title>Default</title><para><varname>604800000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hregion.majorcompaction.jitter"><glossterm><varname>hbase.hregion.majorcompaction.jitter</varname></glossterm><glossdef><para>A multiplier applied to hbase.hregion.majorcompaction to cause compaction to occur
a given amount of time either side of hbase.hregion.majorcompaction. The smaller the number,
the closer the compactions will happen to the hbase.hregion.majorcompaction
interval.</para><formalpara><title>Default</title><para><varname>0.50</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compactionThreshold"><glossterm><varname>hbase.hstore.compactionThreshold</varname></glossterm><glossdef><para> If more than this number of StoreFiles exist in any one Store
(one StoreFile is written per flush of MemStore), a compaction is run to rewrite all
StoreFiles into a single StoreFile. Larger values delay compaction, but when compaction does
occur, it takes longer to complete.</para><formalpara><title>Default</title><para><varname>3</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.flusher.count"><glossterm><varname>hbase.hstore.flusher.count</varname></glossterm><glossdef><para> The number of flush threads. With fewer threads, the MemStore flushes will be
queued. With more threads, the flushes will be executed in parallel, increasing the load on
HDFS, and potentially causing more compactions. </para><formalpara><title>Default</title><para><varname>2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.blockingStoreFiles"><glossterm><varname>hbase.hstore.blockingStoreFiles</varname></glossterm><glossdef><para> If more than this number of StoreFiles exist in any one Store (one StoreFile
is written per flush of MemStore), updates are blocked for this region until a compaction is
completed, or until hbase.hstore.blockingWaitTime has been exceeded.</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.blockingWaitTime"><glossterm><varname>hbase.hstore.blockingWaitTime</varname></glossterm><glossdef><para> The time for which a region will block updates after reaching the StoreFile limit
defined by hbase.hstore.blockingStoreFiles. After this time has elapsed, the region will stop
blocking updates even if a compaction has not been completed.</para><formalpara><title>Default</title><para><varname>90000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.min"><glossterm><varname>hbase.hstore.compaction.min</varname></glossterm><glossdef><para>The minimum number of StoreFiles which must be eligible for compaction before
compaction can run. The goal of tuning hbase.hstore.compaction.min is to avoid ending up with
too many tiny StoreFiles to compact. Setting this value to 2 would cause a minor compaction
each time you have two StoreFiles in a Store, and this is probably not appropriate. If you
set this value too high, all the other values will need to be adjusted accordingly. For most
cases, the default value is appropriate. In previous versions of HBase, the parameter
hbase.hstore.compaction.min was named hbase.hstore.compactionThreshold.</para><formalpara><title>Default</title><para><varname>3</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.max"><glossterm><varname>hbase.hstore.compaction.max</varname></glossterm><glossdef><para>The maximum number of StoreFiles which will be selected for a single minor
compaction, regardless of the number of eligible StoreFiles. Effectively, the value of
hbase.hstore.compaction.max controls the length of time it takes a single compaction to
complete. Setting it larger means that more StoreFiles are included in a compaction. For most
cases, the default value is appropriate.</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.min.size"><glossterm><varname>hbase.hstore.compaction.min.size</varname></glossterm><glossdef><para>A StoreFile smaller than this size will always be eligible for minor compaction.
HFiles this size or larger are evaluated by hbase.hstore.compaction.ratio to determine if
they are eligible. Because this limit represents the "automatic include"limit for all
StoreFiles smaller than this value, this value may need to be reduced in write-heavy
environments where many StoreFiles in the 1-2 MB range are being flushed, because every
StoreFile will be targeted for compaction and the resulting StoreFiles may still be under the
minimum size and require further compaction. If this parameter is lowered, the ratio check is
triggered more quickly. This addressed some issues seen in earlier versions of HBase but
changing this parameter is no longer necessary in most situations. Default: 128 MB expressed
in bytes.</para><formalpara><title>Default</title><para><varname>134217728</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.max.size"><glossterm><varname>hbase.hstore.compaction.max.size</varname></glossterm><glossdef><para>A StoreFile larger than this size will be excluded from compaction. The effect of
raising hbase.hstore.compaction.max.size is fewer, larger StoreFiles that do not get
compacted often. If you feel that compaction is happening too often without much benefit, you
can try raising this value. Default: the value of LONG.MAX_VALUE, expressed in bytes.</para><formalpara><title>Default</title><para><varname>9223372036854775807</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.ratio"><glossterm><varname>hbase.hstore.compaction.ratio</varname></glossterm><glossdef><para>For minor compaction, this ratio is used to determine whether a given StoreFile
which is larger than hbase.hstore.compaction.min.size is eligible for compaction. Its
effect is to limit compaction of large StoreFiles. The value of hbase.hstore.compaction.ratio
is expressed as a floating-point decimal. A large ratio, such as 10, will produce a single
giant StoreFile. Conversely, a low value, such as .25, will produce behavior similar to the
BigTable compaction algorithm, producing four StoreFiles. A moderate value of between 1.0 and
1.4 is recommended. When tuning this value, you are balancing write costs with read costs.
Raising the value (to something like 1.4) will have more write costs, because you will
compact larger StoreFiles. However, during reads, HBase will need to seek through fewer
StoreFiles to accomplish the read. Consider this approach if you cannot take advantage of
Bloom filters. Otherwise, you can lower this value to something like 1.0 to reduce the
background cost of writes, and use Bloom filters to control the number of StoreFiles touched
during reads. For most cases, the default value is appropriate.</para><formalpara><title>Default</title><para><varname>1.2F</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.ratio.offpeak"><glossterm><varname>hbase.hstore.compaction.ratio.offpeak</varname></glossterm><glossdef><para>Allows you to set a different (by default, more aggressive) ratio for determining
whether larger StoreFiles are included in compactions during off-peak hours. Works in the
same way as hbase.hstore.compaction.ratio. Only applies if hbase.offpeak.start.hour and
hbase.offpeak.end.hour are also enabled.</para><formalpara><title>Default</title><para><varname>5.0F</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.time.to.purge.deletes"><glossterm><varname>hbase.hstore.time.to.purge.deletes</varname></glossterm><glossdef><para>The amount of time to delay purging of delete markers with future timestamps. If
unset, or set to 0, all delete markers, including those with future timestamps, are purged
during the next major compaction. Otherwise, a delete marker is kept until the major compaction
which occurs after the marker's timestamp plus the value of this setting, in milliseconds.
</para><formalpara><title>Default</title><para><varname>0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.offpeak.start.hour"><glossterm><varname>hbase.offpeak.start.hour</varname></glossterm><glossdef><para>The start of off-peak hours, expressed as an integer between 0 and 23, inclusive.
Set to -1 to disable off-peak.</para><formalpara><title>Default</title><para><varname>-1</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.offpeak.end.hour"><glossterm><varname>hbase.offpeak.end.hour</varname></glossterm><glossdef><para>The end of off-peak hours, expressed as an integer between 0 and 23, inclusive. Set
to -1 to disable off-peak.</para><formalpara><title>Default</title><para><varname>-1</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.thread.compaction.throttle"><glossterm><varname>hbase.regionserver.thread.compaction.throttle</varname></glossterm><glossdef><para>There are two different thread pools for compactions, one for large compactions and
the other for small compactions. This helps to keep compaction of lean tables (such as
hbase:meta) fast. If a compaction is larger than this threshold, it
goes into the large compaction pool. In most cases, the default value is appropriate. Default:
2 x hbase.hstore.compaction.max x hbase.hregion.memstore.flush.size (which defaults to 128MB).
The value field assumes that the value of hbase.hregion.memstore.flush.size is unchanged from
the default.</para><formalpara><title>Default</title><para><varname>2684354560</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.compaction.kv.max"><glossterm><varname>hbase.hstore.compaction.kv.max</varname></glossterm><glossdef><para>The maximum number of KeyValues to read and then write in a batch when flushing or
compacting. Set this lower if you have big KeyValues and problems with Out Of Memory
Exceptions Set this higher if you have wide, small rows. </para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.storescanner.parallel.seek.enable"><glossterm><varname>hbase.storescanner.parallel.seek.enable</varname></glossterm><glossdef><para>
Enables StoreFileScanner parallel-seeking in StoreScanner,
a feature which can reduce response latency under special conditions.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.storescanner.parallel.seek.threads"><glossterm><varname>hbase.storescanner.parallel.seek.threads</varname></glossterm><glossdef><para>
The default thread pool size if parallel-seeking feature enabled.</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hfile.block.cache.size"><glossterm><varname>hfile.block.cache.size</varname></glossterm><glossdef><para>Percentage of maximum heap (-Xmx setting) to allocate to block cache
used by a StoreFile. Default of 0.4 means allocate 40%.
Set to 0 to disable but it's not recommended; you need at least
enough cache to hold the storefile indices.</para><formalpara><title>Default</title><para><varname>0.4</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hfile.block.index.cacheonwrite"><glossterm><varname>hfile.block.index.cacheonwrite</varname></glossterm><glossdef><para>This allows to put non-root multi-level index blocks into the block
cache at the time the index is being written.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hfile.index.block.max.size"><glossterm><varname>hfile.index.block.max.size</varname></glossterm><glossdef><para>When the size of a leaf-level, intermediate-level, or root-level
index block in a multi-level block index grows to this size, the
block is written out and a new block is started.</para><formalpara><title>Default</title><para><varname>131072</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.bucketcache.ioengine"><glossterm><varname>hbase.bucketcache.ioengine</varname></glossterm><glossdef><para>Where to store the contents of the bucketcache. One of: onheap,
offheap, or file. If a file, set it to file:PATH_TO_FILE. See https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/io/hfile/CacheConfig.html for more information.
</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.bucketcache.combinedcache.enabled"><glossterm><varname>hbase.bucketcache.combinedcache.enabled</varname></glossterm><glossdef><para>Whether or not the bucketcache is used in league with the LRU
on-heap block cache. In this mode, indices and blooms are kept in the LRU
blockcache and the data blocks are kept in the bucketcache.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.bucketcache.size"><glossterm><varname>hbase.bucketcache.size</varname></glossterm><glossdef><para>The size of the buckets for the bucketcache if you only use a single size.
Defaults to the default blocksize, which is 64 * 1024.</para><formalpara><title>Default</title><para><varname>65536</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.bucketcache.sizes"><glossterm><varname>hbase.bucketcache.sizes</varname></glossterm><glossdef><para>A comma-separated list of sizes for buckets for the bucketcache
if you use multiple sizes. Should be a list of block sizes in order from smallest
to largest. The sizes you use will depend on your data access patterns.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hfile.format.version"><glossterm><varname>hfile.format.version</varname></glossterm><glossdef><para>The HFile format version to use for new files.
Version 3 adds support for tags in hfiles (See http://hbase.apache.org/book.html#hbase.tags).
Distributed Log Replay requires that tags are enabled. Also see the configuration
'hbase.replication.rpc.codec'.
</para><formalpara><title>Default</title><para><varname>3</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hfile.block.bloom.cacheonwrite"><glossterm><varname>hfile.block.bloom.cacheonwrite</varname></glossterm><glossdef><para>Enables cache-on-write for inline blocks of a compound Bloom filter.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="io.storefile.bloom.block.size"><glossterm><varname>io.storefile.bloom.block.size</varname></glossterm><glossdef><para>The size in bytes of a single block ("chunk") of a compound Bloom
filter. This size is approximate, because Bloom blocks can only be
inserted at data block boundaries, and the number of keys per data
block varies.</para><formalpara><title>Default</title><para><varname>131072</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rs.cacheblocksonwrite"><glossterm><varname>hbase.rs.cacheblocksonwrite</varname></glossterm><glossdef><para>Whether an HFile block should be added to the block cache when the
block is finished.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rpc.timeout"><glossterm><varname>hbase.rpc.timeout</varname></glossterm><glossdef><para>This is for the RPC layer to define how long HBase client applications
take for a remote call to time out. It uses pings to check connections
but will eventually throw a TimeoutException.</para><formalpara><title>Default</title><para><varname>60000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rpc.shortoperation.timeout"><glossterm><varname>hbase.rpc.shortoperation.timeout</varname></glossterm><glossdef><para>This is another version of "hbase.rpc.timeout". For those RPC operation
within cluster, we rely on this configuration to set a short timeout limitation
for short operation. For example, short rpc timeout for region server's trying
to report to active master can benefit quicker master failover process.</para><formalpara><title>Default</title><para><varname>10000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.ipc.client.tcpnodelay"><glossterm><varname>hbase.ipc.client.tcpnodelay</varname></glossterm><glossdef><para>Set no delay on rpc socket connections. See
http://docs.oracle.com/javase/1.5.0/docs/api/java/net/Socket.html#getTcpNoDelay()</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.keytab.file"><glossterm><varname>hbase.master.keytab.file</varname></glossterm><glossdef><para>Full path to the kerberos keytab file to use for logging in
the configured HMaster server principal.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.kerberos.principal"><glossterm><varname>hbase.master.kerberos.principal</varname></glossterm><glossdef><para>Ex. "hbase/_HOST@EXAMPLE.COM". The kerberos principal name
that should be used to run the HMaster process. The principal name should
be in the form: user/hostname@DOMAIN. If "_HOST" is used as the hostname
portion, it will be replaced with the actual hostname of the running
instance.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.keytab.file"><glossterm><varname>hbase.regionserver.keytab.file</varname></glossterm><glossdef><para>Full path to the kerberos keytab file to use for logging in
the configured HRegionServer server principal.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.kerberos.principal"><glossterm><varname>hbase.regionserver.kerberos.principal</varname></glossterm><glossdef><para>Ex. "hbase/_HOST@EXAMPLE.COM". The kerberos principal name
that should be used to run the HRegionServer process. The principal name
should be in the form: user/hostname@DOMAIN. If "_HOST" is used as the
hostname portion, it will be replaced with the actual hostname of the
running instance. An entry for this principal must exist in the file
specified in hbase.regionserver.keytab.file</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hadoop.policy.file"><glossterm><varname>hadoop.policy.file</varname></glossterm><glossdef><para>The policy configuration file used by RPC servers to make
authorization decisions on client requests. Only used when HBase
security is enabled.</para><formalpara><title>Default</title><para><varname>hbase-policy.xml</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.superuser"><glossterm><varname>hbase.superuser</varname></glossterm><glossdef><para>List of users or groups (comma-separated), who are allowed
full privileges, regardless of stored ACLs, across the cluster.
Only used when HBase security is enabled.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.auth.key.update.interval"><glossterm><varname>hbase.auth.key.update.interval</varname></glossterm><glossdef><para>The update interval for master key for authentication tokens
in servers in milliseconds. Only used when HBase security is enabled.</para><formalpara><title>Default</title><para><varname>86400000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.auth.token.max.lifetime"><glossterm><varname>hbase.auth.token.max.lifetime</varname></glossterm><glossdef><para>The maximum lifetime in milliseconds after which an
authentication token expires. Only used when HBase security is enabled.</para><formalpara><title>Default</title><para><varname>604800000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.ipc.client.fallback-to-simple-auth-allowed"><glossterm><varname>hbase.ipc.client.fallback-to-simple-auth-allowed</varname></glossterm><glossdef><para>When a client is configured to attempt a secure connection, but attempts to
connect to an insecure server, that server may instruct the client to
switch to SASL SIMPLE (unsecure) authentication. This setting controls
whether or not the client will accept this instruction from the server.
When false (the default), the client will not allow the fallback to SIMPLE
authentication, and will abort the connection.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.display.keys"><glossterm><varname>hbase.display.keys</varname></glossterm><glossdef><para>When this is set to true the webUI and such will display all start/end keys
as part of the table details, region names, etc. When this is set to false,
the keys are hidden.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.coprocessor.region.classes"><glossterm><varname>hbase.coprocessor.region.classes</varname></glossterm><glossdef><para>A comma-separated list of Coprocessors that are loaded by
default on all tables. For any override coprocessor method, these classes
will be called in order. After implementing your own Coprocessor, just put
it in HBase's classpath and add the fully qualified class name here.
A coprocessor can also be loaded on demand by setting HTableDescriptor.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.port"><glossterm><varname>hbase.rest.port</varname></glossterm><glossdef><para>The port for the HBase REST server.</para><formalpara><title>Default</title><para><varname>8080</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.readonly"><glossterm><varname>hbase.rest.readonly</varname></glossterm><glossdef><para>Defines the mode the REST server will be started in. Possible values are:
false: All HTTP methods are permitted - GET/PUT/POST/DELETE.
true: Only the GET method is permitted.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.threads.max"><glossterm><varname>hbase.rest.threads.max</varname></glossterm><glossdef><para>The maximum number of threads of the REST server thread pool.
Threads in the pool are reused to process REST requests. This
controls the maximum number of requests processed concurrently.
It may help to control the memory used by the REST server to
avoid OOM issues. If the thread pool is full, incoming requests
will be queued up and wait for some free threads.</para><formalpara><title>Default</title><para><varname>100</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.threads.min"><glossterm><varname>hbase.rest.threads.min</varname></glossterm><glossdef><para>The minimum number of threads of the REST server thread pool.
The thread pool always has at least these number of threads so
the REST server is ready to serve incoming requests.</para><formalpara><title>Default</title><para><varname>2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.support.proxyuser"><glossterm><varname>hbase.rest.support.proxyuser</varname></glossterm><glossdef><para>Enables running the REST server to support proxy-user mode.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.defaults.for.version.skip"><glossterm><varname>hbase.defaults.for.version.skip</varname></glossterm><glossdef><para>Set to true to skip the 'hbase.defaults.for.version' check.
Setting this to true can be useful in contexts other than
the other side of a maven generation; i.e. running in an
ide. You'll want to set this boolean to true to avoid
seeing the RuntimException complaint: "hbase-default.xml file
seems to be for and old version of HBase (\${hbase.version}), this
version is X.X.X-SNAPSHOT"</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.coprocessor.master.classes"><glossterm><varname>hbase.coprocessor.master.classes</varname></glossterm><glossdef><para>A comma-separated list of
org.apache.hadoop.hbase.coprocessor.MasterObserver coprocessors that are
loaded by default on the active HMaster process. For any implemented
coprocessor methods, the listed classes will be called in order. After
implementing your own MasterObserver, just put it in HBase's classpath
and add the fully qualified class name here.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.coprocessor.abortonerror"><glossterm><varname>hbase.coprocessor.abortonerror</varname></glossterm><glossdef><para>Set to true to cause the hosting server (master or regionserver)
to abort if a coprocessor fails to load, fails to initialize, or throws an
unexpected Throwable object. Setting this to false will allow the server to
continue execution but the system wide state of the coprocessor in question
will become inconsistent as it will be properly executing in only a subset
of servers, so this is most useful for debugging only.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.online.schema.update.enable"><glossterm><varname>hbase.online.schema.update.enable</varname></glossterm><glossdef><para>Set true to enable online schema changes.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.table.lock.enable"><glossterm><varname>hbase.table.lock.enable</varname></glossterm><glossdef><para>Set to true to enable locking the table in zookeeper for schema change operations.
Table locking from master prevents concurrent schema modifications to corrupt table
state.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.table.max.rowsize"><glossterm><varname>hbase.table.max.rowsize</varname></glossterm><glossdef><para>
Maximum size of single row in bytes (default is 1 Gb) for Get'ting
or Scan'ning without in-row scan flag set. If row size exceeds this limit
RowTooBigException is thrown to client.
</para><formalpara><title>Default</title><para><varname>1073741824</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.thrift.minWorkerThreads"><glossterm><varname>hbase.thrift.minWorkerThreads</varname></glossterm><glossdef><para>The "core size" of the thread pool. New threads are created on every
connection until this many threads are created.</para><formalpara><title>Default</title><para><varname>16</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.thrift.maxWorkerThreads"><glossterm><varname>hbase.thrift.maxWorkerThreads</varname></glossterm><glossdef><para>The maximum size of the thread pool. When the pending request queue
overflows, new threads are created until their number reaches this number.
After that, the server starts dropping connections.</para><formalpara><title>Default</title><para><varname>1000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.thrift.maxQueuedRequests"><glossterm><varname>hbase.thrift.maxQueuedRequests</varname></glossterm><glossdef><para>The maximum number of pending Thrift connections waiting in the queue. If
there are no idle threads in the pool, the server queues requests. Only
when the queue overflows, new threads are added, up to
hbase.thrift.maxQueuedRequests threads.</para><formalpara><title>Default</title><para><varname>1000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.thrift.htablepool.size.max"><glossterm><varname>hbase.thrift.htablepool.size.max</varname></glossterm><glossdef><para>The upper bound for the table pool used in the Thrift gateways server.
Since this is per table name, we assume a single table and so with 1000 default
worker threads max this is set to a matching number. For other workloads this number
can be adjusted as needed.
</para><formalpara><title>Default</title><para><varname>1000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.thrift.framed"><glossterm><varname>hbase.regionserver.thrift.framed</varname></glossterm><glossdef><para>Use Thrift TFramedTransport on the server side.
This is the recommended transport for thrift servers and requires a similar setting
on the client side. Changing this to false will select the default transport,
vulnerable to DoS when malformed requests are issued due to THRIFT-601.
</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.thrift.framed.max_frame_size_in_mb"><glossterm><varname>hbase.regionserver.thrift.framed.max_frame_size_in_mb</varname></glossterm><glossdef><para>Default frame size when using framed transport</para><formalpara><title>Default</title><para><varname>2</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.thrift.compact"><glossterm><varname>hbase.regionserver.thrift.compact</varname></glossterm><glossdef><para>Use Thrift TCompactProtocol binary serialization protocol.</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.data.umask.enable"><glossterm><varname>hbase.data.umask.enable</varname></glossterm><glossdef><para>Enable, if true, that file permissions should be assigned
to the files written by the regionserver</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.data.umask"><glossterm><varname>hbase.data.umask</varname></glossterm><glossdef><para>File permissions that should be used to write data
files when hbase.data.umask.enable is true</para><formalpara><title>Default</title><para><varname>000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.metrics.showTableName"><glossterm><varname>hbase.metrics.showTableName</varname></glossterm><glossdef><para>Whether to include the prefix "tbl.tablename" in per-column family metrics.
If true, for each metric M, per-cf metrics will be reported for tbl.T.cf.CF.M, if false,
per-cf metrics will be aggregated by column-family across tables, and reported for cf.CF.M.
In both cases, the aggregated metric M across tables and cfs will be reported.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.metrics.exposeOperationTimes"><glossterm><varname>hbase.metrics.exposeOperationTimes</varname></glossterm><glossdef><para>Whether to report metrics about time taken performing an
operation on the region server. Get, Put, Delete, Increment, and Append can all
have their times exposed through Hadoop metrics per CF and per region.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.snapshot.enabled"><glossterm><varname>hbase.snapshot.enabled</varname></glossterm><glossdef><para>Set to true to allow snapshots to be taken / restored / cloned.</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.snapshot.restore.take.failsafe.snapshot"><glossterm><varname>hbase.snapshot.restore.take.failsafe.snapshot</varname></glossterm><glossdef><para>Set to true to take a snapshot before the restore operation.
The snapshot taken will be used in case of failure, to restore the previous state.
At the end of the restore operation this snapshot will be deleted</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.snapshot.restore.failsafe.name"><glossterm><varname>hbase.snapshot.restore.failsafe.name</varname></glossterm><glossdef><para>Name of the failsafe snapshot taken by the restore operation.
You can use the {snapshot.name}, {table.name} and {restore.timestamp} variables
to create a name based on what you are restoring.</para><formalpara><title>Default</title><para><varname>hbase-failsafe-{snapshot.name}-{restore.timestamp}</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.server.compactchecker.interval.multiplier"><glossterm><varname>hbase.server.compactchecker.interval.multiplier</varname></glossterm><glossdef><para>The number that determines how often we scan to see if compaction is necessary.
Normally, compactions are done after some events (such as memstore flush), but if
region didn't receive a lot of writes for some time, or due to different compaction
policies, it may be necessary to check it periodically. The interval between checks is
hbase.server.compactchecker.interval.multiplier multiplied by
hbase.server.thread.wakefrequency.</para><formalpara><title>Default</title><para><varname>1000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.lease.recovery.timeout"><glossterm><varname>hbase.lease.recovery.timeout</varname></glossterm><glossdef><para>How long we wait on dfs lease recovery in total before giving up.</para><formalpara><title>Default</title><para><varname>900000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.lease.recovery.dfs.timeout"><glossterm><varname>hbase.lease.recovery.dfs.timeout</varname></glossterm><glossdef><para>How long between dfs recover lease invocations. Should be larger than the sum of
the time it takes for the namenode to issue a block recovery command as part of
datanode; dfs.heartbeat.interval and the time it takes for the primary
datanode, performing block recovery to timeout on a dead datanode; usually
dfs.client.socket-timeout. See the end of HBASE-8389 for more.</para><formalpara><title>Default</title><para><varname>64000</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.column.max.version"><glossterm><varname>hbase.column.max.version</varname></glossterm><glossdef><para>New column family descriptors will use this value as the default number of versions
to keep.</para><formalpara><title>Default</title><para><varname>1</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.dfs.client.read.shortcircuit.buffer.size"><glossterm><varname>hbase.dfs.client.read.shortcircuit.buffer.size</varname></glossterm><glossdef><para>If the DFSClient configuration
dfs.client.read.shortcircuit.buffer.size is unset, we will
use what is configured here as the short circuit read default
direct byte buffer size. DFSClient native default is 1MB; HBase
keeps its HDFS files open so number of file blocks * 1MB soon
starts to add up and threaten OOME because of a shortage of
direct memory. So, we set it down from the default. Make
it &gt; the default hbase block size set in the HColumnDescriptor
which is usually 64k.
</para><formalpara><title>Default</title><para><varname>131072</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.checksum.verify"><glossterm><varname>hbase.regionserver.checksum.verify</varname></glossterm><glossdef><para>
If set to true (the default), HBase verifies the checksums for hfile
blocks. HBase writes checksums inline with the data when it writes out
hfiles. HDFS (as of this writing) writes checksums to a separate file
than the data file necessitating extra seeks. Setting this flag saves
some on i/o. Checksum verification by HDFS will be internally disabled
on hfile streams when this flag is set. If the hbase-checksum verification
fails, we will switch back to using HDFS checksums (so do not disable HDFS
checksums! And besides this feature applies to hfiles only, not to WALs).
If this parameter is set to false, then hbase will not verify any checksums,
instead it will depend on checksum verification being done in the HDFS client.
</para><formalpara><title>Default</title><para><varname>true</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.bytes.per.checksum"><glossterm><varname>hbase.hstore.bytes.per.checksum</varname></glossterm><glossdef><para>
Number of bytes in a newly created checksum chunk for HBase-level
checksums in hfile blocks.
</para><formalpara><title>Default</title><para><varname>16384</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.hstore.checksum.algorithm"><glossterm><varname>hbase.hstore.checksum.algorithm</varname></glossterm><glossdef><para>
Name of an algorithm that is used to compute checksums. Possible values
are NULL, CRC32, CRC32C.
</para><formalpara><title>Default</title><para><varname>CRC32</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.status.published"><glossterm><varname>hbase.status.published</varname></glossterm><glossdef><para>
This setting activates the publication by the master of the status of the region server.
When a region server dies and its recovery starts, the master will push this information
to the client application, to let them cut the connection immediately instead of waiting
for a timeout.
</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.status.publisher.class"><glossterm><varname>hbase.status.publisher.class</varname></glossterm><glossdef><para>
Implementation of the status publication with a multicast message.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.master.ClusterStatusPublisher$MulticastPublisher</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.status.listener.class"><glossterm><varname>hbase.status.listener.class</varname></glossterm><glossdef><para>
Implementation of the status listener with a multicast message.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.client.ClusterStatusListener$MulticastListener</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.status.multicast.address.ip"><glossterm><varname>hbase.status.multicast.address.ip</varname></glossterm><glossdef><para>
Multicast address to use for the status publication by multicast.
</para><formalpara><title>Default</title><para><varname>226.1.1.3</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.status.multicast.address.port"><glossterm><varname>hbase.status.multicast.address.port</varname></glossterm><glossdef><para>
Multicast port to use for the status publication by multicast.
</para><formalpara><title>Default</title><para><varname>16100</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.dynamic.jars.dir"><glossterm><varname>hbase.dynamic.jars.dir</varname></glossterm><glossdef><para>
The directory from which the custom filter/co-processor jars can be loaded
dynamically by the region server without the need to restart. However,
an already loaded filter/co-processor class would not be un-loaded. See
HBASE-1936 for more details.
</para><formalpara><title>Default</title><para><varname>${hbase.rootdir}/lib</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.security.authentication"><glossterm><varname>hbase.security.authentication</varname></glossterm><glossdef><para>
Controls whether or not secure authentication is enabled for HBase.
Possible values are 'simple' (no authentication), and 'kerberos'.
</para><formalpara><title>Default</title><para><varname>simple</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.rest.filter.classes"><glossterm><varname>hbase.rest.filter.classes</varname></glossterm><glossdef><para>
Servlet filters for REST service.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.rest.filter.GzipFilter</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.master.loadbalancer.class"><glossterm><varname>hbase.master.loadbalancer.class</varname></glossterm><glossdef><para>
Class used to execute the regions balancing when the period occurs.
See the class comment for more on how it works
http://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.html
It replaces the DefaultLoadBalancer as the default (since renamed
as the SimpleLoadBalancer).
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.security.exec.permission.checks"><glossterm><varname>hbase.security.exec.permission.checks</varname></glossterm><glossdef><para>
If this setting is enabled and ACL based access control is active (the
AccessController coprocessor is installed either as a system coprocessor
or on a table as a table coprocessor) then you must grant all relevant
users EXEC privilege if they require the ability to execute coprocessor
endpoint calls. EXEC privilege, like any other permission, can be
granted globally to a user, or to a user on a per table or per namespace
basis. For more information on coprocessor endpoints, see the coprocessor
section of the HBase online manual. For more information on granting or
revoking permissions using the AccessController, see the security
section of the HBase online manual.
</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.procedure.regionserver.classes"><glossterm><varname>hbase.procedure.regionserver.classes</varname></glossterm><glossdef><para>A comma-separated list of
org.apache.hadoop.hbase.procedure.RegionServerProcedureManager procedure managers that are
loaded by default on the active HRegionServer process. The lifecycle methods (init/start/stop)
will be called by the active HRegionServer process to perform the specific globally barriered
procedure. After implementing your own RegionServerProcedureManager, just put it in
HBase's classpath and add the fully qualified class name here.
</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.procedure.master.classes"><glossterm><varname>hbase.procedure.master.classes</varname></glossterm><glossdef><para>A comma-separated list of
org.apache.hadoop.hbase.procedure.MasterProcedureManager procedure managers that are
loaded by default on the active HMaster process. A procedure is identified by its signature and
users can use the signature and an instant name to trigger an execution of a globally barriered
procedure. After implementing your own MasterProcedureManager, just put it in HBase's classpath
and add the fully qualified class name here.</para><formalpara><title>Default</title><para><varname/></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.coordinated.state.manager.class"><glossterm><varname>hbase.coordinated.state.manager.class</varname></glossterm><glossdef><para>Fully qualified name of class implementing coordinated state manager.</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.coordination.ZkCoordinatedStateManager</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.storefile.refresh.period"><glossterm><varname>hbase.regionserver.storefile.refresh.period</varname></glossterm><glossdef><para>
The period (in milliseconds) for refreshing the store files for the secondary regions. 0
means this feature is disabled. Secondary regions sees new files (from flushes and
compactions) from primary once the secondary region refreshes the list of files in the
region (there is no notification mechanism). But too frequent refreshes might cause
extra Namenode pressure. If the files cannot be refreshed for longer than HFile TTL
(hbase.master.hfilecleaner.ttl) the requests are rejected. Configuring HFile TTL to a larger
value is also recommended with this setting.
</para><formalpara><title>Default</title><para><varname>0</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.region.replica.replication.enabled"><glossterm><varname>hbase.region.replica.replication.enabled</varname></glossterm><glossdef><para>
Whether asynchronous WAL replication to the secondary region replicas is enabled or not.
If this is enabled, a replication peer named "region_replica_replication" will be created
which will tail the logs and replicate the mutatations to region replicas for tables that
have region replication &gt; 1. If this is enabled once, disabling this replication also
requires disabling the replication peer using shell or ReplicationAdmin java class.
Replication to secondary region replicas works over standard inter-cluster replication.
So replication, if disabled explicitly, also has to be enabled by setting "hbase.replication"
to true for this feature to work.
</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.http.filter.initializers"><glossterm><varname>hbase.http.filter.initializers</varname></glossterm><glossdef><para>
A comma separated list of class names. Each class in the list must extend
org.apache.hadoop.hbase.http.FilterInitializer. The corresponding Filter will
be initialized. Then, the Filter will be applied to all user facing jsp
and servlet web pages.
The ordering of the list defines the ordering of the filters.
The default StaticUserWebFilter add a user principal as defined by the
hbase.http.staticuser.user property.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.http.lib.StaticUserWebFilter</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.security.visibility.mutations.checkauths"><glossterm><varname>hbase.security.visibility.mutations.checkauths</varname></glossterm><glossdef><para>
This property if enabled, will check whether the labels in the visibility expression are associated
with the user issuing the mutation
</para><formalpara><title>Default</title><para><varname>false</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.http.max.threads"><glossterm><varname>hbase.http.max.threads</varname></glossterm><glossdef><para>
The maximum number of threads that the HTTP Server will create in its
ThreadPool.
</para><formalpara><title>Default</title><para><varname>10</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.replication.rpc.codec"><glossterm><varname>hbase.replication.rpc.codec</varname></glossterm><glossdef><para>
The codec that is to be used when replication is enabled so that
the tags are also replicated. This is used along with HFileV3 which
supports tags in them. If tags are not used or if the hfile version used
is HFileV2 then KeyValueCodec can be used as the replication codec. Note that
using KeyValueCodecWithTags for replication when there are no tags causes no harm.
</para><formalpara><title>Default</title><para><varname>org.apache.hadoop.hbase.codec.KeyValueCodecWithTags</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.http.staticuser.user"><glossterm><varname>hbase.http.staticuser.user</varname></glossterm><glossdef><para>
The user name to filter as, on static web filters
while rendering content. An example use is the HDFS
web UI (user to be used for browsing files).
</para><formalpara><title>Default</title><para><varname>dr.stack</varname></para></formalpara></glossdef></glossentry><glossentry xml:id="hbase.regionserver.handler.abort.on.error.percent"><glossterm><varname>hbase.regionserver.handler.abort.on.error.percent</varname></glossterm><glossdef><para>The percent of region server RPC threads failed to abort RS.
-1 Disable aborting; 0 Abort if even a single handler has died;
0.x Abort only when this percent of handlers have died;
1 Abort only all of the handers have died.</para><formalpara><title>Default</title><para><varname>0.5</varname></para></formalpara></glossdef></glossentry></glossary>

View File

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
version="5.0"
xml:id="hbase_apis"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Apache HBase APIs</title>
<para>This chapter provides information about performing operations using HBase native APIs. This
information is not exhaustive, and provides a quick reference in addition to the <link
xlink:href="http://hbase.apache.org/apidocs/index.html">User API
Reference</link>. The examples here are not comprehensive or complete, and should be used for
purposes of illustration only.</para>
<para>Apache HBase also works with multiple external APIs. See <xref linkend="external_apis" />
for more information.</para>
<example>
<title>Create a Table Using Java</title>
<para>This example has been tested on HBase 0.96.1.1.</para>
<programlisting language="java">
package com.example.hbase.admin;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
import org.apache.hadoop.conf.Configuration;
import static com.example.hbase.Constants.*;
public class CreateSchema {
public static void createOrOverwrite(HBaseAdmin admin, HTableDescriptor table) throws IOException {
if (admin.tableExists(table.getName())) {
admin.disableTable(table.getName());
admin.deleteTable(table.getName());
}
admin.createTable(table);
}
public static void createSchemaTables (Configuration config) {
try {
final HBaseAdmin admin = new HBaseAdmin(config);
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
table.addFamily(new HColumnDescriptor(CF_DEFAULT).setCompressionType(Algorithm.SNAPPY));
System.out.print("Creating table. ");
createOrOverwrite(admin, table);
System.out.println(" Done.");
admin.close();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
}
</programlisting>
</example>
<example>
<title>Add, Modify, and Delete a Table</title>
<para>This example has been tested on HBase 0.96.1.1.</para>
<programlisting language="java">
public static void upgradeFrom0 (Configuration config) {
try {
final HBaseAdmin admin = new HBaseAdmin(config);
TableName tableName = TableName.valueOf(TABLE_ASSETMETA);
HTableDescriptor table_assetmeta = new HTableDescriptor(tableName);
table_assetmeta.addFamily(new HColumnDescriptor(CF_DEFAULT).setCompressionType(Algorithm.SNAPPY));
// Create a new table.
System.out.print("Creating table_assetmeta. ");
admin.createTable(table_assetmeta);
System.out.println(" Done.");
// Update existing table
HColumnDescriptor newColumn = new HColumnDescriptor("NEWCF");
newColumn.setCompactionCompressionType(Algorithm.GZ);
newColumn.setMaxVersions(HConstants.ALL_VERSIONS);
admin.addColumn(tableName, newColumn);
// Disable an existing table
admin.disableTable(tableName);
// Delete an existing column family
admin.deleteColumn(tableName, CF_DEFAULT);
// Delete a table (Need to be disabled first)
admin.deleteTable(tableName);
admin.close();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
</programlisting>
</example>
</chapter>

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="hbase.history"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>HBase History</title>
<itemizedlist>
<listitem><para>2006: <link xlink:href="http://research.google.com/archive/bigtable.html">BigTable</link> paper published by Google.
</para></listitem>
<listitem><para>2006 (end of year): HBase development starts.
</para></listitem>
<listitem><para>2008: HBase becomes Hadoop sub-project.
</para></listitem>
<listitem><para>2010: HBase becomes Apache top-level project.
</para></listitem>
</itemizedlist>
</appendix>

View File

@ -1,237 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="hbck.in.depth"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>hbck In Depth</title>
<para>HBaseFsck (hbck) is a tool for checking for region consistency and table integrity problems
and repairing a corrupted HBase. It works in two basic modes -- a read-only inconsistency
identifying mode and a multi-phase read-write repair mode.
</para>
<section>
<title>Running hbck to identify inconsistencies</title>
<para>To check to see if your HBase cluster has corruptions, run hbck against your HBase cluster:</para>
<programlisting language="bourne">
$ ./bin/hbase hbck
</programlisting>
<para>
At the end of the commands output it prints OK or tells you the number of INCONSISTENCIES
present. You may also want to run run hbck a few times because some inconsistencies can be
transient (e.g. cluster is starting up or a region is splitting). Operationally you may want to run
hbck regularly and setup alert (e.g. via nagios) if it repeatedly reports inconsistencies .
A run of hbck will report a list of inconsistencies along with a brief description of the regions and
tables affected. The using the <code>-details</code> option will report more details including a representative
listing of all the splits present in all the tables.
</para>
<programlisting language="bourne">
$ ./bin/hbase hbck -details
</programlisting>
<para>If you just want to know if some tables are corrupted, you can limit hbck to identify inconsistencies
in only specific tables. For example the following command would only attempt to check table
TableFoo and TableBar. The benefit is that hbck will run in less time.</para>
<programlisting language="bourne">
$ ./bin/hbase hbck TableFoo TableBar
</programlisting>
</section>
<section><title>Inconsistencies</title>
<para>
If after several runs, inconsistencies continue to be reported, you may have encountered a
corruption. These should be rare, but in the event they occur newer versions of HBase include
the hbck tool enabled with automatic repair options.
</para>
<para>
There are two invariants that when violated create inconsistencies in HBase:
</para>
<itemizedlist>
<listitem><para>HBases region consistency invariant is satisfied if every region is assigned and
deployed on exactly one region server, and all places where this state kept is in
accordance.</para>
</listitem>
<listitem><para>HBases table integrity invariant is satisfied if for each table, every possible row key
resolves to exactly one region.</para>
</listitem>
</itemizedlist>
<para>
Repairs generally work in three phases -- a read-only information gathering phase that identifies
inconsistencies, a table integrity repair phase that restores the table integrity invariant, and then
finally a region consistency repair phase that restores the region consistency invariant.
Starting from version 0.90.0, hbck could detect region consistency problems report on a subset
of possible table integrity problems. It also included the ability to automatically fix the most
common inconsistency, region assignment and deployment consistency problems. This repair
could be done by using the <code>-fix</code> command line option. These problems close regions if they are
open on the wrong server or on multiple region servers and also assigns regions to region
servers if they are not open.
</para>
<para>
Starting from HBase versions 0.90.7, 0.92.2 and 0.94.0, several new command line options are
introduced to aid repairing a corrupted HBase. This hbck sometimes goes by the nickname
“uberhbck”. Each particular version of uber hbck is compatible with the HBases of the same
major version (0.90.7 uberhbck can repair a 0.90.4). However, versions &lt;=0.90.6 and versions
&lt;=0.92.1 may require restarting the master or failing over to a backup master.
</para>
</section>
<section><title>Localized repairs</title>
<para>
When repairing a corrupted HBase, it is best to repair the lowest risk inconsistencies first.
These are generally region consistency repairs -- localized single region repairs, that only modify
in-memory data, ephemeral zookeeper data, or patch holes in the META table.
Region consistency requires that the HBase instance has the state of the regions data in HDFS
(.regioninfo files), the regions row in the hbase:meta table., and regions deployment/assignments on
region servers and the master in accordance. Options for repairing region consistency include:
<itemizedlist>
<listitem><para><code>-fixAssignments</code> (equivalent to the 0.90 <code>-fix</code> option) repairs unassigned, incorrectly
assigned or multiply assigned regions.</para>
</listitem>
<listitem><para><code>-fixMeta</code> which removes meta rows when corresponding regions are not present in
HDFS and adds new meta rows if they regions are present in HDFS while not in META.</para>
</listitem>
</itemizedlist>
To fix deployment and assignment problems you can run this command:
</para>
<programlisting language="bourne">
$ ./bin/hbase hbck -fixAssignments
</programlisting>
<para>To fix deployment and assignment problems as well as repairing incorrect meta rows you can
run this command:</para>
<programlisting language="bourne">
$ ./bin/hbase hbck -fixAssignments -fixMeta
</programlisting>
<para>There are a few classes of table integrity problems that are low risk repairs. The first two are
degenerate (startkey == endkey) regions and backwards regions (startkey > endkey). These are
automatically handled by sidelining the data to a temporary directory (/hbck/xxxx).
The third low-risk class is hdfs region holes. This can be repaired by using the:</para>
<itemizedlist>
<listitem><para><code>-fixHdfsHoles</code> option for fabricating new empty regions on the file system.
If holes are detected you can use -fixHdfsHoles and should include -fixMeta and -fixAssignments to make the new region consistent.</para>
</listitem>
</itemizedlist>
<programlisting language="bourne">
$ ./bin/hbase hbck -fixAssignments -fixMeta -fixHdfsHoles
</programlisting>
<para>Since this is a common operation, weve added a the <code>-repairHoles</code> flag that is equivalent to the
previous command:</para>
<programlisting language="bourne">
$ ./bin/hbase hbck -repairHoles
</programlisting>
<para>If inconsistencies still remain after these steps, you most likely have table integrity problems
related to orphaned or overlapping regions.</para>
</section>
<section><title>Region Overlap Repairs</title>
<para>Table integrity problems can require repairs that deal with overlaps. This is a riskier operation
because it requires modifications to the file system, requires some decision making, and may
require some manual steps. For these repairs it is best to analyze the output of a <code>hbck -details</code>
run so that you isolate repairs attempts only upon problems the checks identify. Because this is
riskier, there are safeguard that should be used to limit the scope of the repairs.
WARNING: This is a relatively new and have only been tested on online but idle HBase instances
(no reads/writes). Use at your own risk in an active production environment!
The options for repairing table integrity violations include:</para>
<itemizedlist>
<listitem><para><code>-fixHdfsOrphans</code> option for “adopting” a region directory that is missing a region
metadata file (the .regioninfo file).</para>
</listitem>
<listitem><para><code>-fixHdfsOverlaps</code> ability for fixing overlapping regions</para>
</listitem>
</itemizedlist>
<para>When repairing overlapping regions, a regions data can be modified on the file system in two
ways: 1) by merging regions into a larger region or 2) by sidelining regions by moving data to
“sideline” directory where data could be restored later. Merging a large number of regions is
technically correct but could result in an extremely large region that requires series of costly
compactions and splitting operations. In these cases, it is probably better to sideline the regions
that overlap with the most other regions (likely the largest ranges) so that merges can happen on
a more reasonable scale. Since these sidelined regions are already laid out in HBases native
directory and HFile format, they can be restored by using HBases bulk load mechanism.
The default safeguard thresholds are conservative. These options let you override the default
thresholds and to enable the large region sidelining feature.</para>
<itemizedlist>
<listitem><para><code>-maxMerge &lt;n&gt;</code> maximum number of overlapping regions to merge</para>
</listitem>
<listitem><para><code>-sidelineBigOverlaps</code> if more than maxMerge regions are overlapping, sideline attempt
to sideline the regions overlapping with the most other regions.</para>
</listitem>
<listitem><para><code>-maxOverlapsToSideline &lt;n&gt;</code> if sidelining large overlapping regions, sideline at most n
regions.</para>
</listitem>
</itemizedlist>
<para>Since often times you would just want to get the tables repaired, you can use this option to turn
on all repair options:</para>
<itemizedlist>
<listitem><para><code>-repair</code> includes all the region consistency options and only the hole repairing table
integrity options.</para>
</listitem>
</itemizedlist>
<para>Finally, there are safeguards to limit repairs to only specific tables. For example the following
command would only attempt to check and repair table TableFoo and TableBar.</para>
<screen language="bourne">
$ ./bin/hbase hbck -repair TableFoo TableBar
</screen>
<section><title>Special cases: Meta is not properly assigned</title>
<para>There are a few special cases that hbck can handle as well.
Sometimes the meta tables only region is inconsistently assigned or deployed. In this case
there is a special <code>-fixMetaOnly</code> option that can try to fix meta assignments.</para>
<screen language="bourne">
$ ./bin/hbase hbck -fixMetaOnly -fixAssignments
</screen>
</section>
<section><title>Special cases: HBase version file is missing</title>
<para>HBases data on the file system requires a version file in order to start. If this flie is missing, you
can use the <code>-fixVersionFile</code> option to fabricating a new HBase version file. This assumes that
the version of hbck you are running is the appropriate version for the HBase cluster.</para>
</section>
<section><title>Special case: Root and META are corrupt.</title>
<para>The most drastic corruption scenario is the case where the ROOT or META is corrupted and
HBase will not start. In this case you can use the OfflineMetaRepair tool create new ROOT
and META regions and tables.
This tool assumes that HBase is offline. It then marches through the existing HBase home
directory, loads as much information from region metadata files (.regioninfo files) as possible
from the file system. If the region metadata has proper table integrity, it sidelines the original root
and meta table directories, and builds new ones with pointers to the region directories and their
data.</para>
<screen language="bourne">
$ ./bin/hbase org.apache.hadoop.hbase.util.hbck.OfflineMetaRepair
</screen>
<para>NOTE: This tool is not as clever as uberhbck but can be used to bootstrap repairs that uberhbck
can complete.
If the tool succeeds you should be able to start hbase and run online repairs if necessary.</para>
</section>
<section><title>Special cases: Offline split parent</title>
<para>
Once a region is split, the offline parent will be cleaned up automatically. Sometimes, daughter regions
are split again before their parents are cleaned up. HBase can clean up parents in the right order. However,
there could be some lingering offline split parents sometimes. They are in META, in HDFS, and not deployed.
But HBase can't clean them up. In this case, you can use the <code>-fixSplitParents</code> option to reset
them in META to be online and not split. Therefore, hbck can merge them with other regions if fixing
overlapping regions option is used.
</para>
<para>
This option should not normally be used, and it is not in <code>-fixAll</code>.
</para>
</section>
</section>
</appendix>

View File

@ -1,630 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter
xml:id="mapreduce"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>HBase and MapReduce</title>
<para>Apache MapReduce is a software framework used to analyze large amounts of data, and is
the framework used most often with <link
xlink:href="http://hadoop.apache.org/">Apache Hadoop</link>. MapReduce itself is out of the
scope of this document. A good place to get started with MapReduce is <link
xlink:href="http://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html" />. MapReduce version
2 (MR2)is now part of <link
xlink:href="http://hadoop.apache.org/docs/r2.3.0/hadoop-yarn/hadoop-yarn-site/">YARN</link>. </para>
<para> This chapter discusses specific configuration steps you need to take to use MapReduce on
data within HBase. In addition, it discusses other interactions and issues between HBase and
MapReduce jobs.
<note>
<title>mapred and mapreduce</title>
<para>There are two mapreduce packages in HBase as in MapReduce itself: <filename>org.apache.hadoop.hbase.mapred</filename>
and <filename>org.apache.hadoop.hbase.mapreduce</filename>. The former does old-style API and the latter
the new style. The latter has more facility though you can usually find an equivalent in the older
package. Pick the package that goes with your mapreduce deploy. When in doubt or starting over, pick the
<filename>org.apache.hadoop.hbase.mapreduce</filename>. In the notes below, we refer to
o.a.h.h.mapreduce but replace with the o.a.h.h.mapred if that is what you are using.
</para>
</note>
</para>
<section
xml:id="hbase.mapreduce.classpath">
<title>HBase, MapReduce, and the CLASSPATH</title>
<para>By default, MapReduce jobs deployed to a MapReduce cluster do not have access to either
the HBase configuration under <envar>$HBASE_CONF_DIR</envar> or the HBase classes.</para>
<para>To give the MapReduce jobs the access they need, you could add
<filename>hbase-site.xml</filename> to the
<filename><replaceable>$HADOOP_HOME</replaceable>/conf/</filename> directory and add the
HBase JARs to the <filename><replaceable>HADOOP_HOME</replaceable>/conf/</filename>
directory, then copy these changes across your cluster. You could add hbase-site.xml to
$HADOOP_HOME/conf and add HBase jars to the $HADOOP_HOME/lib. You would then need to copy
these changes across your cluster or edit
<filename><replaceable>$HADOOP_HOME</replaceable>conf/hadoop-env.sh</filename> and add
them to the <envar>HADOOP_CLASSPATH</envar> variable. However, this approach is not
recommended because it will pollute your Hadoop install with HBase references. It also
requires you to restart the Hadoop cluster before Hadoop can use the HBase data.</para>
<para> Since HBase 0.90.x, HBase adds its dependency JARs to the job configuration itself. The
dependencies only need to be available on the local CLASSPATH. The following example runs
the bundled HBase <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/RowCounter.html">RowCounter</link>
MapReduce job against a table named <systemitem>usertable</systemitem> If you have not set
the environment variables expected in the command (the parts prefixed by a
<literal>$</literal> sign and curly braces), you can use the actual system paths instead.
Be sure to use the correct version of the HBase JAR for your system. The backticks
(<literal>`</literal> symbols) cause ths shell to execute the sub-commands, setting the
CLASSPATH as part of the command. This example assumes you use a BASH-compatible shell. </para>
<screen language="bourne">$ <userinput>HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-server-VERSION.jar rowcounter usertable</userinput></screen>
<para>When the command runs, internally, the HBase JAR finds the dependencies it needs for
zookeeper, guava, and its other dependencies on the passed <envar>HADOOP_CLASSPATH</envar>
and adds the JARs to the MapReduce job configuration. See the source at
TableMapReduceUtil#addDependencyJars(org.apache.hadoop.mapreduce.Job) for how this is done. </para>
<note>
<para> The example may not work if you are running HBase from its build directory rather
than an installed location. You may see an error like the following:</para>
<screen>java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.RowCounter$RowCounterMapper</screen>
<para>If this occurs, try modifying the command as follows, so that it uses the HBase JARs
from the <filename>target/</filename> directory within the build environment.</para>
<screen language="bourne">$ <userinput>HADOOP_CLASSPATH=${HBASE_HOME}/hbase-server/target/hbase-server-VERSION-SNAPSHOT.jar:`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-server/target/hbase-server-VERSION-SNAPSHOT.jar rowcounter usertable</userinput></screen>
</note>
<caution>
<title>Notice to Mapreduce users of HBase 0.96.1 and above</title>
<para>Some mapreduce jobs that use HBase fail to launch. The symptom is an exception similar
to the following:</para>
<screen>
Exception in thread "main" java.lang.IllegalAccessError: class
com.google.protobuf.ZeroCopyLiteralByteString cannot access its superclass
com.google.protobuf.LiteralByteString
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at
org.apache.hadoop.hbase.protobuf.ProtobufUtil.toScan(ProtobufUtil.java:818)
at
org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.convertScanToString(TableMapReduceUtil.java:433)
at
org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob(TableMapReduceUtil.java:186)
at
org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob(TableMapReduceUtil.java:147)
at
org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob(TableMapReduceUtil.java:270)
at
org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob(TableMapReduceUtil.java:100)
...
</screen>
<para>This is caused by an optimization introduced in <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-9867">HBASE-9867</link> that
inadvertently introduced a classloader dependency. </para>
<para>This affects both jobs using the <code>-libjars</code> option and "fat jar," those
which package their runtime dependencies in a nested <code>lib</code> folder.</para>
<para>In order to satisfy the new classloader requirements, hbase-protocol.jar must be
included in Hadoop's classpath. See <xref
linkend="hbase.mapreduce.classpath" /> for current recommendations for resolving
classpath errors. The following is included for historical purposes.</para>
<para>This can be resolved system-wide by including a reference to the hbase-protocol.jar in
hadoop's lib directory, via a symlink or by copying the jar into the new location.</para>
<para>This can also be achieved on a per-job launch basis by including it in the
<code>HADOOP_CLASSPATH</code> environment variable at job submission time. When
launching jobs that package their dependencies, all three of the following job launching
commands satisfy this requirement:</para>
<screen language="bourne">
$ <userinput>HADOOP_CLASSPATH=/path/to/hbase-protocol.jar:/path/to/hbase/conf hadoop jar MyJob.jar MyJobMainClass</userinput>
$ <userinput>HADOOP_CLASSPATH=$(hbase mapredcp):/path/to/hbase/conf hadoop jar MyJob.jar MyJobMainClass</userinput>
$ <userinput>HADOOP_CLASSPATH=$(hbase classpath) hadoop jar MyJob.jar MyJobMainClass</userinput>
</screen>
<para>For jars that do not package their dependencies, the following command structure is
necessary:</para>
<screen language="bourne">
$ <userinput>HADOOP_CLASSPATH=$(hbase mapredcp):/etc/hbase/conf hadoop jar MyApp.jar MyJobMainClass -libjars $(hbase mapredcp | tr ':' ',')</userinput> ...
</screen>
<para>See also <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-10304">HBASE-10304</link> for
further discussion of this issue.</para>
</caution>
</section>
<section>
<title>MapReduce Scan Caching</title>
<para>TableMapReduceUtil now restores the option to set scanner caching (the number of rows
which are cached before returning the result to the client) on the Scan object that is
passed in. This functionality was lost due to a bug in HBase 0.95 (<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-11558">HBASE-11558</link>), which
is fixed for HBase 0.98.5 and 0.96.3. The priority order for choosing the scanner caching is
as follows:</para>
<orderedlist>
<listitem>
<para>Caching settings which are set on the scan object.</para>
</listitem>
<listitem>
<para>Caching settings which are specified via the configuration option
<option>hbase.client.scanner.caching</option>, which can either be set manually in
<filename>hbase-site.xml</filename> or via the helper method
<code>TableMapReduceUtil.setScannerCaching()</code>.</para>
</listitem>
<listitem>
<para>The default value <code>HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING</code>, which is set to
<literal>100</literal>.</para>
</listitem>
</orderedlist>
<para>Optimizing the caching settings is a balance between the time the client waits for a
result and the number of sets of results the client needs to receive. If the caching setting
is too large, the client could end up waiting for a long time or the request could even time
out. If the setting is too small, the scan needs to return results in several pieces.
If you think of the scan as a shovel, a bigger cache setting is analogous to a bigger
shovel, and a smaller cache setting is equivalent to more shoveling in order to fill the
bucket.</para>
<para>The list of priorities mentioned above allows you to set a reasonable default, and
override it for specific operations.</para>
<para>See the API documentation for <link
xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html"
>Scan</link> for more details.</para>
</section>
<section>
<title>Bundled HBase MapReduce Jobs</title>
<para>The HBase JAR also serves as a Driver for some bundled mapreduce jobs. To learn about
the bundled MapReduce jobs, run the following command.</para>
<screen language="bourne">$ <userinput>${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-server-VERSION.jar</userinput>
<computeroutput>An example program must be given as the first argument.
Valid program names are:
copytable: Export a table from local cluster to peer cluster
completebulkload: Complete a bulk data load.
export: Write table data to HDFS.
import: Import data written by Export.
importtsv: Import data in TSV format.
rowcounter: Count rows in HBase table</computeroutput>
</screen>
<para>Each of the valid program names are bundled MapReduce jobs. To run one of the jobs,
model your command after the following example.</para>
<screen language="bourne">$ <userinput>${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-server-VERSION.jar rowcounter myTable</userinput></screen>
</section>
<section>
<title>HBase as a MapReduce Job Data Source and Data Sink</title>
<para>HBase can be used as a data source, <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableInputFormat.html">TableInputFormat</link>,
and data sink, <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.html">TableOutputFormat</link>
or <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.html">MultiTableOutputFormat</link>,
for MapReduce jobs. Writing MapReduce jobs that read or write HBase, it is advisable to
subclass <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableMapper.html">TableMapper</link>
and/or <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableReducer.html">TableReducer</link>.
See the do-nothing pass-through classes <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/IdentityTableMapper.html">IdentityTableMapper</link>
and <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/IdentityTableReducer.html">IdentityTableReducer</link>
for basic usage. For a more involved example, see <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/RowCounter.html">RowCounter</link>
or review the <code>org.apache.hadoop.hbase.mapreduce.TestTableMapReduce</code> unit test. </para>
<para>If you run MapReduce jobs that use HBase as source or sink, need to specify source and
sink table and column names in your configuration.</para>
<para>When you read from HBase, the <code>TableInputFormat</code> requests the list of regions
from HBase and makes a map, which is either a <code>map-per-region</code> or
<code>mapreduce.job.maps</code> map, whichever is smaller. If your job only has two maps,
raise <code>mapreduce.job.maps</code> to a number greater than the number of regions. Maps
will run on the adjacent TaskTracker if you are running a TaskTracer and RegionServer per
node. When writing to HBase, it may make sense to avoid the Reduce step and write back into
HBase from within your map. This approach works when your job does not need the sort and
collation that MapReduce does on the map-emitted data. On insert, HBase 'sorts' so there is
no point double-sorting (and shuffling data around your MapReduce cluster) unless you need
to. If you do not need the Reduce, you myour map might emit counts of records processed for
reporting at the end of the jobj, or set the number of Reduces to zero and use
TableOutputFormat. If running the Reduce step makes sense in your case, you should typically
use multiple reducers so that load is spread across the HBase cluster.</para>
<para>A new HBase partitioner, the <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/HRegionPartitioner.html">HRegionPartitioner</link>,
can run as many reducers the number of existing regions. The HRegionPartitioner is suitable
when your table is large and your upload will not greatly alter the number of existing
regions upon completion. Otherwise use the default partitioner. </para>
</section>
<section>
<title>Writing HFiles Directly During Bulk Import</title>
<para>If you are importing into a new table, you can bypass the HBase API and write your
content directly to the filesystem, formatted into HBase data files (HFiles). Your import
will run faster, perhaps an order of magnitude faster. For more on how this mechanism works,
see <xref
linkend="arch.bulk.load" />.</para>
</section>
<section>
<title>RowCounter Example</title>
<para>The included <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/RowCounter.html">RowCounter</link>
MapReduce job uses <code>TableInputFormat</code> and does a count of all rows in the specified
table. To run it, use the following command: </para>
<screen language="bourne">$ <userinput>./bin/hadoop jar hbase-X.X.X.jar</userinput></screen>
<para>This will
invoke the HBase MapReduce Driver class. Select <literal>rowcounter</literal> from the choice of jobs
offered. This will print rowcouner usage advice to standard output. Specify the tablename,
column to count, and output
directory. If you have classpath errors, see <xref linkend="hbase.mapreduce.classpath" />.</para>
</section>
<section
xml:id="splitter">
<title>Map-Task Splitting</title>
<section
xml:id="splitter.default">
<title>The Default HBase MapReduce Splitter</title>
<para>When <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableInputFormat.html">TableInputFormat</link>
is used to source an HBase table in a MapReduce job, its splitter will make a map task for
each region of the table. Thus, if there are 100 regions in the table, there will be 100
map-tasks for the job - regardless of how many column families are selected in the
Scan.</para>
</section>
<section
xml:id="splitter.custom">
<title>Custom Splitters</title>
<para>For those interested in implementing custom splitters, see the method
<code>getSplits</code> in <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.html">TableInputFormatBase</link>.
That is where the logic for map-task assignment resides. </para>
</section>
</section>
<section
xml:id="mapreduce.example">
<title>HBase MapReduce Examples</title>
<section
xml:id="mapreduce.example.read">
<title>HBase MapReduce Read Example</title>
<para>The following is an example of using HBase as a MapReduce source in read-only manner.
Specifically, there is a Mapper instance but no Reducer, and nothing is being emitted from
the Mapper. There job would be defined as follows...</para>
<programlisting language="java">
Configuration config = HBaseConfiguration.create();
Job job = new Job(config, "ExampleRead");
job.setJarByClass(MyReadJob.class); // class that contains mapper
Scan scan = new Scan();
scan.setCaching(500); // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false); // don't set to true for MR jobs
// set other scan attrs
...
TableMapReduceUtil.initTableMapperJob(
tableName, // input HBase table name
scan, // Scan instance to control CF and attribute selection
MyMapper.class, // mapper
null, // mapper output key
null, // mapper output value
job);
job.setOutputFormatClass(NullOutputFormat.class); // because we aren't emitting anything from mapper
boolean b = job.waitForCompletion(true);
if (!b) {
throw new IOException("error with job!");
}
</programlisting>
<para>...and the mapper instance would extend <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableMapper.html">TableMapper</link>...</para>
<programlisting language="java">
public static class MyMapper extends TableMapper&lt;Text, Text&gt; {
public void map(ImmutableBytesWritable row, Result value, Context context) throws InterruptedException, IOException {
// process data for the row from the Result instance.
}
}
</programlisting>
</section>
<section
xml:id="mapreduce.example.readwrite">
<title>HBase MapReduce Read/Write Example</title>
<para>The following is an example of using HBase both as a source and as a sink with
MapReduce. This example will simply copy data from one table to another.</para>
<programlisting language="java">
Configuration config = HBaseConfiguration.create();
Job job = new Job(config,"ExampleReadWrite");
job.setJarByClass(MyReadWriteJob.class); // class that contains mapper
Scan scan = new Scan();
scan.setCaching(500); // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false); // don't set to true for MR jobs
// set other scan attrs
TableMapReduceUtil.initTableMapperJob(
sourceTable, // input table
scan, // Scan instance to control CF and attribute selection
MyMapper.class, // mapper class
null, // mapper output key
null, // mapper output value
job);
TableMapReduceUtil.initTableReducerJob(
targetTable, // output table
null, // reducer class
job);
job.setNumReduceTasks(0);
boolean b = job.waitForCompletion(true);
if (!b) {
throw new IOException("error with job!");
}
</programlisting>
<para>An explanation is required of what <classname>TableMapReduceUtil</classname> is doing,
especially with the reducer. <link
xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/mapreduce/TableOutputFormat.html">TableOutputFormat</link>
is being used as the outputFormat class, and several parameters are being set on the
config (e.g., TableOutputFormat.OUTPUT_TABLE), as well as setting the reducer output key
to <classname>ImmutableBytesWritable</classname> and reducer value to
<classname>Writable</classname>. These could be set by the programmer on the job and
conf, but <classname>TableMapReduceUtil</classname> tries to make things easier.</para>
<para>The following is the example mapper, which will create a <classname>Put</classname>
and matching the input <classname>Result</classname> and emit it. Note: this is what the
CopyTable utility does. </para>
<programlisting language="java">
public static class MyMapper extends TableMapper&lt;ImmutableBytesWritable, Put&gt; {
public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException, InterruptedException {
// this example is just copying the data from the source table...
context.write(row, resultToPut(row,value));
}
private static Put resultToPut(ImmutableBytesWritable key, Result result) throws IOException {
Put put = new Put(key.get());
for (KeyValue kv : result.raw()) {
put.add(kv);
}
return put;
}
}
</programlisting>
<para>There isn't actually a reducer step, so <classname>TableOutputFormat</classname> takes
care of sending the <classname>Put</classname> to the target table. </para>
<para>This is just an example, developers could choose not to use
<classname>TableOutputFormat</classname> and connect to the target table themselves.
</para>
</section>
<section
xml:id="mapreduce.example.readwrite.multi">
<title>HBase MapReduce Read/Write Example With Multi-Table Output</title>
<para>TODO: example for <classname>MultiTableOutputFormat</classname>. </para>
</section>
<section
xml:id="mapreduce.example.summary">
<title>HBase MapReduce Summary to HBase Example</title>
<para>The following example uses HBase as a MapReduce source and sink with a summarization
step. This example will count the number of distinct instances of a value in a table and
write those summarized counts in another table.
<programlisting language="java">
Configuration config = HBaseConfiguration.create();
Job job = new Job(config,"ExampleSummary");
job.setJarByClass(MySummaryJob.class); // class that contains mapper and reducer
Scan scan = new Scan();
scan.setCaching(500); // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false); // don't set to true for MR jobs
// set other scan attrs
TableMapReduceUtil.initTableMapperJob(
sourceTable, // input table
scan, // Scan instance to control CF and attribute selection
MyMapper.class, // mapper class
Text.class, // mapper output key
IntWritable.class, // mapper output value
job);
TableMapReduceUtil.initTableReducerJob(
targetTable, // output table
MyTableReducer.class, // reducer class
job);
job.setNumReduceTasks(1); // at least one, adjust as required
boolean b = job.waitForCompletion(true);
if (!b) {
throw new IOException("error with job!");
}
</programlisting>
In this example mapper a column with a String-value is chosen as the value to summarize
upon. This value is used as the key to emit from the mapper, and an
<classname>IntWritable</classname> represents an instance counter.
<programlisting language="java">
public static class MyMapper extends TableMapper&lt;Text, IntWritable&gt; {
public static final byte[] CF = "cf".getBytes();
public static final byte[] ATTR1 = "attr1".getBytes();
private final IntWritable ONE = new IntWritable(1);
private Text text = new Text();
public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException, InterruptedException {
String val = new String(value.getValue(CF, ATTR1));
text.set(val); // we can only emit Writables...
context.write(text, ONE);
}
}
</programlisting>
In the reducer, the "ones" are counted (just like any other MR example that does this),
and then emits a <classname>Put</classname>.
<programlisting language="java">
public static class MyTableReducer extends TableReducer&lt;Text, IntWritable, ImmutableBytesWritable&gt; {
public static final byte[] CF = "cf".getBytes();
public static final byte[] COUNT = "count".getBytes();
public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException {
int i = 0;
for (IntWritable val : values) {
i += val.get();
}
Put put = new Put(Bytes.toBytes(key.toString()));
put.add(CF, COUNT, Bytes.toBytes(i));
context.write(null, put);
}
}
</programlisting>
</para>
</section>
<section
xml:id="mapreduce.example.summary.file">
<title>HBase MapReduce Summary to File Example</title>
<para>This very similar to the summary example above, with exception that this is using
HBase as a MapReduce source but HDFS as the sink. The differences are in the job setup and
in the reducer. The mapper remains the same. </para>
<programlisting language="java">
Configuration config = HBaseConfiguration.create();
Job job = new Job(config,"ExampleSummaryToFile");
job.setJarByClass(MySummaryFileJob.class); // class that contains mapper and reducer
Scan scan = new Scan();
scan.setCaching(500); // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false); // don't set to true for MR jobs
// set other scan attrs
TableMapReduceUtil.initTableMapperJob(
sourceTable, // input table
scan, // Scan instance to control CF and attribute selection
MyMapper.class, // mapper class
Text.class, // mapper output key
IntWritable.class, // mapper output value
job);
job.setReducerClass(MyReducer.class); // reducer class
job.setNumReduceTasks(1); // at least one, adjust as required
FileOutputFormat.setOutputPath(job, new Path("/tmp/mr/mySummaryFile")); // adjust directories as required
boolean b = job.waitForCompletion(true);
if (!b) {
throw new IOException("error with job!");
}
</programlisting>
<para>As stated above, the previous Mapper can run unchanged with this example. As for the
Reducer, it is a "generic" Reducer instead of extending TableMapper and emitting
Puts.</para>
<programlisting language="java">
public static class MyReducer extends Reducer&lt;Text, IntWritable, Text, IntWritable&gt; {
public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException {
int i = 0;
for (IntWritable val : values) {
i += val.get();
}
context.write(key, new IntWritable(i));
}
}
</programlisting>
</section>
<section
xml:id="mapreduce.example.summary.noreducer">
<title>HBase MapReduce Summary to HBase Without Reducer</title>
<para>It is also possible to perform summaries without a reducer - if you use HBase as the
reducer. </para>
<para>An HBase target table would need to exist for the job summary. The Table method
<code>incrementColumnValue</code> would be used to atomically increment values. From a
performance perspective, it might make sense to keep a Map of values with their values to
be incremeneted for each map-task, and make one update per key at during the <code>
cleanup</code> method of the mapper. However, your milage may vary depending on the
number of rows to be processed and unique keys. </para>
<para>In the end, the summary results are in HBase. </para>
</section>
<section
xml:id="mapreduce.example.summary.rdbms">
<title>HBase MapReduce Summary to RDBMS</title>
<para>Sometimes it is more appropriate to generate summaries to an RDBMS. For these cases,
it is possible to generate summaries directly to an RDBMS via a custom reducer. The
<code>setup</code> method can connect to an RDBMS (the connection information can be
passed via custom parameters in the context) and the cleanup method can close the
connection. </para>
<para>It is critical to understand that number of reducers for the job affects the
summarization implementation, and you'll have to design this into your reducer.
Specifically, whether it is designed to run as a singleton (one reducer) or multiple
reducers. Neither is right or wrong, it depends on your use-case. Recognize that the more
reducers that are assigned to the job, the more simultaneous connections to the RDBMS will
be created - this will scale, but only to a point. </para>
<programlisting language="java">
public static class MyRdbmsReducer extends Reducer&lt;Text, IntWritable, Text, IntWritable&gt; {
private Connection c = null;
public void setup(Context context) {
// create DB connection...
}
public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException {
// do summarization
// in this example the keys are Text, but this is just an example
}
public void cleanup(Context context) {
// close db connection
}
}
</programlisting>
<para>In the end, the summary results are written to your RDBMS table/s. </para>
</section>
</section>
<!-- mr examples -->
<section
xml:id="mapreduce.htable.access">
<title>Accessing Other HBase Tables in a MapReduce Job</title>
<para>Although the framework currently allows one HBase table as input to a MapReduce job,
other HBase tables can be accessed as lookup tables, etc., in a MapReduce job via creating
an Table instance in the setup method of the Mapper.
<programlisting language="java">public class MyMapper extends TableMapper&lt;Text, LongWritable&gt; {
private Table myOtherTable;
public void setup(Context context) {
// In here create a Connection to the cluster and save it or use the Connection
// from the existing table
myOtherTable = connection.getTable("myOtherTable");
}
public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException, InterruptedException {
// process Result...
// use 'myOtherTable' for lookups
}
</programlisting>
</para>
</section>
<section
xml:id="mapreduce.specex">
<title>Speculative Execution</title>
<para>It is generally advisable to turn off speculative execution for MapReduce jobs that use
HBase as a source. This can either be done on a per-Job basis through properties, on on the
entire cluster. Especially for longer running jobs, speculative execution will create
duplicate map-tasks which will double-write your data to HBase; this is probably not what
you want. </para>
<para>See <xref
linkend="spec.ex" /> for more information. </para>
</section>
</chapter>

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="orca"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Apache HBase Orca</title>
<figure>
<title>Apache HBase Orca</title>
<mediaobject>
<imageobject>
<imagedata align="center" valign="right"
fileref="jumping-orca_rotated_25percent.png"/>
</imageobject>
</mediaobject>
</figure>
<para><link xlink:href="https://issues.apache.org/jira/browse/HBASE-4920">An Orca is the Apache
HBase mascot.</link>
See NOTICES.txt. Our Orca logo we got here: http://www.vectorfree.com/jumping-orca
It is licensed Creative Commons Attribution 3.0. See https://creativecommons.org/licenses/by/3.0/us/
We changed the logo by stripping the colored background, inverting
it and then rotating it some.
</para>
</appendix>

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="other.info"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Other Information About HBase</title>
<section xml:id="other.info.videos"><title>HBase Videos</title>
<para>Introduction to HBase
<itemizedlist>
<listitem><para><link xlink:href="http://www.cloudera.com/content/cloudera/en/resources/library/presentation/chicago_data_summit_apache_hbase_an_introduction_todd_lipcon.html">Introduction to HBase</link> by Todd Lipcon (Chicago Data Summit 2011).
</para></listitem>
<listitem><para><link xlink:href="http://www.cloudera.com/videos/intorduction-hbase-todd-lipcon">Introduction to HBase</link> by Todd Lipcon (2010).
</para></listitem>
</itemizedlist>
</para>
<para><link xlink:href="http://www.cloudera.com/videos/hadoop-world-2011-presentation-video-building-realtime-big-data-services-at-facebook-with-hadoop-and-hbase">Building Real Time Services at Facebook with HBase</link> by Jonathan Gray (Hadoop World 2011).
</para>
<para><link xlink:href="http://www.cloudera.com/videos/hw10_video_how_stumbleupon_built_and_advertising_platform_using_hbase_and_hadoop">HBase and Hadoop, Mixing Real-Time and Batch Processing at StumbleUpon</link> by JD Cryans (Hadoop World 2010).
</para>
</section>
<section xml:id="other.info.pres"><title>HBase Presentations (Slides)</title>
<para><link xlink:href="http://www.cloudera.com/content/cloudera/en/resources/library/hadoopworld/hadoop-world-2011-presentation-video-advanced-hbase-schema-design.html">Advanced HBase Schema Design</link> by Lars George (Hadoop World 2011).
</para>
<para><link xlink:href="http://www.slideshare.net/cloudera/chicago-data-summit-apache-hbase-an-introduction">Introduction to HBase</link> by Todd Lipcon (Chicago Data Summit 2011).
</para>
<para><link xlink:href="http://www.slideshare.net/cloudera/hw09-practical-h-base-getting-the-most-from-your-h-base-install">Getting The Most From Your HBase Install</link> by Ryan Rawson, Jonathan Gray (Hadoop World 2009).
</para>
</section>
<section xml:id="other.info.papers"><title>HBase Papers</title>
<para><link xlink:href="http://research.google.com/archive/bigtable.html">BigTable</link> by Google (2006).
</para>
<para><link xlink:href="http://www.larsgeorge.com/2010/05/hbase-file-locality-in-hdfs.html">HBase and HDFS Locality</link> by Lars George (2010).
</para>
<para><link xlink:href="http://ianvarley.com/UT/MR/Varley_MastersReport_Full_2009-08-07.pdf">No Relation: The Mixed Blessings of Non-Relational Databases</link> by Ian Varley (2009).
</para>
</section>
<section xml:id="other.info.sites"><title>HBase Sites</title>
<para><link xlink:href="http://www.cloudera.com/blog/category/hbase/">Cloudera's HBase Blog</link> has a lot of links to useful HBase information.
<itemizedlist>
<listitem><para><link xlink:href="http://www.cloudera.com/blog/2010/04/cap-confusion-problems-with-partition-tolerance/">CAP Confusion</link> is a relevant entry for background information on
distributed storage systems.</para>
</listitem>
</itemizedlist>
</para>
<para><link xlink:href="http://wiki.apache.org/hadoop/HBase/HBasePresentations">HBase Wiki</link> has a page with a number of presentations.
</para>
<para><link xlink:href="http://refcardz.dzone.com/refcardz/hbase">HBase RefCard</link> from DZone.
</para>
</section>
<section xml:id="other.info.books"><title>HBase Books</title>
<para><link xlink:href="http://shop.oreilly.com/product/0636920014348.do">HBase: The Definitive Guide</link> by Lars George.
</para>
</section>
<section xml:id="other.info.books.hadoop"><title>Hadoop Books</title>
<para><link xlink:href="http://shop.oreilly.com/product/9780596521981.do">Hadoop: The Definitive Guide</link> by Tom White.
</para>
</section>
</appendix>

File diff suppressed because it is too large Load Diff

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<preface
version="5.0"
xml:id="preface"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Preface</title>
<para>This is the official reference guide for the <link
xlink:href="http://hbase.apache.org/">HBase</link> version it ships with. Herein you
will find either the definitive documentation on an HBase topic as of its standing when the
referenced HBase version shipped, or it will point to the location in <link
xlink:href="http://hbase.apache.org/apidocs/index.html">javadoc</link>, <link
xlink:href="https://issues.apache.org/jira/browse/HBASE">JIRA</link> or <link
xlink:href="http://wiki.apache.org/hadoop/Hbase">wiki</link> where the pertinent
information can be found.</para>
<formalpara>
<title>About This Guide</title>
<para>This reference guide is a work in progress. The source for this guide can be found in
the <filename>src/main/docbkx</filename> directory of the HBase source. This reference
guide is marked up using <link xlink:href="http://www.docbook.org/">DocBook</link> from
which the the finished guide is generated as part of the 'site' build target. Run
<programlisting language="bourne">mvn site</programlisting> to generate this documentation. Amendments and
improvements to the documentation are welcomed. Click <link
xlink:href="https://issues.apache.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310753&amp;issuetype=1&amp;components=12312132&amp;summary=SHORT+DESCRIPTION"
>this link</link> to file a new documentation bug against Apache HBase with some
values pre-selected.</para>
</formalpara>
<formalpara>
<title>Contributing to the Documentation</title>
<para>For an overview of Docbook and suggestions to get started contributing to the documentation, see <xref linkend="appendix_contributing_to_documentation" />.</para>
</formalpara>
<formalpara>
<title>Providing Feedback</title>
<para>This guide allows you to leave comments or questions on any page, using Disqus. Look
for the Comments area at the bottom of the page. Answering these questions is a
volunteer effort, and may be delayed.</para>
</formalpara>
<note
xml:id="headsup">
<title>Heads-up if this is your first foray into the world of distributed
computing...</title>
<para> If this is your first foray into the wonderful world of Distributed Computing, then
you are in for some interesting times. First off, distributed systems are hard; making a
distributed system hum requires a disparate skillset that spans systems (hardware and
software) and networking. Your cluster' operation can hiccup because of any of a myriad
set of reasons from bugs in HBase itself through misconfigurations -- misconfiguration
of HBase but also operating system misconfigurations -- through to hardware problems
whether it be a bug in your network card drivers or an underprovisioned RAM bus (to
mention two recent examples of hardware issues that manifested as "HBase is slow"). You
will also need to do a recalibration if up to this your computing has been bound to a
single box. Here is one good starting point: <link
xlink:href="http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing">Fallacies
of Distributed Computing</link>. That said, you are welcome. Its a fun place to be.
Yours, the HBase Community. </para>
</note>
</preface>

View File

@ -1,301 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="hbase.rpc"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>0.95 RPC Specification</title>
<para>In 0.95, all client/server communication is done with <link
xlink:href="https://code.google.com/p/protobuf/">protobufed</link> Messages rather than
with <link
xlink:href="http://hadoop.apache.org/docs/current/api/org/apache/hadoop/io/Writable.html">Hadoop
Writables</link>. Our RPC wire format therefore changes. This document describes the
client/server request/response protocol and our new RPC wire-format.</para>
<para />
<para>For what RPC is like in 0.94 and previous, see Benoît/Tsunas <link
xlink:href="https://github.com/OpenTSDB/asynchbase/blob/master/src/HBaseRpc.java#L164">Unofficial
Hadoop / HBase RPC protocol documentation</link>. For more background on how we arrived
at this spec., see <link
xlink:href="https://docs.google.com/document/d/1WCKwgaLDqBw2vpux0jPsAu2WPTRISob7HGCO8YhfDTA/edit#">HBase
RPC: WIP</link></para>
<para />
<section>
<title>Goals</title>
<para>
<orderedlist>
<listitem>
<para>A wire-format we can evolve</para>
</listitem>
<listitem>
<para>A format that does not require our rewriting server core or radically
changing its current architecture (for later).</para>
</listitem>
</orderedlist>
</para>
</section>
<section>
<title>TODO</title>
<para>
<orderedlist>
<listitem>
<para>List of problems with currently specified format and where we would like
to go in a version2, etc. For example, what would we have to change if
anything to move server async or to support streaming/chunking?</para>
</listitem>
<listitem>
<para>Diagram on how it works</para>
</listitem>
<listitem>
<para>A grammar that succinctly describes the wire-format. Currently we have
these words and the content of the rpc protobuf idl but a grammar for the
back and forth would help with groking rpc. Also, a little state machine on
client/server interactions would help with understanding (and ensuring
correct implementation).</para>
</listitem>
</orderedlist>
</para>
</section>
<section>
<title>RPC</title>
<para>The client will send setup information on connection establish. Thereafter, the client
invokes methods against the remote server sending a protobuf Message and receiving a
protobuf Message in response. Communication is synchronous. All back and forth is
preceded by an int that has the total length of the request/response. Optionally,
Cells(KeyValues) can be passed outside of protobufs in follow-behind Cell blocks
(because <link
xlink:href="https://docs.google.com/document/d/1WEtrq-JTIUhlnlnvA0oYRLp0F8MKpEBeBSCFcQiacdw/edit#">we
cant protobuf megabytes of KeyValues</link> or Cells). These CellBlocks are encoded
and optionally compressed.</para>
<para />
<para>For more detail on the protobufs involved, see the <link
xlink:href="http://svn.apache.org/viewvc/hbase/trunk/hbase-protocol/src/main/protobuf/RPC.proto?view=markup">RPC.proto</link>
file in trunk.</para>
<section>
<title>Connection Setup</title>
<para>Client initiates connection.</para>
<section>
<title>Client</title>
<para>On connection setup, client sends a preamble followed by a connection header. </para>
<section>
<title>&lt;preamble&gt;</title>
<programlisting>&lt;MAGIC 4 byte integer&gt; &lt;1 byte RPC Format Version&gt; &lt;1 byte auth type&gt;</programlisting>
<para> We need the auth method spec. here so the connection header is encoded if auth enabled.</para>
<para>E.g.: HBas0x000x50 -- 4 bytes of MAGIC -- HBas -- plus one-byte of
version, 0 in this case, and one byte, 0x50 (SIMPLE). of an auth
type.</para>
</section>
<section>
<title>&lt;Protobuf ConnectionHeader Message&gt;</title>
<para>Has user info, and “protocol”, as well as the encoders and compression the
client will use sending CellBlocks. CellBlock encoders and compressors are
for the life of the connection. CellBlock encoders implement
org.apache.hadoop.hbase.codec.Codec. CellBlocks may then also be compressed.
Compressors implement org.apache.hadoop.io.compress.CompressionCodec. This
protobuf is written using writeDelimited so is prefaced by a pb varint with
its serialized length</para>
</section>
</section>
<!--Client-->
<section>
<title>Server</title>
<para>After client sends preamble and connection header, server does NOT respond if
successful connection setup. No response means server is READY to accept
requests and to give out response. If the version or authentication in the
preamble is not agreeable or the server has trouble parsing the preamble, it
will throw a org.apache.hadoop.hbase.ipc.FatalConnectionException explaining the
error and will then disconnect. If the client in the connection header -- i.e.
the protobufd Message that comes after the connection preamble -- asks for for
a Service the server does not support or a codec the server does not have, again
we throw a FatalConnectionException with explanation.</para>
</section>
</section>
<section>
<title>Request</title>
<para>After a Connection has been set up, client makes requests. Server responds.</para>
<para>A request is made up of a protobuf RequestHeader followed by a protobuf Message
parameter. The header includes the method name and optionally, metadata on the
optional CellBlock that may be following. The parameter type suits the method being
invoked: i.e. if we are doing a getRegionInfo request, the protobuf Message param
will be an instance of GetRegionInfoRequest. The response will be a
GetRegionInfoResponse. The CellBlock is optionally used ferrying the bulk of the RPC
data: i.e Cells/KeyValues.</para>
<section>
<title>Request Parts</title>
<section>
<title>&lt;Total Length&gt;</title>
<para>The request is prefaced by an int that holds the total length of what
follows.</para>
</section>
<section>
<title>&lt;Protobuf RequestHeader Message&gt;</title>
<para>Will have call.id, trace.id, and method name, etc. including optional
Metadata on the Cell block IFF one is following. Data is protobufd inline
in this pb Message or optionally comes in the following CellBlock</para>
</section>
<section>
<title>&lt;Protobuf Param Message&gt;</title>
<para>If the method being invoked is getRegionInfo, if you study the Service
descriptor for the client to regionserver protocol, you will find that the
request sends a GetRegionInfoRequest protobuf Message param in this
position.</para>
</section>
<section>
<title>&lt;CellBlock&gt;</title>
<para>An encoded and optionally compressed Cell block.</para>
</section>
</section>
<!--Request parts-->
</section>
<!--Request-->
<section>
<title>Response</title>
<para>Same as Request, it is a protobuf ResponseHeader followed by a protobuf Message
response where the Message response type suits the method invoked. Bulk of the data
may come in a following CellBlock.</para>
<section>
<title>Response Parts</title>
<section>
<title>&lt;Total Length&gt;</title>
<para>The response is prefaced by an int that holds the total length of what
follows.</para>
</section>
<section>
<title>&lt;Protobuf ResponseHeader Message&gt;</title>
<para>Will have call.id, etc. Will include exception if failed processing.
 Optionally includes metadata on optional, IFF there is a CellBlock
following.</para>
</section>
<section>
<title>&lt;Protobuf Response Message&gt;</title>
<para>Return or may be nothing if exception. If the method being invoked is
getRegionInfo, if you study the Service descriptor for the client to
regionserver protocol, you will find that the response sends a
GetRegionInfoResponse protobuf Message param in this position.</para>
</section>
<section>
<title>&lt;CellBlock&gt;</title>
<para>An encoded and optionally compressed Cell block.</para>
</section>
</section>
<!--Parts-->
</section>
<!--Response-->
<section>
<title>Exceptions</title>
<para>There are two distinct types. There is the request failed which is encapsulated
inside the response header for the response. The connection stays open to receive
new requests. The second type, the FatalConnectionException, kills the
connection.</para>
<para>Exceptions can carry extra information. See the ExceptionResponse protobuf type.
It has a flag to indicate do-no-retry as well as other miscellaneous payload to help
improve client responsiveness.</para>
</section>
<section>
<title>CellBlocks</title>
<para>These are not versioned. Server can do the codec or it cannot. If new version of a
codec with say, tighter encoding, then give it a new class name. Codecs will live on
the server for all time so old clients can connect.</para>
</section>
</section>
<section>
<title>Notes</title>
<section>
<title>Constraints</title>
<para>In some part, current wire-format -- i.e. all requests and responses preceeded by
a length -- has been dictated by current server non-async architecture.</para>
</section>
<section>
<title>One fat pb request or header+param</title>
<para>We went with pb header followed by pb param making a request and a pb header
followed by pb response for now. Doing header+param rather than a single protobuf
Message with both header and param content:</para>
<para>
<orderedlist>
<listitem>
<para>Is closer to what we currently have</para>
</listitem>
<listitem>
<para>Having a single fat pb requires extra copying putting the already pbd
param into the body of the fat request pb (and same making
result)</para>
</listitem>
<listitem>
<para>We can decide whether to accept the request or not before we read the
param; for example, the request might be low priority.  As is, we read
header+param in one go as server is currently implemented so this is a
TODO.</para>
</listitem>
</orderedlist>
</para>
<para>The advantages are minor.  If later, fat request has clear advantage, can roll out
a v2 later.</para>
</section>
<section
xml:id="rpc.configs">
<title>RPC Configurations</title>
<section>
<title>CellBlock Codecs</title>
<para>To enable a codec other than the default <classname>KeyValueCodec</classname>,
set <varname>hbase.client.rpc.codec</varname> to the name of the Codec class to
use. Codec must implement hbase's <classname>Codec</classname> Interface. After
connection setup, all passed cellblocks will be sent with this codec. The server
will return cellblocks using this same codec as long as the codec is on the
servers' CLASSPATH (else you will get
<classname>UnsupportedCellCodecException</classname>).</para>
<para>To change the default codec, set
<varname>hbase.client.default.rpc.codec</varname>. </para>
<para>To disable cellblocks completely and to go pure protobuf, set the default to
the empty String and do not specify a codec in your Configuration. So, set
<varname>hbase.client.default.rpc.codec</varname> to the empty string and do
not set <varname>hbase.client.rpc.codec</varname>. This will cause the client to
connect to the server with no codec specified. If a server sees no codec, it
will return all responses in pure protobuf. Running pure protobuf all the time
will be slower than running with cellblocks. </para>
</section>
<section>
<title>Compression</title>
<para>Uses hadoops compression codecs. To enable compressing of passed CellBlocks,
set <varname>hbase.client.rpc.compressor</varname> to the name of the Compressor
to use. Compressor must implement Hadoops' CompressionCodec Interface. After
connection setup, all passed cellblocks will be sent compressed. The server will
return cellblocks compressed using this same compressor as long as the
compressor is on its CLASSPATH (else you will get
<classname>UnsupportedCompressionCodecException</classname>).</para>
</section>
</section>
</section>
</appendix>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,386 +0,0 @@
<?xml version="1.0"?>
<chapter
xml:id="shell"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>The Apache HBase Shell</title>
<para> The Apache HBase Shell is <link
xlink:href="http://jruby.org">(J)Ruby</link>'s IRB with some HBase particular commands
added. Anything you can do in IRB, you should be able to do in the HBase Shell.</para>
<para>To run the HBase shell, do as follows:</para>
<programlisting>$ ./bin/hbase shell</programlisting>
<para>Type <command>help</command> and then <command>&lt;RETURN&gt;</command> to see a listing
of shell commands and options. Browse at least the paragraphs at the end of the help
emission for the gist of how variables and command arguments are entered into the HBase
shell; in particular note how table names, rows, and columns, etc., must be quoted.</para>
<para>See <xref
linkend="shell_exercises" /> for example basic shell operation. </para>
<para>Here is a nicely formatted listing of <link
xlink:href="http://learnhbase.wordpress.com/2013/03/02/hbase-shell-commands/">all shell
commands</link> by Rajeshbabu Chintaguntla. </para>
<section
xml:id="scripting">
<title>Scripting with Ruby</title>
<para>For examples scripting Apache HBase, look in the HBase <filename>bin</filename>
directory. Look at the files that end in <filename>*.rb</filename>. To run one of these
files, do as follows:</para>
<programlisting>$ ./bin/hbase org.jruby.Main PATH_TO_SCRIPT</programlisting>
</section>
<section>
<title>Running the Shell in Non-Interactive Mode</title>
<para>A new non-interactive mode has been added to the HBase Shell (<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-11658">HBASE-11658)</link>.
Non-interactive mode captures the exit status (success or failure) of HBase Shell
commands and passes that status back to the command interpreter. If you use the normal
interactive mode, the HBase Shell will only ever return its own exit status, which will
nearly always be <literal>0</literal> for success.</para>
<para>To invoke non-interactive mode, pass the <option>-n</option> or
<option>--non-interactive</option> option to HBase Shell.</para>
</section>
<section xml:id="hbase.shell.noninteractive">
<title>HBase Shell in OS Scripts</title>
<para>You can use the HBase shell from within operating system script interpreters like the
Bash shell which is the default command interpreter for most Linux and UNIX
distributions. The following guidelines use Bash syntax, but could be adjusted to work
with C-style shells such as csh or tcsh, and could probably be modified to work with the
Microsoft Windows script interpreter as well. Submissions are welcome.</para>
<note>
<para>Spawning HBase Shell commands in this way is slow, so keep that in mind when you
are deciding when combining HBase operations with the operating system command line
is appropriate.</para>
</note>
<example>
<title>Passing Commands to the HBase Shell</title>
<para>You can pass commands to the HBase Shell in non-interactive mode (see <xref
linkend="hbasee.shell.noninteractive"/>) using the <command>echo</command>
command and the <literal>|</literal> (pipe) operator. Be sure to escape characters
in the HBase commands which would otherwise be interpreted by the shell. Some
debug-level output has been truncated from the example below.</para>
<screen>$ <userinput>echo "describe 'test1'" | ./hbase shell -n</userinput>
<computeroutput>
Version 0.98.3-hadoop2, rd5e65a9144e315bb0a964e7730871af32f5018d5, Sat May 31 19:56:09 PDT 2014
describe 'test1'
DESCRIPTION ENABLED
'test1', {NAME => 'cf', DATA_BLOCK_ENCODING => 'NON true
E', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0',
VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIO
NS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS =>
'false', BLOCKSIZE => '65536', IN_MEMORY => 'false'
, BLOCKCACHE => 'true'}
1 row(s) in 3.2410 seconds
</computeroutput>
</screen>
<para>To suppress all output, echo it to <filename>/dev/null:</filename></para>
<screen>$ <userinput>echo "describe 'test'" | ./hbase shell -n > /dev/null 2>&amp;1</userinput></screen>
</example>
<example>
<title>Checking the Result of a Scripted Command</title>
<para>Since scripts are not designed to be run interactively, you need a way to check
whether your command failed or succeeded. The HBase shell uses the standard
convention of returning a value of <literal>0</literal> for successful commands, and
some non-zero value for failed commands. Bash stores a command's return value in a
special environment variable called <varname>$?</varname>. Because that variable is
overwritten each time the shell runs any command, you should store the result in a
different, script-defined variable.</para>
<para>This is a naive script that shows one way to store the return value and make a
decision based upon it.</para>
<programlisting language="bourne">
#!/bin/bash
echo "describe 'test'" | ./hbase shell -n > /dev/null 2>&amp;1
status=$?
echo "The status was " $status
if ($status == 0); then
echo "The command succeeded"
else
echo "The command may have failed."
fi
return $status
</programlisting>
</example>
<section>
<title>Checking for Success or Failure In Scripts</title>
<para>Getting an exit code of 0 means that the command you scripted definitely
succeeded. However, getting a non-zero exit code does not necessarily mean the
command failed. The command could have succeeded, but the client lost connectivity,
or some other event obscured its success. This is because RPC commands are
stateless. The only way to be sure of the status of an operation is to check. For
instance, if your script creates a table, but returns a non-zero exit value, you
should check whether the table was actually created before trying again to create
it.</para>
</section>
</section>
<section>
<title>Read HBase Shell Commands from a Command File</title>
<para>You can enter HBase Shell commands into a text file, one command per line, and pass
that file to the HBase Shell.</para>
<example>
<title>Example Command File</title>
<screen>
create 'test', 'cf'
list 'test'
put 'test', 'row1', 'cf:a', 'value1'
put 'test', 'row2', 'cf:b', 'value2'
put 'test', 'row3', 'cf:c', 'value3'
put 'test', 'row4', 'cf:d', 'value4'
scan 'test'
get 'test', 'row1'
disable 'test'
enable 'test'
</screen>
</example>
<example>
<title>Directing HBase Shell to Execute the Commands</title>
<para>Pass the path to the command file as the only argument to the <command>hbase
shell</command> command. Each command is executed and its output is shown. If
you do not include the <command>exit</command> command in your script, you are
returned to the HBase shell prompt. There is no way to programmatically check each
individual command for success or failure. Also, though you see the output for each
command, the commands themselves are not echoed to the screen so it can be difficult
to line up the command with its output.</para>
<screen>
$ <userinput>./hbase shell ./sample_commands.txt</userinput>
<computeroutput>0 row(s) in 3.4170 seconds
TABLE
test
1 row(s) in 0.0590 seconds
0 row(s) in 0.1540 seconds
0 row(s) in 0.0080 seconds
0 row(s) in 0.0060 seconds
0 row(s) in 0.0060 seconds
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1407130286968, value=value1
row2 column=cf:b, timestamp=1407130286997, value=value2
row3 column=cf:c, timestamp=1407130287007, value=value3
row4 column=cf:d, timestamp=1407130287015, value=value4
4 row(s) in 0.0420 seconds
COLUMN CELL
cf:a timestamp=1407130286968, value=value1
1 row(s) in 0.0110 seconds
0 row(s) in 1.5630 seconds
0 row(s) in 0.4360 seconds</computeroutput>
</screen>
</example>
</section>
<section>
<title>Passing VM Options to the Shell</title>
<para>You can pass VM options to the HBase Shell using the <code>HBASE_SHELL_OPTS</code>
environment variable. You can set this in your environment, for instance by editing
<filename>~/.bashrc</filename>, or set it as part of the command to launch HBase
Shell. The following example sets several garbage-collection-related variables, just for
the lifetime of the VM running the HBase Shell. The command should be run all on a
single line, but is broken by the <literal>\</literal> character, for
readability.</para>
<screen language="bourne">
$ <userinput>HBASE_SHELL_OPTS="-verbose:gc -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps \
-XX:+PrintGCDetails -Xloggc:$HBASE_HOME/logs/gc-hbase.log" ./bin/hbase shell</userinput>
</screen>
</section>
<section
xml:id="shell_tricks">
<title>Shell Tricks</title>
<section
xml:id="table_variables">
<title>Table variables</title>
<para> HBase 0.95 adds shell commands that provide a jruby-style object-oriented
references for tables. Previously all of the shell commands that act upon a table
have a procedural style that always took the name of the table as an argument. HBase
0.95 introduces the ability to assign a table to a jruby variable. The table
reference can be used to perform data read write operations such as puts, scans, and
gets well as admin functionality such as disabling, dropping, describing tables. </para>
<para> For example, previously you would always specify a table name:</para>
<screen>
hbase(main):000:0> create t, f
0 row(s) in 1.0970 seconds
hbase(main):001:0> put 't', 'rold', 'f', 'v'
0 row(s) in 0.0080 seconds
hbase(main):002:0> scan 't'
ROW COLUMN+CELL
rold column=f:, timestamp=1378473207660, value=v
1 row(s) in 0.0130 seconds
hbase(main):003:0> describe 't'
DESCRIPTION ENABLED
't', {NAME => 'f', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_ true
SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2
147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false
', BLOCKCACHE => 'true'}
1 row(s) in 1.4430 seconds
hbase(main):004:0> disable 't'
0 row(s) in 14.8700 seconds
hbase(main):005:0> drop 't'
0 row(s) in 23.1670 seconds
hbase(main):006:0>
</screen>
<para> Now you can assign the table to a variable and use the results in jruby shell
code.</para>
<screen>
hbase(main):007 > t = create 't', 'f'
0 row(s) in 1.0970 seconds
=> Hbase::Table - t
hbase(main):008 > t.put 'r', 'f', 'v'
0 row(s) in 0.0640 seconds
hbase(main):009 > t.scan
ROW COLUMN+CELL
r column=f:, timestamp=1331865816290, value=v
1 row(s) in 0.0110 seconds
hbase(main):010:0> t.describe
DESCRIPTION ENABLED
't', {NAME => 'f', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_ true
SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2
147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false
', BLOCKCACHE => 'true'}
1 row(s) in 0.0210 seconds
hbase(main):038:0> t.disable
0 row(s) in 6.2350 seconds
hbase(main):039:0> t.drop
0 row(s) in 0.2340 seconds
</screen>
<para> If the table has already been created, you can assign a Table to a variable by
using the get_table method:</para>
<screen>
hbase(main):011 > create 't','f'
0 row(s) in 1.2500 seconds
=> Hbase::Table - t
hbase(main):012:0> tab = get_table 't'
0 row(s) in 0.0010 seconds
=> Hbase::Table - t
hbase(main):013:0> tab.put r1 ,f, v
0 row(s) in 0.0100 seconds
hbase(main):014:0> tab.scan
ROW COLUMN+CELL
r1 column=f:, timestamp=1378473876949, value=v
1 row(s) in 0.0240 seconds
hbase(main):015:0>
</screen>
<para> The list functionality has also been extended so that it returns a list of table
names as strings. You can then use jruby to script table operations based on these
names. The list_snapshots command also acts similarly.</para>
<screen>
hbase(main):016 > tables = list(t.*)
TABLE
t
1 row(s) in 0.1040 seconds
=> #&lt;#&lt;Class:0x7677ce29>:0x21d377a4>
hbase(main):017:0> tables.map { |t| disable t ; drop t}
0 row(s) in 2.2510 seconds
=> [nil]
hbase(main):018:0>
</screen>
</section>
<section>
<title><filename>irbrc</filename></title>
<para>Create an <filename>.irbrc</filename> file for yourself in your home directory.
Add customizations. A useful one is command history so commands are save across
Shell invocations:</para>
<screen>
$ more .irbrc
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"</screen>
<para>See the <application>ruby</application> documentation of
<filename>.irbrc</filename> to learn about other possible configurations.
</para>
</section>
<section>
<title>LOG data to timestamp</title>
<para> To convert the date '08/08/16 20:56:29' from an hbase log into a timestamp,
do:</para>
<screen>
hbase(main):021:0> import java.text.SimpleDateFormat
hbase(main):022:0> import java.text.ParsePosition
hbase(main):023:0> SimpleDateFormat.new("yy/MM/dd HH:mm:ss").parse("08/08/16 20:56:29", ParsePosition.new(0)).getTime() => 1218920189000</screen>
<para> To go the other direction:</para>
<screen>
hbase(main):021:0> import java.util.Date
hbase(main):022:0> Date.new(1218920189000).toString() => "Sat Aug 16 20:56:29 UTC 2008"</screen>
<para> To output in a format that is exactly like that of the HBase log format will take
a little messing with <link
xlink:href="http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</link>.
</para>
</section>
<section>
<title>Debug</title>
<section>
<title>Shell debug switch</title>
<para>You can set a debug switch in the shell to see more output -- e.g. more of the
stack trace on exception -- when you run a command:</para>
<programlisting>hbase> debug &lt;RETURN&gt;</programlisting>
</section>
<section>
<title>DEBUG log level</title>
<para>To enable DEBUG level logging in the shell, launch it with the
<command>-d</command> option.</para>
<programlisting>$ ./bin/hbase shell -d</programlisting>
</section>
</section>
<section>
<title>Commands</title>
<section>
<title>count</title>
<para>Count command returns the number of rows in a table. It's quite fast when
configured with the right CACHE
<programlisting>hbase> count '&lt;tablename&gt;', CACHE => 1000</programlisting>
The above count fetches 1000 rows at a time. Set CACHE lower if your rows are
big. Default is to fetch one row at a time. </para>
</section>
</section>
</section>
</chapter>

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="sql"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>SQL over HBase</title>
<section xml:id="phoenix">
<title>Apache Phoenix</title>
<para><link xlink:href="http://phoenix.apache.org">Apache Phoenix</link></para>
</section>
<section xml:id="trafodion">
<title>Trafodion</title>
<para><link xlink:href="https://wiki.trafodion.org/">Trafodion: Transactional SQL-on-HBase</link></para>
</section>
</appendix>

View File

@ -1,757 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter version="5.0" xml:id="thrift"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Thrift API and Filter Language</title>
<para>Apache <link xlink:href="http://thrift.apache.org/">Thrift</link> is a cross-platform,
cross-language development framework. HBase includes a Thrift API and filter language. The
Thrift API relies on client and server processes. Documentation about the HBase Thrift API
is located at <link xlink:href="http://wiki.apache.org/hadoop/Hbase/ThriftApi"/>. </para>
<para>You can configure Thrift for secure authentication at the server and client side, by
following the procedures in <xref linkend="security.client.thrift"/> and <xref
linkend="security.gateway.thrift"/>. </para>
<para>The rest of this chapter discusses the filter language provided by the Thrift API.</para>
<section
xml:id="thrift.filter-language">
<title>Filter Language</title>
<para
xml:id="use-case">Thrift Filter Language was introduced in APache HBase 0.92. It allows
you to perform server-side filtering when accessing HBase over Thrift or in the HBase
shell. You can find out more about shell integration by using the <code>scan help</code>
command in the shell.</para>
<para>You specify a filter as a string, which is parsed on the server to construct the
filter.</para>
<section
xml:id="general-syntax">
<title>General Filter String Syntax</title>
<para>A simple filter expression is expressed as a string:</para>
<screen>“FilterName (argument, argument,... , argument)”</screen>
<para>Keep the following syntax guidelines in mind.</para>
<itemizedlist>
<listitem>
<para>Specify the name of the filter followed by the comma-separated argument
list in parentheses.</para>
</listitem>
<listitem>
<para>If the argument represents a string, it should be enclosed in single
quotes (<literal>'</literal>).</para>
</listitem>
<listitem>
<para>Arguments which represent a boolean, an integer, or a comparison operator
(such as &lt;, &gt;, or !=), should not be enclosed in quotes</para>
</listitem>
<listitem>
<para>The filter name must be a single word. All ASCII characters are allowed
except for whitespace, single quotes and parentheses.</para>
</listitem>
<listitem>
<para>The filters arguments can contain any ASCII character. If single quotes
are present in the argument, they must be escaped by an additional preceding
single quote.</para>
</listitem>
</itemizedlist>
</section>
<section
xml:id="compound-filters-and-operators">
<title>Compound Filters and Operators</title>
<variablelist>
<title>Binary Operators</title>
<varlistentry>
<term><code>AND</code></term>
<listitem><para>If the <code>AND</code> operator is used, the key-vallue
must satisfy both the filters.</para></listitem>
</varlistentry>
<varlistentry>
<term><code>OR</code></term>
<listitem><para>If the <code>OR</code> operator is used, the key-value
must satisfy at least one of the filters.</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<title>Unary Operators</title>
<varlistentry>
<term><code>SKIP</code></term>
<listitem><para>For a particular row, if any of the key-values fail the
filter condition, the entire row is skipped.</para></listitem>
</varlistentry>
<varlistentry>
<term><code>WHILE</code></term>
<listitem><para>For a particular row, key-values will be emitted until a
key-value is reached t hat fails the filter condition.</para></listitem>
</varlistentry>
</variablelist>
<example>
<title>Compound Operators</title>
<para>You can combine multiple operators to create a hierarchy of filters, such as
the following example:</para>
<programlisting>(Filter1 AND Filter2) OR (Filter3 AND Filter4)</programlisting>
</example>
</section>
<section
xml:id="order-of-evaluation">
<title>Order of Evaluation</title>
<orderedlist>
<listitem><para>Parentheses have the highest precedence.</para></listitem>
<listitem><para>The unary operators <code>SKIP</code> and <code>WHILE</code> are next, and have the same
precedence.</para></listitem>
<listitem><para>The binary operators follow. <code>AND</code> has highest
precedence, followed by <code>OR</code>.</para></listitem>
</orderedlist>
<example>
<title>Precedence Example</title>
<programlisting><userinput>Filter1 AND Filter2 OR Filter</userinput>
is evaluated as
<userinput>(Filter1 AND Filter2) OR Filter3</userinput></programlisting>
<programlisting><userinput>Filter1 AND SKIP Filter2 OR Filter3</userinput>
is evaluated as
<userinput>(Filter1 AND (SKIP Filter2)) OR Filter3</userinput></programlisting>
</example>
<para>You can use parentheses to explicitly control the order of evaluation.</para>
</section>
<section
xml:id="compare-operator">
<title>Compare Operator</title>
<para>The following compare operators are provided:</para>
<orderedlist>
<listitem>
<para>LESS (&lt;)</para>
</listitem>
<listitem>
<para>LESS_OR_EQUAL (&lt;=)</para>
</listitem>
<listitem>
<para>EQUAL (=)</para>
</listitem>
<listitem>
<para>NOT_EQUAL (!=)</para>
</listitem>
<listitem>
<para>GREATER_OR_EQUAL (&gt;=)</para>
</listitem>
<listitem>
<para>GREATER (&gt;)</para>
</listitem>
<listitem>
<para>NO_OP (no operation)</para>
</listitem>
</orderedlist>
<para>The client should use the symbols (&lt;, &lt;=, =, !=, &gt;, &gt;=) to express compare
operators.</para>
</section>
<section
xml:id="comparator">
<title>Comparator</title>
<para>A comparator can be any of the following:</para>
<orderedlist>
<listitem>
<para><emphasis
role="bold">BinaryComparator</emphasis> - This lexicographically
compares against the specified byte array using Bytes.compareTo(byte[],
byte[])</para>
</listitem>
<listitem>
<para><emphasis
role="bold">BinaryPrefixComparator</emphasis> - This lexicographically
compares against a specified byte array. It only compares up to the length
of this byte array.</para>
</listitem>
<listitem>
<para><emphasis
role="bold">RegexStringComparator</emphasis> - This compares against the
specified byte array using the given regular expression. Only EQUAL and
NOT_EQUAL comparisons are valid with this comparator</para>
</listitem>
<listitem>
<para><emphasis
role="bold">SubStringComparator</emphasis> - This tests if the given
substring appears in a specified byte array. The comparison is case
insensitive. Only EQUAL and NOT_EQUAL comparisons are valid with this
comparator</para>
</listitem>
</orderedlist>
<para>The general syntax of a comparator is:<code>
ComparatorType:ComparatorValue</code></para>
<para>The ComparatorType for the various comparators is as follows:</para>
<orderedlist>
<listitem>
<para><emphasis
role="bold">BinaryComparator</emphasis> - binary</para>
</listitem>
<listitem>
<para><emphasis
role="bold">BinaryPrefixComparator</emphasis> - binaryprefix</para>
</listitem>
<listitem>
<para><emphasis
role="bold">RegexStringComparator</emphasis> - regexstring</para>
</listitem>
<listitem>
<para><emphasis
role="bold">SubStringComparator</emphasis> - substring</para>
</listitem>
</orderedlist>
<para>The ComparatorValue can be any value.</para>
<example>
<title>Example 1</title>
<para><code> >, 'binary:abc' </code>will match everything that is
lexicographically greater than "abc" </para>
</example>
<example>
<title>Example 2</title>
<para><code> =, 'binaryprefix:abc' </code>will match everything whose first 3
characters are lexicographically equal to "abc"</para>
</example>
<example>
<title>Example 3</title>
<para><code> !=, 'regexstring:ab*yz' </code>will match everything that doesn't
begin with "ab" and ends with "yz"</para>
</example>
<example>
<title>Example 4</title>
<para><code> =, 'substring:abc123' </code>will match everything that begins
with the substring "abc123"</para>
</example>
</section>
<section
xml:id="examplePHPClientProgram">
<title>Example PHP Client Program that uses the Filter Language</title>
<programlisting language="PHP" role="PHP"><![CDATA[
<? $_SERVER['PHP_ROOT'] = realpath(dirname(__FILE__).'/..');
require_once $_SERVER['PHP_ROOT'].'/flib/__flib.php';
flib_init(FLIB_CONTEXT_SCRIPT);
require_module('storage/hbase');
$hbase = new HBase('<server_name_running_thrift_server>', <port on which thrift server is running>);
$hbase->open();
$client = $hbase->getClient();
$result = $client->scannerOpenWithFilterString('table_name', "(PrefixFilter ('row2') AND (QualifierFilter (>=, 'binary:xyz'))) AND (TimestampsFilter ( 123, 456))");
$to_print = $client->scannerGetList($result,1);
while ($to_print) {
print_r($to_print);
$to_print = $client->scannerGetList($result,1);
}
$client->scannerClose($result);
?>
]]></programlisting>
</section>
<section
xml:id="example-filter-strings">
<title>Example Filter Strings</title>
<para>
<itemizedlist>
<listitem>
<para><code>“PrefixFilter (Row) AND PageFilter (1) AND FirstKeyOnlyFilter
()”</code> will return all key-value pairs that match the following
conditions:</para>
<orderedlist>
<listitem>
<para>The row containing the key-value should have prefix “Row”
</para>
</listitem>
<listitem>
<para>The key-value must be located in the first row of the table
</para>
</listitem>
<listitem>
<para>The key-value pair must be the first key-value in the row
</para>
</listitem>
</orderedlist>
</listitem>
</itemizedlist>
</para>
<orderedlist>
<listitem>
<itemizedlist>
<listitem>
<para><code>“(RowFilter (=, binary:Row 1) AND TimeStampsFilter (74689,
89734)) OR ColumnRangeFilter (abc, true, xyz,
false))”</code> will return all key-value pairs that match both
the following conditions:</para>
<itemizedlist>
<listitem>
<para>The key-value is in a row having row key “Row 1” </para>
</listitem>
<listitem>
<para>The key-value must have a timestamp of either 74689 or
89734.</para>
</listitem>
<listitem>
<para>Or it must match the following condition:</para>
<itemizedlist>
<listitem>
<para>The key-value pair must be in a column that is
lexicographically >= abc and &lt; xyz </para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
<para>
<itemizedlist>
<listitem>
<para><code>“SKIP ValueFilter (0)”</code> will skip the entire row if any of
the values in the row is not 0</para>
</listitem>
</itemizedlist>
</para>
</section>
<section
xml:id="IndividualFilterSyntax">
<title>Individual Filter Syntax</title>
<variablelist>
<varlistentry>
<term>KeyOnlyFilter</term>
<listitem>
<para>This filter doesnt take any arguments. It returns only the key
component of each key-value.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">KeyOnlyFilter ()</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">KeyOnlyFilter ()"</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>FirstKeyOnlyFilter</term>
<listitem>
<para>This filter doesnt take any arguments. It returns only the first
key-value from each row.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">FirstKeyOnlyFilter ()</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">FirstKeyOnlyFilter ()</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>PrefixFilter</term>
<listitem>
<para>This filter takes one argument a prefix of a row key. It returns
only those key-values present in a row that starts with the specified
row prefix</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">PrefixFilter (&lt;row_prefix>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">PrefixFilter (Row)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>ColumnPrefixFilter</term>
<listitem>
<para>This filter takes one argument a column prefix. It returns only
those key-values present in a column that starts with the specified
column prefix. The column prefix must be of the form:
<code>“qualifier”</code>.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">ColumnPrefixFilter(&lt;column_prefix>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">ColumnPrefixFilter(Col)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>MultipleColumnPrefixFilter</term>
<listitem>
<para>This filter takes a list of column prefixes. It returns key-values
that are present in a column that starts with any of the specified
column prefixes. Each of the column prefixes must be of the form:
<code>“qualifier”</code>.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">MultipleColumnPrefixFilter(&lt;column_prefix>, &lt;column_prefix>, …, &lt;column_prefix>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">MultipleColumnPrefixFilter(Col1, Col2)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>ColumnCountGetFilter</term>
<listitem>
<para>This filter takes one argument a limit. It returns the first limit
number of columns in the table.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">ColumnCountGetFilter
(&lt;limit>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">ColumnCountGetFilter (4)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>PageFilter</term>
<listitem>
<para>This filter takes one argument a page size. It returns page size
number of rows from the table.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">PageFilter (&lt;page_size&gt;)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">PageFilter (2)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>ColumnPaginationFilter</term>
<listitem>
<para>This filter takes two arguments a limit and offset. It returns limit
number of columns after offset number of columns. It does this for all
the rows.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">ColumnPaginationFilter(&lt;limit>, &lt;offset>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">ColumnPaginationFilter (3, 5)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>InclusiveStopFilter</term>
<listitem>
<para>This filter takes one argument a row key on which to stop scanning.
It returns all key-values present in rows up to and including the
specified row.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">InclusiveStopFilter(&lt;stop_row_key>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">InclusiveStopFilter ('Row2')</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>TimeStampsFilter</term>
<listitem>
<para>This filter takes a list of timestamps. It returns those key-values
whose timestamps matches any of the specified timestamps.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">TimeStampsFilter (&lt;timestamp>, &lt;timestamp>, ... ,&lt;timestamp>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">TimeStampsFilter (5985489, 48895495, 58489845945)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>RowFilter</term>
<listitem>
<para>This filter takes a compare operator and a comparator. It compares
each row key with the comparator using the compare operator and if the
comparison returns true, it returns all the key-values in that
row.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">RowFilter (&lt;compareOp>, &lt;row_comparator>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">RowFilter (&lt;=, xyz)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>Family Filter</term>
<listitem>
<para>This filter takes a compare operator and a comparator. It compares
each qualifier name with the comparator using the compare operator and
if the comparison returns true, it returns all the key-values in that
column.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">QualifierFilter (&lt;compareOp&gt;, &lt;qualifier_comparator>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">QualifierFilter (=, Column1)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>QualifierFilter</term>
<listitem>
<para>This filter takes a compare operator and a comparator. It compares
each qualifier name with the comparator using the compare operator and
if the comparison returns true, it returns all the key-values in that
column.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">QualifierFilter (&lt;compareOp>,&lt;qualifier_comparator>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">QualifierFilter (=,Column1)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>ValueFilter</term>
<listitem>
<para>This filter takes a compare operator and a comparator. It compares
each value with the comparator using the compare operator and if the
comparison returns true, it returns that key-value.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">ValueFilter (&lt;compareOp>,&lt;value_comparator>) </programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">ValueFilter (!=, Value)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>DependentColumnFilter</term>
<listitem>
<para>This filter takes two arguments a family and a qualifier. It tries
to locate this column in each row and returns all key-values in that row
that have the same timestamp. If the row doesnt contain the specified
column none of the key-values in that row will be returned.</para>
<para>The filter can also take an optional boolean argument
dropDependentColumn. If set to true, the column we were depending on
doesnt get returned.</para>
<para>The filter can also take two more additional optional arguments a
compare operator and a value comparator, which are further checks in
addition to the family and qualifier. If the dependent column is found,
its value should also pass the value check and then only is its
timestamp taken into consideration.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java"><![CDATA[DependentColumnFilter (<family>,<qualifier>, <boolean>, <compare operator>, <value
comparator)]]></programlisting>
</listitem>
<listitem>
<programlisting language="java"><![CDATA[DependentColumnFilter (<family>,<qualifier>, <boolean>)]]></programlisting>
</listitem>
<listitem>
<programlisting language="java">DependentColumnFilter (&lt;family>,&lt;qualifier>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">DependentColumnFilter (conf, blacklist, false, >=, zebra)</programlisting>
</listitem>
<listitem>
<programlisting language="java">DependentColumnFilter (conf, 'blacklist', true)</programlisting>
</listitem>
<listitem>
<programlisting language="java">DependentColumnFilter (conf, 'blacklist')</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>SingleColumnValueFilter</term>
<listitem>
<para>This filter takes a column family, a qualifier, a compare operator and
a comparator. If the specified column is not found all the columns of
that row will be emitted. If the column is found and the comparison with
the comparator returns true, all the columns of the row will be emitted.
If the condition fails, the row will not be emitted. </para>
<para>This filter also takes two additional optional boolean arguments
filterIfColumnMissing and setLatestVersionOnly</para>
<para>If the filterIfColumnMissing flag is set to true the columns of the
row will not be emitted if the specified column to check is not found in
the row. The default value is false.</para>
<para>If the setLatestVersionOnly flag is set to false, it will test
previous versions (timestamps) too. The default value is true.</para>
<para>These flags are optional and if you must set neither or both.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">SingleColumnValueFilter(&lt;family>,&lt;qualifier>, &lt;compare operator>, &lt;comparator>, &lt;filterIfColumnMissing_boolean>, &lt;latest_version_boolean>)</programlisting>
</listitem>
<listitem>
<programlisting language="java">SingleColumnValueFilter(&lt;family>, &lt;qualifier>, &lt;compare operator>, &lt;comparator>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">SingleColumnValueFilter (FamilyA, Column1, &lt;=, abc, true, false)</programlisting>
</listitem>
<listitem>
<programlisting>SingleColumnValueFilter (FamilyA, Column1, &lt;=, abc)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>SingleColumnValueExcludeFilter</term>
<listitem>
<para>This filter takes the same arguments and behaves same as
SingleColumnValueFilter however, if the column is found and the
condition passes, all the columns of the row will be emitted except for
the tested column value.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">SingleColumnValueExcludeFilter('&lt;family>', '&lt;qualifier>', &lt;compare operator>, '&lt;comparator>', &lt;latest_version_boolean>, &lt;filterIfColumnMissing_boolean>)</programlisting>
</listitem>
<listitem>
<programlisting language="java">SingleColumnValueExcludeFilter('&lt;family>', '&lt;qualifier>', &lt;compare operator>, '&lt;comparator>')</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">SingleColumnValueExcludeFilter (FamilyA, Column1, &lt;=, abc, false, true)</programlisting>
</listitem>
<listitem>
<programlisting language="java">SingleColumnValueExcludeFilter (FamilyA, Column1, &lt;=, abc)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>ColumnRangeFilter</term>
<listitem>
<para>This filter is used for selecting only those keys with columns that
are between minColumn and maxColumn. It also takes two boolean variables
to indicate whether to include the minColumn and maxColumn or
not.</para>
<para>If you dont want to set the minColumn or the maxColumn you can pass
in an empty argument.</para>
<itemizedlist>
<title>Syntax</title>
<listitem>
<programlisting language="java">ColumnRangeFilter (&lt;minColumn>, &lt;minColumnInclusive_bool>, &lt;maxColumn>, &lt;maxColumnInclusive_bool>)</programlisting>
</listitem>
</itemizedlist>
<itemizedlist>
<title>Example</title>
<listitem>
<programlisting language="java">ColumnRangeFilter (abc, true, xyz, false)</programlisting>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
</variablelist>
</section>
</section>
</chapter>

View File

@ -1,187 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix
xml:id="tracing"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Enabling Dapper-like Tracing in HBase</title>
<para>
<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-6449">HBASE-6449</link> added support
for tracing requests through HBase, using the open source tracing library, <link
xlink:href="http://github.com/cloudera/htrace">HTrace</link>. Setting up tracing is quite
simple, however it currently requires some very minor changes to your client code (it would not
be very difficult to remove this requirement). </para>
<section
xml:id="tracing.spanreceivers">
<title>SpanReceivers</title>
<para> The tracing system works by collecting information in structs called 'Spans'. It is up to
you to choose how you want to receive this information by implementing the
<classname>SpanReceiver</classname> interface, which defines one method: </para>
<programlisting><![CDATA[
public void receiveSpan(Span span);
]]></programlisting>
<para>This method serves as a callback whenever a span is completed. HTrace allows you to use as
many SpanReceivers as you want so you can easily send trace information to multiple
destinations. </para>
<para> Configure what SpanReceivers you'd like to us by putting a comma separated list of the
fully-qualified class name of classes implementing <classname>SpanReceiver</classname> in
<filename>hbase-site.xml</filename> property:
<varname>hbase.trace.spanreceiver.classes</varname>. </para>
<para> HTrace includes a <classname>LocalFileSpanReceiver</classname> that writes all span
information to local files in a JSON-based format. The
<classname>LocalFileSpanReceiver</classname> looks in <filename>hbase-site.xml</filename>
for a <varname>hbase.local-file-span-receiver.path</varname> property with a value describing
the name of the file to which nodes should write their span information. </para>
<programlisting><![CDATA[
<property>
<name>hbase.trace.spanreceiver.classes</name>
<value>org.htrace.impl.LocalFileSpanReceiver</value>
</property>
<property>
<name>hbase.local-file-span-receiver.path</name>
<value>/var/log/hbase/htrace.out</value>
</property>
]]></programlisting>
<para> HTrace also provides <classname>ZipkinSpanReceiver</classname> which converts spans to <link
xlink:href="http://github.com/twitter/zipkin">Zipkin</link> span format and send them to
Zipkin server. In order to use this span receiver, you need to install the jar of
htrace-zipkin to your HBase's classpath on all of the nodes in your cluster. </para>
<para>
<filename>htrace-zipkin</filename> is published to the maven central repository. You could get
the latest version from there or just build it locally and then copy it out to all nodes,
change your config to use zipkin receiver, distribute the new configuration and then (rolling)
restart. </para>
<para> Here is the example of manual setup procedure. </para>
<screen language="bourne"><![CDATA[
$ git clone https://github.com/cloudera/htrace
$ cd htrace/htrace-zipkin
$ mvn compile assembly:single
$ cp target/htrace-zipkin-*-jar-with-dependencies.jar $HBASE_HOME/lib/
# copy jar to all nodes...
]]></screen>
<para>The <classname>ZipkinSpanReceiver</classname> looks in <filename>hbase-site.xml</filename>
for a <varname>hbase.zipkin.collector-hostname</varname> and
<varname>hbase.zipkin.collector-port</varname> property with a value describing the Zipkin
collector server to which span information are sent. </para>
<programlisting language="xml"><![CDATA[
<property>
<name>hbase.trace.spanreceiver.classes</name>
<value>org.htrace.impl.ZipkinSpanReceiver</value>
</property>
<property>
<name>hbase.zipkin.collector-hostname</name>
<value>localhost</value>
</property>
<property>
<name>hbase.zipkin.collector-port</name>
<value>9410</value>
</property>
]]></programlisting>
<para> If you do not want to use the included span receivers, you are encouraged to write your
own receiver (take a look at <classname>LocalFileSpanReceiver</classname> for an example). If
you think others would benefit from your receiver, file a JIRA or send a pull request to <link
xlink:href="http://github.com/cloudera/htrace">HTrace</link>. </para>
</section>
<section
xml:id="tracing.client.modifications">
<title>Client Modifications</title>
<para> In order to turn on tracing in your client code, you must initialize the module sending
spans to receiver once per client process. </para>
<programlisting language="java"><![CDATA[
private SpanReceiverHost spanReceiverHost;
...
Configuration conf = HBaseConfiguration.create();
SpanReceiverHost spanReceiverHost = SpanReceiverHost.getInstance(conf);
]]></programlisting>
<para>Then you simply start tracing span before requests you think are interesting, and close it
when the request is done. For example, if you wanted to trace all of your get operations, you
change this: </para>
<programlisting language="java"><![CDATA[
HTable table = new HTable(conf, "t1");
Get get = new Get(Bytes.toBytes("r1"));
Result res = table.get(get);
]]></programlisting>
<para>into: </para>
<programlisting language="java"><![CDATA[
TraceScope ts = Trace.startSpan("Gets", Sampler.ALWAYS);
try {
HTable table = new HTable(conf, "t1");
Get get = new Get(Bytes.toBytes("r1"));
Result res = table.get(get);
} finally {
ts.close();
}
]]></programlisting>
<para>If you wanted to trace half of your 'get' operations, you would pass in: </para>
<programlisting language="java"><![CDATA[
new ProbabilitySampler(0.5)
]]></programlisting>
<para>in lieu of <varname>Sampler.ALWAYS</varname> to <classname>Trace.startSpan()</classname>.
See the HTrace <filename>README</filename> for more information on Samplers. </para>
</section>
<section
xml:id="tracing.client.shell">
<title>Tracing from HBase Shell</title>
<para> You can use <command>trace</command> command for tracing requests from HBase Shell.
<command>trace 'start'</command> command turns on tracing and <command>trace
'stop'</command> command turns off tracing. </para>
<programlisting><![CDATA[
hbase(main):001:0> trace 'start'
hbase(main):002:0> put 'test', 'row1', 'f:', 'val1' # traced commands
hbase(main):003:0> trace 'stop'
]]></programlisting>
<para>
<command>trace 'start'</command> and <command>trace 'stop'</command> always returns boolean
value representing if or not there is ongoing tracing. As a result, <command>trace
'stop'</command> returns false on suceess. <command>trace 'status'</command> just returns if
or not tracing is turned on. </para>
<programlisting><![CDATA[
hbase(main):001:0> trace 'start'
=> true
hbase(main):002:0> trace 'status'
=> true
hbase(main):003:0> trace 'stop'
=> false
hbase(main):004:0> trace 'status'
=> false
]]></programlisting>
</section>
</appendix>

File diff suppressed because it is too large Load Diff

View File

@ -1,330 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter version="5.0" xml:id="unit.tests" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Unit Testing HBase Applications</title>
<para>This chapter discusses unit testing your HBase application using JUnit, Mockito, MRUnit,
and HBaseTestingUtility. Much of the information comes from <link
xlink:href="http://blog.cloudera.com/blog/2013/09/how-to-test-hbase-applications-using-popular-tools/"
>a community blog post about testing HBase applications</link>. For information on unit
tests for HBase itself, see <xref linkend="hbase.tests"/>.</para>
<section>
<title>JUnit</title>
<para>HBase uses <link xlink:href="http://junit.org">JUnit</link> 4 for unit tests</para>
<para>This example will add unit tests to the following example class:</para>
<programlisting language="java">
public class MyHBaseDAO {
public static void insertRecord(HTableInterface table, HBaseTestObj obj)
throws Exception {
Put put = createPut(obj);
table.put(put);
}
private static Put createPut(HBaseTestObj obj) {
Put put = new Put(Bytes.toBytes(obj.getRowKey()));
put.add(Bytes.toBytes("CF"), Bytes.toBytes("CQ-1"),
Bytes.toBytes(obj.getData1()));
put.add(Bytes.toBytes("CF"), Bytes.toBytes("CQ-2"),
Bytes.toBytes(obj.getData2()));
return put;
}
}
</programlisting>
<para>The first step is to add JUnit dependencies to your Maven POM file:</para>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
]]></programlisting>
<para>Next, add some unit tests to your code. Tests are annotated with
<literal>@Test</literal>. Here, the unit tests are in bold.</para>
<programlisting language="java">
public class TestMyHbaseDAOData {
@Test
public void testCreatePut() throws Exception {
HBaseTestObj obj = new HBaseTestObj();
obj.setRowKey("ROWKEY-1");
obj.setData1("DATA-1");
obj.setData2("DATA-2");
Put put = MyHBaseDAO.createPut(obj);
<userinput>assertEquals(obj.getRowKey(), Bytes.toString(put.getRow()));
assertEquals(obj.getData1(), Bytes.toString(put.get(Bytes.toBytes("CF"), Bytes.toBytes("CQ-1")).get(0).getValue()));
assertEquals(obj.getData2(), Bytes.toString(put.get(Bytes.toBytes("CF"), Bytes.toBytes("CQ-2")).get(0).getValue()));</userinput>
}
}
</programlisting>
<para>These tests ensure that your <code>createPut</code> method creates, populates, and
returns a <code>Put</code> object with expected values. Of course, JUnit can do much
more than this. For an introduction to JUnit, see <link
xlink:href="https://github.com/junit-team/junit/wiki/Getting-started"
>https://github.com/junit-team/junit/wiki/Getting-started</link>. </para>
</section>
<section xml:id="mockito">
<title>Mockito</title>
<para>Mockito is a mocking framework. It goes further than JUnit by allowing you to test the
interactions between objects without having to replicate the entire environment. You can
read more about Mockito at its project site, <link
xlink:href="https://code.google.com/p/mockito/"
>https://code.google.com/p/mockito/</link>.</para>
<para>You can use Mockito to do unit testing on smaller units. For instance, you can mock a
<classname>org.apache.hadoop.hbase.Server</classname> instance or a
<classname>org.apache.hadoop.hbase.master.MasterServices</classname> interface
reference rather than a full-blown
<classname>org.apache.hadoop.hbase.master.HMaster</classname>.</para>
<para>This example builds upon the example code in <xref linkend="unit.tests"/>, to test the
<code>insertRecord</code> method.</para>
<para>First, add a dependency for Mockito to your Maven POM file.</para>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
]]></programlisting>
<para>Next, add a <code>@RunWith</code> annotation to your test class, to direct it to use
Mockito.</para>
<programlisting language="java">
<userinput>@RunWith(MockitoJUnitRunner.class)</userinput>
public class TestMyHBaseDAO{
@Mock
private HTableInterface table;
@Mock
private HTablePool hTablePool;
@Captor
private ArgumentCaptor putCaptor;
@Test
public void testInsertRecord() throws Exception {
//return mock table when getTable is called
when(hTablePool.getTable("tablename")).thenReturn(table);
//create test object and make a call to the DAO that needs testing
HBaseTestObj obj = new HBaseTestObj();
obj.setRowKey("ROWKEY-1");
obj.setData1("DATA-1");
obj.setData2("DATA-2");
MyHBaseDAO.insertRecord(table, obj);
verify(table).put(putCaptor.capture());
Put put = putCaptor.getValue();
assertEquals(Bytes.toString(put.getRow()), obj.getRowKey());
assert(put.has(Bytes.toBytes("CF"), Bytes.toBytes("CQ-1")));
assert(put.has(Bytes.toBytes("CF"), Bytes.toBytes("CQ-2")));
assertEquals(Bytes.toString(put.get(Bytes.toBytes("CF"),Bytes.toBytes("CQ-1")).get(0).getValue()), "DATA-1");
assertEquals(Bytes.toString(put.get(Bytes.toBytes("CF"),Bytes.toBytes("CQ-2")).get(0).getValue()), "DATA-2");
}
}
</programlisting>
<para>This code populates <code>HBaseTestObj</code> with “ROWKEY-1”, “DATA-1”, “DATA-2” as
values. It then inserts the record into the mocked table. The Put that the DAO would
have inserted is captured, and values are tested to verify that they are what you
expected them to be.</para>
<para>The key here is to manage htable pool and htable instance creation outside the DAO.
This allows you to mock them cleanly and test Puts as shown above. Similarly, you can
now expand into other operations such as Get, Scan, or Delete.</para>
</section>
<section>
<title>MRUnit</title>
<para><link xlink:href="http://mrunit.apache.org/">Apache MRUnit</link> is a library that
allows you to unit-test MapReduce jobs. You can use it to test HBase jobs in the same
way as other MapReduce jobs.</para>
<para>Given a MapReduce job that writes to an HBase table called <literal>MyTest</literal>,
which has one column family called <literal>CF</literal>, the reducer of such a job
could look like the following:</para>
<programlisting language="java"><![CDATA[
public class MyReducer extends TableReducer<Text, Text, ImmutableBytesWritable> {
public static final byte[] CF = "CF".getBytes();
public static final byte[] QUALIFIER = "CQ-1".getBytes();
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
//bunch of processing to extract data to be inserted, in our case, lets say we are simply
//appending all the records we receive from the mapper for this particular
//key and insert one record into HBase
StringBuffer data = new StringBuffer();
Put put = new Put(Bytes.toBytes(key.toString()));
for (Text val : values) {
data = data.append(val);
}
put.add(CF, QUALIFIER, Bytes.toBytes(data.toString()));
//write to HBase
context.write(new ImmutableBytesWritable(Bytes.toBytes(key.toString())), put);
}
} ]]>
</programlisting>
<para>To test this code, the first step is to add a dependency to MRUnit to your Maven POM
file. </para>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>1.0.0 </version>
<scope>test</scope>
</dependency>
]]></programlisting>
<para>Next, use the ReducerDriver provided by MRUnit, in your Reducer job.</para>
<programlisting language="java"><![CDATA[
public class MyReducerTest {
ReduceDriver<Text, Text, ImmutableBytesWritable, Writable> reduceDriver;
byte[] CF = "CF".getBytes();
byte[] QUALIFIER = "CQ-1".getBytes();
@Before
public void setUp() {
MyReducer reducer = new MyReducer();
reduceDriver = ReduceDriver.newReduceDriver(reducer);
}
@Test
public void testHBaseInsert() throws IOException {
String strKey = "RowKey-1", strValue = "DATA", strValue1 = "DATA1",
strValue2 = "DATA2";
List<Text> list = new ArrayList<Text>();
list.add(new Text(strValue));
list.add(new Text(strValue1));
list.add(new Text(strValue2));
//since in our case all that the reducer is doing is appending the records that the mapper
//sends it, we should get the following back
String expectedOutput = strValue + strValue1 + strValue2;
//Setup Input, mimic what mapper would have passed
//to the reducer and run test
reduceDriver.withInput(new Text(strKey), list);
//run the reducer and get its output
List<Pair<ImmutableBytesWritable, Writable>> result = reduceDriver.run();
//extract key from result and verify
assertEquals(Bytes.toString(result.get(0).getFirst().get()), strKey);
//extract value for CF/QUALIFIER and verify
Put a = (Put)result.get(0).getSecond();
String c = Bytes.toString(a.get(CF, QUALIFIER).get(0).getValue());
assertEquals(expectedOutput,c );
}
}
]]></programlisting>
<para>Your MRUnit test verifies that the output is as expected, the Put that is inserted
into HBase has the correct value, and the ColumnFamily and ColumnQualifier have the
correct values.</para>
<para>MRUnit includes a MapperDriver to test mapping jobs, and you can use MRUnit to test
other operations, including reading from HBase, processing data, or writing to
HDFS,</para>
</section>
<section>
<title>Integration Testing with a HBase Mini-Cluster</title>
<para>HBase ships with HBaseTestingUtility, which makes it easy to write integration tests
using a <firstterm>mini-cluster</firstterm>. The first step is to add some dependencies
to your Maven POM file. Check the versions to be sure they are appropriate.</para>
<programlisting language="xml"><![CDATA[
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.0.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.98.3</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.0.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
]]></programlisting>
<para>This code represents an integration test for the MyDAO insert shown in <xref
linkend="unit.tests"/>.</para>
<programlisting language="java">
public class MyHBaseIntegrationTest {
private static HBaseTestingUtility utility;
byte[] CF = "CF".getBytes();
byte[] QUALIFIER = "CQ-1".getBytes();
@Before
public void setup() throws Exception {
utility = new HBaseTestingUtility();
utility.startMiniCluster();
}
@Test
public void testInsert() throws Exception {
HTableInterface table = utility.createTable(Bytes.toBytes("MyTest"),
Bytes.toBytes("CF"));
HBaseTestObj obj = new HBaseTestObj();
obj.setRowKey("ROWKEY-1");
obj.setData1("DATA-1");
obj.setData2("DATA-2");
MyHBaseDAO.insertRecord(table, obj);
Get get1 = new Get(Bytes.toBytes(obj.getRowKey()));
get1.addColumn(CF, CQ1);
Result result1 = table.get(get1);
assertEquals(Bytes.toString(result1.getRow()), obj.getRowKey());
assertEquals(Bytes.toString(result1.value()), obj.getData1());
Get get2 = new Get(Bytes.toBytes(obj.getRowKey()));
get2.addColumn(CF, CQ2);
Result result2 = table.get(get2);
assertEquals(Bytes.toString(result2.getRow()), obj.getRowKey());
assertEquals(Bytes.toString(result2.value()), obj.getData2());
}
}
</programlisting>
<para>This code creates an HBase mini-cluster and starts it. Next, it creates a table called
<literal>MyTest</literal> with one column family, <literal>CF</literal>. A record is
inserted, a Get is performed from the same table, and the insertion is verified.</para>
<note>
<para>Starting the mini-cluster takes about 20-30 seconds, but that should be
appropriate for integration testing. </para>
</note>
<para>To use an HBase mini-cluster on Microsoft Windows, you need to use a Cygwin
environment.</para>
<para>See the paper at <link
xlink:href="http://blog.sematext.com/2010/08/30/hbase-case-study-using-hbasetestingutility-for-local-testing-development/"
>HBase Case-Study: Using HBaseTestingUtility for Local Testing and
Development</link> (2010) for more information about HBaseTestingUtility.</para>
</section>
</chapter>

View File

@ -1,833 +0,0 @@
<?xml version="1.0"?>
<chapter
xml:id="upgrading"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>Upgrading</title>
<para>You cannot skip major versions upgrading. If you are upgrading from version 0.90.x to
0.94.x, you must first go from 0.90.x to 0.92.x and then go from 0.92.x to 0.94.x.</para>
<note>
<para>It may be possible to skip across versions -- for example go from 0.92.2 straight to
0.98.0 just following the 0.96.x upgrade instructions -- but we have not tried it so
cannot say whether it works or not.</para>
</note>
<para> Review <xref
linkend="configuration" />, in particular the section on Hadoop version. </para>
<section
xml:id="hbase.versioning">
<title>HBase version number and compatibility</title>
<para>HBase has two versioning schemes, pre-1.0 and post-1.0. Both are detailed below. </para>
<section xml:id="hbase.versioning.post10">
<title>Post 1.0 versions</title>
<para>Starting with 1.0.0 release, HBase uses <link xlink:href="http://semver.org/">Semantic Versioning</link> for it release versioning.
In summary:
<blockquote>
<para>
Given a version number MAJOR.MINOR.PATCH, increment the:
<itemizedlist>
<listitem>MAJOR version when you make incompatible API changes,</listitem>
<listitem>MINOR version when you add functionality in a backwards-compatible manner, and</listitem>
<listitem>PATCH version when you make backwards-compatible bug fixes.</listitem>
<listitem>Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.</listitem>
</itemizedlist>
</para>
</blockquote>
</para>
<section xml:id="hbase.versioning.compat">
<title>Compatibility Dimensions</title>
<para>In addition to the usual API versioning considerations HBase has other compatibility dimensions that we need to consider.</para>
<section>
<title>Client-Server wire protocol compatibility</title>
<para><itemizedlist>
<listitem>Allows updating client and server out of sync.</listitem>
<listitem>We could only allow upgrading the server first. I.e. the server would be backward compatible to an old client, that way new APIs are OK.</listitem>
<listitem>Example: A user should be able to use an old client to connect to an upgraded cluster.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Server-Server protocol compatibility</title>
<para><itemizedlist>
<listitem>Servers of different versions can co-exist in the same cluster.</listitem>
<listitem>The wire protocol between servers is compatible.</listitem>
<listitem>Workers for distributed tasks, such as replication and log splitting, can co-exist in the same cluster.</listitem>
<listitem>Dependent protocols (such as using ZK for coordination) will also not be changed.</listitem>
<listitem>Example: A user can perform a rolling upgrade.</listitem>
</itemizedlist></para>
</section>
<section>
<title>File format compatibility</title>
<para><itemizedlist>
<listitem>Support file formats backward and forward compatible</listitem>
<listitem>Example: File, ZK encoding, directory layout is upgraded automatically as part of an HBase upgrade. User can rollback to the older version and everything will continue to work.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Client API compatibility</title>
<para><itemizedlist>
<listitem>Allow changing or removing existing client APIs.</listitem>
<listitem>An API needs to deprecated for a major version before we will change/remove it.</listitem>
<listitem>Example: A user using a newly deprecated api does not need to modify application code with hbase api calls until the next major version.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Client Binary compatibility</title>
<para><itemizedlist>
<listitem>Old client code can run unchanged (no recompilation needed) against new jars.</listitem>
<listitem>Example: Old compiled client code will work unchanged with the new jars.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Server-Side Limited API compatibility (taken from Hadoop)</title>
<para><itemizedlist>
<listitem>Internal APIs are marked as Stable, Evolving, or Unstable</listitem>
<listitem>This implies binary compatibility for coprocessors and plugins (pluggable classes, including replication) as long as these are only using marked interfaces/classes.</listitem>
<listitem>Example: Old compiled Coprocessor, Filter, or Plugin code will work unchanged with the new jars.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Dependency Compatibility</title>
<para><itemizedlist>
<listitem>An upgrade of HBase will not require an incompatible upgrade of a dependent project, including the Java runtime.</listitem>
<listitem>Example: An upgrade of Hadoop will not invalidate any of the compatibilities guarantees we made.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Operational Compatibility</title>
<para><itemizedlist>
<listitem>Metric changes</listitem>
<listitem>Behavioral changes of services</listitem>
<listitem>Web page APIs</listitem>
</itemizedlist></para>
</section>
<section>
<title>Summary</title>
<para><itemizedlist>
<listitem>A patch upgrade is a drop-in replacement. Any change that is not Java binary compatible would not be allowed.<footnote><link xlink:href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html"/></footnote></listitem>
<listitem>A minor upgrade requires no application/client code modification. Ideally it would be a drop-in replacement but client code, coprocessors, filters, etc might have to be recompiled if new jars are used.</listitem>
<listitem>A major upgrade allows the HBase community to make breaking changes.</listitem>
</itemizedlist></para>
</section>
<section>
<title>Compatibility Matrix <footnote><para>Note that this indicates what could break, not that it will break. We will/should add specifics in our release notes.</para></footnote></title>
<para> (Y means we support the compatibility. N means we can break it.) </para>
<table>
<title>Compatibility Matrix</title>
<tgroup
cols="4"
align="left"
colsep="1"
rowsep="1">
<colspec
colname="c1"
align="left" />
<colspec
colname="c2"
align="center" />
<colspec
colname="c3"
align="center" />
<colspec
colname="c4"
align="center" />
<thead>
<row>
<entry> </entry>
<entry>Major</entry>
<entry>Minor</entry>
<entry>Patch</entry>
</row>
</thead>
<tbody>
<row>
<entry>Client-Server wire Compatibility</entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry>Server-Server Compatibility</entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry>File Format Compatibility</entry>
<entry>N<footnote><para>Running an offline upgrade tool without rollback might be needed. We will typically only support migrating data from major version X to major version X+1.
</para></footnote></entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry>Client API Compatibility</entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry>Client Binary Compatibility</entry>
<entry>N</entry>
<entry>N</entry>
<entry>Y</entry>
</row>
<row>
<entry>Server-Side Limited API Compatibility</entry>
<entry></entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry><itemizedlist><listitem>Stable</listitem></itemizedlist></entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry><itemizedlist><listitem>Evolving</listitem></itemizedlist></entry>
<entry>N</entry>
<entry>N</entry>
<entry>Y</entry>
</row>
<row>
<entry><itemizedlist><listitem>Unstable</listitem></itemizedlist></entry>
<entry>N</entry>
<entry>N</entry>
<entry>N</entry>
</row>
<row>
<entry>Dependency Compatibility</entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Y</entry>
</row>
<row>
<entry>Operational Compatibility</entry>
<entry>N</entry>
<entry>N</entry>
<entry>Y</entry>
</row>
</tbody>
</tgroup>
</table>
</section>
<section xml:id="hbase.client.api.surface">
<title>HBase API surface</title>
<para> HBase has a lot of API points, but for the compatibility matrix above, we differentiate between Client API, Limited Private API, and Private API. HBase uses a version of
<link xlink:href="https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Compatibility.html">Hadoop's Interface classification</link>. HBase's Interface classification classes can be found <link xlink:href="https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/classification/package-summary.html"> here</link>.
<itemizedlist>
<listitem>InterfaceAudience: captures the intended audience, possible values are Public (for end users and external projects), LimitedPrivate (for other Projects, Coprocessors or other plugin points), and Private (for internal use).</listitem>
<listitem>InterfaceStability: describes what types of interface changes are permitted. Possible values are Stable, Evolving, Unstable, and Deprecated.</listitem>
</itemizedlist>
</para>
<section xml:id="hbase.client.api">
<title>HBase Client API</title>
<para>HBase Client API consists of all the classes or methods that are marked with InterfaceAudience.Public interface. All main classes in hbase-client and dependent modules have either InterfaceAudience.Public, InterfaceAudience.LimitedPrivate, or InterfaceAudience.Private marker. Not all classes in other modules (hbase-server, etc) have the marker. If a class is not annotated with one of these, it is assumed to be a InterfaceAudience.Private class. </para>
</section>
<section xml:id="hbase.limitetprivate.api">
<title>HBase LimitedPrivate API</title>
<para>LimitedPrivate annotation comes with a set of target consumers for the interfaces. Those consumers are coprocessors, phoenix, replication endpoint implemnetations or similar. At this point, HBase only guarantees source and binary compatibility for these interfaces between patch versions. </para>
</section>
<section xml:id="hbase.private.api">
<title>HBase Private API</title>
<para>All classes annotated with InterfaceAudience.Private or all classes that do not have the annotation are for HBase internal use only. The interfaces and method signatures can change at any point in time. If you are relying on a particular interface that is marked Private, you should open a jira to propose changing the interface to be Public or LimitedPrivate, or an interface exposed for this purpose. </para>
</section>
</section>
</section>
</section>
<section xml:id="hbase.versioning.pre10">
<title>Pre 1.0 versions</title>
<para></para>
<para> Before the semantic versioning scheme pre-1.0, HBase tracked either Hadoop's versions (0.2x)
or 0.9x versions. If you are into the arcane, checkout our old wiki page on <link
xlink:href="http://wiki.apache.org/hadoop/Hbase/HBaseVersions">HBase
Versioning</link> which tries to connect the HBase version dots. Below sections cover ONLY the
releases before 1.0.</para>
<section
xml:id="hbase.development.series">
<title>Odd/Even Versioning or "Development"" Series Releases</title>
<para>Ahead of big releases, we have been putting up preview versions to start the
feedback cycle turning-over earlier. These "Development" Series releases, always
odd-numbered, come with no guarantees, not even regards being able to upgrade
between two sequential releases (we reserve the right to break compatibility across
"Development" Series releases). Needless to say, these releases are not for
production deploys. They are a preview of what is coming in the hope that interested
parties will take the release for a test drive and flag us early if we there are
issues we've missed ahead of our rolling a production-worthy release. </para>
<para>Our first "Development" Series was the 0.89 set that came out ahead of HBase
0.90.0. HBase 0.95 is another "Development" Series that portends HBase 0.96.0.
0.99.x is the last series in "developer preview" mode before 1.0. Afterwards,
we will be using semantic versioning naming scheme (see above).
</para>
</section>
<section
xml:id="hbase.binary.compatibility">
<title>Binary Compatibility</title>
<para>When we say two HBase versions are compatible, we mean that the versions are wire
and binary compatible. Compatible HBase versions means that clients can talk to
compatible but differently versioned servers. It means too that you can just swap
out the jars of one version and replace them with the jars of another, compatible
version and all will just work. Unless otherwise specified, HBase point versions are
(mostly) binary compatible. You can safely do rolling upgrades between binary compatible
versions; i.e. across point versions: e.g. from 0.94.5 to 0.94.6. See <link
xlink:href="http://search-hadoop.com/m/bOOvwHGW981/Does+compatibility+between+versions+also+mean+binary+compatibility%253F&amp;subj=Re+">Does
compatibility between versions also mean binary compatibility?</link>
discussion on the hbaes dev mailing list. </para>
</section>
</section>
<section xml:id="hbase.rolling.upgrade">
<title><firstterm>Rolling Upgrades</firstterm></title>
<para>A rolling upgrade is the process by which you update the servers
in your cluster a server at a time. You can rolling upgrade across HBase versions
if they are binary or wire compatible.
See <xlnk href="hbase.rolling.restart" /> for more on what this means.
Coarsely, a rolling upgrade is a graceful stop each server,
update the software, and then restart. You do this for each server in the cluster.
Usually you upgrade the Master first and then the regionservers.
See <xlink href="rolling" /> for tools that can help use the rolling upgrade process.
</para>
<para>For example, in the below, hbase was symlinked to the actual hbase install.
On upgrade, before running a rolling restart over the cluser, we changed the symlink
to point at the new HBase software version and then ran
<programlisting>$ HADOOP_HOME=~/hadoop-2.6.0-CRC-SNAPSHOT ~/hbase/bin/rolling-restart.sh --config ~/conf_hbase</programlisting>
The rolling-restart script will first gracefully stop and restart the master, and then
each of the regionservers in turn. Because the symlink was changed, on restart the
server will come up using the new hbase version. Check logs for errors as the
rolling upgrade proceeds.
</para>
<section
xml:id="hbase.rolling.restart">
<title>Rolling Upgrade between versions that are Binary/Wire compatibile</title>
<para>Unless otherwise specified, HBase point versions are binary compatible. You can do
a <xlink href="hbase.rolling.upgrade" /> between hbase point versions.
For example, you can go to 0.94.6 from 0.94.5 by doing a rolling upgrade
across the cluster replacing the 0.94.5 binary with a 0.94.6 binary.</para>
<para>In the minor version-particular sections below, we call out where the versions
are wire/protocol compatible and in this case, it is also possible to do a
<xlink href="hbase.rolling.upgrade" />. For example, in
<xlink href="upgrade1.0.rolling.upgrade" />, we
state that it is possible to do a rolling upgrade between hbase-0.98.x and hbase-1.0.0.</para>
</section>
</section>
</section>
<section xml:id="upgrade1.0">
<title>Upgrading from 0.98.x to 1.0.x</title>
<para>In this section we first note the significant changes that come in with 1.0.0 HBase and then
we go over the upgrade process. Be sure to read the significant changes section with care
so you avoid surprises.
</para>
<section xml:id="upgrade1.0.changes">
<title>Changes of Note!</title>
<para>In here we list important changes that are in 1.0.0 since 0.98.x., changes you should
be aware that will go into effect once you upgrade.</para>
<section xml:id="zookeeper.3.4"><title>ZooKeeper 3.4 is required in HBase 1.0.0</title>
<para>See <xref linkend="zookeeper.requirements" />.</para>
</section>
<section xml:id="default.ports.changed"><title>HBase Default Ports Changed</title>
<para>The ports used by HBase changed. The used to be in the 600XX range. In
hbase-1.0.0 they have been moved up out of the ephemeral port range and are
160XX instead (Master web UI was 60010 and is now 16030; the RegionServer
web UI was 60030 and is now 16030, etc). If you want to keep the old port
locations, copy the port setting configs from <filename>hbase-default.xml</filename>
into <filename>hbase-site.xml</filename>, change them back to the old values
from hbase-0.98.x era, and ensure you've distributed your configurations before
you restart.</para>
</section>
<section xml:id="upgrade1.0.hbase.bucketcache.percentage.in.combinedcache">
<title>hbase.bucketcache.percentage.in.combinedcache configuration has been REMOVED</title>
<para>You may have made use of this configuration if you are using BucketCache.
If NOT using BucketCache, this change does not effect you.
Its removal means that your L1 LruBlockCache is now sized
using <varname>hfile.block.cache.size</varname> -- i.e. the way you
would size the onheap L1 LruBlockCache if you were NOT doing
BucketCache -- and the BucketCache size is not whatever the
setting for hbase.bucketcache.size is. You may need to adjust
configs to get the LruBlockCache and BucketCache sizes set to
what they were in 0.98.x and previous. If you did not set this
config., its default value was 0.9. If you do nothing, your
BucketCache will increase in size by 10%. Your L1 LruBlockCache will
become <varname>hfile.block.cache.size</varname> times your java
heap size (hfile.block.cache.size is a float between 0.0 and 1.0).
To read more, see
<link xlink:href="https://issues.apache.org/jira/browse/HBASE-11520">HBASE-11520 Simplify offheap cache config by removing the confusing "hbase.bucketcache.percentage.in.combinedcache"</link>.
</para>
</section>
<section xml:id="hbase-12068"><title>If you have your own customer filters....</title>
<para>See the release notes on the issue <link xlink:href="https://issues.apache.org/jira/browse/HBASE-12068">HBASE-12068 [Branch-1] Avoid need to always do KeyValueUtil#ensureKeyValue for Filter transformCell</link>;
be sure to follow the recommendations therein.
</para>
</section>
<section xml:id="dlr"><title>Distributed Log Replay</title>
<para>
<xref linkend="distributed.log.replay" /> is off by default in hbase-1.0.
Enabling it can make a big difference improving HBase MTTR. Enable this
feature if you are doing a clean stop/start when you are upgrading.
You cannot rolling upgrade on to this feature (caveat if you are running
on a version of hbase in excess of hbase-0.98.4 -- see
<link xlink:href="https://issues.apache.org/jira/browse/HBASE-12577">HBASE-12577 Disable distributed log replay by default</link> for more).
</para>
</section>
</section>
<section xml:id="upgrade1.0.rolling.upgrade">
<title>Rolling upgrade from 0.98.x to HBase 1.0.0</title>
<note><title>From 0.96.x to 1.0.0</title>
<para>You cannot do a <xlink href="rolling.upgrade" /> from 0.96.x to 1.0.0 without
first doing a rolling upgrade to 0.98.x. See comment in
<link xlink:href="https://issues.apache.org/jira/browse/HBASE-11164?focusedCommentId=14182330&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&#35;comment-14182330">HBASE-11164 Document and test rolling updates from 0.98 -> 1.0</link> for the why.
Also because hbase-1.0.0 enables hfilev3 by default,
<link xlink:href="https://issues.apache.org/jira/browse/HBASE-9801">HBASE-9801 Change the default HFile version to V3</link>,
and support for hfilev3 only arrives in 0.98, this is another reason you cannot rolling upgrade from hbase-0.96.x;
if the rolling upgrade stalls, the 0.96.x servers cannot open files written by the servers running the newer hbase-1.0.0
hfilev3 writing servers.
</para>
</note>
<para>There are no known issues running a <xlink href="hbase.rolling.upgrade" /> from hbase-0.98.x to hbase-1.0.0.
</para>
</section>
<section xml:id="upgrade1.0.from.0.94">
<title>Upgrading to 1.0 from 0.94</title>
<para>You cannot rolling upgrade from 0.94.x to 1.x.x. You must stop your cluster,
install the 1.x.x software, run the migration described at <xref linkend="executing.the.0.96.upgrade" />
(substituting 1.x.x. wherever we make mention of 0.96.x in the section below),
and then restart. Be sure to upgrade your zookeeper if it is a version less than the required 3.4.x.
</para>
</section>
</section>
<section
xml:id="upgrade0.98">
<title>Upgrading from 0.96.x to 0.98.x</title>
<para>A rolling upgrade from 0.96.x to 0.98.x works. The two versions are not binary
compatible.</para>
<para>Additional steps are required to take advantage of some of the new features of 0.98.x,
including cell visibility labels, cell ACLs, and transparent server side encryption. See
the <xref
linkend="security" /> chapter of this guide for more information. Significant
performance improvements include a change to the write ahead log threading model that
provides higher transaction throughput under high load, reverse scanners, MapReduce over
snapshot files, and striped compaction.</para>
<para>Clients and servers can run with 0.98.x and 0.96.x versions. However, applications may
need to be recompiled due to changes in the Java API.</para>
</section>
<section>
<title>Upgrading from 0.94.x to 0.98.x</title>
<para> A rolling upgrade from 0.94.x directly to 0.98.x does not work. The upgrade path
follows the same procedures as <xref
linkend="upgrade0.96" />. Additional steps are required to use some of the new
features of 0.98.x. See <xref
linkend="upgrade0.98" /> for an abbreviated list of these features. </para>
</section>
<section
xml:id="upgrade0.96">
<title>Upgrading from 0.94.x to 0.96.x</title>
<subtitle>The "Singularity"</subtitle>
<note><title>HBase 0.96.x was EOL'd, September 1st, 2014</title><para>
Do not deploy 0.96.x Deploy a 0.98.x at least.
See <link xlink:href="https://issues.apache.org/jira/browse/HBASE-11642">EOL 0.96</link>.
</para></note>
<para>You will have to stop your old 0.94.x cluster completely to upgrade. If you are
replicating between clusters, both clusters will have to go down to upgrade. Make sure
it is a clean shutdown. The less WAL files around, the faster the upgrade will run (the
upgrade will split any log files it finds in the filesystem as part of the upgrade
process). All clients must be upgraded to 0.96 too. </para>
<para>The API has changed. You will need to recompile your code against 0.96 and you may
need to adjust applications to go against new APIs (TODO: List of changes). </para>
<section xml:id="executing.the.0.96.upgrade">
<title>Executing the 0.96 Upgrade</title>
<note>
<title>HDFS and ZooKeeper must be up!</title>
<para>HDFS and ZooKeeper should be up and running during the upgrade process.</para>
</note>
<para>hbase-0.96.0 comes with an upgrade script. Run
<programlisting language="bourne">$ bin/hbase upgrade</programlisting> to see its usage. The script
has two main modes: -check, and -execute. </para>
<section>
<title>check</title>
<para>The <emphasis>check</emphasis> step is run against a running 0.94 cluster. Run
it from a downloaded 0.96.x binary. The <emphasis>check</emphasis> step is
looking for the presence of <filename>HFileV1</filename> files. These are
unsupported in hbase-0.96.0. To purge them -- have them rewritten as HFileV2 --
you must run a compaction. </para>
<para>The <emphasis>check</emphasis> step prints stats at the end of its run (grep
for “Result:” in the log) printing absolute path of the tables it scanned, any
HFileV1 files found, the regions containing said files (the regions we need to
major compact to purge the HFileV1s), and any corrupted files if any found. A
corrupt file is unreadable, and so is undefined (neither HFileV1 nor HFileV2). </para>
<para>To run the check step, run <command>$ bin/hbase upgrade -check</command>. Here
is sample output:</para>
<screen>
Tables Processed:
hdfs://localhost:41020/myHBase/.META.
hdfs://localhost:41020/myHBase/usertable
hdfs://localhost:41020/myHBase/TestTable
hdfs://localhost:41020/myHBase/t
Count of HFileV1: 2
HFileV1:
hdfs://localhost:41020/myHBase/usertable /fa02dac1f38d03577bd0f7e666f12812/family/249450144068442524
hdfs://localhost:41020/myHBase/usertable /ecdd3eaee2d2fcf8184ac025555bb2af/family/249450144068442512
Count of corrupted files: 1
Corrupted Files:
hdfs://localhost:41020/myHBase/usertable/fa02dac1f38d03577bd0f7e666f12812/family/1
Count of Regions with HFileV1: 2
Regions to Major Compact:
hdfs://localhost:41020/myHBase/usertable/fa02dac1f38d03577bd0f7e666f12812
hdfs://localhost:41020/myHBase/usertable/ecdd3eaee2d2fcf8184ac025555bb2af
There are some HFileV1, or corrupt files (files with incorrect major version)
</screen>
<para>In the above sample output, there are two HFileV1 in two regions, and one
corrupt file. Corrupt files should probably be removed. The regions that have
HFileV1s need to be major compacted. To major compact, start up the hbase shell
and review how to compact an individual region. After the major compaction is
done, rerun the check step and the HFileV1s shoudl be gone, replaced by HFileV2
instances. </para>
<para>By default, the check step scans the hbase root directory (defined as
hbase.rootdir in the configuration). To scan a specific directory only, pass the
<emphasis>-dir</emphasis> option.</para>
<screen language="bourne">$ bin/hbase upgrade -check -dir /myHBase/testTable</screen>
<para>The above command would detect HFileV1s in the /myHBase/testTable directory. </para>
<para> Once the check step reports all the HFileV1 files have been rewritten, it is
safe to proceed with the upgrade. </para>
</section>
<section>
<title>execute</title>
<para>After the check step shows the cluster is free of HFileV1, it is safe to
proceed with the upgrade. Next is the <emphasis>execute</emphasis> step. You
must <emphasis>SHUTDOWN YOUR 0.94.x CLUSTER</emphasis> before you can run the
<emphasis>execute</emphasis> step. The execute step will not run if it
detects running HBase masters or regionservers. <note>
<para>HDFS and ZooKeeper should be up and running during the upgrade
process. If zookeeper is managed by HBase, then you can start zookeeper
so it is available to the upgrade by running <command>$
./hbase/bin/hbase-daemon.sh start zookeeper</command>
</para>
</note>
</para>
<para> The <emphasis>execute</emphasis> upgrade step is made of three substeps. </para>
<itemizedlist>
<listitem>
<para>Namespaces: HBase 0.96.0 has support for namespaces. The upgrade needs
to reorder directories in the filesystem for namespaces to work.</para>
</listitem>
<listitem>
<para>ZNodes: All znodes are purged so that new ones can be written in their
place using a new protobuf'ed format and a few are migrated in place:
e.g. replication and table state znodes</para>
</listitem>
<listitem>
<para>WAL Log Splitting: If the 0.94.x cluster shutdown was not clean, we'll
split WAL logs as part of migration before we startup on 0.96.0. This
WAL splitting runs slower than the native distributed WAL splitting
because it is all inside the single upgrade process (so try and get a
clean shutdown of the 0.94.0 cluster if you can). </para>
</listitem>
</itemizedlist>
<para> To run the <emphasis>execute</emphasis> step, make sure that first you have
copied hbase-0.96.0 binaries everywhere under servers and under clients. Make
sure the 0.94.0 cluster is down. Then do as follows:</para>
<screen language="bourne">$ bin/hbase upgrade -execute</screen>
<para>Here is some sample output.</para>
<programlisting>
Starting Namespace upgrade
Created version file at hdfs://localhost:41020/myHBase with version=7
Migrating table testTable to hdfs://localhost:41020/myHBase/.data/default/testTable
…..
Created version file at hdfs://localhost:41020/myHBase with version=8
Successfully completed NameSpace upgrade.
Starting Znode upgrade
….
Successfully completed Znode upgrade
Starting Log splitting
Successfully completed Log splitting
</programlisting>
<para> If the output from the execute step looks good, stop the zookeeper instance
you started to do the upgrade:
<programlisting language="bourne">$ ./hbase/bin/hbase-daemon.sh stop zookeeper</programlisting>
Now start up hbase-0.96.0. </para>
</section>
<section
xml:id="s096.migration.troubleshooting">
<title>Troubleshooting</title>
<section
xml:id="s096.migration.troubleshooting.old.client">
<title>Old Client connecting to 0.96 cluster</title>
<para>It will fail with an exception like the below. Upgrade.</para>
<screen>17:22:15 Exception in thread "main" java.lang.IllegalArgumentException: Not a host:port pair: PBUF
17:22:15 *
17:22:15 api-compat-8.ent.cloudera.com <20><> <20><><EFBFBD>(
17:22:15 at org.apache.hadoop.hbase.util.Addressing.parseHostname(Addressing.java:60)
17:22:15 at org.apache.hadoop.hbase.ServerName.&amp;init>(ServerName.java:101)
17:22:15 at org.apache.hadoop.hbase.ServerName.parseVersionedServerName(ServerName.java:283)
17:22:15 at org.apache.hadoop.hbase.MasterAddressTracker.bytesToServerName(MasterAddressTracker.java:77)
17:22:15 at org.apache.hadoop.hbase.MasterAddressTracker.getMasterAddress(MasterAddressTracker.java:61)
17:22:15 at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:703)
17:22:15 at org.apache.hadoop.hbase.client.HBaseAdmin.&amp;init>(HBaseAdmin.java:126)
17:22:15 at Client_4_3_0.setup(Client_4_3_0.java:716)
17:22:15 at Client_4_3_0.main(Client_4_3_0.java:63)</screen>
</section>
</section>
<section>
<title>Upgrading <code>META</code> to use Protocol Buffers (Protobuf)</title>
<para>When you upgrade from versions prior to 0.96, <code>META</code> needs to be
converted to use protocol buffers. This is controlled by the configuration
option <option>hbase.MetaMigrationConvertingToPB</option>, which is set to
<literal>true</literal> by default. Therefore, by default, no action is
required on your part.</para>
<para>The migration is a one-time event. However, every time your cluster starts,
<code>META</code> is scanned to ensure that it does not need to be
converted. If you have a very large number of regions, this scan can take a long
time. Starting in 0.98.5, you can set
<option>hbase.MetaMigrationConvertingToPB</option> to
<literal>false</literal> in <filename>hbase-site.xml</filename>, to disable
this start-up scan. This should be considered an expert-level setting.</para>
</section>
</section>
</section>
<section
xml:id="upgrade0.94">
<title>Upgrading from 0.92.x to 0.94.x</title>
<para>We used to think that 0.92 and 0.94 were interface compatible and that you can do a
rolling upgrade between these versions but then we figured that <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-5357">HBASE-5357 Use builder
pattern in HColumnDescriptor</link> changed method signatures so rather than return
void they instead return HColumnDescriptor. This will throw</para>
<screen>java.lang.NoSuchMethodError: org.apache.hadoop.hbase.HColumnDescriptor.setMaxVersions(I)V</screen>
<para>.... so 0.92 and 0.94 are NOT compatible. You cannot do a rolling upgrade between them.</para> </section>
<section
xml:id="upgrade0.92">
<title>Upgrading from 0.90.x to 0.92.x</title>
<subtitle>Upgrade Guide</subtitle>
<para>You will find that 0.92.0 runs a little differently to 0.90.x releases. Here are a few
things to watch out for upgrading from 0.90.x to 0.92.0. </para>
<note>
<title>tl;dr</title>
<para> If you've not patience, here are the important things to know upgrading. <orderedlist>
<listitem>
<para>Once you upgrade, you cant go back.</para>
</listitem>
<listitem>
<para> MSLAB is on by default. Watch that heap usage if you have a lot of
regions.</para>
</listitem>
<listitem>
<para> Distributed Log Splitting is on by default. It should make region server
failover faster. </para>
</listitem>
<listitem>
<para> Theres a separate tarball for security. </para>
</listitem>
<listitem>
<para> If -XX:MaxDirectMemorySize is set in your hbase-env.sh, its going to
enable the experimental off-heap cache (You may not want this). </para>
</listitem>
</orderedlist>
</para>
</note>
<section>
<title>You cant go back! </title>
<para>To move to 0.92.0, all you need to do is shutdown your cluster, replace your hbase
0.90.x with hbase 0.92.0 binaries (be sure you clear out all 0.90.x instances) and
restart (You cannot do a rolling restart from 0.90.x to 0.92.x -- you must restart).
On startup, the <varname>.META.</varname> table content is rewritten removing the
table schema from the <varname>info:regioninfo</varname> column. Also, any flushes
done post first startup will write out data in the new 0.92.0 file format, <link
xlink:href="http://hbase.apache.org/book.html#hfilev2">HFile V2</link>. This
means you cannot go back to 0.90.x once youve started HBase 0.92.0 over your HBase
data directory. </para>
</section>
<section>
<title>MSLAB is ON by default </title>
<para>In 0.92.0, the <link
xlink:href="http://hbase.apache.org/book.html#hbase.hregion.memstore.mslab.enabled">hbase.hregion.memstore.mslab.enabled</link>
flag is set to true (See <xref
linkend="mslab" />). In 0.90.x it was <constant>false</constant>. When it is
enabled, memstores will step allocate memory in MSLAB 2MB chunks even if the
memstore has zero or just a few small elements. This is fine usually but if you had
lots of regions per regionserver in a 0.90.x cluster (and MSLAB was off), you may
find yourself OOME'ing on upgrade because the <code>thousands of regions * number of
column families * 2MB MSLAB (at a minimum)</code> puts your heap over the top.
Set <varname>hbase.hregion.memstore.mslab.enabled</varname> to
<constant>false</constant> or set the MSLAB size down from 2MB by setting
<varname>hbase.hregion.memstore.mslab.chunksize</varname> to something less.
</para>
</section>
<section xml:id="dls">
<title>Distributed Log Splitting is on by default </title>
<para>Previous, WAL logs on crash were split by the Master alone. In 0.92.0, log
splitting is done by the cluster (See See “HBASE-1364 [performance] Distributed
splitting of regionserver commit logs” or see the blog post
<link xlink:href="http://blog.cloudera.com/blog/2012/07/hbase-log-splitting/">Apache HBase Log Splitting</link>).
This should cut down significantly on the
amount of time it takes splitting logs and getting regions back online again.
</para>
</section>
<section>
<title>Memory accounting is different now </title>
<para>In 0.92.0, <xref
linkend="hfilev2" /> indices and bloom filters take up residence in the same LRU
used caching blocks that come from the filesystem. In 0.90.x, the HFile v1 indices
lived outside of the LRU so they took up space even if the index was on a cold
file, one that wasnt being actively used. With the indices now in the LRU, you may
find you have less space for block caching. Adjust your block cache accordingly. See
the <xref
linkend="block.cache" /> for more detail. The block size default size has been
changed in 0.92.0 from 0.2 (20 percent of heap) to 0.25. </para>
</section>
<section>
<title>On the Hadoop version to use </title>
<para>Run 0.92.0 on Hadoop 1.0.x (or CDH3u3 when it ships). The performance benefits are
worth making the move. Otherwise, our Hadoop prescription is as it has been; you
need an Hadoop that supports a working sync. See <xref
linkend="hadoop" />. </para>
<para>If running on Hadoop 1.0.x (or CDH3u3), enable local read. See <link
xlink:href="http://files.meetup.com/1350427/hug_ebay_jdcryans.pdf">Practical
Caching</link> presentation for ruminations on the performance benefits going
local (and for how to enable local reads). </para>
</section>
<section>
<title>HBase 0.92.0 ships with ZooKeeper 3.4.2 </title>
<para>If you can, upgrade your zookeeper. If you cant, 3.4.2 clients should work
against 3.3.X ensembles (HBase makes use of 3.4.2 API). </para>
</section>
<section>
<title>Online alter is off by default </title>
<para>In 0.92.0, weve added an experimental online schema alter facility (See <xref
linkend="hbase.online.schema.update.enable" />). Its off by default. Enable it
at your own risk. Online alter and splitting tables do not play well together so be
sure your cluster quiescent using this feature (for now). </para>
</section>
<section>
<title>WebUI </title>
<para>The webui has had a few additions made in 0.92.0. It now shows a list of the
regions currently transitioning, recent compactions/flushes, and a process list of
running processes (usually empty if all is well and requests are being handled
promptly). Other additions including requests by region, a debugging servlet dump,
etc. </para>
</section>
<section>
<title>Security tarball </title>
<para>We now ship with two tarballs; secure and insecure HBase. Documentation on how to
setup a secure HBase is on the way. </para>
</section>
<section>
<title>Changes in HBase replication </title>
<para>0.92.0 adds two new features: multi-slave and multi-master replication. The way to
enable this is the same as adding a new peer, so in order to have multi-master you
would just run add_peer for each cluster that acts as a master to the other slave
clusters. Collisions are handled at the timestamp level which may or may not be what
you want, this needs to be evaluated on a per use case basis. Replication is still
experimental in 0.92 and is disabled by default, run it at your own risk. </para>
</section>
<section>
<title>RegionServer now aborts if OOME </title>
<para>If an OOME, we now have the JVM kill -9 the regionserver process so it goes down
fast. Previous, a RegionServer might stick around after incurring an OOME limping
along in some wounded state. To disable this facility, and recommend you leave it in
place, youd need to edit the bin/hbase file. Look for the addition of the
-XX:OnOutOfMemoryError="kill -9 %p" arguments (See [HBASE-4769] - Abort
RegionServer Immediately on OOME) </para>
</section>
<section>
<title>HFile V2 and the “Bigger, Fewer” Tendency </title>
<para>0.92.0 stores data in a new format, <xref
linkend="hfilev2" />. As HBase runs, it will move all your data from HFile v1 to
HFile v2 format. This auto-migration will run in the background as flushes and
compactions run. HFile V2 allows HBase run with larger regions/files. In fact, we
encourage that all HBasers going forward tend toward Facebook axiom #1, run with
larger, fewer regions. If you have lots of regions now -- more than 100s per host --
you should look into setting your region size up after you move to 0.92.0 (In
0.92.0, default size is now 1G, up from 256M), and then running online merge tool
(See “HBASE-1621 merge tool should work on online cluster, but disabled table”).
</para>
</section>
</section>
<section
xml:id="upgrade0.90">
<title>Upgrading to HBase 0.90.x from 0.20.x or 0.89.x</title>
<para>This version of 0.90.x HBase can be started on data written by HBase 0.20.x or HBase
0.89.x. There is no need of a migration step. HBase 0.89.x and 0.90.x does write out the
name of region directories differently -- it names them with a md5 hash of the region
name rather than a jenkins hash -- so this means that once started, there is no going
back to HBase 0.20.x. </para>
<para> Be sure to remove the <filename>hbase-default.xml</filename> from your
<filename>conf</filename> directory on upgrade. A 0.20.x version of this file will
have sub-optimal configurations for 0.90.x HBase. The
<filename>hbase-default.xml</filename> file is now bundled into the HBase jar and
read from there. If you would like to review the content of this file, see it in the src
tree at <filename>src/main/resources/hbase-default.xml</filename> or see <xref
linkend="hbase_default_configurations" />. </para>
<para> Finally, if upgrading from 0.20.x, check your <varname>.META.</varname> schema in the
shell. In the past we would recommend that users run with a 16kb
<varname>MEMSTORE_FLUSHSIZE</varname>. Run <code>hbase> scan '-ROOT-'</code> in the
shell. This will output the current <varname>.META.</varname> schema. Check
<varname>MEMSTORE_FLUSHSIZE</varname> size. Is it 16kb (16384)? If so, you will need
to change this (The 'normal'/default value is 64MB (67108864)). Run the script
<filename>bin/set_meta_memstore_size.rb</filename>. This will make the necessary
edit to your <varname>.META.</varname> schema. Failure to run this change will make for
a slow cluster. See <link
xlink:href="https://issues.apache.org/jira/browse/HBASE-3499">HBASE-3499
Users upgrading to 0.90.0 need to have their .META. table updated with the
right MEMSTORE_SIZE</link>
</para>
</section>
</chapter>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<appendix xml:id="ycsb" version="5.0" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:db="http://docbook.org/ns/docbook">
<!--/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>YCSB</title>
<para><link xlink:href="https://github.com/brianfrankcooper/YCSB/">YCSB: The
Yahoo! Cloud Serving Benchmark</link> and HBase</para>
<para>TODO: Describe how YCSB is poor for putting up a decent cluster load.</para>
<para>TODO: Describe setup of YCSB for HBase. In particular, presplit your tables before you
start a run. See <link xlink:href="https://issues.apache.org/jira/browse/HBASE-4163"
>HBASE-4163 Create Split Strategy for YCSB Benchmark</link> for why and a little shell
command for how to do it.</para>
<para>Ted Dunning redid YCSB so it's mavenized and added facility for verifying workloads. See
<link xlink:href="https://github.com/tdunning/YCSB">Ted Dunning's YCSB</link>.</para>
</appendix>

View File

@ -1,513 +0,0 @@
<?xml version="1.0"?>
<chapter
xml:id="zookeeper"
version="5.0"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<title>ZooKeeper<indexterm>
<primary>ZooKeeper</primary>
</indexterm></title>
<para>A distributed Apache HBase installation depends on a running ZooKeeper cluster. All
participating nodes and clients need to be able to access the running ZooKeeper ensemble. Apache
HBase by default manages a ZooKeeper "cluster" for you. It will start and stop the ZooKeeper
ensemble as part of the HBase start/stop process. You can also manage the ZooKeeper ensemble
independent of HBase and just point HBase at the cluster it should use. To toggle HBase
management of ZooKeeper, use the <varname>HBASE_MANAGES_ZK</varname> variable in
<filename>conf/hbase-env.sh</filename>. This variable, which defaults to
<varname>true</varname>, tells HBase whether to start/stop the ZooKeeper ensemble servers as
part of HBase start/stop.</para>
<para>When HBase manages the ZooKeeper ensemble, you can specify ZooKeeper configuration using its
native <filename>zoo.cfg</filename> file, or, the easier option is to just specify ZooKeeper
options directly in <filename>conf/hbase-site.xml</filename>. A ZooKeeper configuration option
can be set as a property in the HBase <filename>hbase-site.xml</filename> XML configuration file
by prefacing the ZooKeeper option name with <varname>hbase.zookeeper.property</varname>. For
example, the <varname>clientPort</varname> setting in ZooKeeper can be changed by setting the
<varname>hbase.zookeeper.property.clientPort</varname> property. For all default values used
by HBase, including ZooKeeper configuration, see <xref
linkend="hbase_default_configurations" />. Look for the
<varname>hbase.zookeeper.property</varname> prefix. For the full list of ZooKeeper configurations, see ZooKeeper's
<filename>zoo.cfg</filename>. HBase does not ship with a <filename>zoo.cfg</filename> so
you will need to browse the <filename>conf</filename> directory in an appropriate ZooKeeper
download.</para>
<para>You must at least list the ensemble servers in <filename>hbase-site.xml</filename> using the
<varname>hbase.zookeeper.quorum</varname> property. This property defaults to a single
ensemble member at <varname>localhost</varname> which is not suitable for a fully distributed
HBase. (It binds to the local machine only and remote clients will not be able to connect). </para>
<note
xml:id="how_many_zks">
<title>How many ZooKeepers should I run?</title>
<para>You can run a ZooKeeper ensemble that comprises 1 node only but in production it is
recommended that you run a ZooKeeper ensemble of 3, 5 or 7 machines; the more members an
ensemble has, the more tolerant the ensemble is of host failures. Also, run an odd number of
machines. In ZooKeeper, an even number of peers is supported, but it is normally not used
because an even sized ensemble requires, proportionally, more peers to form a quorum than an
odd sized ensemble requires. For example, an ensemble with 4 peers requires 3 to form a
quorum, while an ensemble with 5 also requires 3 to form a quorum. Thus, an ensemble of 5
allows 2 peers to fail, and thus is more fault tolerant than the ensemble of 4, which allows
only 1 down peer. </para>
<para>Give each ZooKeeper server around 1GB of RAM, and if possible, its own dedicated disk (A
dedicated disk is the best thing you can do to ensure a performant ZooKeeper ensemble). For
very heavily loaded clusters, run ZooKeeper servers on separate machines from RegionServers
(DataNodes and TaskTrackers).</para>
</note>
<para>For example, to have HBase manage a ZooKeeper quorum on nodes
<emphasis>rs{1,2,3,4,5}.example.com</emphasis>, bound to port 2222 (the default is 2181)
ensure <varname>HBASE_MANAGE_ZK</varname> is commented out or set to <varname>true</varname> in
<filename>conf/hbase-env.sh</filename> and then edit <filename>conf/hbase-site.xml</filename>
and set <varname>hbase.zookeeper.property.clientPort</varname> and
<varname>hbase.zookeeper.quorum</varname>. You should also set
<varname>hbase.zookeeper.property.dataDir</varname> to other than the default as the default
has ZooKeeper persist data under <filename>/tmp</filename> which is often cleared on system
restart. In the example below we have ZooKeeper persist to
<filename>/user/local/zookeeper</filename>.</para>
<programlisting language="java"><![CDATA[
<configuration>
...
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value>
<description>Property from ZooKeeper's config zoo.cfg.
The port at which the clients will connect.
</description>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>rs1.example.com,rs2.example.com,rs3.example.com,rs4.example.com,rs5.example.com</value>
<description>Comma separated list of servers in the ZooKeeper Quorum.
For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
By default this is set to localhost for local and pseudo-distributed modes
of operation. For a fully-distributed setup, this should be set to a full
list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh
this is the list of servers which we will start/stop ZooKeeper on.
</description>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/zookeeper</value>
<description>Property from ZooKeeper's config zoo.cfg.
The directory where the snapshot is stored.
</description>
</property>
...
</configuration>]]></programlisting>
<caution
xml:id="zk.version">
<title>What verion of ZooKeeper should I use?</title>
<para>The newer version, the better. For example, some folks have been bitten by <link
xlink:href="https://issues.apache.org/jira/browse/ZOOKEEPER-1277">ZOOKEEPER-1277</link>. If
running zookeeper 3.5+, you can ask hbase to make use of the new multi operation by enabling <xref
linkend="hbase.zookeeper.useMulti" />" in your <filename>hbase-site.xml</filename>. </para>
</caution>
<caution>
<title>ZooKeeper Maintenance</title>
<para>Be sure to set up the data dir cleaner described under <link
xlink:href="http://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_maintenance">Zookeeper
Maintenance</link> else you could have 'interesting' problems a couple of months in; i.e.
zookeeper could start dropping sessions if it has to run through a directory of hundreds of
thousands of logs which is wont to do around leader reelection time -- a process rare but run
on occasion whether because a machine is dropped or happens to hiccup.</para>
</caution>
<section>
<title>Using existing ZooKeeper ensemble</title>
<para>To point HBase at an existing ZooKeeper cluster, one that is not managed by HBase, set
<varname>HBASE_MANAGES_ZK</varname> in <filename>conf/hbase-env.sh</filename> to
false</para>
<screen language="bourne">
...
# Tell HBase whether it should manage its own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=false</screen>
<para>Next set ensemble locations and client port, if non-standard, in
<filename>hbase-site.xml</filename>, or add a suitably configured
<filename>zoo.cfg</filename> to HBase's <filename>CLASSPATH</filename>. HBase will prefer
the configuration found in <filename>zoo.cfg</filename> over any settings in
<filename>hbase-site.xml</filename>.</para>
<para>When HBase manages ZooKeeper, it will start/stop the ZooKeeper servers as a part of the
regular start/stop scripts. If you would like to run ZooKeeper yourself, independent of HBase
start/stop, you would do the following</para>
<screen language="bourne">
${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper
</screen>
<para>Note that you can use HBase in this manner to spin up a ZooKeeper cluster, unrelated to
HBase. Just make sure to set <varname>HBASE_MANAGES_ZK</varname> to <varname>false</varname>
if you want it to stay up across HBase restarts so that when HBase shuts down, it doesn't take
ZooKeeper down with it.</para>
<para>For more information about running a distinct ZooKeeper cluster, see the ZooKeeper <link
xlink:href="http://hadoop.apache.org/zookeeper/docs/current/zookeeperStarted.html">Getting
Started Guide</link>. Additionally, see the <link
xlink:href="http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A7">ZooKeeper Wiki</link> or the <link
xlink:href="http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_zkMulitServerSetup">ZooKeeper
documentation</link> for more information on ZooKeeper sizing. </para>
</section>
<section
xml:id="zk.sasl.auth">
<title>SASL Authentication with ZooKeeper</title>
<para>Newer releases of Apache HBase (&gt;= 0.92) will support connecting to a ZooKeeper Quorum
that supports SASL authentication (which is available in Zookeeper versions 3.4.0 or
later).</para>
<para>This describes how to set up HBase to mutually authenticate with a ZooKeeper Quorum.
ZooKeeper/HBase mutual authentication (<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-2418">HBASE-2418</link>) is required
as part of a complete secure HBase configuration (<link
xlink:href="https://issues.apache.org/jira/browse/HBASE-3025">HBASE-3025</link>). For
simplicity of explication, this section ignores additional configuration required (Secure HDFS
and Coprocessor configuration). It's recommended to begin with an HBase-managed Zookeeper
configuration (as opposed to a standalone Zookeeper quorum) for ease of learning. </para>
<section>
<title>Operating System Prerequisites</title>
<para> You need to have a working Kerberos KDC setup. For each <code>$HOST</code> that will
run a ZooKeeper server, you should have a principle <code>zookeeper/$HOST</code>. For each
such host, add a service key (using the <code>kadmin</code> or <code>kadmin.local</code>
tool's <code>ktadd</code> command) for <code>zookeeper/$HOST</code> and copy this file to
<code>$HOST</code>, and make it readable only to the user that will run zookeeper on
<code>$HOST</code>. Note the location of this file, which we will use below as
<filename>$PATH_TO_ZOOKEEPER_KEYTAB</filename>. </para>
<para> Similarly, for each <code>$HOST</code> that will run an HBase server (master or
regionserver), you should have a principle: <code>hbase/$HOST</code>. For each host, add a
keytab file called <filename>hbase.keytab</filename> containing a service key for
<code>hbase/$HOST</code>, copy this file to <code>$HOST</code>, and make it readable only
to the user that will run an HBase service on <code>$HOST</code>. Note the location of this
file, which we will use below as <filename>$PATH_TO_HBASE_KEYTAB</filename>. </para>
<para> Each user who will be an HBase client should also be given a Kerberos principal. This
principal should usually have a password assigned to it (as opposed to, as with the HBase
servers, a keytab file) which only this user knows. The client's principal's
<code>maxrenewlife</code> should be set so that it can be renewed enough so that the user
can complete their HBase client processes. For example, if a user runs a long-running HBase
client process that takes at most 3 days, we might create this user's principal within
<code>kadmin</code> with: <code>addprinc -maxrenewlife 3days</code>. The Zookeeper client
and server libraries manage their own ticket refreshment by running threads that wake up
periodically to do the refreshment. </para>
<para>On each host that will run an HBase client (e.g. <code>hbase shell</code>), add the
following file to the HBase home directory's <filename>conf</filename> directory:</para>
<programlisting language="java">
Client {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=false
useTicketCache=true;
};
</programlisting>
<para>We'll refer to this JAAS configuration file as <filename>$CLIENT_CONF</filename>
below.</para>
</section>
<section>
<title>HBase-managed Zookeeper Configuration</title>
<para>On each node that will run a zookeeper, a master, or a regionserver, create a <link
xlink:href="http://docs.oracle.com/javase/1.4.2/docs/guide/security/jgss/tutorials/LoginConfigFile.html">JAAS</link>
configuration file in the conf directory of the node's <filename>HBASE_HOME</filename>
directory that looks like the following:</para>
<programlisting language="java">
Server {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
keyTab="$PATH_TO_ZOOKEEPER_KEYTAB"
storeKey=true
useTicketCache=false
principal="zookeeper/$HOST";
};
Client {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
useTicketCache=false
keyTab="$PATH_TO_HBASE_KEYTAB"
principal="hbase/$HOST";
};
</programlisting>
<para>where the <filename>$PATH_TO_HBASE_KEYTAB</filename> and
<filename>$PATH_TO_ZOOKEEPER_KEYTAB</filename> files are what you created above, and
<code>$HOST</code> is the hostname for that node.</para>
<para>The <code>Server</code> section will be used by the Zookeeper quorum server, while the
<code>Client</code> section will be used by the HBase master and regionservers. The path
to this file should be substituted for the text <filename>$HBASE_SERVER_CONF</filename> in
the <filename>hbase-env.sh</filename> listing below.</para>
<para> The path to this file should be substituted for the text
<filename>$CLIENT_CONF</filename> in the <filename>hbase-env.sh</filename> listing below. </para>
<para>Modify your <filename>hbase-env.sh</filename> to include the following:</para>
<programlisting language="bourne">
export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF"
export HBASE_MANAGES_ZK=true
export HBASE_ZOOKEEPER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF"
export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF"
export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF"
</programlisting>
<para>where <filename>$HBASE_SERVER_CONF</filename> and <filename>$CLIENT_CONF</filename> are
the full paths to the JAAS configuration files created above.</para>
<para>Modify your <filename>hbase-site.xml</filename> on each node that will run zookeeper,
master or regionserver to contain:</para>
<programlisting language="java"><![CDATA[
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>$ZK_NODES</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.property.authProvider.1</name>
<value>org.apache.zookeeper.server.auth.SASLAuthenticationProvider</value>
</property>
<property>
<name>hbase.zookeeper.property.kerberos.removeHostFromPrincipal</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.property.kerberos.removeRealmFromPrincipal</name>
<value>true</value>
</property>
</configuration>
]]></programlisting>
<para>where <code>$ZK_NODES</code> is the comma-separated list of hostnames of the Zookeeper
Quorum hosts.</para>
<para>Start your hbase cluster by running one or more of the following set of commands on the
appropriate hosts: </para>
<screen>
bin/hbase zookeeper start
bin/hbase master start
bin/hbase regionserver start
</screen>
</section>
<section>
<title>External Zookeeper Configuration</title>
<para>Add a JAAS configuration file that looks like:</para>
<programlisting language="java">
Client {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
useTicketCache=false
keyTab="$PATH_TO_HBASE_KEYTAB"
principal="hbase/$HOST";
};
</programlisting>
<para>where the <filename>$PATH_TO_HBASE_KEYTAB</filename> is the keytab created above for
HBase services to run on this host, and <code>$HOST</code> is the hostname for that node.
Put this in the HBase home's configuration directory. We'll refer to this file's full
pathname as <filename>$HBASE_SERVER_CONF</filename> below.</para>
<para>Modify your hbase-env.sh to include the following:</para>
<programlisting language="bourne">
export HBASE_OPTS="-Djava.security.auth.login.config=$CLIENT_CONF"
export HBASE_MANAGES_ZK=false
export HBASE_MASTER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF"
export HBASE_REGIONSERVER_OPTS="-Djava.security.auth.login.config=$HBASE_SERVER_CONF"
</programlisting>
<para>Modify your <filename>hbase-site.xml</filename> on each node that will run a master or
regionserver to contain:</para>
<programlisting language="xml"><![CDATA[
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>$ZK_NODES</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
</configuration>
]]>
</programlisting>
<para>where <code>$ZK_NODES</code> is the comma-separated list of hostnames of the Zookeeper
Quorum hosts.</para>
<para> Add a <filename>zoo.cfg</filename> for each Zookeeper Quorum host containing:</para>
<programlisting language="java">
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
kerberos.removeHostFromPrincipal=true
kerberos.removeRealmFromPrincipal=true
</programlisting>
<para>Also on each of these hosts, create a JAAS configuration file containing:</para>
<programlisting language="java">
Server {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
keyTab="$PATH_TO_ZOOKEEPER_KEYTAB"
storeKey=true
useTicketCache=false
principal="zookeeper/$HOST";
};
</programlisting>
<para>where <code>$HOST</code> is the hostname of each Quorum host. We will refer to the full
pathname of this file as <filename>$ZK_SERVER_CONF</filename> below. </para>
<para> Start your Zookeepers on each Zookeeper Quorum host with:</para>
<programlisting language="bourne">
SERVER_JVMFLAGS="-Djava.security.auth.login.config=$ZK_SERVER_CONF" bin/zkServer start
</programlisting>
<para> Start your HBase cluster by running one or more of the following set of commands on the
appropriate nodes: </para>
<screen>
bin/hbase master start
bin/hbase regionserver start
</screen>
</section>
<section>
<title>Zookeeper Server Authentication Log Output</title>
<para>If the configuration above is successful, you should see something similar to the
following in your Zookeeper server logs:</para>
<screen>
11/12/05 22:43:39 INFO zookeeper.Login: successfully logged in.
11/12/05 22:43:39 INFO server.NIOServerCnxnFactory: binding to port 0.0.0.0/0.0.0.0:2181
11/12/05 22:43:39 INFO zookeeper.Login: TGT refresh thread started.
11/12/05 22:43:39 INFO zookeeper.Login: TGT valid starting at: Mon Dec 05 22:43:39 UTC 2011
11/12/05 22:43:39 INFO zookeeper.Login: TGT expires: Tue Dec 06 22:43:39 UTC 2011
11/12/05 22:43:39 INFO zookeeper.Login: TGT refresh sleeping until: Tue Dec 06 18:36:42 UTC 2011
..
11/12/05 22:43:59 INFO auth.SaslServerCallbackHandler:
Successfully authenticated client: authenticationID=hbase/ip-10-166-175-249.us-west-1.compute.internal@HADOOP.LOCALDOMAIN;
authorizationID=hbase/ip-10-166-175-249.us-west-1.compute.internal@HADOOP.LOCALDOMAIN.
11/12/05 22:43:59 INFO auth.SaslServerCallbackHandler: Setting authorizedID: hbase
11/12/05 22:43:59 INFO server.ZooKeeperServer: adding SASL authorization for authorizationID: hbase
</screen>
</section>
<section>
<title>Zookeeper Client Authentication Log Output</title>
<para>On the Zookeeper client side (HBase master or regionserver), you should see something
similar to the following:</para>
<screen>
11/12/05 22:43:59 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=ip-10-166-175-249.us-west-1.compute.internal:2181 sessionTimeout=180000 watcher=master:60000
11/12/05 22:43:59 INFO zookeeper.ClientCnxn: Opening socket connection to server /10.166.175.249:2181
11/12/05 22:43:59 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 14851@ip-10-166-175-249
11/12/05 22:43:59 INFO zookeeper.Login: successfully logged in.
11/12/05 22:43:59 INFO client.ZooKeeperSaslClient: Client will use GSSAPI as SASL mechanism.
11/12/05 22:43:59 INFO zookeeper.Login: TGT refresh thread started.
11/12/05 22:43:59 INFO zookeeper.ClientCnxn: Socket connection established to ip-10-166-175-249.us-west-1.compute.internal/10.166.175.249:2181, initiating session
11/12/05 22:43:59 INFO zookeeper.Login: TGT valid starting at: Mon Dec 05 22:43:59 UTC 2011
11/12/05 22:43:59 INFO zookeeper.Login: TGT expires: Tue Dec 06 22:43:59 UTC 2011
11/12/05 22:43:59 INFO zookeeper.Login: TGT refresh sleeping until: Tue Dec 06 18:30:37 UTC 2011
11/12/05 22:43:59 INFO zookeeper.ClientCnxn: Session establishment complete on server ip-10-166-175-249.us-west-1.compute.internal/10.166.175.249:2181, sessionid = 0x134106594320000, negotiated timeout = 180000
</screen>
</section>
<section>
<title>Configuration from Scratch</title>
<para>This has been tested on the current standard Amazon Linux AMI. First setup KDC and
principals as described above. Next checkout code and run a sanity check.</para>
<screen>
git clone git://git.apache.org/hbase.git
cd hbase
mvn clean test -Dtest=TestZooKeeperACL
</screen>
<para>Then configure HBase as described above. Manually edit target/cached_classpath.txt (see
below): </para>
<screen>
bin/hbase zookeeper &amp;
bin/hbase master &amp;
bin/hbase regionserver &amp;
</screen>
</section>
<section>
<title>Future improvements</title>
<section>
<title>Fix target/cached_classpath.txt</title>
<para> You must override the standard hadoop-core jar file from the
<code>target/cached_classpath.txt</code> file with the version containing the
HADOOP-7070 fix. You can use the following script to do this:</para>
<screen language="bourne">
echo `find ~/.m2 -name "*hadoop-core*7070*SNAPSHOT.jar"` ':' `cat target/cached_classpath.txt` | sed 's/ //g' > target/tmp.txt
mv target/tmp.txt target/cached_classpath.txt
</screen>
</section>
<section>
<title>Set JAAS configuration programmatically</title>
<para>This would avoid the need for a separate Hadoop jar that fixes <link
xlink:href="https://issues.apache.org/jira/browse/HADOOP-7070">HADOOP-7070</link>.
</para>
</section>
<section>
<title>Elimination of <code>kerberos.removeHostFromPrincipal</code> and
<code>kerberos.removeRealmFromPrincipal</code></title>
<para />
</section>
</section>
</section>
<!-- SASL Authentication with ZooKeeper -->
</chapter>

View File

@ -1,66 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="configuration">
<!--
/**
* Copyright 2010 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
This stylesheet is used making an html version of hbase-default.xml.
-->
<glossary xml:id="hbase_default_configurations"
version="5.0" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<title>HBase Default Configuration</title>
<para>
The documentation below is generated using the default hbase configuration file,
<filename>hbase-default.xml</filename>, as source.
</para>
<xsl:for-each select="property">
<xsl:if test="not(@skipInDoc)">
<glossentry>
<xsl:attribute name="xml:id">
<xsl:value-of select="name" />
</xsl:attribute>
<glossterm>
<varname><xsl:value-of select="name"/></varname>
</glossterm>
<glossdef>
<para><xsl:value-of select="description"/></para>
<formalpara>
<title>Default</title>
<para><varname><xsl:value-of select="value"/></varname></para>
</formalpara>
</glossdef>
</glossentry>
</xsl:if>
</xsl:for-each>
</glossary>
</xsl:template>
</xsl:stylesheet>