HBase:简单的操作HBase(Quick Start)

1.声明

当前内容主要用于本人学习和复习,当前内容为HBase中的QuickStart中使用HBase Shell的操作

当前内容的主要来源:HBase官方的QuickStart

当前内容基于博文:HBase的安装和启动

2.使用HBase SHell实现操作

查看是否启动成功(显示HMaster就表示单机模式启动成功)
在这里插入图片描述
1.连接本地的HBase

./bin/hbase shell

在这里插入图片描述
显示结果中说明了,没有启动本地的Hadoop库,使用了builtin-java的类

可以使用help查看shell命令帮助

可以使用exit退出shell

2.查看帮助

help

在这里插入图片描述
3.create命令
Use the create command to create a new table. You must specify the table name and the ColumnFamily name.

使用create命令去创建一个新表,你必须使用特殊的表名和列族名

create 'test','cf'

意思就是创建表test以及创建列族为cf
在这里插入图片描述

4.list命令
List Information About your Table
列出你的表的信息
Use the list command to confirm your table exists
使用list命令去告诉你表是否存在

list 'test'
list 'te'

在这里插入图片描述
当使用list列出一个不存在的结果,那么返回的结果rows就是0(可以通过list检查当前的table是否存在)

Now use the describe command to see details, including configuration default

显示使用describe命令去显示详情,包括默认的配置

describe 'test'

在这里插入图片描述

5.put命令
To put data into your table, use the put command.
使用put命令向当前table中添加数据

put 'test', 'row1', 'cf:a', 'value1'
put 'test', 'row2', 'cf:b', 'value2'
put 'test', 'row3', 'cf:c', 'value3'

put 数据表,行名,列族:后缀,值
在这里插入图片描述
Here, we insert three values, one at a time. The first insert is at row1, column cf:a, with a value of value1. Columns in HBase are comprised of a column family prefix, cf in this example, followed by a colon and then a column qualifier suffix, a in this case.

这里,我们一次性插入了三个值。这提一个插入的在row1,列cf:a,使用值value1.HBase中的列由一个列系列前缀(在本例中为cf)组成,后跟一个冒号,然后是一个列限定符后缀(在本例中为a)。

也就是说,当前添加的列实际上就是前面创建的列族前缀+冒号:+后缀方式

6.scan命令
Scan the table for all data at once.
一次性扫描表中的所有数据,使用scan

scan 'test'

在这里插入图片描述

7.get命令
Get a single row of data.
获取单行数据

get 'test','row1'

get 数据表,行
在这里插入图片描述

8.disable和enable命令
禁用表
If you want to delete a table or change its settings, as well as in some other situations, you need to disable the table first, using the disable command. You can re-enable it using the enable command
如果你想要删除表或者改变它的设置,以及在其他情况下,你需要在第一时间禁用表,使用disable命令。你还可以使用enable命令重新启用表

disable 'test'
enable 'test'

在这里插入图片描述

9.删除表

disable 'test'
drop 'test'
list 'test'

在这里插入图片描述
10.退出hbase的shell
To exit the HBase Shell and disconnect from your cluster, use the quit command. HBase is still running in the background.

退出HBase Shell和断开你的集群连接,使用quit命令,HBase任然在后台运行

quit

在这里插入图片描述

11.停止HBase

./bin/stop-hbase.sh

在这里插入图片描述

3.总结

1.创建表的时候需要指定表名和列族名称,使用逗号分隔

2.通过bin/start-hbase.sh启动HBase和使用bin/stop-hbase.sh停止HBase

3.添加数据时需要使用put方法,并指定表名,行名,列族:列,值方式添加数据,注意列实际为列族+冒号+列方式

4.删除当前的数据表的之前需要先禁用当前的表

以上纯属个人见解,如有问题请联本人!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值