首页 > 系统相关 >Hbase shell命令操作

Hbase shell命令操作

时间:2023-12-21 18:24:47浏览次数:30  
标签:info shell false list myHbase 命令 Hbase main hbase

1.进入hbase shell 命令行

[hdfs@hadoopm106 ~]$ hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/hdp/3.1.4.0-315/phoenix/phoenix-5.0.0.3.1.4.0-315-server.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/3.1.4.0-315/hadoop/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.0.2.3.1.4.0-315, r, Fri Aug 23 05:15:48 UTC 2019
Took 0.0015 seconds 

2.帮助 help

hbase(main):027:0> help
HBase Shell, version 2.0.2.3.1.4.0-315, r, Fri Aug 23 05:15:48 UTC 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, 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, trace, unassign, wal_roll, zk_dump

  Group name: replication
  Commands: add_peer, 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_namespaces, remove_peer_tableCFs, set_peer_bandwidth, set_peer_exclude_namespaces, set_peer_exclude_tableCFs, set_peer_namespaces, set_peer_replicate_all, 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

3.查看命名空间

hbase(main):028:0> list_namespace
NAMESPACE                                                                                                                                                                                                                 
SYSTEM                                                                                                                                                                                                                    
TEST                                                                                                                                                                                                                      
applet_center                                                                                                                                                                                                             
default                                                                                                                                                                                                                   
hbase                                                                                                                                                                                                                     
log_center                                                                                                                                                                                                                
message_center                                                                                                                                                                                                            
7 row(s)
Took 0.1432 seconds      

4.创建表myHbase

hbase(main):036:0> create 'myHbase',{NAME => 'myCard',VERSIONS =>5} 
Created table myHbase
Took 1.3105 seconds                                                                                                                                                                                                       
=> Hbase::Table - myHbase

创建了一个名为myHbase的表,表里面有1个列簇,名为myCard,保留5个版本信息

5.查看表详细信息

hbase(main):046:0* desc 'myHbase'
Table myHbase is ENABLED                                                                                                                                                                                                  
myHbase                                                                                                                                                                                                                   
COLUMN FAMILIES DESCRIPTION                                                                                                                                                                                               
{NAME => 'myCard', VERSIONS => '5', 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', BLOC
KCACHE => 'true', BLOCKSIZE => '65536'}                                                                                                                                                                                   
1 row(s)
Took 0.0280 seconds       

一个大括号,就相当于一个列簇。

6.添加一个列族

hbase(main):047:0> alter 'myHbase', NAME => 'myInfo'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.3094 seconds  

查看添加结果

hbase(main):051:0* desc 'myHbase'
Table myHbase is ENABLED                                                                                                                                                                                                  
myHbase                                                                                                                                                                                                                   
COLUMN FAMILIES DESCRIPTION                                                                                                                                                                                               
{NAME => 'myCard', VERSIONS => '5', 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', BLOC
KCACHE => 'true', BLOCKSIZE => '65536'}                                                                                                                                                                                   
{NAME => 'myInfo', 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', BLOC
KCACHE => 'true', BLOCKSIZE => '65536'}                                                                                                                                                                                   
2 row(s)
Took 0.0231 seconds 

7.删除一个列族

hbase(main):055:0* alter 'myHbase', NAME => 'myCard',METHOD => 'delete'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.1932 seconds                                                                                                                                                                                                       
hbase(main):056:0> 
hbase(main):057:0* desc 'myHbase'
Table myHbase is ENABLED                                                                                                                                                                                                  
myHbase                                                                                                                                                                                                                   
COLUMN FAMILIES DESCRIPTION                                                                                                                                                                                               
{NAME => 'myInfo', 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', BLOC
KCACHE => 'true', BLOCKSIZE => '65536'}                                                                                                                                                                                   
1 row(s)
Took 0.0273 seconds                

8. 清空表数据

hbase(main):058:0> truncate 'myHbase'
Truncating 'myHbase' table (it may take a while):
Disabling table...
Truncating table...
Took 1.6431 seconds    

9.删除表

hbase(main):059:0> drop 'myHbase'

ERROR: Table myHbase is enabled. Disable it first.

Drop the named table. Table must first be disabled:
  hbase> drop 't1'
  hbase> drop 'ns1:t1'

Took 0.0515 seconds                                                                                                                                                                                                       
hbase(main):060:0> disable 'myHbase'
Took 0.7457 seconds                                                                                                                                                                                                       
hbase(main):061:0> drop 'myHbase'
Took 0.2548 seconds                  

删除表之前需要对表进行disable

10.创建测试表进行写入put 和查询 get和删除delete

#创建测试表
hbase(main):063:0> create 'user_info',{NAME=>'base_info',VERSIONS=>3 }
Created table user_info
Took 1.2638 seconds                                                                                                                                                                                                       
=> Hbase::Table - user_info
# 向 user 表中插入信息,row key 为 user0001,列簇 base_info 中添加 name 列标示符,值为 zhangsan1
hbase(main):064:0> put 'user_info', 'user0001', 'base_info:name', 'zhangsan1'
Took 0.3964 seconds                                                                                                                                                                                                       
hbase(main):065:0> put 'user_info', 'user0001', 'base_info:age', '18'
Took 0.0262 seconds     
#查询表user_info,rowkey 为user0001                                                                                                                                                                                          
hbase(main):066:0> get 'user_info', 'user0001'
COLUMN                                                  CELL                                                                                                                                                              
 base_info:age                                          timestamp=1703152248107, value=18                                                                                                                                 
 base_info:name                                         timestamp=1703152237695, value=zhangsan1                                                                                                                          
1 row(s)
Took 0.2152 seconds   
#扫表数据 
hbase(main):067:0> scan 'user_info'
ROW                                                     COLUMN+CELL                                                                                                                                                       
 user0001                                               column=base_info:age, timestamp=1703152248107, value=18                                                                                                           
 user0001                                               column=base_info:name, timestamp=1703152237695, value=zhangsan1                                                                                                   
1 row(s)
Took 0.0648 seconds   
#删除user_info表row key为user0001,列标示符为base_info:name的数据                                                                                                                                                                                                                                                                                                                                                                                           
hbase(main):070:0> delete 'user_info', 'user0001', 'base_info:name'
Took 0.0188 seconds                                                                                                                                                                                                       
hbase(main):071:0> scan 'user_info'
ROW                                                     COLUMN+CELL                                                                                                                                                       
 user0001                                               column=base_info:age, timestamp=1703152248107, value=18                                                                                                           
1 row(s)
Took 0.0185 seconds                                                                   

标签:info,shell,false,list,myHbase,命令,Hbase,main,hbase
From: https://www.cnblogs.com/whiteY/p/17919811.html

相关文章

  • cmd命令行设置 windows 设置环境变量
    设置用户级别的环境变量::设置新参数JAVA_HOME1setxJAVA_HOME1"c:\test";exit;echo"%JAVA_HOME1%";::追加参数内容JAVA_HOME1setxJAVA_HOME1"%JAVA_HOME1%;c:\test2\;";exit;echo"%JAVA_HOME1%";::追加到Pathsetxpath"%pat......
  • 7z 命令行压缩解压详解-中文版
    1)简介7z,全称7-Zip,是一款开源软件。是目前公认的压缩比例最大的压缩解压软件。主页:http://www.7-zip.org/中文主页:http://7z.sparanoid.com/命令行版本下载:http://7z.sparanoid.com/download.htmlWindows去官网下载安装包安装linux使用命令安装:sudoaptinstallp7zip-full......
  • Shell下处理XML数据工具向导
    目录下载离线安装包安装源码包安装选项参考命令远程获取VmwareESXI机器的网络设备描述远程获取VmwareESXI机器的网络Mac地址参考网址下载离线安装包官方---DownloadPackage---libxml2安装#解析xml数据---xmllint工具--本地源yuminstalllibxml2-de......
  • 如何设置和配置dfsadmin命令
    Hadoop是一个用于处理大规模数据的开源框架,而dfsadmin命令是Hadoop中用于管理分布式文件系统(DFS)的命令。本文将介绍如何设置和配置dfsadmin命令,以便更好地管理和操作Hadoop的分布式文件系统。1.安装Hadoop:首先,需要安装Hadoop并完成基本的配置。可以从Hadoop官方网站下载最新的稳定......
  • 归档压缩_解压缩命令
    tar,即tapearchive归档打包1.创建档案包(以下``符号是为了清楚可见) tar-cvf``打包后的文件名`` ``打包前的文件名``其中,c,表示create创建档案v,表示verbose显示详情f,表示file也可以多个目录打包ta......
  • windows iscsicli 命令使用
      MicrosoftiSCSI发起程序版本6.1內部版本7601iscsicliiscsicliAddTarget<TargetName><TargetAlias><TargetPortalAddress><TargetPortalSocket><Targetflags><Persist><LoginFlags><HeaderDigest><DataDi......
  • centos7 下安装 moodle历史命令(未能包含vim 修改配置文件)
    1init02cd"/data/webapps/moodle"3cd/data/webapps/4ls5ll6cdmoodle/7ls8ll9vimlib/outputrenderers.php10ll11cd../12ll13chmod-R0777./moodle/14ll15......
  • The Missing Semester of Your CS Education----shell工具和脚本
    一.shell脚本1.$的关键字$0-脚本名$1到$9-脚本的参数。$1是第一个参数,依此类推。$@-所有参数$#-参数个数$?-前一个命令的返回值$$-当前脚本的进程识别码!!-完整的上一条命令,包括参数。常见应用:当你因为权限不足执行命令失败时,可以使用sudo!!再尝试一......
  • openGauss学习笔记-167 openGauss 数据库运维-备份与恢复-导入数据-使用gsql元命令导
    openGauss学习笔记-167openGauss数据库运维-备份与恢复-导入数据-使用gsql元命令导入数据gsql工具提供了元命令\copy进行数据导入。167.1\copy命令\copy命令格式以及说明参见表1\copy元命令说明。表1\copy元命令说明语法说明\copy{table[(column_list)......
  • 软件测试/测试开发|Ubuntu系统常用文件管理命令详解
    前言Ubuntu是一种广泛使用的Linux操作系统,提供了丰富而强大的文件管理命令,使用户能够通过命令行轻松管理文件和目录。本文将介绍一些常用的Ubuntu文件管理命令,帮助用户更好地理解和利用系统资源。ls-列出目录内容ls[选项][目录]ls命令用于列出目录中的文件和子目录。一些常用选......