hbase已经自带了这个命令,下面就说一下怎么使用这个命令
(一)设置环境变量
在hadoop-0.20.2/conf/hadoop-env.sh 中添加
export HBASE_HOME=/home/rain/hbase/hbase-0.90.0
export HADOOP_CLASSPATH=$HBASE_HOME/hbase-0.90.0.jar:$HBASE_HOME:$HBASE_HOME/lib/zookeeper-3.3.2.jar:$HBASE_HOME/conf
(二)导出
1)输入命令hadoop-0.20.2/bin/hadoop jar /home/rain/hbase/hbase-0.90.0/hbase-0.90.0.jar export 表名 路径
eg:hadoop-0.20.2/bin/hadoop jar /home/rain/hbase/hbase-0.90.0/hbase-0.90.0.jar export CARREGISTER /home/rain/tableout
2)从hdfs拷出来
输入命令hadoop-0.20.2/bin/hadoop -copyToLocal /home/rain/tableout /somewhere/local
eg:hadoop-0.20.2/bin/hadoop -copyToLocal /home/rain/tableout /home/rain/tableout
查看/home/rain/tableout里是否有part-m-000000,这个就是这个表导出的内容
导入
1)把rt-m-000000导入hdfs
输入命令:hadoop-0.20.2/bin/hadoop -copyFromLocal /somewhere/local /import/your_table
eg.hadoop-0.20.2/bin/hadoop -copyFromLocal /somewhere/local /import/carregister
从hdfs导入到hbase
输入命令:hadoop-0.20.2/bin/hadoop jar /path/to/hbase-0.90.0.jar 表名 hdfs路径
eg。doop-0.20.2/bin/hadoop jar /path/to/hbase-0.90.0.jar CARREGISTER /import/carregister
详细资料参考http://www.sethcall.com/blog/2010/04/10/how-to-export-and-import-an-hbase-table/