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

news2024/9/23 23:21:42

文章目录

  • 说明
  • 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.coloradmin.cn/o/1420948.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一文彻底搞懂redis数据结构及应用

文章目录 1. Redis介绍2.五种基本类型2.1 String字符串2.2 List列表2.3 Set集合2.4 Zset有序集合2.5 Hash散列 3. 三种基本类型3.1 Bitmap &#xff08;位存储&#xff09;3.2 HyperLogLogs&#xff08;基数统计&#xff09;3.3 geospatial (地理位置) 4. Stream详解4.1 Stream…

NTRU-Based GSW-Like FHE:Faster Blind Rotation

参考文献&#xff1a; [XZD23] Xiang, B., Zhang, J., Deng, Y., Dai, Y., Feng, D. (2023). Fast Blind Rotation for Bootstrapping FHEs. In: Handschuh, H., Lysyanskaya, A. (eds) Advances in Cryptology – CRYPTO 2023. CRYPTO 2023. Lecture Notes in Computer Scien…

C++_list

目录 一、模拟实现list 1、list的基本结构 2、迭代器封装 2.1 正向迭代器 2.2 反向迭代器 3、指定位置插入 4、指定位置删除 5、结语 前言&#xff1a; list是STL(标准模板库)中的八大容器之一&#xff0c;而STL属于C标准库的一部分&#xff0c;因此在C中可以直接使用…

实现扫码登录

扫码登录是如何实现的&#xff1f; 二维码信息里主要包括唯一的二维码ID,过期的时间&#xff0c;还有扫描状态&#xff1a;未扫描、已扫描、已失效。 扫码登录流程 用户打开网站登录页面的时候&#xff0c;浏览器会向二维码服务器发送一个获取登录二维码的请求。二维码服务器收…

雨云VPS搭建幻兽帕鲁服务器,PalWorld开服联机教程(Windows),0基础保姆级教程

雨云VPS用Windows系统搭建幻兽帕鲁私服&#xff0c;PalWorld开服联机教程&#xff0c;零基础保姆级教程&#xff0c;本教程使用一键脚本来搭建幻兽帕鲁服务端&#xff0c;并讲了如何配置游戏参数&#xff0c;如何更新服务端等。 最近这游戏挺火&#xff0c;很多人想跟朋友联机…

顶象点选验证码

要放假了好颓废。。。。 没啥事儿干&#xff0c;就把之前剩余的顶象点选系列的验证码类型看了下。 之前分享了一篇关于这个顶象的滑块的 DX算法还原_dx算法还原_逆向学习之旅-CSDN博客&#xff0c;感兴趣可以去看看。 咱们以文字点选为例&#xff1a; def get_image_arry(s…

Spring Boot如何统计一个Bean中方法的调用次数

目录 实现思路 前置条件 实现步骤 首先我们先自定义一个注解 接下来定义一个切面 需要统计方法上使用该注解 测试 实现思路 通过AOP即可实现&#xff0c;通过AOP对Bean进行代理&#xff0c;在每次执行方法前或者后进行几次计数统计。这个主要就是考虑好如何避免并发情况…

AI绘画:PhotoMaker Win11本地安装记录!

昨天介绍一个叫PhotoMaker的AI绘画开源项目。挺不错的&#xff01; 通过这个项目可以快速制作特定人脸的AI绘画作品&#xff0c;相比传统的技术效果会好很多&#xff0c;效率也高很多。 今天趁热打铁&#xff0c;本地电脑装装看&#xff0c;并且记录&#xff0c;分享一下&#…

城建档案数字化管理系统

城市建设档案数字化管理系统是指将城市建设相关档案纸质化资料转换为数字化形式&#xff0c;并通过信息技术手段进行存储、检索、管理和利用的系统。该系统旨在解决传统纸质档案管理存在的问题&#xff0c;提高档案管理的效率和准确性。 专久智能城市建设档案数字化管理系统主要…

自学C语言-7

第7章 循环控制 生活中总会有许多简单而重复的工作&#xff0c;为完成这些重复性工作&#xff0c;需要花费很多时间。使用循环语句来处理程序开发中简单、重复性的工作是最好不过的了。 本章致力于使读者了解while、do…while和for3种循环结构的特点&#xff0c;以及转移语句的…

Python第三方扩展库Matplotlib

Python第三方扩展库Matplotlib Matplotlib 是第三方库&#xff0c;不是Python安装程序自带的库&#xff0c;需要额外安装&#xff0c;它是Python的一个综合性的绘图库&#xff0c;提供了大量的绘图函数用于创建静态、动态、交互式的图形和数据可视化&#xff0c;可以帮助用户创…

Python实现时间序列分析AR定阶自回归模型(ar_select_order算法)项目实战

说明&#xff1a;这是一个机器学习实战项目&#xff08;附带数据代码文档视频讲解&#xff09;&#xff0c;如需数据代码文档视频讲解可以直接到文章最后获取。 1.项目背景 时间序列分析中&#xff0c;AR定阶自回归模型&#xff08;AR order selection&#xff09;是指确定自回…

Springboot使用数据库连接池druid

springboot框架中可以使用druid进行数据库连接池&#xff0c;下面介绍druid在springboot中使用和参数配置介绍。 数据库连接池&#xff08;Druid&#xff09;是一种用于管理数据库连接的机制&#xff0c;其工作原理和常见使用方法如下&#xff1a; 原理&#xff1a;数据库连接…

Android 12 系统开机动画

一、查找Android系统提供的开机动画 在Android系统源码目录下输入 find ./ -name "bootanimation.zip" 如图所示 所输出的路劲即为bootanimation.zip所在路径&#xff0c;每个系统都不一样&#xff0c;建议用命令查找 二、复制到对应目录下 android12\out\target\…

vue使用mpegts.js教程

vue使用mpegts.js教程 最简单好用的H265网页播放器-mpegts.js简介特征受限性 使用步骤安装引入HTML 中添加视频标签video知识扩展 在容器里创建播放器 最简单好用的H265网页播放器-mpegts.js H265是新一代视频编码规范&#xff0c;与H264相比压缩比更高&#xff0c;同样的码率下…

Web实战丨基于Django的简单网页计数器

文章目录 写在前面Django简介主要程序运行结果系列文章写在后面 写在前面 本期内容 基于django的简单网页计数器 所需环境 pythonpycharm或vscodedjango 下载地址 https://download.csdn.net/download/m0_68111267/88795604 Django简介 Django 是一个用 Python 编写的高…

prism 10 for Mac v10.1.1.270激活版 医学绘图分析软件

GraphPad Prism 10 for Mac是一款专为科研工作者和数据分析师设计的绘图和数据可视化软件。以下是该软件的一些主要功能&#xff1a; 软件下载&#xff1a;prism 10 for Mac v10.1.1.270激活版 数据整理和导入&#xff1a;GraphPad Prism 10支持从多种数据源导入数据&#xff0…

设计与实现基于Java+MySQL的考勤发布-签到系统

课题背景 随着现代经济的迅速发展&#xff0c;电子考勤签到服务已经渗透到人们生活的方方面面&#xff0c;成为不可或缺的一项服务。在这个背景下&#xff0c;线上签到作为考勤签到的一种创新形式&#xff0c;为用户提供了便捷的操作方式&#xff0c;使得任务签到、个人签到记…

神经调节的Hebbian学习用于完全测试时自适应

摘要 完全测试时自适应&#xff08;Fully test-time adaptation&#xff09;是指在推理阶段对输入样本进行序列分析&#xff0c;从而对网络模型进行自适应&#xff0c;以解决深度神经网络的跨域性能退化问题。我们从生物学合理性学习中获得灵感&#xff0c;其中神经元反应是基…

【HarmonyOS应用开发】UIAbility实践第一部分(五)

一、UIAbility概述 1、UIAbility是一种包含用户界面的应用组件&#xff0c;主要用于和用户进行交互。UIAbility也是系统调度的单元&#xff0c;为应用提供窗口在其中绘制界面。 2、每一个UIAbility实例&#xff0c;都对应于一个最近任务列表中的任务。 3、一个应用可以有一个UI…