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
相关推荐
例如,list-databases 命令用于列出 MySQL 数据库中的所有数据库,list-tables 命令用于列出指定数据库中的所有表格,import 命令用于将数据从 MySQL 导入到 Hive,export 命令用于将数据从 Hive 导出到 MySQL。...
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_...
sqoop export --connect jdbc:mysql://localhost/testdb --table employees --username root --password hadoop --export-dir /data/employees ``` 3. `import-all-tables` 命令:快速导入数据库中的所有表。 4....
`sqoop export` 命令用于将 HDFS 或 Hive 表中的数据导出至关系型数据库。 ##### 10.2 语法 - **10.2.1 连接到数据库服务器**:使用 `--connect` 参数指定数据库 URL。 - **10.2.2 选择要导出的数据**:通过 `--...
sqoop export --connect jdbc:mysql://localhost:3306/hive --username root --password 123456 --table TBLS2 --export-dir /sqoop/test ``` ##### 5. import - **功能**:将关系数据库中的数据导入到Hive中。...
通常情况下,Sqoop命令包括导入数据到HDFS(sqoop import),从HDFS导出数据到关系数据库(sqoop export),以及在数据库之间转移数据(sqoop job)等。 总结来说,Sqoop在星环大数据平台中扮演着数据导入导出的...
sqoop eval --connect jdbc:mysql://localhost:3306/hive --username root --password 123456 -e "INSERT INTO TBLS2 VALUES(100,1375170308,1,0,'Hadoop',0,1,'guest','MANAGED_TABLE','abc','ddd')" ``` #### ...
sqoop export --connect jdbc:mysql://localhost/mydb --table mytable --username myuser --password mypass --export-dir /data/mytable ``` 此外,Sqoop还支持增量导入、并行导入、分隔符自定义等功能,以满足...
--export-dir /path/to/hive/table/data ``` - **从 HBase 导出数据到 PostgreSQL**: ```bash sqoop export \ --connect jdbc:postgresql://localhost/test \ --username root \ --password root \ --...
Apache Sqoop是一个专门为大数据处理设计的数据迁移工具,它允许用户从关系型数据库管理系统(RDBMS)如MySQL、Oracle、DB2等导入数据到Hadoop的HDFS、Hive、HBase等组件,同时也能将数据导出回RDBMS。Sqoop利用...
sqoop export --connect jdbc:mysql://localhost/your_database --table your_table --username your_username --password your_password --export-dir /hdfs/path/to/data ``` 3. **其他选项**: Sqoop提供了许多...
Sqoop 提供了一种方便的方式来导入和导出数据,支持多种数据库系统,如 MySQL、Oracle、PostgreSQL 等。通过 Sqoop,用户可以将数据从 RDBMS 导入到 HDFS,进而处理 Hadoop MapReduce 或 Hive 等工具,同时也能将...
sqoop import/export --connect <JDBC_URL> --table <TABLE_NAME> --target-dir <HDFS_DIR> --username <USER> --password <PASSWORD> [其他选项] ``` 1.4.2 Sqoop 导入示例 导入 MySQL 数据库中的 `mytable` 到 ...
1. Sqoop安装:学习如何在Hadoop环境中安装和配置Sqoop。 2. 数据导入:掌握如何使用`import`命令将RDBMS(如MySQL、Oracle等)中的数据导入HDFS或Hive表。 3. 数据导出:学习如何使用`export`命令将HDFS或Hive中的...
export SQOOP_HOME=/opt/software/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0 export PATH=$PATH:$SQOOP_HOME/bin ``` 并执行`source ~/.bash_profile`使配置生效。 3. **配置Sqoop环境**:在`sqoop`的`conf`目录下,...
sqoop export --connect jdbc:mysql://localhost:3306/db --username user --password pass --table table_name --export-dir /hdfs/path ``` #### 五、实施朴素贝叶斯分类器 ##### 5.1 使用Mahout的文本分类器 **...
data_source "myhadoop" 192.168.1.131 192.168.1.132 192.168.1.133 192.168.1.134 ``` - **配置gmond.conf文件** - 设置集群名称,例如: ```ini cluster { name = "myhadoop" } ``` - **同步所有被监控...