您现在的位置是:主页 > news > 自助网站开发/合肥头条今日头条新闻最新消息

自助网站开发/合肥头条今日头条新闻最新消息

admin2025/5/2 20:48:10news

简介自助网站开发,合肥头条今日头条新闻最新消息,wordpress自动 插件怎么用,贵州建设学校网站客户端操作1、客户端2、DDLNameSpace的管理创建列举删除表的管理创建列举删除3、DML【增删改查】put:插入数据/更新数据【类似于mysql中的replace,如果不存在就插入,如果存在就更新】get:获取数据delete:删除数据scan&…

自助网站开发,合肥头条今日头条新闻最新消息,wordpress自动 插件怎么用,贵州建设学校网站客户端操作1、客户端2、DDLNameSpace的管理创建列举删除表的管理创建列举删除3、DML【增删改查】put:插入数据/更新数据【类似于mysql中的replace,如果不存在就插入,如果存在就更新】get:获取数据delete:删除数据scan&…

客户端操作

  • 1、客户端
  • 2、DDL
    • NameSpace的管理
      • 创建
      • 列举
      • 删除
    • 表的管理
      • 创建
      • 列举
      • 删除
  • 3、DML【增删改查】
      • put:插入数据/更新数据【类似于mysql中的replace,如果不存在就插入,如果存在就更新】
      • get:获取数据
      • delete:删除数据
      • scan:扫描数据

1、客户端

  • hbase
[root@node-01 hbase-1.2.0-cdh5.14.0]# hbase
Usage: hbase [<options>] <command> [<args>]Commands:
Some commands take arguments. Pass no args or -h for usage.shell           Run the HBase shellhbck            Run the hbase 'fsck' toolsnapshot        Create a new snapshot of a tablesnapshotinfo    Tool for dumping snapshot informationwal             Write-ahead-log analyzerhfile           Store file analyzerzkcli           Run the ZooKeeper shellupgrade         Upgrade hbasemaster          Run an HBase HMaster noderegionserver    Run an HBase HRegionServer nodezookeeper       Run a Zookeeper serverrest            Run an HBase REST serverthrift          Run the HBase Thrift serverthrift2         Run the HBase Thrift2 serverclean           Run the HBase clean up scriptclasspath       Dump hbase CLASSPATHmapredcp        Dump CLASSPATH entries required by mapreducepe              Run PerformanceEvaluationltt             Run LoadTestToolversion         Print the versionCLASSNAME       Run the class named CLASSNAME
  • hbase shell
    • 运行hbase 的客户端命令行
    • 退出:exit
    • 注意事项一
      • 不支持SQL语句
      • 不支持SQL语句
      • 不支持SQL语句
      • 命令不能用分号结尾
      • 命令不能用分号结尾
      • 命令不能用分号结尾
    • 查看命令帮助文档
      • HBase Shell; enter ‘help’ for list of supported commands.
      • help
    • 注意事项二
      • 这个命令行如果写错了,删除不能直接按backspace按键
      • 默认删除是向后删除
      • 按住ctrl+backspace删除键可以向前删除(或者设置会话选项里的映射键,打两个√)

2、DDL

NameSpace的管理

  Group name: namespaceCommands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables
  • 如果不知道某个命令的用法
help 'command'
help 'create_namespace'

创建

  • 语法
    • create_namespace ‘ns1’
  • 测试
    • create_namespace ‘hanjiaxiaozhi01’
    • create_namespace ‘hanjiaxiaozhi02’
    • create_namespace ‘student’

列举

list_namespace

删除

drop_namespace 'hanjiaxiaozhi02'
  • 列举某个namespace中所有的表
    在这里插入图片描述

表的管理

Group name: ddlCommands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, locate_region, show_filters
  • 官方文档中的缩写的含义
    • ns:namespace
    • t:table
    • r:rowkey
    • f:列族
    • c:列
    • v:值
    • ts:时间戳

创建

  • 必须指定在哪个namespace中创建表,如果不指定,就默认在default的namespace中创建
  • 必须指定表的名称
  • 必须至少指定创建一个列族
  • 方式一:直接给定列族的名称,不需要配置列族的属性
create 'ns1:t1', 'f1'
create 'ns1:t1', 'f1','f2'
  • 测试
create 'hanjiaxiaozhi01:hanjiaxiaozhi','cf1'
create 'heima' ,'cf1','cf2'
  • 不加ns,就代表操作default的ns
  • 方式二:需要更改列族的属性
create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}
  • 测试
create 'student:stu3',{NAME=>'basic',VERSIONS=>3},'other'

列举

  • list

删除

  • 语法
drop  'nsname:tbname'
  • 测试
drop  'heima'
  • 注意
    • Hbase所有的表是有两种状态
    • ENABLED启动状态:可以正常读写的表
    • Disable禁用状态:不可以读写
  • 需要修改或者删除Hbase表,必须先禁用
    • 为了避免有人正在使用这张表,而突然修改导致不一致性的出现
    • 修改成功以后,要重新启用表,这张表才可用
  • 测试
disable 'heima'
drop 'heima'
  • 启用表
enable 'ns:tbname'
  • 禁用表
disable 'ns:tbname'
  • 描述
desc 'hanjiaxiaozhi01:hanjiaxiaozhi'{NAME => 'cf1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS=> 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIO
NS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'} 
desc 'heima'{NAME => 'cf1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS=> 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIO
NS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}               
{NAME => 'cf2', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS=> 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIO
NS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}               
desc 'student:stu'{NAME => 'basic', BLOOMFILTER => 'ROW', VERSIONS => '3', IN_MEMORY => 'false', KEEP_DELETED_CEL
LS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERS
IONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}             
{NAME => 'other', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CEL
LS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERS
IONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}             
2 row(s) in 0.2280 seconds

3、DML【增删改查】

Group name: dmlCommands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve

put:插入数据/更新数据【类似于mysql中的replace,如果不存在就插入,如果存在就更新】

  • 功能:为Hbase表的某一行插入一列
  • 语法
put 'ns1:t1', 'r1', 'c1', 'value'
put 't1', 'r1', 'c1', 'value', ts1
  • 测试
put 'student:stu','20200101_001','basic:name','laoda'
put 'student:stu','20200101_001','basic:age',18
put 'student:stu','20200101_001','basic:sex','male'
put 'student:stu','20200101_001','other:phone','110'
put 'student:stu','20200101_001','other:addr','shanghai'put 'student:stu','20200103_002','basic:name','laoer'
put 'student:stu','20200103_002','basic:age',20
put 'student:stu','20200103_002','other:phone','119'put 'student:stu','20200102_003','basic:name','laosan'
put 'student:stu','20200102_003','other:phone','120'
put 'student:stu','20200102_003','other:addr','beijing'
  • 更新
put 'student:stu','20200103_002','basic:name','laosi'
scan 'student:stu',{VERSIONS=>10}

get:获取数据

  • 功能:最多返回一个rowkey的所有数据
  • 查询最快的方式
  • 为什么:必须指定rowkey,rowkey是底层Hbase的索引
  • 语法
get 'ns1:t1', 'r1'
get 'ns1:t1', 'r1','c1'
  • 测试
get 'student:stu','20200103_002'
get 'student:stu','20200103_002','basic'
get 'student:stu','20200103_002','basic:name'

delete:删除数据

  • 功能:删除某列或者某个版本的数据
  • 语法
delete 'ns1:t1', 'r1', 'c1', ts1
  • 测试
delete 'student:stu','20200102_003','other:phone'

scan:扫描数据

  • 用法一:scan ‘ns:tbname’
    • 扫描全表
scan 'student:stu'
  • 用法二:scan ‘ns:tbname’ + 过滤器
    • 过滤查询