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

说明

  • 本文适合HBase初学者快速搭建HBase环境,练习常见shell使用
  • 本文参考资料

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
    
宿主机端口 容器端口 功能
2181 2181 ZooKeeper端口,用于HBase集群的协调和通信
8080 8080 HBase主控台Web界面端口,用于管理和监控
8085 8085 HBase REST服务端口,通过REST API访问HBase
9090 9090 HBase主控节点的RPC端口,客户端与主控节点通信
9000 9000 HDFS的默认文件系统端口,用于数据存储
9095 9095 HBase主控节点的Master服务端口,管理Master节点
16000 16000 HBase区域服务器的RPC端口,客户端与区域服务器通信
16010 16010 HBase区域服务器的Web界面端口,管理和监控区域服务器
16201 16201 HBase区域服务器的备用RPC端口,用于故障转移和容错
16301 16301 HBase区域服务器的备用Web界面端口,用于故障转移和容错
16020 16020 HBase主控节点的备用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',{NUMREGIONS => 15,SPLITALGO => 'HexStringSplit'}
    # 创建表 t1,指定切分点
    create 't5',{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',BLOCKSIZE => '65536'}                                                                
    {NAME => 'f3',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',{COLUMN => 'f1',version=>4} 
    2.1.3,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','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.',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,Mon Feb 11 15:45:33 CST 2019
Took 0.0004 seconds  

访问HBase WebUI

http://服务器IP:16010/master-status
  • 具体的内容,各位可以自行探究

    在这里插入图片描述

原文地址:https://blog.csdn.net/yang2330648064/article/details/135938873

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


文章浏览阅读301次。你可以使用Thrift客户端来测试HBase Thrift服务。例如,在Python中,你可以使用。请确保你的HBase伪集群已正确配置并且Thrift服务已经启动。这将在你的伪集群中启动HBase Thrift服务。库或者直接使用Thrift接口。进入HBase的安装目录,找到。请根据需要进行相应的配置。这将停止Thrift服务。_hbase 单机 thrift 配置
文章浏览阅读565次。hive和hbase数据迁移_hive转hbase
文章浏览阅读707次。基于单机版安装HBase,前置条件为Hadoop安装完成,安装Hadoop可以参考链接,Hadoop单机安装。地址:https://dlcdn.apache.org/hbase/2.4.13/hbase-2.4.13-src.tar.gz2.解压缩文件3.进入到conf目录下4.修改配置文件 hbase-env.sh示例:示例:6.修改配置文件 hbase-site.xml示例:8.访问页面访问你所以在服务器的16010端口,查看页面以上就是单机版安装HBase的内容,后续_hbase 2.4.13下载
文章浏览阅读301次。linux集群搭建-HBase_linux中在/home目录下创建目录hbase
文章浏览阅读933次。中没有库的概念,说一个数据说的是哪一个名称空间下的那一张表下的哪一个行键的哪一个列族下面的哪一个列对应的是这个数据。注意:put数据需要指定往哪个命名空间的哪个表的哪个rowKey的哪个列族的哪个列中put数据,put的值是什么。注意:put数据需要指定往哪个命名空间的哪个表的哪个rowKey的哪个列族的哪个列中put数据,put的值是什么。注意:put数据需要指定往哪个命名空间的哪个表的哪个rowKey的哪个列族的哪个列中put数据,put的值是什么。操作Hbase系统DDL,对名称空间等进行操作。_hbase中报错undefined method for main:object
文章浏览阅读1k次,点赞16次,收藏21次。整理和梳理日常hbase的监控核心指标,作为经验沉淀_hbase 对应promethus指标名
文章浏览阅读1.5k次,点赞45次,收藏20次。今天把之前学习Hbase的入门基础知识笔记翻出来了,为了不忘记也是帮助身边的小伙伴,我把他又整理了下放了出来给大家,希望对HBASE一知半解的小伙伴,能够对Hbase有一个清晰的认识,好了废话不多说,进入正题。以上内容就是初的识HBase 入门知识,包含了hbase的由来,特性,物理存储,逻辑存储模型,以及优缺点,应用场景这些内容,相信后面在使用或更深入的研究Hbase打下了良好的基础,后面的更深入的学习内容,看计划安排在后面的文章中进行更新。
文章浏览阅读655次。HDFS,适合运行在通用硬件上的分布式文件系统,是一个高度容错性的系统,适合部署在廉价的机器上。Hbase,是一个分布式的、面向列的开源数据库,适合于非结构化数据存储。MapReduce,一种编程模型,方便编程人员在不会分布式并行编程的情况下,将自己的程序运行在分布式系统上。Chukwa,是一个开源的用于监控大型分布式系统的数据收集系统。_开源非结构化数据存储
文章浏览阅读1.9k次。mongodb和hbase的区别和应用场景_hbase和mongodb的区别
文章浏览阅读1.2k次。Hbase入门篇01---基本概念和部署教程_hbase教程
文章浏览阅读1.6k次,点赞19次,收藏25次。hbase相关内容
文章浏览阅读942次,点赞16次,收藏20次。在hbase1.x中transition是令广大大数据运维人员头疼的一个话题,因为,region 的状态转移涉及到了三个核心组件,分别为:hbase master,zookeeper和hbase 的regionserver,这三个组件中的某一个region的状态都是一致的情况下,这个region 才算是正常,状态转移过程及其复杂,hbase 集群很容易出现RIT。好消息是,hbase2.x中有个工具HBCK2,这个工具可不是简单的hbase1.x中hbck 的升级,变化有点大,详细变化请参考帮助文档(
文章浏览阅读1k次。在HBase中,Region分裂是一种自动的机制,用于在Region大小达到一定阈值时将其分裂成两个Region,以便更好地管理数据。HBase中的Region大小是可以配置的,通过设置HBase表的最小和最大Region大小来控制。需要注意的是,禁止Region分裂后,当表的大小达到一定阈值时,数据将不再分裂成新的Region,因此需要根据实际需求进行调整。需要注意的是,禁止Region分裂后,当表的大小达到一定阈值时,数据将不再分裂成新的Region,因此需要根据实际需求进行调整。_hbase region大小
文章浏览阅读737次。可以看出,HBase作为数据仓库的一种补充,可以用于存储和管理大量数据,以便快速地分析和查询。是一种基于数据库的形式,用于存储和管理大量数据,以便快速地分析和查询。例如,可以使用HBase存储一些用户行为数据,然后进行分析,以便更好地了解用户行为和需求。其次,需要配置HBase相关的环境变量,例如JAVA_HOME、HBASE_HOME等。HBase可以用于存储结构化和非结构化数据,包括文本、图像、视频等。例如,可以使用HBase存储一些传感器数据,然后进行实时分析和处理。一、HBase集群环境搭建。_用hbase 搭建数仓
文章浏览阅读1.9k次。Data。_springboot整合hbase
文章浏览阅读880次,点赞23次,收藏20次。etc/abrt下的两个文件,分别是:abrt-action-save-package-data.conf 和 abrt.conf,修改内容如下。我们后面排查的时候去查看/run/cloudera-scm-agent/process/2325-hbase-REGIONSERVER下是否有。发现有个hs_err_pid15967.log JVM生成的错误日志,那么把这个日志下载查看,返现日志这么写的。接下来就等下一次hbase的节点挂了之后查看转储文件,转储文件在/var/sqool/abrt下。_regionserver 退出 没有错误日志
文章浏览阅读1.7k次。以下命令都需要在Hbase Shell中运行:Hbase信息status:服务器状态version:版本表操作查看所有表:list表基本信息:describe "表名称"查看表是否存在:exists '表名称'创建表:create '表名称', '列族1', '列族2', '列族3'删除表:首先禁用表:disable '表名称'然后删除表:drop '表名称'修改表:表数据操作查看所有数据:scan "表名称"..._hbase sehll怎么看登录的是哪个hbase
文章浏览阅读885次,点赞18次,收藏21次。在HBase中执行查询操作通常使用HBase Shell或编程语言API(如Java或Python)来执行。使用编程语言API,您可以使用相应的HBase客户端库来执行查询操作。这是一个简单的Java代码示例,演示了如何使用HBase Java API进行单行查询。这些示例仅为基本查询操作,HBase Shell还提供其他高级查询功能,如按时间戳过滤,使用正则表达式进行查询等。请注意,这只是HBase查询的基本示例,您可以根据实际需求和HBase的数据模型进行更复杂的查询操作。
文章浏览阅读7.3k次,点赞7次,收藏28次。找到hbase的bin目录并进入,执行启动hbase hmaster命令。问题原因 hmaster挂了 ,需要重新启动hmaster才行。hbase shell输入命令出现如下问题。_keepererrorcode = nonode for /hbase/master
文章浏览阅读1.3k次。三次信息化浪潮。_大数据应用开发技术笔记