简体   繁体   English

从 Hive 到 Hive 的 Sqoop 导入

[英]Sqoop Import from Hive to Hive

Can we import tables from Hive DataSource to Hive DataSource using Sqoop .我们可以使用Sqoop将表从 Hive DataSource 导入到 Hive DataSource

Query like -查询如 -

sqoop import --connect jdbc:hive2://localhost:10000/default --driver org.apache.hive.jdbc.HiveDriver --username root --password root --table student1 -m 1 --target-dir hdfs://localhost:9000/user/dummy/hive2result

Right now its throwing the below exception现在它抛出以下异常

15/07/19 19:50:18 ERROR manager.SqlManager: Error reading from database: java.sql.SQLException: Method not supported
java.sql.SQLException: Method not supported
    at org.apache.hive.jdbc.HiveResultSetMetaData.isSigned(HiveResultSetMetaData.java:141)
    at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:290)
    at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240)
    at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:226)
    at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295)
    at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1773)
    at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1578)
    at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
    at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:478)
    at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:601)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:236)

Sqoop is not a tool for transferring data from one hive instance to another hive instance. Sqoop 不是将数据从一个配置单元实例传输到另一个配置单元实例的工具。 Seems like your requirement is to transfer data in hive from one cluster to another cluster.似乎您的要求是将 hive 中的数据从一个集群传输到另一个集群。 This can be achieved using hadoop distcp.这可以使用 hadoop distcp 来实现。 The full form of sqoop itself is SQl to hadOOP and viceversa. sqoop 本身的完整形式是 SQl 到 hadOOP,反之亦然。

If you want to migrate multiple databases and tables from one hive to another hive instance, the best approach is to transfer the data using hadoop distcp and trigger the DDLs in the 2nd hive instance.如果要将多个数据库和表从一个 hive 迁移到另一个 hive 实例,最好的方法是使用 hadoop distcp 传输数据并触发第二个 hive 实例中的 DDL。 If you don't have the DDLs handy with you, no need to worry.如果您手边没有 DDL,则无需担心。 Just take a dump of the metastore database.只需转储 Metastore 数据库即可。 Open the dump file using a notepad or textpad Replace the hdfs uri with the new hdfs uri.使用记事本或文本板打开转储文件 将 hdfs uri 替换为新的 hdfs uri。 Import the mysql dump to the metastore of the 2nd hive instance.将 mysql 转储导入到第二个 hive 实例的 Metastore。 Refresh the tables.刷新表。 An example is given in the below blog post https://amalgjose.wordpress.com/2013/10/11/migrating-hive-from-one-hadoop-cluster-to-another-cluster-2/以下博客文章中给出了一个示例https://amalgjose.wordpress.com/2013/10/11/migrating-hive-from-one-hadoop-cluster-to-another-cluster-2/

distcp will work only for external tables. distcp 仅适用于外部表。 For managed tables (transactional) use export import DDL.对于托管表(事务性),请使用导出导入 DDL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM