`

Sqoop1:export data to mysql

 
阅读更多

When I export data to mysql using the following sqoop commands

 

--options-file  sqoop.export.opt --export-dir inok/test/friendrecomend2 
--table friend_rec --staging-table friend_rec_stage --clear-staging-table 
--update-key id --update-mode  allowinsert  

the content of sqoop.export.opt likes

export
--verbose
--connect
jdbc:mysql://192.168.122.1:3306/inokdatamine
--username
zhaohj
--password
123456
--direct
-m
1

 

 

The error comes:

1.

Staging table cannot be used when export is running in update mode.

Solution: delete --update-xx parameters

 

2.

Error during export: The active connection manager 
(org.apache.sqoop.manager.DirectMySQLManager) does not support staging of data for export.

Solution: delete --staging-xxxx parameters

 

Note

Support for staging data prior to pushing it into the destination table is not available for --direct exports. It is also not available when export is invoked using the --update-key option for updating existing data, and when stored procedures are used to insert the data.

 

 

3.

Cannot run program "mysqlimport": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
	at java.lang.Runtime.exec(Runtime.java:617)

 Solution: Some suggest to install mysql-client in all nodes not only in some of ones. But When I add

--driver com.mysql.jdbc.Driver , then the error disappers.

Note

When using export in direct mode with MySQL, the MySQL bulk utility mysqlimport must be available in the shell path of the task process.


 

4.

Caused by: java.lang.NumberFormatException: For input string: "1	156 (12: [69"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:492)

 

I run a mapreduce job to produce the friendrecomend2 data which using org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; format. The content likes

2	4 (1: [5])
3	5 (2: [1, 4])
4	2 (1: [5]),6 (1: [5])
5	3 (2: [1, 4]),1 (1: [4])
6	2 (1: [5]),4 (1: [5]),5 (1: [2])

 

I thought the error due to sqoop parse the line use default delimiters(comma-separated fields with newline-separated records).

Solution: add parameter --input-fields-terminated-by \t (Note: don't put sqoop commands is command input area

when there is space in parameter value. Instead, Using Params)

 

5.

java.io.IOException: com.mysql.jdbc.MysqlDataTruncation: Data truncation: 
Data too long for column 'friends' at row 1
	at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.write(AsyncSqlRecordWriter.java:220)

 

the friend_rec table in mysql is :

 

 

Solution: change the friends filed length to 30000. This solve the sample data. But in my situation, the second filed in the files in hdfs may be longer more than 30000. So,I need to design the file output format

or schema to avoid this error.

 

 6.

ERROR org.apache.sqoop.tool.ExportTool  - Error during export: 
Mixed update/insert is not supported against the target database yet

 where the sqoop export action likes

<sqoop xmlns="uri:oozie:sqoop-action:0.2">
  <job-tracker>192.168.122.1:2015</job-tracker>
  <name-node>hdfs://192.168.122.1:2014</name-node>
  <arg>--options-file</arg>
  <arg>sqoop.export.opt</arg>
  <arg>--export-dir</arg>
  <arg>/user/zhaohj/inok/friendrec2/data/friendrecomend</arg>
  <arg>--table</arg>
  <arg>friend_rec</arg>
  <arg>--driver</arg>
  <arg>com.mysql.jdbc.Driver</arg>
  <arg>--input-fields-terminated-by</arg>
  <arg>\t</arg>
  <arg>--update-key</arg>
  <arg>id</arg>
  <arg>--update-mode</arg>
  <arg>allowinsert</arg>
  <file>/user/zhaohj/inok/friendrec/sqoop.export.opt#sqoop.export.opt</file>
</sqoop>

 

 google results show that it is a bug in sqoop1.4.2 but my sqoop is 1.4.4

 

When I delete the --driver com.mysql.jdbc.Driver. The error No.6 disappers. But new one comes:

 Error during export: MySQL direct connector does not support upsert mode.
 Please use JDBC based connector (remove --direct parameter)

Solution: remove --direct

The root reason is that mysql connector does't support upsert mode.

 

 

 http://mail-archives.apache.org/mod_mbox/sqoop-user/201210.mbox/%3C20121004152956.GT16616@jarcec-thinkpad%3E

 

 

Note:Sqoop automatically generates code to parse and interpret records of the files containing the data to be exported back to the database. If these files were created with non-default delimiters (comma-separated fields with newline-separated records), you should specify the same delimiters again so that Sqoop can parse your files.

 

 

 

 

 

 References

https://groups.google.com/a/cloudera.org/forum/#!topic/cdh-user/K44cK_ZI_2w

 

 

 

 

 

  • 大小: 9 KB
分享到:
评论

相关推荐

    sqoop-1.4.7.zip

    运行Sqoop报错:找不到或无法加载主类 org.apache.sqoop.sqoop 将sqoop-1.4.7.jar包放到Sqoop的lib目录下,问题解决。

    sqoop1: import to hive partitioned table

    NULL 博文链接:https://ylzhj02.iteye.com/blog/2051729

    sqoop-1.4.6.jar

    sqoop-1.4.6.jar,sqoop报错找不到加载类的时候 将该文件放入sqoop的lib文件夹下

    docker-sqoop:Apache Sqoop Docker映像

    Apache Sqoop Docker映像 注意:这是master分支-对于特定的Sqoop版本,请...sqoop import --connect jdbc:mysql://$MYSQL_HOST/$MYSQL_DB --table $MYSQL_TABLE --username $MYSQL_USER --password $MYSQL_PASS -m 1

    2、sqoop导入(RMDB-mysql、sybase到HDFS-hive)

    2、sqoop导入(RMDB-mysql、sybase到HDFS-hive) 网址:https://blog.csdn.net/chenwewi520feng/article/details/130572275 介绍sqoop从关系型数据库mysql、sybase同步到hdfs、hive中

    sqoop_export.zip

    Sqoop(发音:skup)是一款开源的工具,主要用于在Hadoop(Hive)与传统的数据库(mysql、postgresql...)间进行数据的传递,可以将一个关系型数据库(例如 : MySQL ,Oracle ,Postgres等)中的数据导进到Hadoop的HDFS中,...

    sqoop学习文档(2){Sqoop import、Sqoop export}.docx

    sqoop学习文档(2){Sqoop import、Sqoop export}。记录我的学习之旅,每份文档倾心倾力,带我成我大牛,回头观望满脸笑意,望大家多多给予意见,有问题或错误,请联系 我将及时改正;借鉴文章标明出处,谢谢

    sqoop-1.4.7.jar

    sqoop框架开发工具使用的jar sqoop-1.4.7.jar 手动安装到maven &lt;groupId&gt;org.apache.sqoop &lt;artifactId&gt;sqoop &lt;version&gt;1.4.7 &lt;/dependency&gt;

    使用sqoop抽取mysql数据

    使用sqoop从传统数据库mysql中抽取数据到大数据集群。

    sqoop-1.4.6-cdh5.13.2.tar

    1、sqoop的解压并配置环境变量: tar -zxvf /bigdata/sqoop-1.4.6-cdh5.13.2.tar.gz -C /usr/local 配置环境变量: vi /etc/profile export SQOOP_HOME=/usr/local/sqoop-1.4.6-cdh5.13.2 export PATH=$PATH:$SQOOP_...

    java连接sqoop源码-quick-sqoop:ApacheSqoopETL工具的快速参考

    java连接sqoop源码Apache Sqoop 目录 #Getting Started下载并安装 Sqoop 注意:选择合适的版本,不要使用 sqoop2 因为它不是正式的 GA 并且可能永远不会 $ wget ...

    sqoop-1.4.5-cdh5.4.2.tar.gz

    sqoop对数据进行加工传输,有这丰富的sql语法,嵌套到python中,再使用airflow 很方便的做到自动化的数据处理

    sqoop的操作

    sqoop是一种导入导出数据的工具,这里用思维导图的形式展现了sqoop的一些简单应用。

    sqoop-spark-hive:MYSQL | SQOOP | 火花| HIVE工作流程

    sqoop job for loda data to hdfs from mysql "retail_db" databasesqoop job --create loadorders \-- import \--connect " jdbc:mysql://quickstart.cloudera:3306/retail_db " \--username retail_dba \--...

    基于Sqoop+Hive+Spark+MySQL+AirFlow+Grafana的工业大数据离线数仓项目

    基于Sqoop+Hive+Spark+MySQL+AirFlow+Grafana的工业大数据离线数仓项目

    java-json.7z

    sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException,没遇到可以跳过 19/09/20 09:57:47 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException at org.json...

    sqoop jdbc驱动包

    sqoop 导入数据时候报错ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: oracle.jdbc.OracleDriver 缺少驱动包。

    yinian_hive_increase_sqoop:sqoop从mysql同步数据到hive

    yinian_hive_increase_sqoop sqoop从mysql同步数据到hive

    Sqoop通过Phoenix导hbase数据到hive

    出现此问题时使用:java.lang.NullPointerException at org.json.JSONObject.(JSONObject.java:144) at org.apache.sqoop.util.SqoopJsonUtil.... at org.apache.sqoop.Sqoop.main(Sqoop.java:252)

    load_data_incr_sqoop (2).zip

    /qybpm/ods/ods_INCIDENTS

Global site tag (gtag.js) - Google Analytics