HBaseshell执⾏脚本(批量添加数据)
HBase shell执⾏脚本(批量添加数据)
上⼀篇⽂章中(blog.csdn/wild46cat/article/details/53214159)写了⼀些如何在HBase 的shell中单条添加数据。现在介绍⼀种通过shell脚本⽅式批量进⾏Hbase shell操作的⽅法。
本⽂主要参考,官⽅⽂档:/book.html#shell
1、⾸先,编写⼀个⽂本⽂件:
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'shell界面
2、在HBase shell中运⾏这个脚本:
利⽤命令:hbase :
下⾯是运⾏结果:
需要注意的是,如果编写的txt⽂件中没有exit这条命令的话,当脚本执⾏完成后,会停留在hbase shell的界⾯中,如果有exit 命令的话,就会退出到系统shell中。