Get output from scans in hbase shell

时光总嘲笑我的痴心妄想 提交于 2019-12-18 10:41:58

问题


Is there any way I can output the results from a scan in the hbase shell to a file? I'm assuming this is easy but I haven't been able to find anything in the documentation.


回答1:


I know that this post is quite old but i was searching something about HBase myself and came across with it.

Well i don't know if this is the best way to do it, but you can definitely use the scripting option HBase gives you. Just open a shell (preferably go to the directory bin of HBase) and run

echo "scan 'foo'" | ./hbase shell > myText

where foo is the name of the table you want to scan. If you then open myText you will see the results in there. Hope i helped!




回答2:


Another option using an EOF here doc, potentially more customizable:

hbase shell <<EOF >myText
scan 'foo'
EOF



回答3:


You can also use here strings too (if your shell supports them):

$ hbase shell <<< "scan 'sometable'" > myoutput.txt

Above I'm doing this in Bash on a Linux system, for example.




回答4:


ex : file.sh contains scan 'tablename';

Execute bellow command to capture result to log file....

hbase shell < file.sh(which contains hbase commands) > output.lo


来源:https://stackoverflow.com/questions/10035475/get-output-from-scans-in-hbase-shell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!