Sqoop import to HCatalog/Hive - table not visible - hadoop

HDP-2.4.2.0-258 installed using Ambari 2.2.2.0
I have to import several SQL Server schema which should be accessible via Hive, Pig, MR and any third party(in future). I decided to import in HCatalog.
Sqoop provides ways to import to Hive OR HCatalog, I guess if I import to HCatalog, the same table will be accessible from Hive CLI, to MR and to Pig(please evaluate my assumption).
Questions :
If imported to Hive directly, will the table be available to Pig, MR
?
If imported to HCatalog, what needs to be done for accessing via Hive ?
Is pre-creation of tables in Hive necessary ? If yes, what is the advantage of the importing in HCatalog, (I can import in Hive directly)/(import in HDFS and then create external table) ?
Issue :
I wish to achieve the following in one step :
Import of the data(from SQL Server tables)
Avoid 'pre-creating' or writing create statements for those tables(there are 100s of them)
Store the table in ORC format
Store this data at custom HDFS path say /org/data/schema1, /org/data/schema2 and so on(is this impossible because Sqoop says it (--target-dir/--warehouse-dir)
I executed the following command :
-bash-4.2$ sqoop import --connect 'jdbc:sqlserver://<IP>;database=FleetManagement' --username --password --table SettingAttribute -- --schema Administration --hcatalog-home /usr/hdp/current/hive-webhcat --hcatalog-database default --hcatalog-table SettingAttribute --create-hcatalog-table --hcatalog-storage-stanza "stored as orcfile"
The source table contains 109 records and those are fetched :
16/08/10 15:02:27 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.4.2.0-258
16/08/10 15:02:27 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
16/08/10 15:02:28 INFO manager.SqlManager: Using default fetchSize of 1000
16/08/10 15:02:28 INFO manager.SQLServerManager: We will use schema Administration
16/08/10 15:02:28 INFO tool.CodeGenTool: Beginning code generation
16/08/10 15:02:28 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM [Administration].[SettingAttribute] AS t WHERE 1=0
16/08/10 15:02:28 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/hdp/2.4.2.0-258/hadoop-mapreduce
Note: /tmp/sqoop-ojoqcu/compile/dfab14748c41a566ec286b7e4b11004d/SettingAttribute.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
16/08/10 15:02:30 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-ojoqcu/compile/dfab14748c41a566ec286b7e4b11004d/SettingAttribute.jar
16/08/10 15:02:30 INFO mapreduce.ImportJobBase: Beginning import of SettingAttribute
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/hdp/2.4.2.0-258/hadoop/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/2.4.2.0-258/zookeeper/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/2.4.2.0-258/accumulo/lib/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
16/08/10 15:02:31 INFO impl.TimelineClientImpl: Timeline service address: http://l4373t.sss.com:8188/ws/v1/timeline/
16/08/10 15:02:31 INFO client.RMProxy: Connecting to ResourceManager at l4283t.sss.com/138.106.9.80:8050
16/08/10 15:02:33 INFO db.DBInputFormat: Using read commited transaction isolation
16/08/10 15:02:33 INFO db.DataDrivenDBInputFormat: BoundingValsQuery: SELECT MIN([SettingAttributeId]), MAX([SettingAttributeId]) FROM [Administration].[SettingAttribute]
16/08/10 15:02:33 INFO mapreduce.JobSubmitter: number of splits:4
16/08/10 15:02:33 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1467787344827_0013
16/08/10 15:02:34 INFO impl.YarnClientImpl: Submitted application application_1467787344827_0013
16/08/10 15:02:34 INFO mapreduce.Job: The url to track the job: http://l4283t.sss.com:8088/proxy/application_1467787344827_0013/
16/08/10 15:02:34 INFO mapreduce.Job: Running job: job_1467787344827_0013
16/08/10 15:02:41 INFO mapreduce.Job: Job job_1467787344827_0013 running in uber mode : false
16/08/10 15:02:41 INFO mapreduce.Job: map 0% reduce 0%
16/08/10 15:02:47 INFO mapreduce.Job: map 100% reduce 0%
16/08/10 15:02:48 INFO mapreduce.Job: Job job_1467787344827_0013 completed successfully
16/08/10 15:02:48 INFO mapreduce.Job: Counters: 30
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=616636
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=540
HDFS: Number of bytes written=10079
HDFS: Number of read operations=16
HDFS: Number of large read operations=0
HDFS: Number of write operations=8
Job Counters
Launched map tasks=4
Other local map tasks=4
Total time spent by all maps in occupied slots (ms)=16132
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=16132
Total vcore-seconds taken by all map tasks=16132
Total megabyte-seconds taken by all map tasks=66076672
Map-Reduce Framework
Map input records=109
Map output records=109
Input split bytes=540
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=320
CPU time spent (ms)=6340
Physical memory (bytes) snapshot=999870464
Virtual memory (bytes) snapshot=21872697344
Total committed heap usage (bytes)=943194112
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=10079
16/08/10 15:02:48 INFO mapreduce.ImportJobBase: Transferred 9.8428 KB in 17.2115 seconds (585.597 bytes/sec)
16/08/10 15:02:48 INFO mapreduce.ImportJobBase: Retrieved 109 records.
The files are created under my user :
hdfs dfs -ls /user/ojoqcu/SettingAttribute
Found 5 items
-rw------- 3 ojoqcu hdfs 0 2016-08-10 15:02 /user/ojoqcu/SettingAttribute/_SUCCESS
-rw------- 3 ojoqcu hdfs 8378 2016-08-10 15:02 /user/ojoqcu/SettingAttribute/part-m-00000
-rw------- 3 ojoqcu hdfs 144 2016-08-10 15:02 /user/ojoqcu/SettingAttribute/part-m-00001
-rw------- 3 ojoqcu hdfs 1123 2016-08-10 15:02 /user/ojoqcu/SettingAttribute/part-m-00002
-rw------- 3 ojoqcu hdfs 434 2016-08-10 15:02 /user/ojoqcu/SettingAttribute/part-m-00003
I cannot see anything in HCatalog(nor in Hive)
-bash-4.2$ /usr/hdp/2.4.2.0-258/hive-hcatalog/bin/hcat -e "show tables in default;"
WARNING: Use "yarn jar" to launch YARN applications.
16/08/10 15:07:12 WARN conf.HiveConf: HiveConf of name hive.server2.enable.impersonation does not exist
OK
Time taken: 2.007 seconds
Is there some authorization issue ?
I checked the var/log but none exist for Sqoop, Hive-Hcatalog and Hive, how can I view the authorization issue and fix it ?

Well, I'm unsure whether it was an authorization issue or a mere parsing problem or both. I did the following and it worked :
Did an su hive
Executed the following command(probably, the -- --schema should be
the last arg, Sqoop simply ignores/breaks after that!)
sqoop import --hcatalog-home /usr/hdp/current/hive-webhcat --hcatalog-database FleetManagement_Ape --hcatalog-table DatabaseLog --create-hcatalog-table --hcatalog-storage-stanza "stored as orcfile" --connect 'jdbc:sqlserver://<IP>;database=FleetManagement' --username --password --table DatabaseLog -- --schema ape

Related

ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF _DIR is set correctly

I am trying to import data from sqoop to hive
MySQL
use sample;
create table forhive( id int auto_increment,
firstname varchar(36),
lastname varchar(36),
primary key(id)
);
insert into forhive(firstname, lastname) values("sample","singh");
select * from forhive;
1 abhay agrawal
2 vijay sharma
3 sample singh
This is the Sqoop command I'm using (version 1.4.7)
sqoop import --connect jdbc:mysql://********:3306/sample
--table forhive --split-by id --columns id,firstname,lastname
--target-dir /home/programmeur_v/forhive
--hive-import --create-hive-table --hive-table sqp.forhive --username vaibhav -P
This is the error I'm getting
Error Log
18/08/02 19:19:49 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Enter password:
18/08/02 19:19:55 INFO tool.BaseSqoopTool: Using Hive-specific
delimiters for output. You can override
18/08/02 19:19:55 INFO tool.BaseSqoopTool: delimiters with
--fields-terminated-by, etc.
18/08/02 19:19:55 INFO manager.MySQLManager: Preparing to use a MySQL
streaming resultset.
18/08/02 19:19:55 INFO tool.CodeGenTool: Beginning code generation
18/08/02 19:19:56 INFO manager.SqlManager: Executing SQL statement:
SELECT t.* FROM forhive AS t LIMIT 1
18/08/02 19:19:56 INFO manager.SqlManager: Executing SQL statement:
SELECT t.* FROM forhive AS t LIMIT 1
18/08/02 19:19:56 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is
/home/programmeur_v/softwares/hadoop-2.9.1
Note:
/tmp/sqoop-programmeur_v/compile/e8ffa12496a2e421f80e1fa16e025d28/forhive.java
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details. 18/08/02 19:19:58
INFO orm.CompilationManager: Writing jar file:
/tmp/sqoop-programmeur_v/compile/e8ffa12496a2e421f80e1fa16e025d28/forhive.jar
18/08/02 19:19:58 WARN manager.MySQLManager: It looks like you are
importing from mysql.
18/08/02 19:19:58 WARN manager.MySQLManager: This transfer can be
faster! Use the --direct
18/08/02 19:19:58 WARN manager.MySQLManager: option to exercise a
MySQL-specific fast path.
18/08/02 19:19:58 INFO manager.MySQLManager: Setting zero DATETIME
behavior to convertToNull (mysql)
18/08/02 19:19:58 INFO mapreduce.ImportJobBase: Beginning import of
forhive
18/08/02 19:19:58 INFO Configuration.deprecation: mapred.jar is
deprecated. Instead, use mapreduce.job.jar
18/08/02 19:19:59 INFO Configuration.deprecation: mapred.map.tasks is
deprecated. Instead, use mapreduce.job.maps
18/08/02 19:19:59 INFO client.RMProxy: Connecting to ResourceManager
at /0.0.0.0:8032
18/08/02 19:20:02 INFO db.DBInputFormat: Using read commited
transaction isolation
18/08/02 19:20:02 INFO db.DataDrivenDBInputFormat: BoundingValsQuery:
SELECT MIN(id), MAX(id) FROM forhive
18/08/02 19:20:02 INFO db.IntegerSplitter: Split size: 0; Num splits:
4 from: 1 to: 3
18/08/02 19:20:02 INFO mapreduce.JobSubmitter: number of splits:3
18/08/02 19:20:02 INFO Configuration.deprecation:
yarn.resourcemanager.system-metrics-publisher.enabled is deprecated.
Instead, use yarn.system-metrics-publisher.enabl ed
18/08/02 19:20:02 INFO mapreduce.JobSubmitter: Submitting tokens for
job: job_1533231535061_0006
18/08/02 19:20:03 INFO impl.YarnClientImpl: Submitted application
application_1533231535061_0006
18/08/02 19:20:03 INFO mapreduce.Job: The url to track the job:
http://instance-1:8088/proxy/application_1533231535061_0006/
18/08/02 19:20:03 INFO mapreduce.Job: Running job:
job_1533231535061_0006
18/08/02 19:20:11 INFO mapreduce.Job: Job job_1533231535061_0006
running in uber mode : false
18/08/02 19:20:11 INFO mapreduce.Job: map 0% reduce 0%
18/08/02 19:20:21 INFO mapreduce.Job: map 33% reduce 0%
18/08/02 19:20:24 INFO mapreduce.Job: map 100% reduce 0%
18/08/02 19:20:25 INFO mapreduce.Job: Job job_1533231535061_0006
completed successfully
18/08/02 19:20:25 INFO mapreduce.Job: Counters: 31
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=622830
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=295
HDFS: Number of bytes written=48
HDFS: Number of read operations=12
HDFS: Number of large read operations=0
HDFS: Number of write operations=6
Job Counters
Killed map tasks=1
Launched map tasks=3
Other local map tasks=3
Total time spent by all maps in occupied slots (ms)=27404
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=27404
Total vcore-milliseconds taken by all map tasks=27404
Total megabyte-milliseconds taken by all map tasks=28061696
Map-Reduce Framework
Map input records=3
Map output records=3
Input split bytes=295
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=671
CPU time spent (ms)=4210
Physical memory (bytes) snapshot=616452096
Virtual memory (bytes) snapshot=5963145216
Total committed heap usage (bytes)=350224384
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=48
18/08/02 19:20:25 INFO mapreduce.ImportJobBase: Transferred 48 bytes
in 25.828 seconds (1.8584 bytes/sec)
18/08/02 19:20:25 INFO mapreduce.ImportJobBase: Retrieved 3 records.
18/08/02 19:20:25 INFO mapreduce.ImportJobBase: Publishing Hive/Hcat
import job data to Listeners for table forhive
18/08/02 19:20:25 INFO manager.SqlManager: Executing SQL statement:
SELECT t.* FROM forhive AS t LIMIT 1
18/08/02 19:20:25 INFO hive.HiveImport: Loading uploaded data into
Hive
18/08/02 19:20:25 ERROR hive.HiveConfig: Could not load
org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set
correctly.
18/08/02 19:20:25 ERROR tool.ImportTool: Import failed:
java.io.IOException: java.lang.ClassNotFoundException:
org.apache.hadoop.hive.conf.HiveConf
at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:50)
at org.apache.sqoop.hive.HiveImport.getHiveArgs(HiveImport.java:392)
at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:379)
at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:337)
at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:241)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:537)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:628)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
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.hadoop.hive.conf.HiveConf
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:44)
... 12 more
After I did google for the same error I added HIVE_CONF_DIR also to my bashrc
export HIVE_HOME=/home/programmeur_v/softwares/apache-hive-1.2.2-bin
export
HIVE_CONF_DIR=/home/programmeur_v/softwares/apache-hive-1.2.2-bin/conf
export
PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HIVE_HOME/bin:$SQOOP_HOME/bin:$HIVE_CONF_DIR
All my Hadoop services are also up and running.
6976 NameNode
7286 SecondaryNameNode
7559 NodeManager
7448 ResourceManager
8522 DataNode
14587 Jps
I'm just unable to figure out what mistake I'm making here. Please guide!
Download the file "hive-common-0.10.0.jar" by googling. Place this in "sqoop/lib" folder. This solution worked for me.
Go to $HIVE_HOME/lib directory using
cd $HIVE_HOME/lib
then copy hive-common-x.x.x.jar and paste it in $SQOOP_HOME/lib using
cp hive-common-x.x.x.jar $SQOOP_HOME/lib
You need to download the file hive-common-0.10.0.jar and copy it to $SQOOP_HOME/lib folder.
edit your .bash_profile ,then add HADOOP_CLASSPATH
vim ~/.bash_profile
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*
source ~/.bash_profile
I got the same issue when I tried to import data from MySQL to Hive with the following command:
sqoop import --connect jdbc:mysql://localhost:3306/sqoop --username root --password z*****3 --table users -m 1 --hive-home /opt/hive --hive-import --hive-overwrite
Finally, these environment variables made it work perfectly.
export HIVE_HOME=/opt/hive
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*
export HIVE_CONF_DIR=$HIVE_HOME/conf

import-all-tables hanging in during hive-import

[cloudera#quickstart ~]$ sqoop import-all-tables --connect="jdbc:mysql://serverip:3306/dbname"
--username=xxx --password=yyy -m 1 --hive-import --hive-overwrite
--create-hive-table --hive-database sqoopimport --hive-home /user/hive/warehouse
It is running upto map-reduce and during hive import it is hanging in below step, am I doing any mistake?
Logging initialized using configuration in jar:file:/usr/jars/hive-common-1.1.0-cdh5.7.0.jar!/hive-log4j.properties
Full log:
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
16/08/13 21:20:37 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.7.0
16/08/13 21:20:37 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
16/08/13 21:20:37 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
16/08/13 21:20:37 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
16/08/13 21:20:38 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
16/08/13 21:20:39 INFO tool.CodeGenTool: Beginning code generation
16/08/13 21:20:39 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `categories` AS t LIMIT 1
16/08/13 21:20:39 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `categories` AS t LIMIT 1
16/08/13 21:20:39 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/lib/hadoop-mapreduce
Note: /tmp/sqoop-cloudera/compile/af1ef62229d717800a3cd16b42f53dc3/categories.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
16/08/13 21:20:43 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-cloudera/compile/af1ef62229d717800a3cd16b42f53dc3/categories.jar
16/08/13 21:20:43 WARN manager.MySQLManager: It looks like you are importing from mysql.
16/08/13 21:20:43 WARN manager.MySQLManager: This transfer can be faster! Use the --direct
16/08/13 21:20:43 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.
16/08/13 21:20:43 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)
16/08/13 21:20:43 INFO mapreduce.ImportJobBase: Beginning import of categories
16/08/13 21:20:44 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
16/08/13 21:20:45 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
16/08/13 21:20:46 INFO client.RMProxy: Connecting to ResourceManager at quickstart.cloudera/10.0.2.15:8032
16/08/13 21:20:49 INFO db.DBInputFormat: Using read commited transaction isolation
16/08/13 21:20:49 INFO mapreduce.JobSubmitter: number of splits:1
16/08/13 21:20:49 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1470828230815_0030
16/08/13 21:20:50 INFO impl.YarnClientImpl: Submitted application application_1470828230815_0030
16/08/13 21:20:50 INFO mapreduce.Job: The url to track the job: http://quickstart.cloudera:8088/proxy/application_1470828230815_0030/
16/08/13 21:20:50 INFO mapreduce.Job: Running job: job_1470828230815_0030
16/08/13 21:21:07 INFO mapreduce.Job: Job job_1470828230815_0030 running in uber mode : false
16/08/13 21:21:07 INFO mapreduce.Job: map 0% reduce 0%
16/08/13 21:21:18 INFO mapreduce.Job: map 100% reduce 0%
16/08/13 21:21:18 INFO mapreduce.Job: Job job_1470828230815_0030 completed successfully
16/08/13 21:21:18 INFO mapreduce.Job: Counters: 30
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=139452
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=87
HDFS: Number of bytes written=1029
HDFS: Number of read operations=4
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=1
Other local map tasks=1
Total time spent by all maps in occupied slots (ms)=1008512
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=7879
Total vcore-seconds taken by all map tasks=7879
Total megabyte-seconds taken by all map tasks=1008512
Map-Reduce Framework
Map input records=58
Map output records=58
Input split bytes=87
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=78
CPU time spent (ms)=950
Physical memory (bytes) snapshot=143511552
Virtual memory (bytes) snapshot=726700032
Total committed heap usage (bytes)=48234496
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=1029
16/08/13 21:21:18 INFO mapreduce.ImportJobBase: Transferred 1.0049 KB in 32.6366 seconds (31.5291 bytes/sec)
16/08/13 21:21:18 INFO mapreduce.ImportJobBase: Retrieved 58 records.
16/08/13 21:21:18 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `categories` AS t LIMIT 1
16/08/13 21:21:18 INFO hive.HiveImport: Loading uploaded data into Hive
Logging initialized using configuration in jar:file:/usr/jars/hive-common-1.1.0-cdh5.7.0.jar!/hive-log4j.properties

No tables are created inside HIVE but data is crerated inside hdfs

I am new to HDFS and I am trying to import data from my oracle 12c db. I have a table EMP, it needs to be imported inside hdfs as well as hive tables.
My data is getting created inside hdfs ('/user/hdfs' a folder 'EMP' gets created). But when I open hive query editor and type 'show tables' I don't get to see any tables here. I need the tables to be created inside HIVE as well
I am running the following commands.
1. Since am running sqoop as root user
usermod -a -G supergroup hardik
2.
export SQOOP_HOME=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/sqoop
export HIVE_HOME=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/hive
export HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/sqoop/lib/ojdbc7.jar:/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/hive/lib/*
export HADOOP_USER_NAME=hdfs
3.
export PATH=$PATH:$HIVE_HOME/bin
Now am running the SQOOP import command and I get the following on the console
4.
sqoop import --connect jdbc:oracle:thin:#bigdatadev2:1521/orcl --username BDD1 --password oracle123 --table EMP --hive-import -m 1 --create-hive-table --hive-table EMP
[root#bigdatadev1 ~]# sqoop import --connect jdbc:oracle:thin:#bigdatadev2:1521/orcl --username BDD1 --password oracle123 --table EMP --hive-import -m 1 --create-hive-table --hive-table EMP
Warning: /opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
16/04/07 22:15:23 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.5.1
16/04/07 22:15:23 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
16/04/07 22:15:23 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
16/04/07 22:15:23 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
16/04/07 22:15:23 INFO oracle.OraOopManagerFactory: Data Connector for Oracle and Hadoop is disabled.
16/04/07 22:15:23 INFO manager.SqlManager: Using default fetchSize of 1000
16/04/07 22:15:23 INFO tool.CodeGenTool: Beginning code generation
16/04/07 22:15:24 INFO manager.OracleManager: Time zone has been set to GMT
16/04/07 22:15:24 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM EMP t WHERE 1=0
16/04/07 22:15:24 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce
Note: /tmp/sqoop-root/compile/fcb6484db042a7b4295d911956145a4e/EMP.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
16/04/07 22:15:25 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/fcb6484db042a7b4295d911956145a4e/EMP.jar
16/04/07 22:15:25 INFO manager.OracleManager: Time zone has been set to GMT
16/04/07 22:15:25 INFO manager.OracleManager: Time zone has been set to GMT
16/04/07 22:15:25 INFO mapreduce.ImportJobBase: Beginning import of EMP
16/04/07 22:15:25 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
16/04/07 22:15:25 INFO manager.OracleManager: Time zone has been set to GMT
16/04/07 22:15:26 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
16/04/07 22:15:26 INFO client.RMProxy: Connecting to ResourceManager at bigdata/10.103.25.39:8032
16/04/07 22:15:30 INFO db.DBInputFormat: Using read commited transaction isolation
16/04/07 22:15:30 INFO mapreduce.JobSubmitter: number of splits:1
16/04/07 22:15:30 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1460040138373_0007
16/04/07 22:15:31 INFO impl.YarnClientImpl: Submitted application application_1460040138373_0007
16/04/07 22:15:31 INFO mapreduce.Job: The url to track the job: http://bigdata:8088/proxy/application_1460040138373_0007/
16/04/07 22:15:31 INFO mapreduce.Job: Running job: job_1460040138373_0007
16/04/07 22:15:37 INFO mapreduce.Job: Job job_1460040138373_0007 running in uber mode : false
16/04/07 22:15:37 INFO mapreduce.Job: map 0% reduce 0%
16/04/07 22:15:43 INFO mapreduce.Job: Task Id : attempt_1460040138373_0007_m_000000_0, Status : FAILED
Error: EMP : Unsupported major.minor version 52.0
16/04/07 22:15:56 INFO mapreduce.Job: Task Id : attempt_1460040138373_0007_m_000000_1, Status : FAILED
Error: EMP : Unsupported major.minor version 52.0
16/04/07 22:16:03 INFO mapreduce.Job: map 100% reduce 0%
16/04/07 22:16:04 INFO mapreduce.Job: Job job_1460040138373_0007 completed successfully
16/04/07 22:16:04 INFO mapreduce.Job: Counters: 31
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=137942
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=87
HDFS: Number of bytes written=12
HDFS: Number of read operations=4
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Failed map tasks=2
Launched map tasks=3
Other local map tasks=3
Total time spent by all maps in occupied slots (ms)=20742
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=20742
Total vcore-seconds taken by all map tasks=20742
Total megabyte-seconds taken by all map tasks=10619904
Map-Reduce Framework
Map input records=3
Map output records=3
Input split bytes=87
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=53
CPU time spent (ms)=2090
Physical memory (bytes) snapshot=207478784
Virtual memory (bytes) snapshot=2169630720
Total committed heap usage (bytes)=134217728
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=12
16/04/07 22:16:04 INFO mapreduce.ImportJobBase: Transferred 12 bytes in 38.6207 seconds (0.3107 bytes/sec)
16/04/07 22:16:04 INFO mapreduce.ImportJobBase: Retrieved 3 records.
16/04/07 22:16:05 INFO manager.OracleManager: Time zone has been set to GMT
16/04/07 22:16:05 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM EMP t WHERE 1=0
16/04/07 22:16:05 INFO hive.HiveImport: Loading uploaded data into Hive
Logging initialized using configuration in jar:file:/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/jars/hive-common-1.1.0-cdh5.5.1.jar!/hive-log4j.properties
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Table EMP already exists)
I have tried all variations of sqoop import commands but none have succeeded. I am even more confuse today. Please help. Please do not mark this as duplicate.
From your logs, I found two errors:
Error: EMP : Unsupported major.minor version 52.0
Unsupported major.minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g. JRE 1.7 or JRE 1.6. Check more here.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Table EMP already exists)
Your job worked till taking data to hdfs. You must be trying same command again without deleting this /user/hdfs/EMP directory. That's why you got this error.
Check this related answer.

Sqoop Reading 0 records while doing a full load

PROBLEM DESCRIPTION:
I was trying to sqoop data but the sqoop returns zero records without any error.
But when I try to retrieve records using a certain limit it gets the data , but once i proceed further with a greater limit it does not fetch any record.
The QUERY that was passes using the Sqoop is as mentioned below:
select usr.id,usr.login,usr.auto_login,usr.password,usr.password_salt,usr.member,usr.first_name,usr.middle_name,usr.last_name,usr.user_type,usr.locale,usr.lastactivity_date,usr.lastpwdupdate,usr.generatedpwd,usr.registration_date,usr.email,usr.email_status,usr.receive_email,usr.last_emailed,usr.gender,usr.date_of_birth,usr.securitystatus,usr.description,usr.realm_id,usr.password_kdf,dcspp_order.last_modified_date, 20151223080640 FROM <TABLE_NAME> usr JOIN atgprdcore.dcspp_order ON (usr.id = dcspp_order.profile_id ) WHERE $CONDITIONS'
Generated SQOOP Command: sqoop job -Dmapred.child.java.opts="-Djava.security.egd=file:/dev/../dev/urandom" -libjars /<COMP>/stage/da_data/DataAqusition_ATG/dm-sqoop-1.0.0/lib/tdgssconfig.jar,/<COMP>/stage/da_data/DataAqusition_ATG/dm-sqoop-1.0.0/lib/ojdbc6.jar,/<COMP>/stage/da_data/DataAqusition_ATG/dm-sqoop-1.0.0/lib/nzjdbc3.jar,/<COMP>/stage/da_data/DataAqusition_ATG/dm-sqoop-1.0.0/lib/terajdbc4.jar -Dfile.encoding=UTF-8 -Dmapreduce.job.queuename=long_running -Dmapreduce.job.name=sample-job-name --create Sqoop_Utility1253423780 -- import --connect jdbc:oracle:thin:#10.202.201.15:9101:KOHLDBSA1 --username XXXXXX --password-file /tmp/sqoop-nzhdusr/27c6d6d50fccdc67342374a4f560d1d6-asdfg.txt --fetch-size 100 --query 'select usr.id,usr.login,usr.auto_login,usr.password,usr.password_salt,usr.member,usr.first_name,usr.middle_name,usr.last_name,usr.user_type,usr.locale,usr.lastactivity_date,usr.lastpwdupdate,usr.generatedpwd,usr.registration_date,usr.email,usr.email_status,usr.receive_email,usr.last_emailed,usr.gender,usr.date_of_birth,usr.securitystatus,usr.description,usr.realm_id,usr.password_kdf,dcspp_order.last_modified_date, 20151223080640 FROM <database>.<tablename> usr JOIN atgprdcore.dcspp_order ON (usr.id = dcspp_order.profile_id ) WHERE $CONDITIONS' --hive-drop-import-delims --null-string "" --target-dir /tmp/sqoop-nzhdusr/dps_user --num-mappers 1 --fields-terminated-by "|"
[INFO] running sqoop
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/12/23 08:07:10 INFO sqoop.Sqoop: Running Sqoop version: 1.4.4.2.1.10.0-881
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/12/23 08:07:15 INFO sqoop.Sqoop: Running Sqoop version: 1.4.4.2.1.10.0-881
15/12/23 08:07:18 INFO tool.CodeGenTool: Beginning code generation
15/12/23 08:07:19 INFO manager.OracleManager: Time zone has been set to GMT
15/12/23 08:07:19 INFO manager.SqlManager: Executing SQL statement: select usr.id,usr.login,usr.auto_login,usr.password,usr.password_salt,usr.member,usr.first_name,usr.middle_name,usr.last_name,usr.user_type,usr.locale,usr.lastactivity_date,usr.lastpwdupdate,usr.generatedpwd,usr.registration_date,usr.email,usr.email_status,usr.receive_email,usr.last_emailed,usr.gender,usr.date_of_birth,usr.securitystatus,usr.description,usr.realm_id,usr.password_kdf,dcspp_order.last_modified_date, 20151223080640 FROM <database>.<tablename> tab1 JOIN atgprdcore.dcspp_order ON (usr.id = dcspp_order.profile_id ) WHERE (1 = 0)
15/12/23 08:07:19 INFO manager.SqlManager: Executing SQL statement: select usr.id,usr.login,usr.auto_login,usr.password,usr.password_salt,usr.member,usr.first_name,usr.middle_name,usr.last_name,usr.user_type,usr.locale,usr.lastactivity_date,usr.lastpwdupdate,usr.generatedpwd,usr.registration_date,usr.email,usr.email_status,usr.receive_email,usr.last_emailed,usr.gender,usr.date_of_birth,usr.securitystatus,usr.description,usr.realm_id,usr.password_kdf,dcspp_order.last_modified_date, 20151223080640 FROM <database>.<tablename> tab2 JOIN atgprdcore.dcspp_order ON (usr.id = dcspp_order.profile_id ) WHERE (1 = 0)
15/12/23 08:07:19 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/lib/hadoop-mapreduce
Note: /tmp/sqoop-nzhdusr/compile/ed8d5029fc473715d385a2c0b7e002c4/QueryResult.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
15/12/23 08:07:21 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-nzhdusr/compile/ed8d5029fc473715d385a2c0b7e002c4/QueryResult.jar
15/12/23 08:07:21 INFO mapreduce.ImportJobBase: Beginning query import.
15/12/23 08:07:21 INFO client.RMProxy: Connecting to ResourceManager at nhga0002.tst.<COMP>.com/10.200.0.3:8050
15/12/23 08:07:21 INFO hdfs.DFSClient: Created HDFS_DELEGATION_TOKEN token 47174 for nzhdusr on ha-hdfs:<URL>
15/12/23 08:07:21 INFO security.TokenCache: Got dt for hdfs://<URL>; Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:<URL>, Ident: (HDFS_DELEGATION_TOKEN token 47174 for nzhdusr)
15/12/23 08:07:23 INFO db.DBInputFormat: Using read commited transaction isolation
15/12/23 08:07:24 INFO mapreduce.JobSubmitter: number of splits:1
15/12/23 08:07:24 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1444949527622_18165
15/12/23 08:07:24 INFO mapreduce.JobSubmitter: Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:<URL>, Ident: (HDFS_DELEGATION_TOKEN token 47174 for nzhdusr)
15/12/23 08:07:24 INFO impl.YarnClientImpl: Submitted application application_1444949527622_18165
15/12/23 08:07:25 INFO mapreduce.Job: The url to track the job: https://nhga0002.tst.<COMP>.com:8090/proxy/application_1444949527622_18165/
15/12/23 08:07:25 INFO mapreduce.Job: Running job: job_1444949527622_18165
15/12/23 08:07:35 INFO mapreduce.Job: Job job_1444949527622_18165 running in uber mode : false
15/12/23 08:07:35 INFO mapreduce.Job: map 0% reduce 0%
15/12/23 08:24:57 INFO mapreduce.Job: map 100% reduce 0%
15/12/23 08:24:57 INFO mapreduce.Job: Job job_1444949527622_18165 completed successfully
15/12/23 08:24:57 INFO mapreduce.Job: Counters: 30
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=117614
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=87
HDFS: Number of bytes written=0
HDFS: Number of read operations=4
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=1
Other local map tasks=1
Total time spent by all maps in occupied slots (ms)=1039640
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=1039640
Total vcore-seconds taken by all map tasks=1039640
Total megabyte-seconds taken by all map tasks=6919843840
Map-Reduce Framework
Map input records=0
Map output records=0
Input split bytes=87
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=119
CPU time spent (ms)=7760
Physical memory (bytes) snapshot=315817984
Virtual memory (bytes) snapshot=6523957248
Total committed heap usage (bytes)=1114112000
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=0
15/12/23 08:24:57 INFO mapreduce.ImportJobBase: Transferred 0 bytes in 1,055.9463 seconds (0 bytes/sec)
15/12/23 08:24:57 INFO mapreduce.ImportJobBase: Retrieved 0 records.

Oracle Sqoop Retrieves 0 Records

I have a table in Oracle XE 11g
SQL> create table bloblkup (
2 id NUMBER PRIMARY KEY,
3 name varchar(28) NOT NULL,
4 fdata BLOB
5 );
Table created.
SQL> desc bloblkup
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(28)
FDATA BLOB
populated with
SQL> select * from bloblkup;
ID NAME
---------- ----------------------------
FDATA
--------------------------------------------------------------------------------
1 photo.jpg
032135435135
From the cluster I attempt to Sqoop this table into HDFS
sqoop import --connect jdbc:oracle:thin:#Rhea:1521:xe --username SYSTEM --password oracle --table bloblkup --columns 'name' -m 1
that executes to completion every time but provides INFO
15/03/24 09:14:39 INFO mapreduce.ImportJobBase: Retrieved 0 records.
I can retrieve databases and tables.
I am logging in as system which created and owns the table.
I have also found that I can query tables such as the all_tables and return rows just not table that I have created through sqlplus>
I added --m 1 flag after the first attempted failed due to being unable to located an primary key for the table. I added a primary key to the table using alter table with no change.
thoughts?
console output:
[root#sandbox ~]# sqoop import --connect jdbc:oracle:thin:#Rhea:1521:xe --username SYSTEM --password oracle --table bloblkup --columns 'name' -m 1
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/03/24 09:14:02 INFO sqoop.Sqoop: Running Sqoop version: 1.4.4.2.1.1.0-385
15/03/24 09:14:02 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
15/03/24 09:14:02 INFO manager.SqlManager: Using default fetchSize of 1000
15/03/24 09:14:02 INFO tool.CodeGenTool: Beginning code generation
15/03/24 09:14:04 INFO manager.OracleManager: Time zone has been set to GMT
15/03/24 09:14:05 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM bloblkup t WHERE 1=0
15/03/24 09:14:05 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/lib/hadoop-mapreduce
Note: /tmp/sqoop-root/compile/ce267f99c7e1b14da474c2c395368b67/bloblkup.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
15/03/24 09:14:08 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/ce267f99c7e1b14da474c2c395368b67/bloblkup.jar
15/03/24 09:14:08 INFO manager.OracleManager: Time zone has been set to GMT
15/03/24 09:14:08 INFO mapreduce.ImportJobBase: Beginning import of bloblkup
15/03/24 09:14:09 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
15/03/24 09:14:10 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
15/03/24 09:14:10 INFO client.RMProxy: Connecting to ResourceManager at sandbox.hortonworks.com/192.168.1.91:8050
15/03/24 09:14:12 INFO db.DBInputFormat: Using read commited transaction isolation
15/03/24 09:14:13 INFO mapreduce.JobSubmitter: number of splits:1
15/03/24 09:14:13 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1427151026592_0037
15/03/24 09:14:14 INFO impl.YarnClientImpl: Submitted application application_1427151026592_0037
15/03/24 09:14:14 INFO mapreduce.Job: The url to track the job: http://sandbox.hortonworks.com:8088/proxy/application_1427151026592_0037/
15/03/24 09:14:14 INFO mapreduce.Job: Running job: job_1427151026592_0037
15/03/24 09:14:27 INFO mapreduce.Job: Job job_1427151026592_0037 running in uber mode : false
15/03/24 09:14:27 INFO mapreduce.Job: map 0% reduce 0%
15/03/24 09:14:38 INFO mapreduce.Job: map 100% reduce 0%
15/03/24 09:14:39 INFO mapreduce.Job: Job job_1427151026592_0037 completed successfully
15/03/24 09:14:39 INFO mapreduce.Job: Counters: 30
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=107031
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=87
HDFS: Number of bytes written=0
HDFS: Number of read operations=4
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=1
Other local map tasks=1
Total time spent by all maps in occupied slots (ms)=8553
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=8553
Total vcore-seconds taken by all map tasks=8553
Total megabyte-seconds taken by all map tasks=2138250
Map-Reduce Framework
Map input records=0
Map output records=0
Input split bytes=87
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=76
CPU time spent (ms)=2170
Physical memory (bytes) snapshot=145907712
Virtual memory (bytes) snapshot=897458176
Total committed heap usage (bytes)=75497472
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=0
15/03/24 09:14:39 INFO mapreduce.ImportJobBase: Transferred 0 bytes in 28.8478 seconds (0 bytes/sec)
15/03/24 09:14:39 INFO mapreduce.ImportJobBase: Retrieved 0 records.
Update the Oracle driver version ojdbc6.jar appears to work, but be flaky with JDK 1.7 use ojdbc7.jar
Also, you must "commit" database changes in SQLPLUS for them to persist
Check whether jdbc driver is under $SQOOP_HOME/lib if not copy the ojdbc6.jar file to:
/usr/lib/sqoop/lib/ directory
Provide more details from console.
If every thing is fine then add --target-dir to see output on that specific directory.
/usr/bin/sqoop import --connect jdbc:oracle:thin:system/system#<IP address>:1521:xe --username <username> -P--table <database name>.<table name> --columns "<column names>" --target-dir <target directory path> -m 1

Resources