Reputation: 41
Importing data from MySQL sqoopdb
to HDFS from table employee
Commands
sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --username sqoop -P --table employee
sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --username sqoop -P --table employee --m 1
Both generate the below error:
Warning: /usr/local/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /usr/local/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/local/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /usr/local/sqoop/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
2019-03-24 16:08:19,779 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Enter password:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at org.apache.sqoop.tool.BaseSqoopTool.validateHiveOptions(BaseSqoopTool.java:1583)
at org.apache.sqoop.tool.ImportTool.validateOptions(ImportTool.java:1178)
at org.apache.sqoop.Sqoop.run(Sqoop.java:137)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more`
Upvotes: 2
Views: 2380
Reputation: 154
Download and copy the commons-lang-2.6.jar
to /usr/local/sqoop/lib
folder and import
will work fine.
I am using Hadoop - 3.2.0
and Sqoop 1.4.7
Upvotes: 5
Reputation: 872
Try the below command:
sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --driver com.mysql.jdbc.Driver --username sqoop -P --table employee --m 1
Also make sure you have granted the access for this database using
% mysql -u root -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON sqoopdb.* TO ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
Upvotes: 0