使用脚本批量执行hbase语句

编写HBase语句的可执行脚本

1
2
3
4
5
6
7
8
9
#!/bin/bash
source /etc/profile
exec hbase shell <<EOF
truncate 't_user_info'
major_compact('t_user_info')
disable 't_user_info'
drop 't_user_info'
create 't_user_info_new', 'info'
EOF

chmod +x create_htable.sh
执行脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# sh create_htable.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/bigdata/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/bigdata/hadoop-2.6.5-src/hadoop-dist/target/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017

truncate 't_user_info'
Truncating 't_user_info' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.8750 seconds

major_compact('t_user_info')
0 row(s) in 0.1390 seconds

disable 't_user_info'
0 row(s) in 2.2420 seconds

drop 't_user_info'
0 row(s) in 1.2750 seconds

create 't_user_info_new', 'info'
0 row(s) in 1.3500 seconds

Hbase::Table - t_user_info_new
邵志鹏 wechat
扫一扫上面的二维码关注我的公众号
0%