zoukankan      html  css  js  c++  java
  • sqoop简单使用

    一,通过sqoop将MySQL里面的数据加载到HDFS

    先查看有哪些数据库

    查看表person

    sqoop list-databases --connect jdbc:mysql://ly-p2p4:3306/test --username root -password 123456

     将数据库test下的person表加载到HDFS下的sqoop目录下

    结果

     导入表的子集

    sqoop import --connect jdbc:mysql://ly-p2p4:3306/test --username root -password 123456 --table person --m 1 --where "age"='10' --target -dir /sqoop/test/

    查看

     

     增量导入(即只导入新添加的那部分数据) 

    --incremental <mode> 选择模式,有:append 和 lastmodified

    --check-column <column name> 检查那一列的元素,比如 id

    --last-value <last check column value> 原来数据最后一条的参数,比如 最后一条id为3,则填3

    先给表person里面插入一条数据

     sqoop import --connect jdbc:mysql://ly-p2p4:3306/test --username root -password 123456 --table person --m 1 --target-dir /sqoop/ --incremental append --check-column id --last-value 3

     

    查询

    注意:参数-append将数据追加到HDFS已经存在的数据集中。使用该参数时,sqoop将数据先导入到一个临时目录中,然后重新给文件命名到一个正式的目录中,以避免和该目录中已经存在的文件重名

  • 相关阅读:
    【leetcode】修剪二叉搜索树
    053-621
    053-620
    053-619
    053-618
    053-617
    053-616
    053-615
    053-614
    053-613
  • 原文地址:https://www.cnblogs.com/lyywj170403/p/9476991.html
Copyright © 2011-2022 走看看