【hbase】hbase的shell操作笔记
HBase Shell
$ ./bin/hbase shell # 进入交互界面
DDL操作:
create:创建表(默认命名空间为default)
# create '表名','列族1','列族2'...
hbase(main):005:0> create 'student','info'
0 row(s) in 1.4250 seconds
=> Hbase::Table - student
list:列出所有table
hbase(main):005:0> list # 列出所有的Table
TABLE
student
1 row(s) in 0.0160 seconds
=> ["student"]describe '表名':查看表详细信息
# 查看表详细信息describe
hbase(main):007:0> describe 'student'
Table student is ENABLED
student
COLUMN FAMILIES DESCRIPTION
{NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '', BLOCKCACHE => 'true', BLOCKSIZE => '', REPLICATION_SCOPE => ''}
1 row(s) in 0.1090 secondsNAME:列族名
BLOOMFILTER:布隆过滤器
VERSIONS:版本数,当前列族可以存多少版本
alter:修改某列族的信息:
# alter '表名',{NAME=>'列族名' ....}
# 比如:修改VERSION版本数
hbase(main):011:0> alter 'student',{NAME=>'info',VERSIONS=>3}
hbase(main):012:0> describe 'student' # 再次查看
{NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '',....删除表,需要先disabled
# 删除表,需要先disabled,再drop
hbase(main):016:0> disable 'student'
hbase(main):017:0> drop 'student'
命名空间:
查看命名空间:list_namespace
hbase(main):019:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.0330 seconds创建命名空间:create_namespace '空间名'
hbase(main):020:0> create_namespace 'bigdata'
创建表到指定命名空间
hbase(main):022:0> create 'bigdata:student','info'
0 row(s) in 2.2200 seconds
=> Hbase::Table - bigdata:student删除命名空间:drop_namespace (必须是空的命名空间,要先删表)
hbase(main):023:0> disable 'bigdata:student'
0 row(s) in 2.2510 seconds
hbase(main):024:0> drop 'bigdata:student'
0 row(s) in 1.2370 seconds
hbase(main):026:0> drop_namespace 'bigdata'
0 row(s) in 0.8750 seconds
DML
put:增加,修改数据
# put '表名','RowKey','列族:列名','数据'
hbase(main):030:0> put 'test','','info1:name','zhangsan'scan:扫描查询(最大范围是查整个table)
# 注意:下面查询结果为3条数据
hbase(main):040:0> scan 'test'
ROW COLUMN+CELL
1001 column=info1:age, timestamp=1571381227061, value=17
1001 column=info1:name, timestamp=1571380877053, value=zhangsan
1001 column=info2:addr, timestamp=1571381241065, value=shanghai
1002 column=info1:age, timestamp=1571381266364, value=16
1002 column=info1:name, timestamp=1571381256744, value=lily
1002 column=info2:addr, timestamp=1571381276540, value=beijing
1003 column=info2:addr, timestamp=1571381290769, value=nanjing
3 row(s) in 0.0590 seconds
# 查看,左闭右开区间
hbase(main):044:0> scan 'test',{STARTROW=>'',ENDROW=>''}
# 查看,覆盖的版本,已经type
hbase(main):059:0> scan 'test',{RAW=>TRUE,VERSIONS=>3}
ROW COLUMN+CELL
1001 column=info1:age, timestamp=1571381227061, value=17
1001 column=info1:name, timestamp=1571382287224, type=DeleteColumn
1001 column=info1:name, timestamp=1571382179439, value=zhangsansan
1001 column=info1:name, timestamp=1571382130052, value=zhang
1001 column=info2:addr, timestamp=1571381241065, value=shanghai
1002 column=info1:age, timestamp=1571381266364, value=16
1002 column=info1:name, timestamp=1571381256744, value=lily
1002 column=info2:addr, timestamp=1571381276540, value=beijing
1003 column=info2:addr, timestamp=1571381290769, value=nanjingget:查询(最大范围是查RowKey)
# 查看一条数据,一个RowKey
hbase(main):041:0> get 'test',''
COLUMN CELL
info1:age timestamp=1571381227061, value=17
info1:name timestamp=1571380877053, value=zhangsan
info2:addr timestamp=1571381241065, value=shanghai
1 row(s) in 0.0050 seconds
# 查看某列
hbase(main):042:0> get 'test','','info1:name'
COLUMN CELL
info1:name timestamp=1571380877053, value=zhangsandelete:删除数据,在shell命令中必须指定到列,API中可以指定到列族
# 指定到列
hbase(main):054:0> delete 'test','','info1:name'alter:变更表信息
# 将info列族修改为可以存放3个版本
hbase(main):004:0> alter 'stu',{NAME=>'info',VERSIONS=>3}多版本查询
hbase(main):007:0> get 'stu','',{COLUMN=>'info:name',VERSIONS=>3}
COLUMN CELL
info:name timestamp=1571383299883, value=lucy
info:name timestamp=1571383293258, value=lily
【hbase】hbase的shell操作笔记的更多相关文章
- Hbase快速开始——shell操作
一. 介绍 HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实 ...
- HBase(四)HBase集群Shell操作
一.进入HBase命令行 在你安装的随意台服务器节点上,执行命令:hbase shell,会进入到你的 hbase shell 客 户端 [admin@node21 ~]$ hbase shell S ...
- Hbase数据结构和shell操作
Hbase的数据结构 基本要素:命名空间.表.行.列.单元格,region,时间戳. 1.命名空间:NameSpaces的作用 Table:表,所有的表都是命名空间的成员,即表必属于某个命名空间,如果 ...
- HBase学习之路 (三)HBase集群Shell操作
进入HBase命令行 在你安装的随意台服务器节点上,执行命令:hbase shell,会进入到你的 hbase shell 客 户端 [hadoop@hadoop1 ~]$ hbase shell S ...
- Hbase(二)【shell操作】
目录 一.基础操作 1.进入shell命令行 2.帮助查看命令 二.命名空间操作 1.创建namespace 2.查看namespace 3.删除命名空间 三.表操作 1.查看所有表 2.创建表 3. ...
- Hbase的常见shell操作
1.带namespace的:https://blog.csdn.net/opensure/article/details/46470969 2.http://www.cnblogs.com/xing9 ...
- HBase学习笔记——配置及Shell操作
1.HBase的配置 还是以前配置的集群,见:http://www.cnblogs.com/DarrenChan/p/6493373.html 我们约定:weekend03和weekend04放HMa ...
- Hbase之shell操作
一. 介绍 HBase是一个分布式的.面向列的 开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源 ...
- HBase(3)-安装与Shell操作
一. 安装 1. 启动Zookeeper集群 2. 启动Hadoop集群 3. 上传并解压HBase -bin.tar.gz -C /opt/module 4. 修改配置文件 #修改habse-env ...
随机推荐
- Spring Boot源码中模块详解
Spring Boot源码中模块详解 一.源码 spring boot2.1版本源码地址:https://github.com/spring-projects/spring-boot/tree/2.1 ...
- openresty开发系列32--openresty执行流程之1初始化阶段
openresty开发系列32--openresty执行流程之初始化阶段 一)初始化阶段 1)init_by_lua init_by_lua_block init_by_lua_file语 ...
- springboot 整合mongodb
Mongodb Mongodb是为快速开发互联网Web应用而构建的数据库系统,其数据模型和持久化策略就是为了构建高读/写吞吐量和高自动灾备伸缩性的系统. 在pom.xml中添加相关依赖 <!-- ...
- tp-rbac应该这么用
一.安装 1.下载gmars/tp5-rbac composer require gmars/tp5-rbac 如果该方法报错请按照以下方式操作: 打开项目根目录下的composer.json 在re ...
- [LeetCode] 283. Move Zeroes 移动零
Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...
- 【网络开发】详谈socket请求Web服务器过程
最开始我们需要明白一件事情,因为这是这篇文章的前提: HTTP协议只是一个应用层协议,它底层是通过TCP进行传输数据的.因此,浏览器访问Web服务器的过程必须先有"连接建立"的发生 ...
- Linux中buff/cache内存占用过高解决办法
在Linux系统中,我们经常用free命令来查看系统内存的使用状态.在一个centos7的系统上,free命令的显示内容大概是这样一个状态: 这个命令几乎是每一个使用过Linux的人必会的命令,但越是 ...
- Python简介及开发环境搭建
Python简介 Python是一门动态解释性的强类型定义的计算机程序设计语言,是一种完全面向对象的语言,由荷兰人"龟叔"-Guido van Rossum于1989年开发,于19 ...
- xorm插入数据实例
package main import ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/ ...
- Hadoop 系列(六)—— HDFS 常用 Shell 命令
一.基本命令 打开 Hbase Shell: # hbase shell 1.1 获取帮助 # 获取帮助 help # 获取命令的详细信息 help 'status' 1.2 查看服务器状态 stat ...