zoukankan      html  css  js  c++  java
  • 调用Mapreduce,org.apache.hadoop.hbase.mapreduce处理hbase问题

    调用Mapreduce,org.apache.hadoop.hbase.mapreduce处理hbase问题

    hbase org.apache.hadoop.hbase.mapreduce.Export
    ERROR: Wrong number of arguments: 0
    Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> [<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]
    
      Note: -D properties will be applied to the conf used. 
      For example: 
       -D mapreduce.output.fileoutputformat.compress=true
       -D mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec
       -D mapreduce.output.fileoutputformat.compress.type=BLOCK
      Additionally, the following SCAN properties can be specified
      to control/limit what is exported..
       -D hbase.mapreduce.scan.column.family=<familyName>
       -D hbase.mapreduce.include.deleted.rows=true
       -D hbase.mapreduce.scan.row.start=<ROWSTART>
       -D hbase.mapreduce.scan.row.stop=<ROWSTOP>
    For performance consider the following properties:
       -Dhbase.client.scanner.caching=100
       -Dmapreduce.map.speculative=false
       -Dmapreduce.reduce.speculative=false
    For tables with very wide rows consider setting the batch size as below:
       -Dhbase.export.scanner.batch=10
    

      

    Hbase 大表快速count

    hbase org.apache.hadoop.hbase.mapreduce.RowCounter 'osinfo_xdja'
    

    (1)  从hbase表导出(# 默认不写file://的时候就是导出到hdfs上了  )

    HBase数据导出到HDFS或者本地文件

    hbase org.apache.hadoop.hbase.mapreduce.Export emp file:///Users/a6/Applications/experiment_data/hbase_data/bak
    

    HBase数据导出到本地文件

    hbase org.apache.hadoop.hbase.mapreduce.Export emp /hbase/emp_bak
    

    导出时可以限制scanner.batch的大小

    如果在hbase中的一个row出现大量的数据,那么导出时会报出ScannerTimeoutException的错误。这时候需要设置hbase.export.scaaner.batch 这个参数。这样导出时的错误就可以避免了。

    hbase org.apache.hadoop.hbase.mapreduce.Export -Dhbase.export.scanner.batch=2000  emp file:///Users/a6/Applications/experiment_data/hbase_data/bak

    hbase的数据导出的时候,如果不适用compress的选项,数据量的大小可能相差5倍。因此使用compress的选项,备份数据的时候是可以节省不少空间的。
    并且本人测试了compress选项的导出速度,和无此选项时差别不大(几乎无差别):

    hbase org.apache.hadoop.hbase.mapreduce.Export -Dhbase.export.scanner.batch=2000 -D mapred.output.compress=true
    

    通过添加compress选项,最终导出文件的大小由335字节变成了325字节,
    File Output Format Counters File Output Format Counters
    Bytes Written=335 Bytes Written=323

    导出指定行键范围和列族

    在公司准备要更换数据中心,需要将hbase数据库中的数据进行迁移。虽然进行hbase数据库数据迁移时,使用其自带的工具import和export是很方便的。只不过,在迁移大量数据时,可能需要运行很长的时间,甚至可能出错。这时,是可以通过指定行键范围和列族,来减少单次export工具的运行时间。可以看出,支持的选项有好几个。假如,我们想导出表test的数据,且只要列族Info,行键范围在000到001之间,可以这样写:

    这样就可以了,且数据将会保存在hdfs中。
    通过指定列族和行键范围,可以只导出部分数据,避免export启动的mapreduce任务运行时间过长。也就是可以分多次导出数据。

    ./hbase org.apache.hadoop.hbase.mapreduce.Export -D hbase.mapreduce.scan.column.family=Info -D hbase.mapreduce.scan.row.start=000 -D hbase.mapreduce.scan.row.stop=001 test /test_datas
    

    导入hbase表(# 默认不写file://的时候就是导出到hdfs上了  )

    将hdfs上的数据导入到备份目标表中
    localhost:bin a6$ hbase org.apache.hadoop.hbase.mapreduce.Driver import emp_bak /hbase/emp_bak/*
    将本地文件上的数据导入到备份目标表中
    hbase org.apache.hadoop.hbase.mapreduce.Driver import emp_bak file:///Users/a6/Applications/experiment_data/hbase_data/bak/*
    

     

  • 相关阅读:
    自学Python5.2-类和对象概念
    自学Python5.1-面向对象与面向过程
    自学Python2.1-基本数据类型-字符串str(object) 上
    自学Python2.10-跳出循环(break、continue)
    自学Python2.9-循环(while、for)
    自学Python2.8-条件(if、if...else)
    自学Python1.8-python input/print用法 格式化输出
    自学Python1.6-Centos内英文语法切换
    自学Python1.7-python变量以及类型
    自学Python1.5-Centos内python2识别中文
  • 原文地址:https://www.cnblogs.com/idvcn/p/10612777.html
Copyright © 2011-2022 走看看