实验二:熟悉常用Hbase操作
一、实验目的
- 理解Hbase在Hadoop体系结构中的角色;
- 熟练使用Hbase操作常用的Shell命令;
二、实验平台
- 操作系统:Linux(建议CentOS);
- Hadoop版本:2.6.1;
三、实验步骤
- 理解Hbase在Hadoop体系结构中的角色;
- 熟练使用Hbase操作常用的Shell命令;
二、实验平台
- 操作系统:Linux(建议CentOS);
- Hadoop版本:2.6.1;
三、实验步骤
(一)编程实现以下功能,并利用Hbase提供的Shell命令完成任务:
创建一个表;
hbase(main):004:0> create 'test1',{NAME=>'f1', VERSIONS=>5, BLOCKCACHE => true}
Created table test1
Took 2.1334 seconds
=> Hbase::Table - test1
修改表的结构
hbase(main):010:0> alter 'test1', {NAME=>'basic',IN_MEMORY=> true}
Updating all regions with the new schema...
1/1 regions updated.
Done.
描述表的结构
hbase(main):011:0> describe 'test1'
Table test1 is ENABLED
test1
COLUMN FAMILIES DEscriptION
{NAME => 'basic', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOR
EVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'f1', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '5', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVE
R', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
确认表是否存在
hbase(main):015:0> exists 'test1' Table test1 does exist Took 0.0147 seconds => true
显示所有表名列表
hbase(main):019:0> list TABLE table1 table2 test1 3 row(s) Took 0.0077 seconds => ["table1", "table2", "test1"]
禁用/解禁一个表
hbase(main):020:0> disable 'test1' Took 0.3914 seconds hbase(main):021:0> scan 'test1' ROW COLUMN+CELL org.apache.hadoop.hbase.TableNotEnabledException: test1 is disabled. hbase(main):022:0> enable 'test1' Took 0.6739 seconds hbase(main):023:0> scan 'test1' ROW COLUMN+CELL 0 row(s) Took 0.0357 seconds
确认表是否被禁用
hbase(main):003:0> is_disabled 'test1' true Took 0.0129 seconds => 1
删除一个表
=> ["table1", "table2", "test1"] hbase(main):005:0> drop 'test1' Took 0.1325 seconds hbase(main):006:0> list TABLE table1 table2 2 row(s) Took 0.0210 seconds => ["table1", "table2"]
禁用删除并重建一个表
hbase(main):007:0> truncate 'table1' Truncating 'table1' table (it may take a while): Disabling table... Truncating table... Took 2.5566 seconds
- 实验总结及问题
1、学会使用什么做什么事情;
学会hbase shell命令的基本使用
2、在实验过程中遇到了什么问题?是如何解决的?
安装hbase时出现错误,hadoop3.3.1版本过高不兼容,换低版本
注意:
- 请大家通过学习通提交作业;



