zoukankan      html  css  js  c++  java
  • 1.11-1.12 Sqoop导入数据时两种增量方式导入及direct

    一、增量数据的导入

    1、两种方式

    ## query
    有一个唯一标识符,通常这个表都有一个字段,类似于插入时间createtime    
    where createtime => 20150924000000000 and createtime < 20150925000000000
    
    
    ##sqoop参数
    Incremental import arguments:
       --check-column <column>            Source column to check for incremental change
       --incremental <import-type>        Define an incremental import of type 'append' or 'lastmodified'
       --last-value <value>                   Last imported value in the incremental check column


    2、用sqoop参数增量导入的方式

    ##
    bin/sqoop import 
    --connect jdbc:mysql://hadoop-senior.ibeifeng.com:3306/test 
    --username root 
    --password 123456 
    --table my_user 
    --target-dir /user/root/sqoop/imp_my_incr 
    --num-mappers 1 
    --incremental append 
    --check-column id 
    --last-value 4  
    
    
    #--incremental append       //追加方式
    #--check-column        //检查的字段
    #--last-value        //最后的值,不包含这个值,从这个值后面的开始导入
    
    
    ##
    [root@hadoop-senior hadoop-2.5.0-cdh5.3.6]# bin/hdfs dfs -text /user/root/sqoop/imp_my_incr/part-m-00000
    5,test,test
    6,pudong,pudong
    7,qiqi,qiqi


    二、direct参数

    直接导出模式(优化速度);

    使用的是关系数据库自带的导入导出工具;

    ##
    bin/sqoop import 
    --connect jdbc:mysql://hadoop-senior.ibeifeng.com:3306/test 
    --username root 
    --password 123456 
    --table my_user 
    --target-dir /user/root/sqoop/imp_my_incr 
    --num-mappers 1 
    --delete-target-dir 
    --direct
  • 相关阅读:
    poj3660 最短路/拓扑序
    poj1502 最短路
    poj3259 最短路判环
    poj1680 最短路判环
    一些自己常用的cdn
    bower
    vuejs点滴
    jquery的ajax
    jquery点滴
    githubpage+hexo构建自己的个人博客
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/10821223.html
Copyright © 2011-2022 走看看