hbase 基本命令
来源:互联网 发布:明底线知敬畏演讲稿 编辑:程序博客网 时间:2024/05/29 12:28
http://www.linuxidc.com/Linux/2015-03/114670.htmhttp://www.cnblogs.com/end/archive/2011/04/12/2013804.htmlhttp://www.cnblogs.com/end/archive/2011/04/12/2013804.htmlDisabled by default. Example: hbase> scan 't1', {RAW => true, VERSIONS => 10}Besides the default 'toStringBinary' format, 'scan' supports custom formattingby column. A user can define a FORMATTER by adding it to the column name inthe scan specification. The FORMATTER can be stipulated: 1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString) 2. or as a custom class followed by method name: e.g. 'c(MyFormatterClass).format'.Example formatting cf:qualifier1 and cf:qualifier2 both as Integers: hbase> scan 't1', {COLUMNS => ['cf:qualifier1:toInt', 'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] } Note that you can specify a FORMATTER by column only (cf:qualifer). You cannotspecify a FORMATTER for all columns of a column family.Scan can also be used directly from a table, by first getting a reference to atable, like such: hbase> t = get_table 't' hbase> t.scanNote in the above situation, you can still provide all the filtering, columns,options, etc as described above.hbase(main):018:0> scan 'scores'ROW COLUMN+CELL Jerry column=course:art, timestamp=1467043674178, value=80 Jerry column=course:math, timestamp=1467043661806, value=100 Jerry column=grade:, timestamp=1467043649929, value=2 Tom column=course:art, timestamp=1467043633328, value=97 Tom column=course:math, timestamp=1467043619083, value=87 Tom column=grade:, timestamp=1467043589481, value=1 2 row(s) in 0.0640 secondshbase(main):019:0> get 'scores', 'Tom'COLUMN CELL course:art timestamp=1467043633328, value=97 course:math timestamp=1467043619083, value=87 grade: timestamp=1467043589481, value=1 3 row(s) in 0.0310 secondshbase(main):020:0> create 'scores', 'grade', 'course'ERROR: Table already exists: scores!Here is some help for this command:Creates a table. Pass a table name, and a set of column familyspecifications (at least one), and, optionally, table configuration.Column specification can be a simple string (name), or a dictionary(dictionaries are described below in main help output), necessarily including NAME attribute. Examples:Create a table with namespace=ns1 and table qualifier=t1 hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}Create a table with namespace=default and table qualifier=t1 hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'} hbase> # The above in shorthand would be the following: hbase> create 't1', 'f1', 'f2', 'f3' hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true} hbase> create 't1', {NAME => 'f1', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}} Table configuration options can be put at the end.Examples: hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40'] hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40'] hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe' hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' } hbase> # Optionally pre-split the table into NUMREGIONS, using hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname) hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'} hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}} hbase> create 't1', {NAME => 'f1', DFS_REPLICATION => 1}You can also keep around a reference to the created table: hbase> t1 = create 't1', 'f1'Which gives you a reference to the table named 't1', on which you can thencall methods.hbase(main):021:0> version0.98.20-hadoop2, r9624f3a9eb76f84656a41de0e2099c97f949e831, Tue Jun 7 17:40:20 PDT 2016hbase(main):022:0> describe 'member'Table member is ENABLED member COLUMN FAMILIES DESCRIPTION {NAME => 'address', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} {NAME => 'member_id', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 3 row(s) in 0.0970 secondshbase(main):023:0> alter 'member',{NAME=>'member_id',METHOD=>'delete'}Updating all regions with the new schema...0/1 regions updated.1/1 regions updated.Done.0 row(s) in 2.6480 secondshbase(main):024:0> describe 'member'Table member is ENABLED member COLUMN FAMILIES DESCRIPTION {NAME => 'address', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 2 row(s) in 0.3380 secondshbase(main):025:0> is_enabled 'member'true 0 row(s) in 0.0510 secondshbase(main):026:0> is_disabled 'member'false 0 row(s) in 0.0480 secondshbase(main):027:0> listTABLE member scores 2 row(s) in 0.0220 seconds=> ["member", "scores"]hbase(main):028:0> exists 'member'Table member does exist 0 row(s) in 0.0490 secondshbase(main):029:0> exists 'member_temp'Table member_temp does not exist 0 row(s) in 0.0470 secondshbase(main):030:0> scan 'member'ROW COLUMN+CELL 0 row(s) in 0.0330 secondshbase(main):031:0> put'member','scutshuxue','info:age','24'0 row(s) in 0.0270 secondshbase(main):032:0> hbase(main):033:0* put'member','scutshuxue','info:birthday','1987-06-17'0 row(s) in 0.0050 secondshbase(main):034:0> hbase(main):035:0* put'member','scutshuxue','info:company','alibaba'0 row(s) in 0.0100 secondshbase(main):036:0> hbase(main):037:0* put'member','scutshuxue','address:contry','china'0 row(s) in 0.0240 secondshbase(main):038:0> hbase(main):039:0* put'member','scutshuxue','address:province','zhejiang'0 row(s) in 0.0050 secondshbase(main):040:0> hbase(main):041:0* put'member','scutshuxue','address:city','hangzhou'0 row(s) in 0.0130 secondshbase(main):042:0> scan 'member'ROW COLUMN+CELL scutshuxue column=address:city, timestamp=1467044198878, value=hangzhou scutshuxue column=address:contry, timestamp=1467044197312, value=china scutshuxue column=address:province, timestamp=1467044197387, value=zhejiang scutshuxue column=info:age, timestamp=1467044197146, value=24 scutshuxue column=info:birthday, timestamp=1467044197222, value=1987-06-17 scutshuxue column=info:company, timestamp=1467044197268, value=alibaba 1 row(s) in 0.0320 secondshbase(main):043:0> put'member','xiaofeng','info:birthday','1987-4-17'0 row(s) in 0.0160 secondshbase(main):044:0> hbase(main):045:0* put'member','xiaofeng','info:favorite','movie' 0 row(s) in 0.0090 secondshbase(main):046:0> hbase(main):047:0* put'member','xiaofeng','info:company','alibaba'0 row(s) in 0.0030 secondshbase(main):048:0> hbase(main):049:0* put'member','xiaofeng','address:contry','china'0 row(s) in 0.0070 secondshbase(main):050:0> hbase(main):051:0* put'member','xiaofeng','address:province','guangdong'0 row(s) in 0.0040 secondshbase(main):052:0> hbase(main):053:0* put'member','xiaofeng','address:city','jieyang'0 row(s) in 0.0080 secondshbase(main):054:0> hbase(main):055:0* put'member','xiaofeng','address:town','xianqiao'0 row(s) in 0.0110 secondshbase(main):056:0> scan 'member'ROW COLUMN+CELL scutshuxue column=address:city, timestamp=1467044198878, value=hangzhou scutshuxue column=address:contry, timestamp=1467044197312, value=china scutshuxue column=address:province, timestamp=1467044197387, value=zhejiang scutshuxue column=info:age, timestamp=1467044197146, value=24 scutshuxue column=info:birthday, timestamp=1467044197222, value=1987-06-17 scutshuxue column=info:company, timestamp=1467044197268, value=alibaba xiaofeng column=address:city, timestamp=1467044214211, value=jieyang xiaofeng column=address:contry, timestamp=1467044214109, value=china xiaofeng column=address:province, timestamp=1467044214168, value=guangdong xiaofeng column=address:town, timestamp=1467044215505, value=xianqiao xiaofeng column=info:birthday, timestamp=1467044213955, value=1987-4-17 xiaofeng column=info:company, timestamp=1467044214068, value=alibaba xiaofeng column=info:favorite, timestamp=1467044214015, value=movie 2 row(s) in 0.0300 secondshbase(main):057:0> get member scutshuxueNameError: undefined local variable or method `scutshuxue' for #<Object:0x1945458>hbase(main):058:0> get member scutshuxue'hbase(main):059:0' get 'member' 'scutshuxue'hbase(main):060:0' hbase(main):061:0' hbase(main):062:0' [root@cdh1 conf]# hbase shell2016-06-27 09:18:14,682 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.availableHBase Shell; enter 'help<RETURN>' for list of supported commands.Type "exit<RETURN>" to leave the HBase ShellVersion 0.98.20-hadoop2, r9624f3a9eb76f84656a41de0e2099c97f949e831, Tue Jun 7 17:40:20 PDT 2016hbase(main):001:0> get 'member' 'scutshuxue'ERROR: wrong number of arguments (1 for 2)Here is some help for this command:Get row or cell contents; pass table name, row, and optionallya dictionary of column(s), timestamp, timerange and versions. Examples: hbase> get 'ns1:t1', 'r1' hbase> get 't1', 'r1' hbase> get 't1', 'r1', {TIMERANGE => [ts1, ts2]} hbase> get 't1', 'r1', {COLUMN => 'c1'} hbase> get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']} hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1} hbase> get 't1', 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4} hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4} hbase> get 't1', 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"} hbase> get 't1', 'r1', 'c1' hbase> get 't1', 'r1', 'c1', 'c2' hbase> get 't1', 'r1', ['c1', 'c2'] hbsase> get 't1','r1', {COLUMN => 'c1', ATTRIBUTES => {'mykey'=>'myvalue'}} hbsase> get 't1','r1', {COLUMN => 'c1', AUTHORIZATIONS => ['PRIVATE','SECRET']}Besides the default 'toStringBinary' format, 'get' also supports custom formatting bycolumn. A user can define a FORMATTER by adding it to the column name in the getspecification. The FORMATTER can be stipulated: 1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString) 2. or as a custom class followed by method name: e.g. 'c(MyFormatterClass).format'.Example formatting cf:qualifier1 and cf:qualifier2 both as Integers: hbase> get 't1', 'r1' {COLUMN => ['cf:qualifier1:toInt', 'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] } Note that you can specify a FORMATTER by column only (cf:qualifer). You cannot specifya FORMATTER for all columns of a column family. The same commands also can be run on a reference to a table (obtained via get_table orcreate_table). Suppose you had a reference t to table 't1', the corresponding commandswould be: hbase> t.get 'r1' hbase> t.get 'r1', {TIMERANGE => [ts1, ts2]} hbase> t.get 'r1', {COLUMN => 'c1'} hbase> t.get 'r1', {COLUMN => ['c1', 'c2', 'c3']} hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1} hbase> t.get 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4} hbase> t.get 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4} hbase> t.get 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"} hbase> t.get 'r1', 'c1' hbase> t.get 'r1', 'c1', 'c2' hbase> t.get 'r1', ['c1', 'c2']hbase(main):002:0> get 'member' ,'scutshuxue'SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/user/local/hbase-0.98.20-hadoop2/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/user/local/hadoop-2.6.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.COLUMN CELL address:city timestamp=1467044198878, value=hangzhou address:contry timestamp=1467044197312, value=china address:province timestamp=1467044197387, value=zhejiang info:age timestamp=1467044197146, value=24 info:birthday timestamp=1467044197222, value=1987-06-17 info:company timestamp=1467044197268, value=alibaba 6 row(s) in 0.4280 secondshbase(main):003:0> scan 'member'ROW COLUMN+CELL scutshuxue column=address:city, timestamp=1467044198878, value=hangzhou scutshuxue column=address:contry, timestamp=1467044197312, value=china scutshuxue column=address:province, timestamp=1467044197387, value=zhejiang scutshuxue column=info:age, timestamp=1467044197146, value=24 scutshuxue column=info:birthday, timestamp=1467044197222, value=1987-06-17 scutshuxue column=info:company, timestamp=1467044197268, value=alibaba xiaofeng column=address:city, timestamp=1467044214211, value=jieyang xiaofeng column=address:contry, timestamp=1467044214109, value=china xiaofeng column=address:province, timestamp=1467044214168, value=guangdong xiaofeng column=address:town, timestamp=1467044215505, value=xianqiao xiaofeng column=info:birthday, timestamp=1467044213955, value=1987-4-17 xiaofeng column=info:company, timestamp=1467044214068, value=alibaba xiaofeng column=info:favorite, timestamp=1467044214015, value=movie 2 row(s) in 0.1100 secondshbase(main):004:0> get 'member' ,'scutshuxue','info'COLUMN CELL info:age timestamp=1467044197146, value=24 info:birthday timestamp=1467044197222, value=1987-06-17 info:company timestamp=1467044197268, value=alibaba 3 row(s) in 0.0530 secondshbase(main):005:0> get 'member' ,'scutshuxue'COLUMN CELL address:city timestamp=1467044198878, value=hangzhou address:contry timestamp=1467044197312, value=china address:province timestamp=1467044197387, value=zhejiang info:age timestamp=1467044197146, value=24 info:birthday timestamp=1467044197222, value=1987-06-17 info:company timestamp=1467044197268, value=alibaba 6 row(s) in 0.0190 secondshbase(main):006:0> get 'member' ,'scutshuxue','info:age'COLUMN CELL info:age timestamp=1467044197146, value=24 1 row(s) in 0.0530 secondshbase(main):007:0> get 'member' ,'scutshuxue','info:company'COLUMN CELL info:company timestamp=1467044197268, value=alibaba 1 row(s) in 0.0140 secondshbase(main):008:0> get 'member' ,'scutshuxue','info:age'COLUMN CELL info:age timestamp=1467044197146, value=24 1 row(s) in 0.0180 secondshbase(main):009:0> put 'member','scutshuxue','info:age' ,'99'0 row(s) in 0.1070 secondshbase(main):010:0> get 'member' ,'scutshuxue','info:age'COLUMN CELL info:age timestamp=1467044462445, value=99 1 row(s) in 0.0190 secondshbase(main):011:0> get 'member' ,'scutshuxue','info'COLUMN CELL info:age timestamp=1467044462445, value=99 info:birthday timestamp=1467044197222, value=1987-06-17 info:company timestamp=1467044197268, value=alibaba 3 row(s) in 0.0280 secondshbase(main):012:0> get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1321586238965}COLUMN CELL 0 row(s) in 0.0230 secondshbase(main):013:0> get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1467044462445}COLUMN CELL info:age timestamp=1467044462445, value=99 1 row(s) in 0.0070 secondshbase(main):014:0> get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1467044462445}COLUMN CELL info:age timestamp=1467044462445, value=99 1 row(s) in 0.0210 secondshbase(main):015:0> get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1467044197146}COLUMN CELL info:age timestamp=1467044197146, value=24 1 row(s) in 0.0230 secondshbase(main):016:0> scan 'member'ROW COLUMN+CELL scutshuxue column=address:city, timestamp=1467044198878, value=hangzhou scutshuxue column=address:contry, timestamp=1467044197312, value=china scutshuxue column=address:province, timestamp=1467044197387, value=zhejiang scutshuxue column=info:age, timestamp=1467044462445, value=99 scutshuxue column=info:birthday, timestamp=1467044197222, value=1987-06-17 scutshuxue column=info:company, timestamp=1467044197268, value=alibaba xiaofeng column=address:city, timestamp=1467044214211, value=jieyang xiaofeng column=address:contry, timestamp=1467044214109, value=china xiaofeng column=address:province, timestamp=1467044214168, value=guangdong xiaofeng column=address:town, timestamp=1467044215505, value=xianqiao xiaofeng column=info:birthday, timestamp=1467044213955, value=1987-4-17 xiaofeng column=info:company, timestamp=1467044214068, value=alibaba xiaofeng column=info:favorite, timestamp=1467044214015, value=movie 2 row(s) in 0.0800 secondshbase(main):017:0> get 'member','temp'COLUMN CELL 0 row(s) in 0.0240 secondshbase(main):018:0> get 'member','scutshuxue','info:age'COLUMN CELL info:age timestamp=1467044462445, value=99 1 row(s) in 0.0110 secondshbase(main):019:0> get 'member','xiaofeng','info:age'COLUMN CELL 0 row(s) in 0.0240 secondshbase(main):020:0> put 'member','xiaofeng','info:age','110'0 row(s) in 0.0130 secondshbase(main):021:0> get 'member','xiaofeng','info:age'COLUMN CELL info:age timestamp=1467044830542, value=110 1 row(s) in 0.0210 secondshbase(main):022:0> delete 'member','xiaofeng','info:age'0 row(s) in 0.0700 secondshbase(main):023:0> get 'member','xiaofeng','info:age'COLUMN CELL 0 row(s) in 0.0420 secondshbase(main):024:0> get 'member','xiaofeng','info'COLUMN CELL info:birthday timestamp=1467044213955, value=1987-4-17 info:company timestamp=1467044214068, value=alibaba info:favorite timestamp=1467044214015, value=movie 3 row(s) in 0.0130 secondshbase(main):025:0> put 'member','xiaofeng','info:age','110'0 row(s) in 0.0130 secondshbase(main):026:0> get 'member','xiaofeng','info'COLUMN CELL info:age timestamp=1467044893778, value=110 info:birthday timestamp=1467044213955, value=1987-4-17 info:company timestamp=1467044214068, value=alibaba info:favorite timestamp=1467044214015, value=movie 4 row(s) in 0.0270 secondshbase(main):027:0> get 'member','xiaofeng'COLUMN CELL address:city timestamp=1467044214211, value=jieyang address:contry timestamp=1467044214109, value=china address:province timestamp=1467044214168, value=guangdong address:town timestamp=1467044215505, value=xianqiao info:age timestamp=1467044893778, value=110 info:birthday timestamp=1467044213955, value=1987-4-17 info:company timestamp=1467044214068, value=alibaba info:favorite timestamp=1467044214015, value=movie 8 row(s) in 0.0280 secondshbase(main):028:0> deleteall 'member','xiaofeng'0 row(s) in 0.0180 secondshbase(main):029:0> get 'member','xiaofeng'COLUMN CELL 0 row(s) in 0.0040 secondshbase(main):030:0> count 'member' 1 row(s) in 0.1440 seconds=> 1hbase(main):031:0> incr 'member','xiaofeng','info:age' COUNTER VALUE = 10 row(s) in 0.0340 secondshbase(main):032:0> get 'member','xiaofeng'COLUMN CELL info:age timestamp=1467044961664, value=\x00\x00\x00\x00\x00\x00\x00\x01 1 row(s) in 0.0230 secondshbase(main):033:0> incr 'member','xiaofeng','info:age' COUNTER VALUE = 20 row(s) in 0.0250 secondshbase(main):034:0> get 'member','xiaofeng'COLUMN CELL info:age timestamp=1467045000778, value=\x00\x00\x00\x00\x00\x00\x00\x02 1 row(s) in 0.0090 secondshbase(main):035:0> get_counter 'member','xiaofeng','info:age'COUNTER VALUE = 2hbase(main):036:0> truncate 'member'Truncating 'member' table (it may take a while): - Disabling table... - Truncating table...0 row(s) in 1.8810 secondshbase(main):037:0>
0 0
- HBase基本命令
- HBase基本命令
- hbase shell 基本命令
- HBase基本命令
- HBase Shell基本命令
- hbase 基本shell命令
- hbase shell基本命令
- hbase shell基本命令
- hbase 基本命令
- hbase基本命令
- hbase 基本命令
- HBase Shell 基本命令
- hbase 基本命令
- HBase基本命令
- hbase基本操作命令
- Hbase基本shell命令
- Hbase笔记三:Hbase基本命令
- hbase--Hbase 建表基本命令总结
- 基于多个MPC的的调度控制器
- codeforces 357div2总结
- 从服务业突然决定转行进入IT界
- 手机网络状态查询工具类
- 序列化二叉树
- hbase 基本命令
- C++中的继承
- Android开发指南--0 总览
- poj3258 二分(连续区间求和)
- U3D自定义滑动面板ViewPager
- 自制的通讯录APP(SQLite的应用)
- Redis-sds源码剖析第一天
- android studio无法设置java jdk
- 黑马程序员——基本数据类型总结