标签:
数据导入
./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
标签:
原文地址:http://www.cnblogs.com/szw-blog/p/5512349.html