【问题标题】:Sqoop export from hdfs to GreenPlum is not working从 hdfs 到 GreenPlum 的 Sqoop 导出不起作用
【发布时间】:2018-12-05 14:03:02
【问题描述】:

我正在尝试将数据从 hdfs 位置导出到 Greenplum 用户定义的架构(不是默认架构)。

尝试使用 Sqoop Eval 检查连接。

sqoop eval --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sample_user --password xxxx --query "SELECT * FROM sample_db.sample_table LIMIT 3"

结果: 工作正常

尝试使用--schema 选项

/usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert

结果:

Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:09:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:09:41 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Error parsing arguments for export:
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: sample_schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --export-dir=/sample/gp_export
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --input-fields-terminated-by
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: ,
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --update-mode
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: allowinsert

根据 sqoop 文档在 '--schema' 之前添加了额外的 '--' https://sqoop.apache.org/docs/1.4.3/SqoopUserGuide.html

 /usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table -- --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert

结果:

Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:06:26 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:06:26 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
Export requires an --export-dir argument or --hcatalog-table argument.
Try --help for usage instructions.

有人可以指导我吗?谢谢

【问题讨论】:

  • 你有一个空的-- 结束参数
  • 额外 -- 根据 sqoop 文档预计
  • 根据该架构,该架构位于所有其他参数的最后
  • 改变 -- 模式的位置正在工作。如下 /usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --export-dir=/sample/gp_export --input-fields -terminated-by ',' --update-mode allowinsert --table sample_table --schema sample_schema
  • 虽然导出工作正常,但 Postgresql 尚不支持 upsert 操作。

标签: hadoop hdfs sqoop greenplum


【解决方案1】:

--export-dir 之后不需要=,请查看以下示例。另一个建议是在遇到此类问题时使用--verbose

sqoop export --libjars /path/some.jar \
--connect 'jdbc:sqlserver://IP:1433;database=db' \
--username someName -password somePassword -m 10 \
--verbose --mysql-delimiters \
--export-dir /HDFS/Path/someFile.csv \
--table "RDBMSTABLENAME"

【讨论】:

    【解决方案2】:

    感谢@cricket_007 的澄清。

    --schema 参数应该在 sqoop 命令的最后。所以下面的代码是有效的。

        /usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb"  \ 
    --username sampleuser --password samplepassword  \ 
    --export-dir=/sample/gp_export --input-fields-terminated-by ','  \ 
    --table sample_table -- --schema sample_schema
    

    但 postgresSql 不支持 UPSERT 操作。这里有一张开放的 Jira 票。 https://issues.apache.org/jira/browse/SQOOP-1270

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 2013-08-16
      • 1970-01-01
      相关资源
      最近更新 更多