Hbase之shell操作
一. 介绍
HBase是一个分布式的、面向列的 开源数据库,源于google的一篇论文《bigtable:一个结构化数据的分布式存储系统》。HBase是Google Bigtable的开源实现,它利用Hadoop HDFS作为其文件存储系统,利用Hadoop MapReduce来处理HBase中的海量数据,利用Zookeeper作为协同服务。
HBase以表的形式存储数据。表有行和列组成。列划分为若干个列族/列簇(column family)。

如上图所示,key1, key2, key3是三条记录的唯一的row key值,column-family1, column-family2, column-family3是三个列族,每个列族下又包括几列。比如 column-family1这个列族下包括两列,名字是column1和column2。t1:abc,t2:gdxdf是由row key1和column-family1-column1唯一确定的一个单元cell。这个cell中有两个数据,abc和gdxdf。两个值的时间戳不 一样,分别是t1,t2, hbase会返回最新时间的值给请求者。
二. 安装
下载HBase最新版本,放到合适的目录,比如/usr/local 或 /opt
之后解压
tar -zxvf hbase-x.y.z tar.gz
三. 命令行操作
进入解压后的目录,开启hbase,启动hbase shell
bin/start-hbase.sh
bin/hbase shell

输入 help 可以看到命令分组

部分命令清单

下边分组举例
general操作
查询服务器状态 status

查询hbase版本 version

ddl操作
1. 创建一个表
create 'table1', 'tab1_id', 'tab1_add', 'tab1_info'
2. 列出所有的表
list

3. 获得表的描述
describe "table1"

4. 删除一个列族 disable alter enable
disable 'table1'
alter 'table1', {NAME=>'tab1_add', METHOD=>'delete'}
enable 'table1'
5. 查看表是否存在
exists 'table2'

6. 判断表是否为‘enable’
is_enabled 'table1'
判断表是否为‘disable’
is_disabled 'table1'
7. 删除一个表
disable 'table1'
drop 'table1'
dml操作
1. 插入几条记录
|
1
2
3
4
5
6
|
put 'member', 'scutshuxue', 'info:age', '24'put 'member', 'scutshuxue', 'info:birthday', '1987-06-17'put 'member', 'scutshuxue', 'info:company', 'alibaba'put 'member', 'scutshuxue', 'address:contry', 'china'put 'member', 'scutshuxue', 'address:province', 'zhejiang'put 'member', 'scutshuxue', 'address:city', 'hangzhou' |
2. 全表扫描 scan

3. 获得数据 get
3.1 获得一行的所有数据

3.2 获得某行,某列族的所有数据

3.3 获得某行,某列族,某列的所有数据

4. 更新一条记录 put(把scutshuxue年龄改为99)
put 'member', 'scutshuxue', 'info:age',
5. 删除 delete、 deleteall
5.1 (删除行'scutshuxue', 列族为‘info' 中age的值
delete 'member', 'scutshuxue', 'info:age'
5.2 删除整行
deleteall 'member', 'scutshuxue'
6. 查询表中有多少行
count 'member'
7. 给‘xiaoming’这个id增加'info:age'字段,并使用counter实现递增
incr 'member', 'xiaoming', 'info:age'
8. 将整个表清空
truncate 'member'

四. 参考
http://smallwildpig.iteye.com/blog/1705718
Hbase之shell操作的更多相关文章
- HBASE与hive对比使用以及HBASE常用shell操作。与sqoop的集成
2.6.与 Hive 的集成2.6.1.HBase 与 Hive 的对比1) Hive(1) 数据仓库Hive 的本质其实就相当于将 HDFS 中已经存储的文件在 Mysql 中做了一个双射关系,以方 ...
- 【hbase】hbase的shell操作笔记
HBase Shell $ ./bin/hbase shell # 进入交互界面 DDL操作: create:创建表(默认命名空间为default) # create '表名','列族1','列族2' ...
- HBase常用shell操作
行(row),列(Column),列蔟(Column Family),列标识符(Column Qualifier)和单元格(Cell) 行:由一个个行键(rowkey)和一个多个列组成.其中rowke ...
- HBase filter shell操作
创建表 create 'test1', 'lf', 'sf' lf: column family of LONG values (binary value) -- sf: column family ...
- HBase的Shell操作
1.进入命令行 bin/hbase shell 2.输入help 查看各种命令组. 命令是分组的,可以执行help 'general'查看general组的命令. 3.常用命令 --显示有哪些表 li ...
- HBase scan shell操作详解
创建表 create 'test1', 'lf', 'sf' lf: column family of LONG values (binary value) -- sf: column family ...
- hbase的常用的shell命令&hbase的DDL操作&hbase的DML操作
前言 笔者在分类中的hbase栏目之前已经分享了hbase的安装以及一些常用的shell命令的使用,这里不仅仅重新复习一下shell命令,还会介绍hbase的DDL以及DML的相关操作. hbase的 ...
- Hbase_02、Hbase的常用的shell命令&Hbase的DDL操作&Hbase的DML操作(转)
阅读目录 前言 一.hbase的shell操作 1.1启动hbase shell 1.2执行hbase shell的帮助文档 1.3退出hbase shell 1.4使用status命令查看hbase ...
- HBase学习笔记——配置及Shell操作
1.HBase的配置 还是以前配置的集群,见:http://www.cnblogs.com/DarrenChan/p/6493373.html 我们约定:weekend03和weekend04放HMa ...
随机推荐
- Delphi调用外部程序函数:WinExec() 和ShellExecute详解
1,WinExec(): WinExec主要运行EXE文件,不能运行其他类型的文件.不用引用特别单元. 原型:UINT WinExec(exePath,ShowCmd) 示例,我想要用记事 ...
- [kuangbin带你飞]专题二十二 区间DP
ID Origin Title 17 / 60 Problem A ZOJ 3537 Cake 54 / 105 Problem B LightOJ 1422 Hallowee ...
- esriSRProjCS2Type Constants
ArcGIS Developer Help (Geometry) esriSRProjCS2Type Constants See Also esriSRProjCSType Constants ...
- A - Red and Black(3.2.1)(小递归)
Description There is a rectangular room, covered with square tiles. Each tile is colored either red ...
- 访问控制符private,default,protect和public
程序,通过封装以实现"高内聚,内耦合". 个人理解,类内,包内,子类和所有类,是java的四个范围. private表示作用区域为类内,即只是自己(像牙刷). default表示作 ...
- OC基础(17)
ARC基本概念 ARC快速入门 ARC下的内存管理 ARC和MRC兼容和转换 *:first-child { margin-top: 0 !important; } body > *:last- ...
- Windows 2008下部署Exchange Server 2007
对于很多政府及企业来说,微软的邮件服务器Exchange Server都是一个不错的通信和协作平台选择,尤其新版邮件服务器Exchange Server 2007 和OCS的组合,在微软UC平台上创下 ...
- Rman-03002,Rman-12010,Rman-12012
为什么会出现如此的错误呢? 答:因为我们在分配通道时设备类型分配为磁带,但是你并没有安装磁带设备,所以就会出现这样的错误. 错误如下: 解决方法: 登陆你的目标数据库,重新进行设置,命令如下: con ...
- dedecms首页怎么调用公司简介的内容
DeDeCMS功能虽然强大,但还是有些细节上的功能没有实现,正如本文描述的问题一样,DEDECMS要在网站首页调用公司简介的内容,而且还要截取前多少个字符数的时候,DEDECMS标签中没有能实现这样的 ...
- 菜鸟学sql,Oracle数据库结构比较
转载自:http://www.cnblogs.com/tianqing/archive/2008/06/25/1229419.html 做oracle下数据库结构比较,比较具体详细差异,例如:2个库具 ...