Added notes on shell -- in particular the -d flag I just used to help me figure out fail in shell

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1030724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-11-03 22:03:53 +00:00
parent 5f6a76d68f
commit 6cd4370f94

View File

@ -364,7 +364,77 @@ stopping hbase...............</programlisting></para>
<chapter xml:id="shell">
<title>The HBase Shell</title>
<para></para>
<para>
The HBase Shell is <link xlink:href="http://jruby.org">(J)Ruby</link>'s
IRB with some HBase particular verbs addded. 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:
<programlisting>$ ./bin/hbase shell</programlisting>
Type <command>help</command> followed by <command>&lt;RETURN&gt;</command>
to see a complete listing of commands available.
Take some time to study the tail of the help screen where it
does a synopsis of IRB syntax specifying arguments -- usually you must
quote -- and how to write out dictionaries, etc.
</para>
<section><title>Scripting</title>
<para>For examples scripting 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:
<programlisting>$ ./bin/hbase org.jruby.Main PATH_TO_SCRIPT</programlisting>
</para>
</section>
<section><title>Shell Tricks</title>
<section><title><filename>irbrc</filename></title>
<para>Create an <filename>.irbrc</filename> file for yourself in your
home directory. Add HBase Shell customizations. A useful one is
command history:
<programlisting>
$ more .irbrc
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
</programlisting>
</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:
<programlisting>
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
</programlisting>
</para>
<para>
To go the other direction:
<programlisting>
hbase(main):021:0> import java.util.Date
hbase(main):022:0> Date.new(1218920189000).toString() => "Sat Aug 16 20:56:29 UTC 2008"
</programlisting>
</para>
<para>
To output in a format that is exactly like hbase log format is a pain 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
when you run a command:
<programlisting>hbase> debug &lt;RETURN&gt;</programlisting>
</para>
</section>
<section><title>DEBUG log level</title>
<para>To enable DEBUG level logging in the shell, launch it with the <command>-d</command> option.
<programlisting>$ ./bin/hbase shell -d</programlisting>
</para>
</section>
</section>
</section>
</chapter>
<chapter xml:id="datamodel">