zoukankan      html  css  js  c++  java
  • Sqoop-从hive导出分区表到MySQL

    经多次验证,发现并没有特殊的方法能够直接把多个分区一次性读入,并插入MySQL的方法,以后发现会在此添加。

    Sqoop只提供了从MySQL导入到HIVE分区表的相关参数,反向并无特别参数。

    从HIVE分区表导入到MySQL,需要依次导入每个分区的数据

    sqoop export  

    --connect jdbc:mysql://server74:3306/Server74  

    --username root  

    --password 123456  

    --table dw_pvs_hour

    --hive-partition-key datestr

    --hive-partition-value ‘2017-11-05’

    --export-dir /user/hive/warehouse/dw_pvs_hour/datestr=2017-11-15/ 

    --input-fields-terminated-by '01'  

    --input-lines-terminated-by ' '

     

    根据官方文档的说法,---export-dir这个参数是必须的,指定hive表源文件路径后,sqoop回到路径下路径下的文件,文件不是路径否则报错。所以分区表需要单独指定每个分区的目录,分别导入。

    The --export-dir argument and one of --table or --call are required. These specify the table to populate in the database (or the stored procedure to call), and the directory in HDFS that contains the source data.

  • 相关阅读:
    excel 常用小技巧
    如何以正确的顺序重新安装驱动程序
    kaby LAKE 仅支持 Windows10
    关闭远程计算机CMD命令
    根据IP查主机名
    Charles安装与使用
    常用的算法思想总结
    iOS学习之单例模式
    PHP之简单实现MVC框架
    Objective-C 继承和多态
  • 原文地址:https://www.cnblogs.com/kouryoushine/p/7844352.html
Copyright © 2011-2022 走看看