From 6cd4370f9483dc505d4d630af92f5f929bcccf49 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 3 Nov 2010 22:03:53 +0000 Subject: [PATCH] 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 --- src/docbkx/book.xml | 72 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/docbkx/book.xml b/src/docbkx/book.xml index 069b50f0c63..153837cb59d 100644 --- a/src/docbkx/book.xml +++ b/src/docbkx/book.xml @@ -364,7 +364,77 @@ stopping hbase............... The HBase Shell - + + The HBase Shell is (J)Ruby's + IRB with some HBase particular verbs addded. Anything you can do in + IRB, you should be able to do in the HBase Shell. + To run the HBase shell, + do as follows: + $ ./bin/hbase shell + Type help followed by <RETURN> + 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. + + +
Scripting + For examples scripting HBase, look in the + HBase bin directory. Look at the files + that end in *.rb. To run one of these + files, do as follows: + $ ./bin/hbase org.jruby.Main PATH_TO_SCRIPT + +
+ +
Shell Tricks +
<filename>irbrc</filename> + Create an .irbrc file for yourself in your + home directory. Add HBase Shell customizations. A useful one is + command history: + + $ more .irbrc + require 'irb/ext/save-history' + IRB.conf[:SAVE_HISTORY] = 100 + IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" + + +
+
Log data to timestamp + + To convert the date '08/08/16 20:56:29' from an hbase log into a timestamp, do: + + 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 + + + + To go the other direction: + + hbase(main):021:0> import java.util.Date + hbase(main):022:0> Date.new(1218920189000).toString() => "Sat Aug 16 20:56:29 UTC 2008" + + + + To output in a format that is exactly like hbase log format is a pain messing with + SimpleDateFormat. + +
+
Debug +
Shell debug switch + You can set a debug switch in the shell to see more output + when you run a command: + hbase> debug <RETURN> + +
+
DEBUG log level + To enable DEBUG level logging in the shell, launch it with the -d option. + $ ./bin/hbase shell -d + +
+
+