Hbase 使用方法
列出所有 table¶
hbase(main):> list
新增 table¶
A . 直接增加一個表 t2
hbase(main):> create 't2'
B . 增加一個擁有 'f1','f2','fn' 為 column family 的表: t1
hbase(main):> create 't1','f1','f2','fn'
查詢 Table 欄位¶
hbase(main):> describe 't1'
執行結果參考
hbase(main):> describe 't1'
DESCRIPTION ENABLED
{NAME => 't1', FAMILIES => [{NAME => 'f1', COMPRESSION => 'NONE', VERS true
IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => '
false', BLOCKCACHE => 'true'}, {NAME => 'f2', COMPRESSION => 'NONE', V
ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY =
> 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NONE'
, VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR
Y => 'false', BLOCKCACHE => 'true'}]}
加入cell-value¶
需先擁有表 t1 與column-family : f1 並且加入一個 column-quantifier c1
hbase(main):> put 't1', 'r1', 'f1', 'v1'
hbase(main):> put 't1', 'r1', 'f1:c1', 'v2'
hbase(main):> put 't1', 'r2', 'f2', 'v3'
hbase(main):> put 't1', 'r2', 'f2:c2', 'v4'
| Table: 't1' | ||||||
| row-key | 'f1' | 'f2' | 'fn' | column-family | ||
| * | 'c1' | * | 'c2' | * | column-quantifier | |
| r1 | v1 | |||||
| v2 | ||||||
| r2 | v3 | |||||
| v4 | ||||||
列出cell-value¶
A . 列出一列(row)
hbase(main):> get 't1', 'r1'
執行結果參考
COLUMN CELL
f1: timestamp=1285737082689, value=v1
f1:c1 timestamp=1285737085874, value=v2
| Table: 't1' | ||||||
| row-key | 'f1' | 'f2' | 'fn' | column-family | ||
| * | 'c1' | * | 'c2' | * | column-quantifier | |
| r1 | v1 | |||||
| v2 | ||||||
| r2 | v3 | |||||
| v4 | ||||||
B . 列出一個 cell 的值
hbase(main):> get 't1', 'r1', {COLUMN => 'f1:c1'}
執行結果參考
COLUMN CELL
f1:c1 timestamp=1285737085874, value=v2
| Table: 't1' | ||||||
| row-key | 'f1' | 'f2' | 'fn' | column-family | ||
| * | 'c1' | * | 'c2' | * | column-quantifier | |
| r1 | v1 | |||||
| v2 | ||||||
| r2 | v3 | |||||
| v4 | ||||||
刪除 cell-value¶
hbase(main):> deleteall 't1','r1'
執行結果:會把 row-key 是 'r1' 的所有紀錄。此時資料表 't1' 會變成如下表所示。
hbase(main):> scan 't1'
ROW COLUMN+CELL
r2 column=f2:, timestamp=1285737091644, value=v3
r2 column=f2:c2, timestamp=1285737094157, value=v4
| Table: 't1' | ||||||
| row-key | 'f1' | 'f2' | 'fn' | column-family | ||
| * | 'c1' | * | 'c2' | * | column-quantifier | |
| r2 | v3 | |||||
| v4 | ||||||
加入column family¶
hbase(main):> disable 't1'
hbase(main):> alter 't1', {NAME => 'f3'}
hbase(main):> enable 't1'
執行結果:多了一個 column-family 'f3' 可以用 describe 指令查詢,結果示意如下表:
hbase(main):021:0> describe 't1'
DESCRIPTION ENABLED
{NAME => 't1', FAMILIES => [{NAME => 'f1', COMPRESSION => 'NONE', VERS true
IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => '
false', BLOCKCACHE => 'true'}, {NAME => 'f2', COMPRESSION => 'NONE', V
ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY =
> 'false', BLOCKCACHE => 'true'}, {NAME => 'f3', VERSIONS => '3', COMP
RESSION => 'NONE', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR
Y => 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NO
NE', VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_ME
MORY => 'false', BLOCKCACHE => 'true'}]}
| Table: 't1' | |||||||
| row-key | 'f1' | 'f2' | 'f3' | 'fn' | column-family | ||
| * | 'c1' | * | 'c2' | * | * | column-quantifier | |
| r2 | v3 | ||||||
| v4 | |||||||
刪除column family¶
hbase(main):> disable 't1'
hbase(main):> alter 't1', {NAME => 'f1', METHOD => 'delete'}
hbase(main):> enable 't1'
執行結果:會移除 column family 為 'f1' 的所有欄位,可用 describe 指令確認,結果如下表所示。
hbase(main):053:0> describe 't1'
DESCRIPTION ENABLED
{NAME => 't1', FAMILIES => [{NAME => 'f2', COMPRESSION => 'NONE', VERS true
IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => '
false', BLOCKCACHE => 'true'}, {NAME => 'f3', COMPRESSION => 'NONE', V
ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY =
> 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NONE'
, VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR
Y => 'false', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0200 seconds
| Table: 't1' | |||||||
| row-key | 'f2' | 'f3' | 'fn' | column-family | |||
| * | 'c2' | * | * | column-quantifier | |||
| r2 | v3 | ||||||
| v4 | |||||||
節點狀態¶
hbase(main):> status
刪除整張table¶
hbase(main):> truncate 't1'
- 執行完 truncate 後,所有 't1' 的內容都會被移除。但此時,下 list 還會有 't1' 這個表格存在。
hbase(main):> disable 't1'
hbase(main):> drop 't1'
- 要完整移除 't1' 資料表,必須使用 disable 先將 't1' 停用,再用 drop 指令把 't1' 完全刪除。
转自:http://trac.nchc.org.tw/cloud/wiki/NCHCCloudCourse100929_2_USE
Hbase 使用方法的更多相关文章
- HBase多条件及分页查询的一些方法
HBase是Apache Hadoop生态系统中的重要一员,它的海量数据存储能力,超高的数据读写性能,以及优秀的可扩展性使之成为最受欢迎的NoSQL数据库之一.它超强的插入和读取性能与它的数据组织方式 ...
- hbase运行mapreduce设置及基本数据加载方法
hbase与mapreduce集成后,运行mapreduce程序,同时需要mapreduce jar和hbase jar文件的支持,这时我们需要通过特殊设置使任务可以同时读取到hadoop jar和h ...
- HBase应用开发回顾与总结系列之四:HBase配置管理类接口设计
利用Eclipse进行HBase应用开发时,至少需要确定三个配置信息,如下表所示: #hbase config #HMaster服务部署主机及端口号 hbase.master=hdp-wuyong ...
- HBase 的安装与配置
实验简介 本次实验学习和了解 HBase 在不同模式下的配置和安装,以及 HBase 后续的启动和停止等. 一.实验环境说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou,密码shi ...
- hbase安装配置(整合到hadoop)
hbase安装配置(整合到hadoop) 如果想详细了解hbase的安装:http://abloz.com/hbase/book.html 和官网http://hbase.apache.org/ 1. ...
- hbase+springboot+redis实现分页
实现原理: 1.读取hbase数据每页的数据时多取一条数据.如:分页是10条一页,第一次查询hbase时, 取10+1条数据,然后把第一条和最后一条rowkey数据保存在redis中,redis中的k ...
- 大数据查询——HBase读写设计与实践
导语:本文介绍的项目主要解决 check 和 opinion2 张历史数据表(历史数据是指当业务发生过程中的完整中间流程和结果数据)的在线查询.原实现基于 Oracle 提供存储查询服务,随着数据量的 ...
- HBase读写的几种方式(三)flink篇
1. HBase连接的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一 ...
- [HBase Manual] CH2 Getting Started
Getting Started Getting Started 1. Introduction 2.Quick Start-Strandalone HBase 2.1 JDK版本选择 2.2 Get ...
随机推荐
- python3 中引用 HTMLTestRunner.py 模块的注意事项
HTMLTestRunner.py支持python2中运行,如果在python3.6.2中引用HTMLTestRunner.py模块,需要做一下更改: 1.更改HTMLTestRunner.py模块中 ...
- Android学习笔记之AndroidManifest.xml文件解析(详解)
一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(activiti ...
- spring tiles界面为空白
Caused by: org.apache.jasper.JasperException: /WEB-INF/views/admin_template.jsp(3,62) Unable to read ...
- English Phrases
@1:Phrases requst sth from/of sb 向某人要求某物 a new lease on life 重获新生.焕发生机 state of the art 最先进的 at th ...
- Harbor私有仓库搭建
1.安装docker yum install -y dockersystemctl start dockersystemctl enable docker 2.安装docker-compose 1.下 ...
- HTTP学习笔记02-HTTP报文格式之概述
HTTP学习笔记02-HTTP报文格式之概述 HTTP学习笔记02-HTTP报文格式之概述 HTTP报文格式 报文的语法 起始行 首部 实体部分 学习一个协议感觉最有意思的就是看包结构…在我看来这是唯 ...
- /usr/lib/update-notifier/updates-available
/usrb/update-notifier/update-motd-updates-available: 49: /usrb/update-notifier/update-motd-updates- ...
- Delphi 2005 以上版本GIF动画播放设置
源: Delphi 2005 以上版本GIF动画播放设置
- Windows下MarialDB使用
命令行控制启动和关闭:mysqld --console #这样启动ctrl+c即为关闭 启动:双击mysqld.exe即可 #此为后台启动 关闭:mysqladmin -uroot -pr ...
- SOA 面向服务架构 阅读笔记(一)
Service Oriented Architecture 面向服务架构 学习笔记(一) 1.业务自由 1.1 在很多企业中,业务和IT技术是各自独立的,无法使用通用的统一语言进行管理. 1.2 ...