hbase的namespace操作

HBase的命名空间逻辑概念类似于关系型数据库的DataBase,使用表时需要注意带上namespace:table_name

列出所有命名空间

1
2
3
4
5
hbase(main):003:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.0630 seconds

创建命名空间

1
2
3
4
5
6
7
8
9
hbase(main):005:0> create_namespace 'test'
0 row(s) in 0.9290 seconds

hbase(main):006:0> list_namespace
NAMESPACE
default
hbase
test
3 row(s) in 0.0470 seconds

在命名空间上创建HBase表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
hbase(main):007:0> create 'test:test_datax', { NAME=>'td', VERSIONS=>2147483647}
0 row(s) in 1.2800 seconds

=> Hbase::Table - test:test_datax
hbase(main):008:0> scan 'test:test_datax'
ROW COLUMN+CELL
0 row(s) in 0.0300 seconds

hbase(main):009:0> count 'test:test_datax'
0 row(s) in 0.0290 seconds

=> 0
hbase(main):010:0> count 'test:test_datax'
490 row(s) in 0.1680 seconds

=> 490
hbase(main):011:0> truncate 'test:test_datax'
Truncating 'test:test_datax' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.4110 seconds

删除命名空间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
hbase(main):012:0> drop_namespace 'test'

ERROR: org.apache.hadoop.hbase.constraint.ConstraintException: Only empty namespaces can be removed. Namespace test has 1 tables
......

hbase(main):013:0> disable 'test:test_datax'
0 row(s) in 2.2590 seconds

hbase(main):014:0> drop 'test:test_datax'
0 row(s) in 1.2610 seconds

hbase(main):015:0> drop_namespace 'test'
0 row(s) in 0.8750 seconds

hbase(main):016:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.0180 seconds

命名空间描述和列出相应的表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
hbase(main):017:0> describe_namespace 'hbase'
DESCRIPTION
{NAME => 'hbase'}
1 row(s) in 0.0430 seconds

hbase(main):018:0> list_namespace_tables 'hbase'
TABLE
meta
namespace
2 row(s) in 0.0430 seconds

hbase(main):019:0> list_namespace_tables 'default'
TABLE
global_query_review_history
kylin_metadata
kylin_metadata_acl
kylin_metadata_user
t_user_info_new
test_datax
test_residential_building_house_no
7 row(s) in 0.0230 seconds
邵志鹏 wechat
扫一扫上面的二维码关注我的公众号
0%