2011-03-25 06:19:18 +00:00
|
|
|
<?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">
|
2011-10-23 21:19:23 +00:00
|
|
|
<!--
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
-->
|
2011-03-25 06:19:18 +00:00
|
|
|
<title>Getting Started</title>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<title>Introduction</title>
|
|
|
|
|
2011-04-22 19:07:56 +00:00
|
|
|
<para><xref linkend="quickstart" /> will get you up and
|
2011-06-22 05:39:32 +00:00
|
|
|
running on a single-node instance of HBase using the local filesystem.
|
|
|
|
<xref linkend="configuration" /> describes setup
|
2011-03-25 06:19:18 +00:00
|
|
|
of HBase in distributed mode running on top of HDFS.</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section xml:id="quickstart">
|
|
|
|
<title>Quick Start</title>
|
|
|
|
|
|
|
|
<para>This guide describes setup of a standalone HBase instance that uses
|
|
|
|
the local filesystem. It leads you through creating a table, inserting
|
2011-04-22 19:07:56 +00:00
|
|
|
rows via the HBase <command>shell</command>, and then cleaning
|
2011-03-25 06:19:18 +00:00
|
|
|
up and shutting down your standalone HBase instance. The below exercise
|
|
|
|
should take no more than ten minutes (not including download time).</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<section>
|
|
|
|
<title>Download and unpack the latest stable release.</title>
|
|
|
|
|
|
|
|
<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 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 file that ends in
|
|
|
|
<filename>.tar.gz</filename> to your local filesystem; e.g.
|
|
|
|
<filename>hbase-<?eval ${project.version}?>.tar.gz</filename>.</para>
|
|
|
|
|
|
|
|
<para>Decompress and untar your download and then change into the
|
|
|
|
unpacked directory.</para>
|
|
|
|
|
|
|
|
<para><programlisting>$ tar xfz hbase-<?eval ${project.version}?>.tar.gz
|
2011-03-15 22:23:12 +00:00
|
|
|
$ cd hbase-<?eval ${project.version}?>
|
|
|
|
</programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>At this point, you are ready to start HBase. But before starting
|
|
|
|
it, you might want to edit <filename>conf/hbase-site.xml</filename> and
|
|
|
|
set the directory you want HBase to write to,
|
|
|
|
<varname>hbase.rootdir</varname>. <programlisting>
|
|
|
|
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
|
|
|
<configuration>
|
|
|
|
<property>
|
|
|
|
<name>hbase.rootdir</name>
|
|
|
|
<value>file:///DIRECTORY/hbase</value>
|
|
|
|
</property>
|
|
|
|
</configuration>
|
|
|
|
|
|
|
|
</programlisting> Replace <varname>DIRECTORY</varname> in the above with a
|
|
|
|
path to a directory where you want HBase to store its data. By default,
|
|
|
|
<varname>hbase.rootdir</varname> is set to
|
|
|
|
<filename>/tmp/hbase-${user.name}</filename> which means you'll lose all
|
|
|
|
your data whenever your server reboots (Most operating systems clear
|
|
|
|
<filename>/tmp</filename> on restart).</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section xml:id="start_hbase">
|
|
|
|
<title>Start HBase</title>
|
|
|
|
|
|
|
|
<para>Now start HBase:<programlisting>$ ./bin/start-hbase.sh
|
2011-03-15 22:23:12 +00:00
|
|
|
starting Master, logging to logs/hbase-user-master-example.org.out</programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>You should now have a running standalone HBase instance. In
|
|
|
|
standalone mode, HBase runs all daemons in the the one JVM; i.e. both
|
|
|
|
the HBase and ZooKeeper daemons. HBase logs can be found in the
|
|
|
|
<filename>logs</filename> subdirectory. Check them out especially if
|
|
|
|
HBase had trouble starting.</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<title>Is <application>java</application> installed?</title>
|
|
|
|
|
|
|
|
<para>All of the above presumes a 1.6 version of Oracle
|
|
|
|
<application>java</application> is installed on your machine and
|
|
|
|
available on your path; i.e. when you type
|
|
|
|
<application>java</application>, you see output that describes the
|
|
|
|
options the java program takes (HBase requires java 6). If this is not
|
|
|
|
the case, HBase will not start. Install java, edit
|
|
|
|
<filename>conf/hbase-env.sh</filename>, uncommenting the
|
|
|
|
<envar>JAVA_HOME</envar> line pointing it to your java install. Then,
|
|
|
|
retry the steps above.</para>
|
|
|
|
</note>
|
|
|
|
</section>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<section xml:id="shell_exercises">
|
|
|
|
<title>Shell Exercises</title>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-04-22 19:07:56 +00:00
|
|
|
<para>Connect to your running HBase via the <command>shell</command>.</para>
|
2011-03-25 06:19:18 +00:00
|
|
|
|
|
|
|
<para><programlisting>$ ./bin/hbase shell
|
2011-03-15 22:23:12 +00:00
|
|
|
HBase Shell; enter 'help<RETURN>' for list of supported commands.
|
|
|
|
Type "exit<RETURN>" to leave the HBase Shell
|
2011-03-25 06:19:18 +00:00
|
|
|
Version: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010
|
2011-03-15 22:23:12 +00:00
|
|
|
|
|
|
|
hbase(main):001:0> </programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Type <command>help</command> and then
|
|
|
|
<command><RETURN></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>
|
|
|
|
|
2011-04-22 19:07:56 +00:00
|
|
|
<para>Create a table named <varname>test</varname> with a single column family named <varname>cf</varname>.
|
2011-03-25 06:19:18 +00:00
|
|
|
Verify its creation by listing all tables and then insert some
|
|
|
|
values.</para>
|
|
|
|
|
|
|
|
<para><programlisting>hbase(main):003:0> create 'test', 'cf'
|
2011-03-15 22:23:12 +00:00
|
|
|
0 row(s) in 1.2200 seconds
|
2011-12-06 23:26:14 +00:00
|
|
|
hbase(main):003:0> list 'test'
|
|
|
|
..
|
2011-03-15 22:23:12 +00:00
|
|
|
1 row(s) in 0.0550 seconds
|
|
|
|
hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'
|
|
|
|
0 row(s) in 0.0560 seconds
|
|
|
|
hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'
|
|
|
|
0 row(s) in 0.0370 seconds
|
|
|
|
hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'
|
|
|
|
0 row(s) in 0.0450 seconds</programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Above we inserted 3 values, one at a time. The first insert is at
|
|
|
|
<varname>row1</varname>, column <varname>cf:a</varname> with a value of
|
2011-04-22 19:07:56 +00:00
|
|
|
<varname>value1</varname>. Columns in HBase are comprised of a column family prefix --
|
2011-03-25 06:19:18 +00:00
|
|
|
<varname>cf</varname> in this example -- followed by a colon and then a
|
|
|
|
column qualifier suffix (<varname>a</varname> in this case).</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Verify the data insert.</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Run a scan of the table by doing the following</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para><programlisting>hbase(main):007:0> scan 'test'
|
2011-03-15 22:23:12 +00:00
|
|
|
ROW COLUMN+CELL
|
|
|
|
row1 column=cf:a, timestamp=1288380727188, value=value1
|
|
|
|
row2 column=cf:b, timestamp=1288380738440, value=value2
|
|
|
|
row3 column=cf:c, timestamp=1288380747365, value=value3
|
|
|
|
3 row(s) in 0.0590 seconds</programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Get a single row as follows</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para><programlisting>hbase(main):008:0> get 'test', 'row1'
|
2011-03-15 22:23:12 +00:00
|
|
|
COLUMN CELL
|
|
|
|
cf:a timestamp=1288380727188, value=value1
|
|
|
|
1 row(s) in 0.0400 seconds</programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Now, disable and drop your table. This will clean up all done
|
|
|
|
above.</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para><programlisting>hbase(main):012:0> disable 'test'
|
2011-03-15 22:23:12 +00:00
|
|
|
0 row(s) in 1.0930 seconds
|
|
|
|
hbase(main):013:0> drop 'test'
|
|
|
|
0 row(s) in 0.0770 seconds </programlisting></para>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Exit the shell by typing exit.</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para><programlisting>hbase(main):014:0> exit</programlisting></para>
|
|
|
|
</section>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<section xml:id="stopping">
|
|
|
|
<title>Stopping HBase</title>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>Stop your hbase instance by running the stop script.</para>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para><programlisting>$ ./bin/stop-hbase.sh
|
|
|
|
stopping hbase...............</programlisting></para>
|
2011-03-15 22:23:12 +00:00
|
|
|
</section>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<section>
|
|
|
|
<title>Where to go next</title>
|
2011-03-15 22:23:12 +00:00
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
<para>The above described standalone setup is good for testing and
|
2011-06-22 05:39:32 +00:00
|
|
|
experiments only. Next move on to <xref linkend="configuration" /> where we'll go into
|
2011-03-25 06:19:18 +00:00
|
|
|
depth on the different HBase run modes, requirements and critical
|
|
|
|
configurations needed setting up a distributed HBase deploy.</para>
|
|
|
|
</section>
|
2011-03-15 22:23:12 +00:00
|
|
|
</section>
|
|
|
|
|
2011-03-25 06:19:18 +00:00
|
|
|
</chapter>
|