HBase Shell 命令使用方法

时间:2020-04-26
本文章向大家介绍HBase Shell 命令使用方法,主要包括HBase Shell 命令使用方法使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1. 交互模式

$ hbase shell

2. 非交互模式

$ echo "describe 'test'" | hbase shell -n
$ echo $?
# 返回0成功,返回其他失败
# 结果输出到文件 $ echo
"describe 'test'" | hbase shell -n > tmp.log # 不打印输出结果 $ echo "describe 'test" | hbase shell -n > /dev/null 2>&1

3. 使用Bash脚本

3.1)单命令执行

#!/bin/bash
echo "describe 'test:t'" | hbase shell -n > tmp.log
status=$?
echo "status:" $status
if [ $status == 0 ]; then
  echo "succee"
else
  echo "fail"
fi

3.2) 交互界面执行

#!/bin/bash
 arr=('test:t1' 'test:t2')
 
 for table in ${arr[@]}
 do 
     echo \'$table\'
     hbase shell << EOF 
     disable '$table'
   drop '$table'
    exit
EOF
done

4.读取文本文件

执行

$ hbase shell ./commands.txt
commands.txt内容如下:
create 'test', 'cf'
list 'test'
put 'test', 'row1', 'cf:a', 'value1'
put 'test', 'row2', 'cf:b', 'value2'
put 'test', 'row3', 'cf:c', 'value3'
put 'test', 'row4', 'cf:d', 'value4'
scan 'test'
get 'test', 'row1'
disable 'test'
enable 'test'
exit

5. 传递VM参数

$ HBASE_SHELL_OPTS="-verbose:gc -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps \
 -XX:+PrintGCDetails -Xloggc:$HBASE_HOME/logs/gc-hbase.log" hbase shell

6. 配置覆盖

$ hbase shell -Dhbase.zookeeper.quorum=ZK0.remote.cluster.example.org,ZK1.remote.cluster.example.org,ZK2.remote.cluster.example.org -Draining=false

7. 开启debug模式

hbase(main):007:0> debug
Debug mode is ON

hbase(main):008:0> debug
Debug mode is OFF
$ ./bin/hbase shell -d

原文地址:https://www.cnblogs.com/yyy-blog/p/12781650.html