| <?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 instance of HBase using the local filesystem. |
| <xref linkend="configuration" /> describes setup |
| 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 |
| rows via the HBase <command>shell</command>, and then cleaning |
| up and shutting down your standalone HBase instance. The below exercise |
| should take no more than ten minutes (not including download time).</para> |
| |
| <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 |
| $ cd hbase-<?eval ${project.version}?> |
| </programlisting></para> |
| |
| <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 |
| starting Master, logging to logs/hbase-user-master-example.org.out</programlisting></para> |
| |
| <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> |
| |
| <section xml:id="shell_exercises"> |
| <title>Shell Exercises</title> |
| |
| <para>Connect to your running HBase via the <command>shell</command>.</para> |
| |
| <para><programlisting>$ ./bin/hbase shell |
| HBase Shell; enter 'help<RETURN>' for list of supported commands. |
| Type "exit<RETURN>" to leave the HBase Shell |
| Version: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010 |
| |
| hbase(main):001:0> </programlisting></para> |
| |
| <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> |
| |
| <para>Create a table named <varname>test</varname> with a single column family named <varname>cf</varname>. |
| Verify its creation by listing all tables and then insert some |
| values.</para> |
| |
| <para><programlisting>hbase(main):003:0> create 'test', 'cf' |
| 0 row(s) in 1.2200 seconds |
| hbase(main):003:0> list 'test' |
| .. |
| 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> |
| |
| <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 |
| <varname>value1</varname>. Columns in HBase are comprised of a column family prefix -- |
| <varname>cf</varname> in this example -- followed by a colon and then a |
| column qualifier suffix (<varname>a</varname> in this case).</para> |
| |
| <para>Verify the data insert.</para> |
| |
| <para>Run a scan of the table by doing the following</para> |
| |
| <para><programlisting>hbase(main):007:0> scan 'test' |
| 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> |
| |
| <para>Get a single row as follows</para> |
| |
| <para><programlisting>hbase(main):008:0> get 'test', 'row1' |
| COLUMN CELL |
| cf:a timestamp=1288380727188, value=value1 |
| 1 row(s) in 0.0400 seconds</programlisting></para> |
| |
| <para>Now, disable and drop your table. This will clean up all done |
| above.</para> |
| |
| <para><programlisting>hbase(main):012:0> disable 'test' |
| 0 row(s) in 1.0930 seconds |
| hbase(main):013:0> drop 'test' |
| 0 row(s) in 0.0770 seconds </programlisting></para> |
| |
| <para>Exit the shell by typing exit.</para> |
| |
| <para><programlisting>hbase(main):014:0> exit</programlisting></para> |
| </section> |
| |
| <section xml:id="stopping"> |
| <title>Stopping HBase</title> |
| |
| <para>Stop your hbase instance by running the stop script.</para> |
| |
| <para><programlisting>$ ./bin/stop-hbase.sh |
| stopping hbase...............</programlisting></para> |
| </section> |
| |
| <section> |
| <title>Where to go next</title> |
| |
| <para>The above described standalone setup is good for testing and |
| experiments only. Next move on to <xref linkend="configuration" /> where we'll go into |
| depth on the different HBase run modes, requirements and critical |
| configurations needed setting up a distributed HBase deploy.</para> |
| </section> |
| </section> |
| |
| </chapter> |