【问题标题】:How to load split HDFS files to Oracle database?如何将拆分的 HDFS 文件加载到 Oracle 数据库?
【发布时间】:2017-07-26 17:52:09
【问题描述】:

我需要将数据从 HDFS 上的拆分文件加载到 Oracle 数据库。

[user@asdf 007]$ hadoop dfs -ls 
hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/*
Found 18 items
drwxrwxrwx   - bigsql hdfs          0 2017-07-24 01:00 hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=1
drwxrwxrwx   - bigsql hdfs          0 2017-07-24 01:00 hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=2
drwxrwxrwx   - bigsql hdfs          0 2017-07-24 01:00 hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=3
drwxrwxrwx   - bigsql hdfs          0 2017-07-24 01:00 hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=4
drwxrwxrwx   - bigsql hdfs          0 2017-07-24 01:00 hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=5
.......

如果我打开任何文件夹中的文件

hdfs://XXXXXX/split_files/test_folder/test_table_with_partitions/tm=2017-07-24/dept=5

他们没有时间和部门信息。因此,当我使用 sqoop 时,信息不会加载到数据库表中。

我怎样才能将这些信息也加载到数据库中? sqoop 中是否有任何选项可以做到这一点?

【问题讨论】:

    标签: hadoop hive sqoop


    【解决方案1】:

    从给定的细节来看,您所指的 HDFS 文件似乎来自 Hive 表。

    要将已分区的配置单元表导出到 RDBMS,您必须使用 sqoop--hcatalog-table 参数。下面给出了示例,其中 test1 配置单元表已分区并正在导出到 MySQL 表 test.test。

    sqoop export --connect jdbc:mysql://10.0.0.35:3306/test --username root --table test1 --hcatalog-table test1
    

    要导出到 Oracle 数据库,您必须将 jdbc:mysql://10.0.0.35:3306/test 替换为 jdbc:oracle:thin:@<hostname>:<port>:<service>

    【讨论】:

    • 嗨,Shubhangi,感谢您的帮助!这正是我一直在寻找的。​​span>
    猜你喜欢
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 2013-12-12
    • 1970-01-01
    • 2017-08-29
    相关资源
    最近更新 更多