如何通过hdfs(hadoop命令)导入/导出hbase数据 [英] How to import/export hbase data via hdfs (hadoop commands)

查看:1035
本文介绍了如何通过hdfs(hadoop命令)导入/导出hbase数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过nutch在Hbase中保存了我的抓取的数据,其文件系统为hdfs。然后,我通过命令将我的数据(hbase的一个表)直接拷贝到本地目录中。
$ b

  hadoop fs -CopyToLocal / hbase / input〜/ Documents / output 

之后,我将该数据复制回另一个hbase(其他系统)通过以下命令:

  hadoop fs -CopyFromLocal〜/ Documents / input / hbase / mydata 

它保存在hdfs中,当我在hbase shell中使用 list 命令时,它显示它作为另一个表,即'mydata',但是当我运行 scan 命令时,它表示没有'mydata'名称的表。



以上程序有什么问题?
简单地说:


  1. 我想通过使用hadoop命令将hbase表复制到我的本地文件系统中

  2. 然后,我想通过hadoop命令将其直接保存在另一个系统的hdfs中。最后,我希望表出现在hbase中并将其数据显示为原始表


解决方案

如果要从一个hbase集群导出表并导入它到另一个,使用以下任何一种方法:使用Hadoop

使用Hadoop


  • 导出

      $ bin / hadoop jar < tablename> < outputdir>并[d版本>并[d开始时间> [< endtime>]] 

    注意:输出目录在hdfs中从源到目标集群

  • 导入

      $ bin / hadoop jar< path / to / hbase- {version} .jar>导入<表名> < inputdir> 




注意: outputdir和inputdir使用Hbase




  • 导出

      $ bin / hbase org.apache.hadoop.hbase.mapreduce.Export \ 
    < tablename> < outputdir>并[d版本>并[d开始时间> [< endtime>]]]


  • 将hdfs中的输出目录从源文件复制到目的地群集


  • 导入

      $ bin / hbase org .apache.hadoop.hbase.mapreduce.Import< tablename> < inputdir> 

    参考: Hbase工具导出和导入



I have saved my crawled data by nutch in Hbase whose file system is hdfs. Then I copied my data (One table of hbase) from hdfs directly to some local directory by command

hadoop fs -CopyToLocal /hbase/input ~/Documents/output

After that, I copied that data back to another hbase (other system) by following command

hadoop fs -CopyFromLocal ~/Documents/input /hbase/mydata

It is saved in hdfs and when I use list command in hbase shell, it shows it as another table i.e 'mydata' but when I run scan command, it says there is no table with 'mydata' name.

What is problem with above procedure? In simple words:

  1. I want to copy hbase table to my local file system by using a hadoop command
  2. Then, I want to save it directly in hdfs in another system by hadoop command
  3. Finally, I want the table to be appeared in hbase and display its data as the original table

解决方案

If you want to export the table from one hbase cluster and import it to another, use any one of the following method:

Using Hadoop

  • Export

    $ bin/hadoop jar <path/to/hbase-{version}.jar> export \
         <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]
    

    NOTE: Copy the output directory in hdfs from the source to destination cluster

  • Import

    $ bin/hadoop jar <path/to/hbase-{version}.jar> import <tablename> <inputdir>
    

Note: Both outputdir and inputdir are in hdfs.

Using Hbase

  • Export

    $ bin/hbase org.apache.hadoop.hbase.mapreduce.Export \
       <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]
    

  • Copy the output directory in hdfs from the source to destination cluster

  • Import

    $ bin/hbase org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
    

    Reference: Hbase tool to export and import

这篇关于如何通过hdfs(hadoop命令)导入/导出hbase数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆