Search code examples
oracle-databasesqoop

Sqoop - problems with --options-file parameter


I created a file called database.txt which content is:

--connect jdbc:oracle:thin:@//123.123.123.123:123/database --username user --password pass

And when I try to use it in the sqoop query like follows:

sqoop import --options-file database.txt --table MyTable --as-avrodatafile --null-string '\N' --null-non-string '\N' --compress --compression-codec org.apache.hadoop.io.compress.DeflateCodec --target-dir hdfs:///user/myuser/AvroFiles/table --split-by SRC --enclosed-by '\"' --map-column-java CREATED_DATT=String,UPDATED_DATT=String

I get the following error:

17/03/15 11:06:23 ERROR tool.BaseSqoopTool: Error parsing arguments for import: 17/03/15 11:06:23 ERROR tool.BaseSqoopTool: Unrecognized argument: --connect jdbc:oracle:thin:@//123.123.123.123:123/database --username user --password pass 17/03/15 11:06:23 ERROR tool.BaseSqoopTool: Unrecognized argument: --table 17/03/15 11:06:23 ERROR tool.BaseSqoopTool: Unrecognized argument: MyTable 17/03/15 11:06:23 ERROR tool.BaseSqoopTool: Unrecognized argument: --as-avrodatafile ...

However if I write the connection parameters directly everything works fine:

sqoop import --connect jdbc:oracle:thin:@//123.123.123.123:123/database --username user --password pass --table MyTable --as-avrodatafile --null-string '\N' --null-non-string '\N' --compress --compression-codec org.apache.hadoop.io.compress.DeflateCodec --target-dir hdfs:///user/myuser/AvroFiles/table --split-by SRC --enclosed-by '\"' --map-column-java CREATED_DATT=String,UPDATED_DATT=String

What am I doing wrong?


Solution

  • An options file is a text file where each line identifies an option in the order that it appears otherwise on the command line.

    Modify database.txt :

    --connect
    jdbc:oracle:thin:@//123.123.123.123:123/database
    --username
    user
    --password
    pass
    

    Check sqoop documentation for more details.