Sqoop related issue


#1

[cloudera@quickstart ~]$ sqoop import --connect “jdbc:mysql://quickstart.cloudera:3306/retail_dba” --username root --password cloudera --table categories -m1 --target-dir categories_subset;
Warning: /usr/lib/sqoop/…/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
17/08/15 12:18:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.11.1
17/08/15 12:18:42 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.

17/08/15 12:18:50 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
17/08/15 12:18:50 INFO tool.CodeGenTool: Beginning code generation
17/08/15 12:18:54 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1036)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:338)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2232)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:790)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:904)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:763)
at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:786)
at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:289)
at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:260)
at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:246)
at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:327)
at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1858)
at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1657)
at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:494)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
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.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:213)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:297)
… 33 more
17/08/15 12:18:54 ERROR tool.ImportTool: Import failed: java.io.IOException: No columns to generate for ClassWriter
at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1663)
at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:494)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
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)

please help me in solving this issue.


#2

Hello Teju,

After seeing you command, it seems like you have not kept any space between -m and 1.
Please try using below command to see if it helps:
sqoop import --connect “jdbc:mysql://quickstart.cloudera:3306/retail_dba” --username root --password cloudera --table categories -m 1 --target-dir categories_subset


#3

No Shivendra. even after removing keeping the same.it is still showing the
communication link failure.
sqoop import --connect “jdbc:mysql://quickstart.cloudera:3306/retail_dba” --username root --password cloudera --table categories -m 1 --target-dir categories_subset;

there is sub problem with hostname i guess.i query hostname -f in cloudera.it gives me quickstart.cloudera.even i tried with this no solution.


#4

I found a different issue with your code(marked in bold). It would be great if you can confirm.
sqoop import --connect “jdbc:mysql://quickstart.cloudera:3306/retail_dba” --username root --password cloudera --table categories -m 1 --target-dir categories_subset

Could you please check if you have specified right database(i am hoping it should be retail_db) and username(retail_dba maybe).


#5

ya in cloudera the database name mentioned is retail_db.
same iisue no solution.shivendra


#6

You have specified retail_dba as your database.
If retail _db is the database, then use below command:
sqoop import --connect “jdbc:mysql://quickstart.cloudera:3306/retail_db” --username root --password cloudera --table categories -m 1 --target-dir categories_subset

I hope username and password are correct.


#7

this seems an gateway issue .

can you check if all the ports are opened?


#8

Hi Teju

If you are running this on the Cloudera image, I believe your query should be like this.

sqoop import --connect jdbc:mysql://quickstart:3306/retail_db --username retail_dba --password cloudera --table categories --m 1 --target-dir categories_subset;

I did following changes in your original query statement:

I have removed double quotes from driver name and cloudera word, set db name as retail_db, username is retail_dba and added one -(hyphen) and space in mappers syntax. Please run above query and check if you are successful.


#10

thankyou Jyutika…it was soved. but i have a question as i am new to the environment.can i know how you are knowing username retail_dba and hostname is quickstart:3306. when i found for hostname in cloudera Vm using hostname -f it displayed as quickstart.cloudera.
please tell me how to find username and hostname.
Thanks in Advance


#11

Even i was suggesting the same solution teju. You should have atleast tried it.
Anyways.The usename and password you are referring to are the mysql username and password through which you will be able to access the database retail_db and table categories under it.
For checking, login into mysql using below command:

mysql -retail_dba -p

and then enter password when prompted: cloudera

Then you can check if you are able to access the database and the tables.


#12

Hi Teju

I followed this video

and this documentation as well for reference:


#13

Thank you all guys.it really helped me .