HBase(docker版)简单部署和HBase shell操作实践

文章目录

  • 说明
  • HBase部署
  • 访问HBase Shell
  • 常见命令
    • 数据定义语言(DDL)
  • 数据操作语言(DML)
  • 通用操作
  • 访问HBase WebUI

说明

  • 本文适合HBase初学者快速搭建HBase环境,练习常见shell使用
  • 本文参考资料
    • 《大数据技术原理和应用》(林子雨 编著 第三版)
    • zhoupengbo的大数据练手项目

HBase部署

  1. 安装docker:可以安装1panel快速安装docker,然后再管理面板中配置镜像加速
  2. 然后在面板中拉取harisekhon/hbase镜像到本地
    在这里插入图片描述
  3. 运行容器
    docker run -d -h docker-hbase \
            -p 2181:2181 \
            -p 8080:8080 \
            -p 8085:8085 \
            -p 9090:9090 \
            -p 9000:9000 \
            -p 9095:9095 \
            -p 16000:16000 \
            -p 16010:16010 \
            -p 16201:16201 \
            -p 16301:16301 \
            -p 16020:16020\
            --name hbase \
            harisekhon/hbase
    
宿主机端口容器端口功能
21812181ZooKeeper端口,用于HBase集群的协调和通信
80808080HBase主控台Web界面端口,用于管理和监控
80858085HBase REST服务端口,通过REST API访问HBase
90909090HBase主控节点的RPC端口,客户端与主控节点通信
90009000HDFS的默认文件系统端口,用于数据存储
90959095HBase主控节点的Master服务端口,管理Master节点
1600016000HBase区域服务器的RPC端口,客户端与区域服务器通信
1601016010HBase区域服务器的Web界面端口,管理和监控区域服务器
1620116201HBase区域服务器的备用RPC端口,用于故障转移和容错
1630116301HBase区域服务器的备用Web界面端口,用于故障转移和容错
1602016020HBase主控节点的备用RPC端口,用于故障转移和容错

访问HBase Shell

# 查看运行的容器
docker ps
# 找到容器id,进入容器
docker exec -it <container ID前缀> bash
# 访问HBase Shell,进入容器后输入
hbase shell

常见命令

  • 在终端输入“hbase shell”命令进入该 Shell环境,输入“help”,可以查看 HBase 支持的所有 Shell 命令

    HBase Shell, version 2.1.3, rda5ec9e4c06c537213883cca8f3cc9a7c19daf67, Mon Feb 11 15:45:33 CST 2019
    Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
    Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.
    
    COMMAND GROUPS:
      Group name: general
      Commands: processlist, status, table_help, version, whoami
    
      Group name: ddl
      Commands: alter, alter_async, alter_status, clone_table_schema, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, list_regions, locate_region, show_filters
    
      Group name: namespace
      Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables
    
      Group name: dml
      Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve
    
      Group name: tools
      Commands: assign, balance_switch, balancer, balancer_enabled, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, cleaner_chore_enabled, cleaner_chore_run, cleaner_chore_switch, clear_block_cache, clear_compaction_queues, clear_deadservers, close_region, compact, compact_rs, compaction_state, flush, is_in_maintenance_mode, list_deadservers, major_compact, merge_region, move, normalize, normalizer_enabled, normalizer_switch, split, splitormerge_enabled, splitormerge_switch, stop_master, stop_regionserver, trace, unassign, wal_roll, zk_dump
    
      Group name: replication
      Commands: add_peer, append_peer_exclude_namespaces, append_peer_exclude_tableCFs, append_peer_namespaces, append_peer_tableCFs, disable_peer, disable_table_replication, enable_peer, enable_table_replication, get_peer_config, list_peer_configs, list_peers, list_replicated_tables, remove_peer, remove_peer_exclude_namespaces, remove_peer_exclude_tableCFs, remove_peer_namespaces, remove_peer_tableCFs, set_peer_bandwidth, set_peer_exclude_namespaces, set_peer_exclude_tableCFs, set_peer_namespaces, set_peer_replicate_all, set_peer_serial, set_peer_tableCFs, show_peer_tableCFs, update_peer_config
    
      Group name: snapshots
      Commands: clone_snapshot, delete_all_snapshot, delete_snapshot, delete_table_snapshots, list_snapshots, list_table_snapshots, restore_snapshot, snapshot
    
      Group name: configuration
      Commands: update_all_config, update_config
    
      Group name: quotas
      Commands: list_quota_snapshots, list_quota_table_sizes, list_quotas, list_snapshot_sizes, set_quota
    
      Group name: security
      Commands: grant, list_security_capabilities, revoke, user_permission
    
      Group name: procedures
      Commands: list_locks, list_procedures
    
      Group name: visibility labels
      Commands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibility
    
      Group name: rsgroup
      Commands: add_rsgroup, balance_rsgroup, get_rsgroup, get_server_rsgroup, get_table_rsgroup, list_rsgroups, move_namespaces_rsgroup, move_servers_namespaces_rsgroup, move_servers_rsgroup, move_servers_tables_rsgroup, move_tables_rsgroup, remove_rsgroup, remove_servers_rsgroup
    
    SHELL USAGE:
    Quote all names in HBase Shell such as table and column names.  Commas delimit
    command parameters.  Type <RETURN> after entering a command to run it.
    Dictionaries of configuration used in the creation and alteration of tables are
    Ruby Hashes. They look like this:
    
      {'key1' => 'value1', 'key2' => 'value2', ...}
    
    and are opened and closed with curley-braces.  Key/values are delimited by the
    '=>' character combination.  Usually keys are predefined constants such as
    NAME, VERSIONS, COMPRESSION, etc.  Constants do not need to be quoted.  Type
    'Object.constants' to see a (messy) list of all constants in the environment.
    
    If you are using binary keys or values and need to enter them in the shell, use
    double-quote'd hexadecimal representation. For example:
    
      hbase> get 't1', "key\x03\x3f\xcd"
      hbase> get 't1', "key\003\023\011"
      hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"
    
    The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
    For more on the HBase Shell, see http://hbase.apache.org/book.html
    

数据定义语言(DDL)

  1. create:创建表
    # 创建表 t1,列族为 f1,列族版本号为 5
    create 't1', {NAME => 'f1', VERSIONS => 5}
    # 创建表 t2,3 个列族分别为 f1、f2、f3
    create 't2', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
    # 等价的命令
    create 't2', 'f1', 'f2', 'f3'
    # 创建表 t3,将表依据分割算法 HexStringSplit 分布在 15 个 Region 里
    create 't3', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
    # 创建表 t1,指定切分点
    create 't5', 'f1', {SPLITS => ['10', '20', '30', '40']} 
    
  2. list:列出表信息
    hbase(main):035:0> list
    TABLE                                                                                                      
    t1                                                                                                         
    1 row(s)
    Took 0.0260 seconds                                                                                        
    => ["t1"]
    
  3. alter:修改列族模式
    # 向表t2添加列族 f1
    hbase(main):025:0> alter 't2', NAME => 'f4' 
    Updating all regions with the new schema...
    1/1 regions updated.
    Done.
    Took 1.9711 seconds                                                                                        
    # 删除表t2中的列族 f1
    hbase(main):026:0> alter 't2', NAME => 'f4', METHOD => 'delete'
    Updating all regions with the new schema...
    1/1 regions updated.
    Done.
    Took 1.7745 seconds  
    # 设定表t2中列族 f1 最大为 128 MB                                                                                      
    hbase(main):027:0> alter 't2', METHOD => 'table_att', MAX_FILESIZE => '134217728'
    Updating all regions with the new schema...
    1/1 regions updated.
    Done.
    Took 1.6691 seconds
    
  4. describe:显示表的相关信息
    hbase(main):039:0> describe 't2'
    Table t2 is ENABLED                                                                                        
    t2, {TABLE_ATTRIBUTES => {MAX_FILESIZE => '134217728'}                                                     
    COLUMN FAMILIES DESCRIPTION                                                                                
    {NAME => 'f1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}                                                                
    {NAME => 'f2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}                                                                
    {NAME => 'f3', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}                                                                
    3 row(s)
    Took 0.0345 seconds  
    
  5. 失效、删除表
    • 在HBase shell中,要删除一个表,首先需要确保该表是被禁用的(disable),然后才能进行删除(drop)。此外,表名应该用引号包围,因为它是一个字符串。
    # 先禁用表
    hbase(main):003:0> disable 't1'
    # 删除
    hbase(main):004:0> drop 't1'
    

数据操作语言(DML)

  1. put:向表、行、列指定的单元格添加数据
    # 向表t2中行row1和列f1:c1所对应的单元格中添加数据value1,时间戳为1421822284898
    hbase(main):011:0> put 't2', 'row1', 'f1:c1', 'value1', 1421822284898
    Took 0.0933 seconds    
    
  2. get:查询单元格数据
    # 获得表 t2、行 row1、列 c1、版本号为 4 的数据
    hbase(main):018:0> get 't2', 'row1', {COLUMN => 'f1',version=>4} 
    2.1.3, rda5ec9e4c06c537213883cca8f3cc9a7c19daf67, Mon Feb 11 15:45:33 CST 2019
    Took 0.0003 seconds                                                                                        
    COLUMN                      CELL                                                                           
     f1:c1                      timestamp=1421822284898, value=value1                                          
    1 row(s)
    Took 0.0059 seconds
    # 获得表t2、行row1、列c1和c2的数据
    hbase(main):021:0> get 't1','row1','f1'
    COLUMN                      CELL                                                                           
     f1:c1                      timestamp=1421822284898, value=value1                                          
    1 row(s)
    Took 0.0071 seconds     
    
  3. scan:浏览表的相关信息
    hbase(main):022:0> scan '.META.', {COLUMNS => 'info:regioninfo'}
    ERROR: .META. no longer exists. The table has been renamed to hbase:meta
    For usage try 'help "scan"'
    Took 0.0020 seconds                                                                                        
    hbase(main):023:0> scan 'hbase:meta', {COLUMNS => 'info:regioninfo'}
    ROW                         COLUMN+CELL                                                                    
    hbase:namespace,,170660797 column=info:regioninfo, timestamp=1706607975642, value={ENCODED => 8df5ef60ba63
    4908.8df5ef60ba6316c3e7dd2 16c3e7dd2e8cad870dc1, NAME => 'hbase:namespace,,1706607974908.8df5ef60ba6316c3ee8cad870dc1.  7dd2e8cad870dc1.', STARTKEY => '', ENDKEY => ''}                               
    t1,,1706610172446.41e2dba0 column=info:regioninfo, timestamp=1706610172938, value={ENCODED => 41e2dba025fd
    25fd0c022b04007fc93e380a.  0c022b04007fc93e380a, NAME => 't1,,1706610172446.41e2dba025fd0c022b04007fc93e380a.', STARTKEY => '', ENDKEY => ''}                                            
    2 row(s)
    Took 0.0389 seconds 
    
  4. count:统计表中的行数
    hbase(main):028:0> count 't1'
    1 row(s)
    Took 0.0440 seconds                                                                                        
    => 1
    

通用操作

  1. status:输出 HBase 集群状态信息
    • 可以通过 summary、simple 或者 detailed指定输出信息的详细程度
    hbase(main):031:0> status 'summary'
    1 active master, 0 backup masters, 1 servers, 0 dead, 3.0000 average load
    Took 0.0143 seconds                                                                                        
    hbase(main):032:0> status 'simple'
    active master:  docker-hbase:16000 1706607959227
    0 backup masters
    1 live servers
        docker-hbase:16020 1706607960371
            requestsPerSecond=0.0, numberOfOnlineRegions=3, usedHeapMB=52, maxHeapMB=1958, numberOfStores=7, numberOfStorefiles=7, storefileUncompressedSizeMB=0, storefileSizeMB=0, memstoreSizeMB=0, storefileIndexSizeKB=0, readRequestsCount=79, filteredReadRequestsCount=7, writeRequestsCount=36, rootIndexSizeKB=0, totalStaticIndexSizeKB=0, totalStaticBloomSizeKB=0, totalCompactingKVs=24, currentCompactedKVs=24, compactionProgressPct=1.0, coprocessors=[MultiRowMutationEndpoint]
    0 dead servers
    Aggregate load: 0, regions: 3
    Took 0.0077 seconds   
    
  2. version:查看版本
hbase(main):040:0> version
2.1.3, rda5ec9e4c06c537213883cca8f3cc9a7c19daf67, Mon Feb 11 15:45:33 CST 2019
Took 0.0004 seconds  

访问HBase WebUI

http://服务器IP:16010/master-status
  • 具体的内容,各位可以自行探究
    在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/358950.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C++ 滑动窗口

目录 1、209. 长度最小的子数组 2、3. 无重复字符的最长子串 3、1004. 最大连续1的个数 III 4、1658. 将 x 减到 0 的最小操作数 5、904. 水果成篮 6、438. 找到字符串中所有字母异位词 7、30. 串联所有单词的子串 8、76. 最小覆盖子串 1、209. 长度最小的子数组 思路&…

存储监控工具:监控存储区域网络(SAN)

从托管应用程序到提供大型多媒体服务&#xff0c;组织都依靠其 IT 基础架构来提供无与伦比的最终用户体验。为了提供这种卓越的体验&#xff0c;必须大大提高应用程序的可用性和性能。在许多其他挑战中&#xff0c;存储区域网络 &#xff08;SAN&#xff09; 正好用于应对这些挑…

TPCC-MySQL

简介 TPC-C是专门针对联机交易处理系统&#xff08;OLTP系统&#xff09;的规范&#xff0c;一般情况下我们也把这类系统称为业务处理系统。 Tpcc-mysql是percona基于TPC-C(下面简写成TPCC)衍生出来的产品&#xff0c;专用于MySQL基准测试。其源码放在launchpad上&#xff0c…

使用xlsx、xlsx-style导出表格添加背景色;合并单元格部分样式缺失问题解决

这篇说一下使用xlsx-style导出excel时样式的设置。需要安装xlsx、xlsx-style、file-saver插件&#xff08;file-saver可以不装&#xff0c;用a标签代替也可以&#xff09;&#xff0c;安装时可能会碰到一些报错问题&#xff0c;可以去看下我之前一篇博客&#xff1a;纯前端导出…

C语言之刷到的怪题(i与sizeof(i)比较大小)

这个题目一般都是选择输出<。为什么呢&#xff1f;因为i是一个全局变量&#xff0c;并且没有初始化&#xff0c;那么i的值就等于0。i--之后就是-1了。而sizeof(i)求出的就是整形变量对应的大小4个字节。-1<4&#xff0c;因此就选择 输出<。其实不然&#xff0c;这个si…

QEMU - e1000全虚拟化前端与TAP/TUN后端流程简析

目录 1. Host -> Guest 2.Guest ->Host 3. 如何修改以支持TUN设备的后端&#xff1f; 4. 相关 QEMU 源码 5. 实验 1. Host -> Guest 2.Guest ->Host 3. 如何修改以支持TUN设备的后端&#xff1f; 1. 简单通过后端网卡名字来判断是TUN还是TAP。 2. 需要前端全…

秋招面试—CSS篇

2021 CSS面试题 1.CSS可继承属性有哪些&#xff1f; 文字相关&#xff1a;font-famliy 、font-weight 、font-size 、font-style文本相关&#xff1a;text-indent&#xff08;首行缩进&#xff09; 、text-align&#xff08;水平对齐&#xff09; 、line-height 、text-trans…

node.js基础--01

Author nodes&#xff1a;&#xff08;题记&#xff09; node.js is an open-source&#xff0c;cross-platform JAVAScript runtime environment。 node.js是一个开源&#xff0c;跨平台的js运行环境 common commands&#xff08;常用指令&#xff09; 1、C: enter hard …

C# 一个快速读取写入操作execl的方法封装

这里封装了3个实用类ExcelDataReaderExtensions&#xff0c;ExcelDataSetConfiguration&#xff0c;ExcelDataTableConfiguration和一个实用代码参考&#xff1a; using ExcelDataReader; using System; using System.Collections.Generic; using System.Linq; using System.T…

解剖 Python 代码,深入学习 interpret 库的功能和应用!

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com Python是一门广泛应用的编程语言&#xff0c;拥有丰富的标准库和第三方库&#xff0c;可以用于各种应用场景。在Python中&#xff0c;有一个名为interpret的库&#xff0c;它提供了一种强大的方式来处理和执行Py…

一个通过下标查找数值的面试题解法

最近看到一道面试题&#xff0c;面试官说是算法题。我粗略看了下&#xff0c;努力在其中寻找数学公式&#xff0c;但是最后发现它算是一个数据结构相关的题目&#xff0c;没有算法层面的知识。 // There is an array generated by a rule. // The first item is 1. If k is in …

Codeforces Round 918 (Div. 4) 解题报告 | 珂学家 | 偏序 + 扩展Dijkstra

前言 整体评价 属于VP&#xff0c;感觉还是能AK的&#xff0c;E是偏序题&#xff0c;F是改版的迪杰特斯拉。 A. Odd One Out 题型: 签到 t int(input())for i in range(t):a, b, c list(map(int, input().split()))if a b:print (c)elif a c:print (b)else:print (a)B. …

基于Python的全国主要城市天气数据可视化大屏系统

1 绪论 1.1 研究的目的与意义 近年来&#xff0c;气候变化引发全球范围内的关注。天气数据的采集和分析对于气候预测、生态环境保护等方面都起着至关重要的作用。同时&#xff0c;随着科技的不断发展&#xff0c;数据可视化已经成为了许多领域中不可或缺的一部分。基于此&…

防御保护 笔记整理

一、ASPF--- 针对应用层的包过滤 ASPF --- 针对应用层的包过滤 --- 用来抓取多通道协议中协商端口的关键数据包&#xff0c;之后&#xff0c;将端 口算出&#xff0c;将结果记录在sever-map表中&#xff0c;相当于开辟了一条隐形的通道。 FTP --- 文件传输协议 FTP协议是一个典…

指针进阶1

一&#xff0c;字符指针 顾名思义&#xff1a;字符指针指的是一种指针类型为字符指针 char*&#xff1b; char*可以是一个字符也可以是一个字符串&#xff0c;前者很好理解&#xff0c;让我们看看后者&#xff1b; eg&#xff1a;char*p"abcdef";//实际上是将首元…

【开源精选导航】GitHub-Chinese-Top-Charts:一榜在手,优质中文项目轻松找寻

各位热爱开源技术的朋友们&#xff0c;你们是否有过这样的困扰&#xff1a;面对浩瀚的GitHub海洋&#xff0c;想找寻那些具有高质量中文文档的优秀开源项目却无从下手&#xff1f;今天&#xff0c;我们就为大家揭晓一个宝藏般的开源项目——GitHub 中文项目集合&#xff08;访问…

如何在win系统部署Apache服务并实现无公网ip远程访问

文章目录 前言1.Apache服务安装配置1.1 进入官网下载安装包1.2 Apache服务配置 2.安装cpolar内网穿透2.1 注册cpolar账号2.2 下载cpolar客户端 3. 获取远程桌面公网地址3.1 登录cpolar web ui管理界面3.2 创建公网地址 4. 固定公网地址 前言 Apache作为全球使用较高的Web服务器…

idea项目如何上传gitee

1.先创建仓库 2.从gitee上面clone下来 3.配置一下git 4.在idea里面安装Gitee插件&#xff08;安装完插件重启一下&#xff09; 5.将项目提交到远程仓库 git->add->✔ 完后点击↗ 在码云如何获取token&#xff1f; 注&#xff1a;没有解决&#xff0c;有时间在继续研究

linux kernel 内存踩踏之KASAN(一)

一、背景 linux 内核出现内存类问题时&#xff0c;我们常用的调试工具就是kasan&#xff0c;kasan有三种模式&#xff1a; 1. Generic KASAN &#xff08;这个就是我们最常用的&#xff0c;1 debug byte indicate 8 bytes use state, 对标用户层 asan&#xff09; 2. Softwa…

滴滴举行网约车合作伙伴大会,与174家合作伙伴共商发展

近日&#xff0c;滴滴在昆明举行主题为“凝心聚力&#xff0c;共享发展”的第四届网约车合作伙伴大会&#xff0c;汽车租赁公司、司机服务公司、主机厂、金融机构等174家上下游生态链合作伙伴齐聚一堂。滴滴已连续四年举办网约车合作伙伴大会&#xff0c;邀请合作伙伴广泛参与、…