资源描述:
《HBase表结构设计》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、表结构操作1.建立一个表scores,有两个列族grad和course[hadoop@weekend01~]$hbaseshellhbase(main):006:0>create'scores','grade','course'0row(s)in0.4120seconds=>Hbase::Table-scores2.查看Hbase中的所有表hbase(main):007:0>listTABLEhbase_studentmy_datanew_scoresscoresstudentuser6row(s)in0.0150
2、seconds=>["hbase_student","my_data","new_scores","scores","student","user"]3.查看scores表结构hbase(main):008:0>desc'scores'TablescoresisENABLEDscoresCOLUMNFAMILIESDESCRIPTION{NAME=>'course',DATA_BLOCK_ENCODING=>'NONE',BLOOMFILTER=>'ROW',REPLICATION_SCOPE=>'0',VERSION
3、S=>'1',COMPRESSION=>'NONE',MIN_VERSIONS=>'0',TTL=>'FOREVER',KEEP_DELETED_CELLS=>'FALSE',BLOCKSIZE=>'65536',IN_MEMORY=>'false',BLOCKCACHE=>'true'}{NAME=>'grade',DATA_BLOCK_ENCODING=>'NONE',BLOOMFILTER=>'ROW',REPLICATION_SCOPE=>'0',VERSIONS=>'1',COMPRESSION=>'NONE
4、',MIN_VERSIONS=>'0',TTL=>'FOREVER',KEEP_DELETED_CELLS=>'FALSE',BLOCKSIZE=>'65536',IN_MEMORY=>'false',BLOCKCACHE=>'true'}2row(s)in0.0550seconds4.查询表scores是否存在hbase(main):009:0>exists'scores'Tablescoresdoesexist0row(s)in0.0180seconds5.判断表scores是否enablehbase(main):
5、010:0>is_enabled'scores'true0row(s)in0.0160seconds6.判断表scores是否disablehbase(main):011:0>is_disabled'scores'false0row(s)in0.0210seconds7.使表scores不可用hbase(main):012:0>disable'scores'0row(s)in1.3380seconds8.恢复表scores可用hbase(main):013:0>enable'scores'0row(s)in0.5680
6、seconds9.增加一个school列族hbase(main):002:0>alter'scores',{NAME=>'school',VERSIONS=>3}Updatingallregionswiththenewschema...0/1regionsupdated.1/1regionsupdated.Done.0row(s)in2.3390seconds10.删除一个school列族hbase(main):005:0>alter'scores',{NAME=>'school',METHOD=>'delete'}U
7、pdatingallregionswiththenewschema...0/1regionsupdated.1/1regionsupdated.Done.0row(s)in2.1970seconds11.删除表scores操作步骤:先禁用表,再删除表hbase(main):004:0>disable'scores'#先将scores表改为offline状态0row(s)in1.3100secondshbase(main):005:0>drop'scores'#再删除表0row(s)in0.2250seconds二、DM
8、L操作(数据操纵)1.添加scores数据其scores表数据如下:Tomgrade:5Tomcourse:math97Tomcourse:art87Tomcourse:english80Jimgrade:4Jimcourse:chinese89Jimcourse:english80hbase(main):006:0>put'sc