HBASE基础部署与命令行
Posted 杀智勇双全杀
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HBASE基础部署与命令行相关的知识,希望对你有一定的参考价值。
HBASE基础(二)部署与命令行
部署
解压安装
先下载安装包,或者直接上传:
cd /export/software/
rz
解压:
tar -zxvf hbase-2.1.0.tar.gz -C /export/server/
切换目录后查看内容:
cd /export/server/hbase-2.1.0/
ll -ah
[root@node1 hbase-2.1.0]# ll -ah
总用量 680K
drwxr-xr-x 7 root root 182 5月 24 17:51 .
drwxr-xr-x. 8 root root 143 5月 24 17:50 ..
drwxr-xr-x 4 user1 user1 4.0K 5月 24 17:55 bin
-rw-r--r-- 1 user1 user1 39K 7月 10 2018 CHANGES.md
drwxr-xr-x 2 user1 user1 178 7月 6 2018 conf
drwxrwxr-x 12 user1 user1 4.0K 7月 10 2018 docs
drwxr-xr-x 7 user1 user1 80 7月 10 2018 hbase-webapps
-rw-rw-r-- 1 user1 user1 262 7月 6 2018 LEGAL
drwxr-xr-x 6 root root 8.0K 5月 24 17:51 lib
-rw-rw-r-- 1 user1 user1 127K 7月 10 2018 LICENSE.txt
-rw-rw-r-- 1 user1 user1 460K 7月 10 2018 NOTICE.txt
-rw-r--r-- 1 user1 user1 1.5K 7月 6 2018 README.txt
-rw-r--r-- 1 user1 user1 21K 7月 10 2018 RELEASENOTES.md
修改配置
配置文件当然在conf
配置目录里:
cd /export/server/hbase-2.1.0/conf/
ll -ah
先配置环境变量,使用vim修改hbase-env.sh:
vim hbase-env.sh
显示行号方便查找内容:
:set number
分别修改28行和125行为:
export JAVA_HOME=/export/server/jdk1.8.0_241
export HBASE_MANAGES_ZK=false
记得保存。这样就配置好了Java环境变量,且关闭了HBASE自带的Zookeeper(∵之前的集群已经自己搭建好了Zookeeper)。
再修改hbase-site.xml:
cd /export/server/hbase-2.1.0/
mkdir datas
vim conf/hbase-site.xml
在configuration标签里按o
插入:
<property >
<name>hbase.tmp.dir</name>
<value>/export/server/hbase-2.1.0/datas</value>
</property>
<property >
<name>hbase.rootdir</name>
<value>hdfs://node1:8020/hbase</value>
</property>
<property >
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node1:2181,node2:2181,node3:2181</value>
</property>
记得保存。之后配置regionservers:
vim conf/regionservers
由于之前已经配置过映射,直接dd
删掉原有的localhost
并添加:
node1
node2
node3
记得保存。
之后配置环境变量,方便从任意位置使用命令:
vim /etc/profile
找个空行:
#HBASE_HOME
export HBASE_HOME=/export/server/hbase-2.1.0
export PATH=:$PATH:$HBASE_HOME/bin
保存后刷新环境变量:
source /etc/profile
分发
由于要搭建集群,需要分发给其余节点:
cd /export/server/
scp -r hbase-2.1.0 node2:$PWD
scp -r hbase-2.1.0 node3:$PWD
PWD是大写!!!
服务端启动
由于HBASE高度依赖Zookeeper和HDFS,故启动和关闭都有严格的顺序,必须遵循:
启动Zookeeper和HDFS→Zookeeper和HDFS启动完成→启动HBASE
的顺序。启动HBASE前必须先把Zookeeper和HDFS启动好(这两个没有先后顺序)。
按照之前的配置,需要node1:
start-zk-all.sh
start-dfs.sh
node3:
start-yarn.sh
在node1:50070看到安全模式关闭:
才可以启动HBASE:
start-hbase.sh
启动后可以jps
查看进程:
[root@node1 server]# jps
2768 NodeManager
3024 HMaster
3490 Jps
2615 SecondaryNameNode
2440 DataNode
2157 QuorumPeerMain
2301 NameNode
3151 HRegionServer
由于使用了Zookeeper,在3个节点都可以启动HBASE,执行启动命令的机器一定是最先启动(就是HMaster),后启动的就是HRegionServer。QuorumPeerMain就是Zookeeper。
服务端关闭
关闭必须遵循先开的后关,后开的先关:
关闭HBASE→等待关闭完成→关闭Zookeeper和HDFS
node1要分别执行:
stop-hbase.sh
stop-zk-all.sh
stop-dfs.sh
一定要确保HBASE成功关闭才能关闭Zookeeper和HDFS!!!
一定要确保HBASE成功关闭才能关闭Zookeeper和HDFS!!!
一定要确保HBASE成功关闭才能关闭Zookeeper和HDFS!!!
重要的话说三遍!!!
Web UI
在浏览器:
node1:16010
可以看到:
1.x
的老版本和CDH
版本的是60010
。
可以看到HBASE自己创建了2张表。。。
Backup Masters也是没有的。
HA架构搭建
先关闭HBASE:
stop-hbase.sh
切换到路径:
cd /export/server/hbase-2.1.0/conf
查看目录内的内容:
[root@node1 hbase-2.1.0]# ll ./conf/ -ah
总用量 40K
drwxr-xr-x 2 user1 user1 178 5月 24 19:12 .
drwxr-xr-x 9 root root 207 5月 24 19:39 ..
-rw-r--r-- 1 user1 user1 1.8K 7月 6 2018 hadoop-metrics2-hbase.properties
-rw-r--r-- 1 user1 user1 4.2K 7月 6 2018 hbase-env.cmd
-rw-r--r-- 1 user1 user1 7.1K 5月 24 18:59 hbase-env.sh
-rw-r--r-- 1 user1 user1 2.3K 7月 6 2018 hbase-policy.xml
-rw-r--r-- 1 user1 user1 1.4K 5月 24 19:08 hbase-site.xml
-rw-r--r-- 1 user1 user1 4.9K 7月 6 2018 log4j.properties
-rw-r--r-- 1 user1 user1 18 5月 24 19:12 regionservers
虽然没有,但是依然先创建:
vim conf/backup-masters
填上node2。再次启动HBASE后node2就会变成Backup Masters。当node1宕机后,Zookeeper会协助将Backup Masters配置的node切换为Active状态的主节点。
[root@node1 hbase-2.1.0]# ll ./bin -ah
总用量 184K
drwxr-xr-x 4 user1 user1 4.0K 5月 24 17:55 .
drwxr-xr-x 9 root root 207 5月 24 19:39 ..
-rwxr-xr-x 1 user1 user1 2.0K 7月 6 2018 considerAsDead.sh
-rwxr-xr-x 1 user1 user1 4.3K 7月 6 2018 draining_servers.rb
-rwxr-xr-x 1 user1 user1 1.6K 7月 6 2018 get-active-master.rb
-rwxr-xr-x 1 user1 user1 6.5K 7月 6 2018 graceful_stop.sh
-rwxr-xr-x 1 user1 user1 23K 7月 6 2018 hbase
-rwxr-xr-x 1 user1 user1 4.5K 7月 6 2018 hbase-cleanup.sh
-rw-rw-r-- 1 user1 user1 15K 7月 6 2018 hbase.cmd
-rwxr-xr-x 1 user1 user1 1.6K 7月 6 2018 hbase-common.sh
-rw-rw-r-- 1 user1 user1 2.4K 7月 6 2018 hbase-config.cmd
-rwxr-xr-x 1 user1 user1 5.5K 7月 6 2018 hbase-config.sh
-rwxr-xr-x 1 user1 user1 13K 7月 6 2018 hbase-daemon.sh
-rwxr-xr-x 1 user1 user1 2.1K 7月 6 2018 hbase-daemons.sh
-rwxr-xr-x 1 user1 user1 876 7月 6 2018 hbase-jruby
-rwxr-xr-x 1 user1 user1 7.6K 7月 6 2018 hirb.rb
-rwxr-xr-x 1 user1 user1 2.3K 7月 6 2018 local-master-backup.sh
-rwxr-xr-x 1 user1 user1 2.6K 7月 6 2018 local-regionservers.sh
-rwxr-xr-x 1 user1 user1 2.3K 7月 6 2018 master-backup.sh
-rwxr-xr-x 1 user1 user1 1.2K 7月 6 2018 region_mover.rb
-rwxr-xr-x 1 user1 user1 2.7K 7月 6 2018 regionservers.sh
-rwxr-xr-x 1 user1 user1 4.8K 7月 6 2018 region_status.rb
drwxr-xr-x 2 user1 user1 33 5月 24 17:51 replication
-rwxr-xr-x 1 user1 user1 7.9K 7月 6 2018 rolling-restart.sh
-rwxr-xr-x 1 user1 user1 1.9K 7月 6 2018 shutdown_regionserver.rb
-rw-rw-r-- 1 user1 user1 2.3K 7月 6 2018 start-hbase.cmd
-rwxr-xr-x 1 user1 user1 2.4K 7月 6 2018 start-hbase.sh
-rw-rw-r-- 1 user1 user1 1.8K 7月 6 2018 stop-hbase.cmd
-rwxr-xr-x 1 user1 user1 2.3K 7月 6 2018 stop-hbase.sh
drwxr-xr-x 2 user1 user1 38 5月 24 17:51 test
-rwxr-xr-x 1 user1 user1 1.9K 7月 6 2018 zookeepers.sh
在node1
使用:
hbase-daemon.sh stop master
可以手动强制关闭master状态的主节点,node2会自动切换为主节点。自己玩也用不上HA架构(咳。咳。咳。虚拟机性能差)。。。玩腻了就可以关闭HBASE,再删掉这个配置文件,重新启动就是单个主节点的模式。。。
命令行
Linux命令行中输入hbase shell
就可以进入命令行模式:
[root@node1 ~]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/server/hadoop-2.7.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/server/hbase-2.1.0/lib/client-facing-thirdparty/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.
Version 2.1.0, re1673bb0bbfea21d6e5dba73e013b09b8b49b89b, Tue Jul 10 17:26:48 CST 2018
Took 0.0027 seconds
hbase(main):001:0>
敲个help
就可以显示命令组
:
hbase(main):001:0> help
HBase Shell, version 2.1.0, re1673bb0bbfea21d6e5dba73e013b09b8b49b89b, Tue Jul 10 17:26:48 CST 2018
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_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_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: abort_procedure, 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
hbase(main):002:0>
使用exit
可以退出。
使用hbase shell 文件
可以直接执行文件(如:txt文件)内的命令行。文件结尾最好写上exit
,不然还得人工exit退出。
DDL
操作namespace
帮助中已经看到了Group name: namespace
命令组有alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables
,先拿最简单的list_namespace_tables
开刀(可以自动补全):
hbase(main):002:0> list_namespace
NAMESPACE
default
hbase
2 row(s)
Took 0.9154 seconds
这货列出了所有命名空间(也就是HBASE的数据库名),和之前在浏览器node1:16010
看到的一样。。。
hbase(main):003:0> list_namespace_tables 'hbase'
TABLE
meta
namespace
2 row(s)
Took 0.0566 seconds
=> ["meta", "namespace"]
这个命令展示出hbase命名空间内的表名。。。不懂语法套路的话,可以使用help
查看帮助:
hbase(main):004:0> help 'list_namespace_tables'
List all tables that are members of the namespace.
Examples:
hbase> list_namespace_tables 'ns1'
帮助会给出语法套路。。。自己改参数即可。。。
hbase(main):005:0> create_namespace 'test210524'
Took 0.3198 seconds
hbase(main):006:0> list_namespace
NAMESPACE
default
hbase
test210524
3 row(s)
Took 0.0221 seconds
这个可以创建命名空间。
drop_namespace自然就是删除命名空间,留着有用,暂时不删。。。如果已经有表,那么,必须先禁用表→删除表
,才能删除命名空间。
操作table
帮助中已经看到了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
。
当然先看帮助:
hbase(main):008:0> help 'create'
Creates a table. Pass a table name, and a set of column family
specifications (at least one), and, optionally, table configuration.
Column specification can be a simple string (name), or a dictionary
(dictionaries are described below in main help output), necessarily
including NAME attribute.
Examples:
Create a table with namespace=ns1 and table qualifier=t1
hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}
Create a table with namespace=default and table qualifier=t1
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
hbase> create 't1', {NAME => 'f1', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
hbase> create 't1', {NAME => 'f1', IS_MOB => true, MOB_THRESHOLD => 1000000, MOB_COMPACT_PARTITION_POLICY => 'weekly'}
Table configuration options can be put at the end.
Examples:
hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe'
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' }
hbase> # Optionally pre-split the table into NUMREGIONS, using
hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', REGION_REPLICATION => 2, CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}}
hbase> create 't1', {NAME => 'f1', DFS_REPLICATION => 1}
You can also keep around a reference to the created table:
hbase> t1 = create 't1', 'f1'
Which gives you a reference to the table named 't1', on which you can then
call methods.
可以看出:
create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}
这种套路可以在指定的命名空间创建表,并且指定某个列族的名称、该列族可以存储多少个版本的值。
这种就是简介的写法:
create 't1', 'f1', 'f2', 'f3'
类似TTL之类的参数也可以配置。。。
先试试:
create 'test210524:t1', {NAME=>'cf1'}, {NAME=>'cf2', VERSIONS => 3}, {NAME=>'cf3'}
居然报错:
SyntaxError: (hbase):10: syntax error, unexpected tIDENTIFIER
原来要求这么严格!!!一个空格都不能错!!!改为:
create 'test210524:t1', {NAME => 'f1'}, {NAME => 'f2', VERSIONS => 3}, {NAME => 'f3'}
才能建表:
hbase(main):015:0> create 'test210524:t1', {NAME => 'f1'}, {NAME => 'f2', VERSIONS => 3}, {NAME => 'f3'}
Created table test210524:t1
Took 1.3701 seconds
=> Hbase::Table - test210524:t1
可以看到建出来的表:
hbase(main):016:0> list_namespace_tables 'test210524'
TABLE
t1
1 row(s)
Took 0.0228 seconds
=> ["t1"]
查看描述:
hbase(main):017:0> desc 'test210524:t1'
Table test210524:t1 is ENABLED
test210524:t1
COLUMN FAMILIES DESCRIPTION
{NAME => 'f1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CA
CHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMF
ILTER => '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 => '3', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CA
CHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMF
ILTER => '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', CA
CHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMF
ILTER => '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.2315 seconds
直接删除表肯定是不行的:
hbase(main):018:0> drop 'test210524:t1'
ERROR: Table test210524:t1 is enabled. Disable it first.
For usage try 'help "drop"'
Took 0.0207 seconds
HBASE为了避免修改或者删除表,影响这张表正在对外提供读写服务,规定了修改或者删除表时,必须先禁用表,表示这张表暂时不能对外提供服务。修改表:禁用表→修改表→启用表
。删除表:禁用表→删除表
。语法套路没有任何创新:
disable '命名空间:表名'
enable '命名空间:表名'
删掉所有表,命名空间为空,才能删除命名空间。
exists '命名空间:表名'
可以判断某命名空间下的某表是否存在。
DML
帮助中已经看到了Group name: dml
命令组有:Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve
。。。套路还是老套路。。。
put
查看帮助的老套路:
hbase(main):019:0> help 'put'
Put a cell 'value' at specified table/row/column and optionally
timestamp coordinates. To put a cell value into table 'ns1:t1' or 't1'
at row 'r1' under column 'c1' marked with the time 'ts1', do:
hbase> put 'ns1:t1', 'r1', 'c1', 'value'
hbase> put 't1', 'r1', 'c1', 'value'
hbase> put 't1', 'r1', 'c1', 'value', ts1
hbase> put 't1', 'r1', 'c1', 'value', {ATTRIBUTES=>{'mykey'=>'myvalue'}}
hbase> put 't1', 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
hbase> put 't1', 'r1', 'c1', 'value', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
The same commands also can be run on a table reference. Suppose you had a reference
t to table 't1', the corresponding command would be:
hbase> t.put 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
鹅鹅鹅。。。不是一般的坑爹。。。居然是一次只能对某表中的某行、某列处的某个数据进行赋值。。。手动操作的效率太低。。。大概率不会手动一个值一个值输入。。。哪天百无聊赖再试试手工put几个值,scan查看。。。
事实上,Hbase表会自动按照Rowkey构建字典有序:逐位比较。且HBASE是LSM数据模型,没有更新(或者称为覆盖)和删除,是通过插入来代替的,做了标记使之前的数据不再显示。
get
不解释:
hbase(main):021:0> help 'get'
Get row or cell contents; pass table name, row, and optionally
a dictionary of column(s), timestamp, timerange and versions. Examples:
hbase> get 'ns1:t1', 'r1'
hbase> get 't1', 'r1'
hbase> get 't1', 'r1', {TIMERANGE => [ts1, ts2]}
hbase> get 't1', 'r1', {COLUMN => 'c1'}
hbase> get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> get 't1', 'r1', {COLUMN => 'c1', TIMESTAMP => ts1, VERSIONS => 4}
hbase> get 't1', 'r1', {FILTER => "ValueFilter(=, 'binary:abc')"}
hbase> get 't1', 'r1', 'c1'
hbase> get 't1', 'r1', 'c1', 'c2'
hbase> get 't1', 'r1', ['c1', 'c2']
hbase> get 't1', 'r1', {COLUMN => 'c1', ATTRIBUTES => {'mykey'=>'myvalue'Apache HBase基础知识