about HBase
[Email protected] root]$ hbaseusage:hbase [<options>] <command> [<args>]options:--config DIR Configuration direction to use. Default:./conf --hosts hosts Override the list in ' regionservers ' fileCommands:some Commands take arguments. Pass No argsor-H forUsage. Shell Run theHBase Shell Hbck Run theHBase ' fsck ' tool Hlog write-ahead-LogAnalyzer hfile StorefileAnalyzer ZKCLI Run theZooKeeper Shell upgrade Upgrade HBase Master run an hbase hmaster node Regionserver Run an hbase HR Egionserver node Zookeeper Run a zookeeper serverRestRun an HBase REST server thrift Run theHBase Thrift Server thrift2 Run theHBase Thrift2 Server Clean Run theHBase Clean UpScriptClasspath dump hbase classpath MAPREDCP dump CLASSPATH entries required byMapReduce PE run performanceevaluation ltt run LoadtesttoolversionPrint the versionCLASSNAME Run the classNamed CLASSNAME
go to command line
[root@hadoop1 ~]# hbase shell
Exit command line
hbase(main):001:0exit
View All Tables
hbase(main):001:0listTABLE01.9500 seconds=> []
Create a table
‘表名称‘,‘列名称1‘,...,‘列名称n‘eg:建立一个表scores,有两个列族grad和courese。hbase(main):004:0‘scores‘,‘grad‘,‘courese‘0in1.5820 seconds=> Hbase::Table - scoreshbase(main):005:0> listTABLEscores1in0.0080 seconds=> ["scores"]
View Table Structure
Add a record
put ' table name ',' Row key Name ',' column name ',' cell value ',' time stamp 'Time stamp can be omitted. HBase (Main):009:0>put ' scores ',' Tom ',' Grad: ',' 5 'HBase (Main):011:0>put ' scores ',' Tom ',' Courese:math ',' + 'HBase (Main):012:0>put ' scores ',' Tom ',' Courese:art ',' + 'HBase (Main):013:0>put ' scores ',' Mark ',' Grad ',' 6 'HBase (Main):014:0>put ' scores ',' Mark ',' Courese:english ',' + 'HBase (Main):015:0>put ' scores ',' Mark ',' Courese:chinese ',' 108 '
view all records of a table (full scan)
‘scores‘
Find a record
HBase (Main):020:0>Get ' scores ',' Mark 'COLUMN CELL Courese:chinese timestamp=1435491529683,value=108Courese:中文版timestamp=1435491508206,value= -grad:timestamp=1435491484521,value=63Row (s)inch 0.0520 secondsHBase (Main):021:0>Get ' scores ',' Mark ',' Grad 'COLUMN CELL grad:timestamp=1435491484521,value=61Row (s)inch 0.0390 seconds
Modifying the version of a data store
view multiple versions of a record
number of rows of statistics
Hbase>Count ' Ns1:t1 'Hbase>Count ' T1 'Hbase>Count ' T1 ', INTERVAL =100000Hbase>Count ' T1 ', CACHE = +Hbase>Count ' T1 ', INTERVAL =Ten, CACHE = +Statistics are generally time consuming, using MapReduce for statistics, statistical results are cached, default isTenRow, the statistics interval is the default +Yes. HBase (Main):038:0>Count ' scores '2Row (s) in0.0290Seconds=>2
Modify Table Structure
Add a list of family HBase (main):048:0> Alter' scores ',name=>' Info 'Updating all regions withTheNewSchema ...0/1Regions updated.1/1Regions updated. Done.0Row (s)inch 2.4330Seconds delete a column family HBase (main):053:0> Alter' scores ',name=>' Name=info ', METHOD= 'delete'Updating all regions with the New schema... 0/1 Regions updated. 1/1 Regions updated. done. 0 Row(s) in 2.4670 secondshbase(main) :055:0> Alter' scores ',' Delete '=' Courese '
But can not be deleted, first disable ‘scores‘ , after the modification enable ‘scores‘ .
Delete a table
先禁用表hbase(main):057:0‘scores‘然后删除表hbase(main):057:0drop‘scores‘
Delete specified data
delete‘scores‘,‘Mark‘,‘courese:english‘
Delete entire row
‘表名‘,‘行键‘‘scores‘,‘Mark‘(慎用)
Clear Table
The table structure is still in.
truncate ‘scores‘
HBase command-line basic operations