usage
-
to invoke non-interactive mode pass
-n
or--non-interactive
option to hbase shell -
hbase shell in os scripts
$ echo "describe 'test'" | hbase shell -n $ echo "describe 'test'" | hbase shell -n > /dev/null 2>&1
-
read hbase shell commands from file
$ pico hbase.cmd 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'  $ habse shell ./hbase.cmd
-
passing vm options to shell
$ HBASE_SHELL_OPTS="-verbose:gc \ -XX:+PrintGCApplicationStoppedTime \ -XX:+PrintGCDateStamps \ -XX:+PrintGCDetails \ -Xloggc:$HBASE_HOME/log/gc-hbase.log" hbase shell
-
shell tricks
-
assign a table to a variable by using
get_table
methodhbase(main):001 > create 't', 'f' hbase(main):001 > tab = get_table 't' hbase(main):001 > tab.put r1, f, v hbase(main):001 > tab.scan hbase(main):001 > tables = list( t.* ) hbase(main):001 > tables.map { |t| disable t; drop t}
-
-
debug
-
shell debug switch
hbase> debug
-
debug log level
$ hbase shell -d
-
-
commands
-
count
hbase> count 'test', CACHE => 1000
-
fixed
-
can’t create table
-
when create table
hbase(main):002:0> create 'test', 'cf' ERROR: Table already exists: test!
-
try to disable table
hbase(main):003:0> disable 'test' ERROR: Table test does not exist.
-
fixed
# 1. start zookeeper zkCli $ bin/zkCli Connecting to localhost:2181 Welcome to ZooKeeper! JLine support is enabled # 2. list /hbase/table [zk: localhost:2181(CONNECTED) 1] ls /hbase/table [hbase:meta, hbase:namespace, test] # 3. rm this znode [zk: localhost:2181(CONNECTED) 2] rmr /hbase/table [zk: localhost:2181(CONNECTED) 3] ls /hbase/table Node does not exist: /hbase/table # 4. restart hbase then list /hbase/table [zk: localhost:2181(CONNECTED) 4] ls /hbase/table []
-