數據導入
./hbase org.apache.hadoop.hbase.mapreduce.Driver import 表名 數據文件位置
hdfs
數據文件位置 可以加 前綴 file:///
否則 會訪問 hdfs 地址。
數據導出
./hbase org.apache.hadoop.hbase.mapreduce.Driver export 表名 數據文件位置
進入shell 命令。
cd /hbaseHOME/bin/
cd ./hbase shell
2016-05-20 15:36:32,370 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.98.6-zdh2.1.0-SNAPSHOT, r112581, Mon Jan 25 05:25:14 CST 2016
hbase(main):001:0>
hbase(main):001:0>
創建 hbase 表格
create '表名稱', '列名稱1','列名稱2','列名稱N'
hbase(main):001:0>create 'test' ,'name' ,'value'
查看test 表構造
在shell中輸入describe ‘表名’
hbase(main):003:0> desc 'test'
DESCRIPTION ENABLED
'test', {NAME => 'course', DATA_BLOCK_ENCODING => 'NONE', REPL true
ICATION => '0', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0'
, COMPRESSION => 'NONE', VERSIONS => '1', MIN_VERSIONS => '0',
TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
'65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'false', BLOC
KCACHE => 'true'}, {NAME => 'name', DATA_BLOCK_ENCODING => 'NO
NE', REPLICATION => '0', BLOOMFILTER => 'ROW', REPLICATION_SCO
PE => '0', COMPRESSION => 'NONE', VERSIONS => '1', MIN_VERSION
S => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLO
CKSIZE => '65536', ENCODE_ON_DISK => 'true', IN_MEMORY => 'fal
se', BLOCKCACHE => 'true'}
1 row(s) in 0.0820 seconds
hbase(main):004:0>
添加數據
在shell中輸入:put '表名稱', '行名稱', '列名稱:', '值'
hbase(main):005:0>put 'test','Tom','value:scores','80'
0 row(s) in 0.1420 seconds
查看數據
在shell中輸入:get '表名稱', '行名稱'
hbase(main):010:0> get 'test','Tom'
COLUMN CELL
course:math timestamp=1463730444304, value=90
1 row(s) in 0.0140 seconds
hbase(main):006:0>
查看總數據
在shell中輸入:scan '表名稱'
hbase(main):006:0>scan 'test'
ROW COLUMN+CELL
Tom column=course:math, timestamp=1463730322512, value=80
1 row(s) in 0.0750 seconds
修改數據
在shell中輸入:put '表名稱', '行名稱', '列名稱:', '值'(對原數值修改)
hbase(main):007:0>put 'test','Tom','course:math','90'
put 'test','Tom','course:math','90'
hbase(main):007:0>scan 'test'
ROW COLUMN+CELL
Tom column=course:math, timestamp=1463730444304, value=90
1 row(s) in 0.0140 seconds
另外還有 list 方法。 查看所有的表格。
count ‘表名’ 查看 記錄總數 等。
先到這里
the end